text stringlengths 1 1.05M |
|---|
// seed 2
lbi r0, 217 // icount 0
slbi r0, 53 // icount 1
lbi r1, 16 // icount 2
slbi r1, 137 // icount 3
lbi r2, 72 // icount 4
slbi r2, 14 // icount 5
lbi r3, 48 // icount 6
slbi r3, 25 // icount 7
lbi r4, 131 // icount 8
slbi r4, 245 // icount 9
lbi r5, 32 // icount 10
slbi r5, 217 // icount 11
lbi r6, 214 // icount 12
slbi r6, 253 // icount 13
lbi r7, 173 // icount 14
slbi r7, 177 // icount 15
lbi r4, 5 // icount 16
lbi r1, 7 // icount 17
lbi r5, 15 // icount 18
lbi r1, 8 // icount 19
lbi r0, 3 // icount 20
lbi r1, 14 // icount 21
lbi r7, 11 // icount 22
lbi r5, 0 // icount 23
lbi r5, 0 // icount 24
lbi r2, 9 // icount 25
lbi r7, 8 // icount 26
lbi r5, 13 // icount 27
lbi r4, 13 // icount 28
lbi r3, 10 // icount 29
lbi r0, 14 // icount 30
lbi r6, 12 // icount 31
halt // icount 32
|
; A272576: a(n) = f(10, f(9, n)), where f(k,m) = floor(m*k/(k-1)).
; 0,1,2,3,4,5,6,7,10,11,12,13,14,15,16,17,20,21,22,23,24,25,26,27,30,31,32,33,34,35,36,37,40,41,42,43,44,45,46,47,50,51,52,53,54,55,56,57,60,61,62,63,64,65,66,67,70,71,72,73,74,75,76,77,80,81,82,83,84,85,86,87,90
mov $1,$0
div $1,8
mul $1,2
add $0,$1
|
SECTION code_clib
SECTION code_fp_am9511
PUBLIC cam32_sccz80_readl_callee
PUBLIC cam32_sccz80_read1_callee
.cam32_sccz80_readl_callee
; sccz80 float primitive
; Read right sccz80 float from the stack
;
; enter : stack = sccz80_float left, sccz80_float right, ret1, ret0
;
; exit : sccz80_float right, ret1
; DEHL = sccz80_float right
;
; uses : af, bc, de, hl, bc', de', hl'
pop af ; my return
pop bc ; ret 1
exx
pop hl ; sccz80_float right
pop de
exx
pop hl ; sccz80_float left
pop de
exx
push de ; sccz80_float right
push hl
exx ; sccz80_float left
push bc ; ret 1
push af ; my return
ret
.cam32_sccz80_read1_callee
; sccz80 float primitive
; Read a single sccz80 float from the stack
;
; enter : stack = sccz80_float, ret1, ret0
;
; exit : ret1
; DEHL = sccz80_float
;
; uses : af, bc, de, hl
pop af ; my return
pop bc ; ret 1
pop hl ; sccz80_float
pop de
push bc
push af
ret
|
db STEELIX ; 208
db 75, 85, 200, 30, 55, 65
; hp atk def spd sat sdf
db STEEL, GROUND ; type
db 25 ; catch rate
db 196 ; base exp
db NO_ITEM, METAL_COAT ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 25 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/steelix/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_MINERAL, EGG_MINERAL ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROLLOUT, ROAR, TOXIC, ROCK_SMASH, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, ENDURE, FRUSTRATION, IRON_TAIL, DRAGONBREATH, EARTHQUAKE, RETURN, DIG, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, DEFENSE_CURL, REST, ATTRACT, CUT, STRENGTH
; end
|
page 58,82
TITLE entrypt - Entry points from Opus
?PLM = 1
?WIN = 1
?MEDIUM = 1
.xlist
include cmacros.inc
.list
cwStack equ 2048
cbHeap equ 40960
public _hStackCaller
public _hwndCaller
externFP <LocalInit, HstackMyData, CreateStack>
sBegin DATA
Stack dw cwStack dup(?)
StackMax label word
StackEnd equ dataOffset StackMax - 2
fHeapInit db 0
_hStackCaller dw ?
_hwndCaller dw ?
sEnd DATA
createSeg ENTRYPT_TEXT,nres,byte,public,CODE
sBegin nres
assumes cs, nres
assumes ds, DATA
; Initializes library local heap.
;
; Exit: ax = 0 if error
;
cProc HeapInit,<FAR,PUBLIC>,<si,di>
cBegin HeapInit
cmp [fHeapInit],0
jnz HeapInitExitOK ; just return if already set up
mov [fHeapInit],1
mov cx,cbHeap
xor ax,ax
cCall LocalInit,<ax,ax,cx>
xor ax,ax
jcxz HeapInitExit ; Fail if no heap
HeapInitExitOK:
mov ax,1
HeapInitExit:
cEnd HeapInit
; InitConverter(hStack, hwnd)
cProc InitConverter, <FAR, PUBLIC>, <>
parmW <hStack>
parmW <hwnd>
cBegin
mov ax,[hStack]
mov _hStackCaller, ax
cCall HeapInit
cCall HstackMyData
push ax ; save for return
mov bx,StackEnd
cCall CreateStack, <ax, bx>
mov ax,[hwnd] ; save away the owner
mov _hwndCaller,ax
pop ax
cEnd
sEnd nres
END
|
db "FREEZE@" ; species name
db "Legendary bird"
next "#MON. As it"
next "flies through the"
page "sky, it cools the"
next "air, causing snow"
next "to fall.@"
|
;
; jcsample.asm - downsampling (SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright (C) 2016, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; [TAB8]
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 32
;
; Downsample pixel values of a single component.
; This version handles the common case of 2:1 horizontal and 1:1 vertical,
; without smoothing.
;
; GLOBAL(void)
; jsimd_h2v1_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
; JDIMENSION v_samp_factor,
; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
; JSAMPARRAY output_data);
;
%define img_width(b) (b) + 8 ; JDIMENSION image_width
%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
align 32
GLOBAL_FUNCTION(jsimd_h2v1_downsample_sse2)
EXTN(jsimd_h2v1_downsample_sse2):
push ebp
mov ebp, esp
; push ebx ; unused
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
mov ecx, JDIMENSION [width_blks(ebp)]
shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
jz near .return
mov edx, JDIMENSION [img_width(ebp)]
; -- expand_right_edge
push ecx
shl ecx, 1 ; output_cols * 2
sub ecx, edx
jle short .expand_end
mov eax, INT [max_v_samp(ebp)]
test eax, eax
jle short .expand_end
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
alignx 16, 7
.expandloop:
push eax
push ecx
mov edi, JSAMPROW [esi]
add edi, edx
mov al, JSAMPLE [edi-1]
rep stosb
pop ecx
pop eax
add esi, byte SIZEOF_JSAMPROW
dec eax
jg short .expandloop
.expand_end:
pop ecx ; output_cols
; -- h2v1_downsample
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
test eax, eax
jle near .return
mov edx, 0x00010000 ; bias pattern
movd xmm7, edx
pcmpeqw xmm6, xmm6
pshufd xmm7, xmm7, 0x00 ; xmm7={0, 1, 0, 1, 0, 1, 0, 1}
psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
alignx 16, 7
.rowloop:
push ecx
push edi
push esi
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
alignx 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
pxor xmm1, xmm1
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
alignx 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqa xmm1, XMMWORD [esi+1*SIZEOF_XMMWORD]
.downsample:
movdqa xmm2, xmm0
movdqa xmm3, xmm1
pand xmm0, xmm6
psrlw xmm2, BYTE_BIT
pand xmm1, xmm6
psrlw xmm3, BYTE_BIT
paddw xmm0, xmm2
paddw xmm1, xmm3
paddw xmm0, xmm7
paddw xmm1, xmm7
psrlw xmm0, 1
psrlw xmm1, 1
packuswb xmm0, xmm1
movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
sub ecx, byte SIZEOF_XMMWORD ; outcol
add esi, byte 2*SIZEOF_XMMWORD ; inptr
add edi, byte 1*SIZEOF_XMMWORD ; outptr
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
test ecx, ecx
jnz short .columnloop_r8
pop esi
pop edi
pop ecx
add esi, byte SIZEOF_JSAMPROW ; input_data
add edi, byte SIZEOF_JSAMPROW ; output_data
dec eax ; rowctr
jg near .rowloop
.return:
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
; pop ebx ; unused
pop ebp
ret
; --------------------------------------------------------------------------
;
; Downsample pixel values of a single component.
; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
; without smoothing.
;
; GLOBAL(void)
; jsimd_h2v2_downsample_sse2(JDIMENSION image_width, int max_v_samp_factor,
; JDIMENSION v_samp_factor,
; JDIMENSION width_in_blocks, JSAMPARRAY input_data,
; JSAMPARRAY output_data);
;
%define img_width(b) (b) + 8 ; JDIMENSION image_width
%define max_v_samp(b) (b) + 12 ; int max_v_samp_factor
%define v_samp(b) (b) + 16 ; JDIMENSION v_samp_factor
%define width_blks(b) (b) + 20 ; JDIMENSION width_in_blocks
%define input_data(b) (b) + 24 ; JSAMPARRAY input_data
%define output_data(b) (b) + 28 ; JSAMPARRAY output_data
align 32
GLOBAL_FUNCTION(jsimd_h2v2_downsample_sse2)
EXTN(jsimd_h2v2_downsample_sse2):
push ebp
mov ebp, esp
; push ebx ; unused
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
mov ecx, JDIMENSION [width_blks(ebp)]
shl ecx, 3 ; imul ecx,DCTSIZE (ecx = output_cols)
jz near .return
mov edx, JDIMENSION [img_width(ebp)]
; -- expand_right_edge
push ecx
shl ecx, 1 ; output_cols * 2
sub ecx, edx
jle short .expand_end
mov eax, INT [max_v_samp(ebp)]
test eax, eax
jle short .expand_end
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
alignx 16, 7
.expandloop:
push eax
push ecx
mov edi, JSAMPROW [esi]
add edi, edx
mov al, JSAMPLE [edi-1]
rep stosb
pop ecx
pop eax
add esi, byte SIZEOF_JSAMPROW
dec eax
jg short .expandloop
.expand_end:
pop ecx ; output_cols
; -- h2v2_downsample
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
test eax, eax
jle near .return
mov edx, 0x00020001 ; bias pattern
movd xmm7, edx
pcmpeqw xmm6, xmm6
pshufd xmm7, xmm7, 0x00 ; xmm7={1, 2, 1, 2, 1, 2, 1, 2}
psrlw xmm6, BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
alignx 16, 7
.rowloop:
push ecx
push edi
push esi
mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
mov edi, JSAMPROW [edi] ; outptr
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
alignx 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
pxor xmm2, xmm2
pxor xmm3, xmm3
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
alignx 16, 7
.columnloop:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
movdqa xmm1, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqa xmm2, XMMWORD [edx+1*SIZEOF_XMMWORD]
movdqa xmm3, XMMWORD [esi+1*SIZEOF_XMMWORD]
.downsample:
movdqa xmm4, xmm0
movdqa xmm5, xmm1
pand xmm0, xmm6
psrlw xmm4, BYTE_BIT
pand xmm1, xmm6
psrlw xmm5, BYTE_BIT
paddw xmm0, xmm4
paddw xmm1, xmm5
movdqa xmm4, xmm2
movdqa xmm5, xmm3
pand xmm2, xmm6
psrlw xmm4, BYTE_BIT
pand xmm3, xmm6
psrlw xmm5, BYTE_BIT
paddw xmm2, xmm4
paddw xmm3, xmm5
paddw xmm0, xmm1
paddw xmm2, xmm3
paddw xmm0, xmm7
paddw xmm2, xmm7
psrlw xmm0, 2
psrlw xmm2, 2
packuswb xmm0, xmm2
movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm0
sub ecx, byte SIZEOF_XMMWORD ; outcol
add edx, byte 2*SIZEOF_XMMWORD ; inptr0
add esi, byte 2*SIZEOF_XMMWORD ; inptr1
add edi, byte 1*SIZEOF_XMMWORD ; outptr
cmp ecx, byte SIZEOF_XMMWORD
jae near .columnloop
test ecx, ecx
jnz near .columnloop_r8
pop esi
pop edi
pop ecx
add esi, byte 2*SIZEOF_JSAMPROW ; input_data
add edi, byte 1*SIZEOF_JSAMPROW ; output_data
dec eax ; rowctr
jg near .rowloop
.return:
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
; pop ebx ; unused
pop ebp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 32
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xf324, %r14
nop
nop
nop
nop
cmp %r8, %r8
mov (%r14), %r15w
nop
nop
nop
xor $54621, %rsi
lea addresses_A_ht+0xbb04, %rsi
lea addresses_normal_ht+0xaf84, %rdi
nop
nop
nop
nop
nop
add $50215, %r8
mov $97, %rcx
rep movsb
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0x9b04, %rcx
nop
sub $3697, %r14
mov $0x6162636465666768, %rsi
movq %rsi, %xmm3
movups %xmm3, (%rcx)
nop
nop
cmp $18117, %r8
lea addresses_normal_ht+0x1e1f4, %r8
sub $23436, %r15
vmovups (%r8), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rsi
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_WC_ht+0x8b3c, %rcx
nop
nop
nop
nop
sub %rbp, %rbp
movb (%rcx), %r8b
nop
nop
add %rbp, %rbp
lea addresses_WC_ht+0x8754, %rsi
lea addresses_A_ht+0xbbb4, %rdi
nop
nop
nop
nop
nop
xor $18561, %r12
mov $112, %rcx
rep movsl
nop
nop
nop
nop
nop
and $14098, %r12
lea addresses_WT_ht+0xa604, %r12
nop
nop
nop
nop
add %r14, %r14
mov (%r12), %cx
nop
nop
nop
nop
sub %r15, %r15
lea addresses_WT_ht+0x15000, %rsi
lea addresses_UC_ht+0xc524, %rdi
clflush (%rsi)
nop
nop
inc %r14
mov $40, %rcx
rep movsq
nop
nop
cmp $11902, %rdi
lea addresses_UC_ht+0x1b604, %rsi
lea addresses_WC_ht+0x4a9c, %rdi
nop
nop
cmp $52741, %r12
mov $34, %rcx
rep movsb
nop
nop
nop
xor $280, %rdi
lea addresses_A_ht+0x4f9a, %rsi
lea addresses_UC_ht+0x1e984, %rdi
sub $48336, %r8
mov $12, %rcx
rep movsw
nop
nop
nop
nop
sub $33742, %r15
lea addresses_D_ht+0x10604, %rsi
lea addresses_WC_ht+0xd544, %rdi
and %r15, %r15
mov $6, %rcx
rep movsq
nop
nop
nop
nop
inc %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r8
push %rbx
push %rcx
// Store
mov $0x7cf0580000000294, %rcx
nop
nop
nop
nop
nop
add %r11, %r11
mov $0x5152535455565758, %r13
movq %r13, %xmm1
movups %xmm1, (%rcx)
nop
nop
nop
nop
add %r13, %r13
// Faulty Load
lea addresses_US+0x10504, %r11
clflush (%r11)
nop
nop
add $21353, %r8
mov (%r11), %ebx
lea oracles, %r12
and $0xff, %rbx
shlq $12, %rbx
mov (%r12,%rbx,1), %rbx
pop %rcx
pop %rbx
pop %r8
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 3}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_US', 'same': True, 'AVXalign': True, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 2, 'NT': True, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': True, 'AVXalign': False, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_A_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 6}}
{'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
*/
|
; A314670: Coordination sequence Gal.5.50.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; 1,5,9,13,17,21,25,29,33,37,42,47,51,55,59,63,67,71,75,79,84,89,93,97,101,105,109,113,117,121,126,131,135,139,143,147,151,155,159,163,168,173,177,181,185,189,193,197,201,205
mov $2,$0
mov $3,$0
trn $0,2
add $0,2
add $2,3
lpb $0
sub $0,8
trn $0,1
mov $1,$0
sub $0,1
add $2,2
add $1,$2
add $1,4
lpe
lpb $3
add $1,3
sub $3,1
lpe
sub $1,8
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1995 -- All Rights Reserved
GEOWORKS CONFIDENTIAL
PROJECT: Socket
MODULE: PPP Driver
FILE: pppMain.asm
AUTHOR: Jennifer Wu, Apr 19, 1995
ROUTINES:
Name Description
---- -----------
Socket driver function handlers:
--------------------------------
PPPStrategy
PPPDoNothing
PPPInit
PPPExit
PPPSuspend
PPPRegister
PPPUnregister
PPPAllocConnection
PPPLinkConnectRequest
PPPStopLinkConnect
PPPDisconnectRequest
PPPSendDatagram
PPPResetRequest
PPPGetInfo
PPPResolveAddr
PPPMediumActivated
PADCallTerminated ; Penelope PAD
Method handlers for PPPProcessClass:
------------------------------------
PPPDetach
PPPTimeout
PPPOpenLink
PPPCloseLink
PPPSendFrame
PPPHandleDataNotification
PPPHandlePadStreamStatus ; Penelope PAD
PPPPClientDataProto ; Penelope PAD
PPPPClientConnectProto ; Penelope PAD
PPPPClientErrorProto ; Penelope PAD
Misc:
-----
ECCheckClientInfo
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 4/19/95 Initial revision
DESCRIPTION:
$Id: pppMain.asm,v 1.34 98/08/12 17:24:12 jwu Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;---------------------------------------------------------------------------
; Dgroup
;---------------------------------------------------------------------------
ResidentCode segment resource
DriverTable SocketDriverInfoStruct <
<PPPStrategy,
0,
DRIVER_TYPE_SOCKET>,
0,
(mask SDPO_MAX_PKT or mask SDPO_UNIT),
PPP_MIN_DGRAM_HDR
>
ForceRef DriverTable
ResidentCode ends
idata segment
;
; First word in segment of process class must be a handle or
; kernel code will die when calling superclass. Process class
; created in drivers must manually put the handle in dgroup.
;
myHandle hptr handle 0
port SerialPortNum PPP_DEFAULT_PORT
baud SerialBaud PPP_DEFAULT_BAUD
if _RESPONDER
;
; Data structure for logging outgoing calls with Contact Log.
;
pppLogEntry LogEntry <
0, ; LE_number
LECI_INVALID_CONTACT_ID, ; LE_contactID
LET_DATA, ; LE_type
LED_SENT, ; LE_direction
0, ; LE_duration
<0>, ; LE_datetime
0> ; LE_flags
endif ; _RESPONDER
idata ends
ForceRef myHandle
udata segment
pppThread hptr.HandleThread
timerHandle hptr
hugeLMem hptr
inputBuffer hptr
regSem hptr ; semaphore for registering clients
taskSem hptr ; mutex for PPP actions that need to
; be synchronized
clientInfo PppClientInfo
flowCtrl SerialFlowControl
serialStrategy fptr
if not _PENELOPE
serialDr hptr
modemStrategy fptr
modemDr hptr ; only loaded when needed
baudRate word ; the baud rate from modem
endif
mediumType MediumType ; for Clavin notifications
spaceToken word ; token from GeodeRequestSpace
if _RESPONDER
vpClientToken VpClientToken ; token assigned by VP library
vpCallID byte
callEnded BooleanByte
endif
if _PENELOPE
padOptr optr ; PAD's optr to send messages
padLibrary hptr ; PAD's library handle
padResponse AtTranslationType_e ; latest response from PAD
padStatus word ; initially 0x0040 (CD set).
padSignalDone byte ; -1 TRUE, 0 FALSE for
; PPPGetPADResponse
padAbnormalDisconnect byte ; -1 if PAD disconnects us
; abnormally, else 0
padStreamDr hptr
padStreamStrategy fptr
padUpStream word ; StreamToken to read data
padDnStream word ; StreamToken to write data
endif
udata ends
idata segment
;; The data will be used by internet dial-up application.
bytesSent dword 0
bytesReceived dword 0
idRegistered byte 0
idata ends
PPPClassStructures segment resource
PPPProcessClass
PPPUIClass
PPPAddressControlClass
PPPSpecialTextClass
PPPClassStructures ends
;---------------------------------------------------------------------------
; Strategy Routine
;---------------------------------------------------------------------------
ResidentCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPStrategy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Entry point for all PPP driver calls.
CALLED BY: EXTERNAL (PPP client)
PASS: di = SocketFunction
see specific socket function for other arguments
RETURN: carry set if some error occurred
see specific socket function for return values
DESTROYED: nothing
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 4/19/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPStrategy proc far
uses di
.enter
EC < call ECCheckClientInfo >
cmp di, SOCKET_DR_FIRST_SPEC_FUNC
jge dialup
shl di ; index (4-byte) fptrs
cmp di, size driverProcTable
jae badCall
pushdw cs:driverProcTable[di]
call PROCCALLFIXEDORMOVABLE_PASCAL
exit:
.leave
ret
dialup:
;check if the function is one of our special functions defined for the
;internet dialup application
sub di, SOCKET_DR_FIRST_SPEC_FUNC
shl di
cmp di, size PPPIDFuncTable
jae badCall
pushdw cs:PPPIDFuncTable[di]
call PROCCALLFIXEDORMOVABLE_PASCAL
jmp exit
badCall:
mov ax, SDE_UNSUPPORTED_FUNCTION
stc
jmp exit
PPPStrategy endp
driverProcTable fptr.far \
PPPInit,
PPPExit,
PPPSuspend,
PPPDoNothing, ; DR_UNSUSPEND
PPPRegister,
PPPUnregister,
PPPAllocConnection,
PPPLinkConnectRequest,
PPPDoNothing, ; DR_SOCKET_DATA_CONNECT_REQUEST
PPPStopLinkConnect,
PPPDisconnectRequest,
PPPDoNothing, ; DR_SOCKET_SEND_DATA
PPPDoNothing, ; DR_SOCKET_STOP_SEND_DATA
PPPSendDatagram,
PPPResetRequest,
PPPDoNothing, ; DR_SOCKET_ATTACH
PPPDoNothing, ; DR_SOCKET_REJECT
PPPGetInfo,
PPPDoNothing, ; DR_SOCKET_SET_OPTION
PPPDoNothing, ; DR_SOCKET_GET_OPTION
PPPResolveAddr,
PPPDoNothing, ; DR_SOCKET_STOP_RESOLVE
PPPDoNothing, ; DR_SOCKET_CLOSE_MEDIUM
PPPDoNothing, ; DR_SOCKET_MEDIUM_CONNECT_REQUEST
PPPMediumActivated,
PPPDoNothing, ; DR_SOCKET_SET_MEDIUM_OPTION
PPPDoNothing ; DR_SOCKET_RESOLVE_LINK_LEVEL_ADDRESS
PPPIDFuncTable fptr.far \
PPPIDGetBaudRate,
PPPIDGetBytesSent,
PPPIDGetBytesReceived,
PPPIDRegister,
PPPIDUnregister,
PPPIDForceDisconnect
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPDoNothing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Just clear the carry.
CALLED BY: PPPStrategy
RETURN: carry clear
DESTROYED: nothing
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPDoNothing proc far
clc
ret
PPPDoNothing endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckClientInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Validate clientInfo structure.
CALLED BY: PPPStrategy
PASS: nothing
RETURN: only if clientInfo is valid
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 7/25/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ERROR_CHECK
ECCheckClientInfo proc far
uses bx, ds
.enter
mov bx, handle dgroup
call MemDerefDS
tst ds:[clientInfo].PCI_unit
ERROR_NE PPP_CORRUPT_CLIENT_INFO
mov bl, ds:[clientInfo].PCI_linkState
Assert etype, bl, PppLinkState
mov bx, ds:[clientInfo].PCI_mutex
tst bx
je checkError
test bl, 00001111b ; just check 16 byte boundary
ERROR_NE PPP_CORRUPT_CLIENT_INFO
checkError:
mov bx, ds:[clientInfo].PCI_error
tst bx
je exit
Assert etype, bl, SocketDrError
clr bl
Assert etype, bx, SpecSocketDrError
exit:
.leave
ret
ECCheckClientInfo endp
endif ; ERROR_CHECK
ResidentCode ends
InitCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize the PPP driver.
CALLED BY: PPPStrategy
PASS: nothing
RETURN: carry clear if driver successfully initialized
DESTROYED: ax, cx, dx, bp, di, si, ds, es (allowed)
PSEUDO CODE/STRATEGY:
Load appropriate serial driver and get strategy routine
Allocate input buffer block
Allocate a HugeLMem
Allocate registration semaphore
call PPPSetup to initialize the protocols
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPInit proc far
uses bx
.enter
;
; Get some elbow room. (Use UI for the app.) Bail if
; request is denied.
;
mov bx, handle dgroup
call MemDerefDS
mov ax, SGIT_UI_PROCESS
call SysGetInfo ; ax = UI handle
mov cx, PPP_SPACE_NEEDED
mov_tr bx, ax
call GeodeRequestSpace ; bx = reservation token
jc exit
mov ds:[spaceToken], bx
;
; Load appropriate serial driver and get serial strategy routine.
;
; For Penelope, PAD loads the serial driver and returns to us a
; stream handle. So serial driver is not always loaded.
;
if _PENELOPE
;
; For PENELOPE, medium is GMID_CELL_MODEM and Unit is 0. Port
; is used as the Unit in many routines in PPP.
;
mov ds:[port], 0 ; unit = 0 (for Medium
; and Unit).
else
call PPPLoadSerialDriver
jc error
;
; Read port and baud settings.
;
call PPPGetPortSettings
endif
;
; Allocate block for input buffer and make sure we own it.
;
mov ax, PPP_INPUT_BUFFER_SIZE
mov cx, ALLOC_DYNAMIC or mask HF_SHARABLE
mov bx, handle 0
call MemAllocSetOwner
jc error
mov ds:[inputBuffer], bx
;
; Create huge lmem for allocating buffers.
;
clr ax
mov bx, MIN_OPTIMAL_BLOCK_SIZE
mov cx, MAX_OPTIMAL_BLOCK_SIZE
call HugeLMemCreate
jc error
mov ds:[hugeLMem], bx
;
; Allocate the semaphore for synchronizing client registration
; and link open/closes. Make sure we own both!
;
mov bx, 1
call ThreadAllocSem
mov ds:[regSem], bx
mov ax, handle 0
call HandleModifyOwner ; destroys AX
mov bx, 1
call ThreadAllocSem
mov ds:[taskSem], bx
mov ax, handle 0
call HandleModifyOwner
;
; Initialize PPP protocols. DS already points to dgroup for
; the C routine.
;
call PPPSetup
clc
jmp exit
error:
call PPPExit
stc
exit:
.leave
ret
PPPInit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPExit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Shutdown the PPP driver.
CALLED BY: PPPStrategy
PPPInit
PASS: nothing
RETURN: nothing
DESTROYED: ax, bx, cx, dx, si, di, ds, es (allowed)
PSEUDO CODE/STRATEGY:
Shutdown PPP protocol.
Close any open devices.
Free input buffer
Free HugeLmem
Free registration semaphore
Return requested space.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPExit proc far
;
; Only cleanup if not doing a dirty shutdown.
;
mov bx, handle dgroup
call MemDerefDS
mov al, ds:[clientInfo].PCI_status
and ax, mask CS_REGISTERED
EC < WARNING_NZ PPP_DIRTY_SHUTDOWN >
push ax
call PPPShutdown
if _PENELOPE
;
; Unregister from PAD and unload PAD. PAD is responsible for
; loading and unloading serial driver.
;
call PPPUnloadPAD
else
;
; Unload serial driver, if loaded. If not, then we didn't get
; any further so just return the borrowed space.
;
clr bx
xchg bx, ds:[serialDr]
tst bx
je returnSpace
call GeodeFreeDriver
endif
;
; Free input buffer. If not allocated, then hugelmem and
; reg semaphore never got created.
;
clr bx
xchg bx, ds:[inputBuffer]
tst bx
je returnSpace
call MemFree
;
; Free huge lmem and registration semaphore. If huge lmem was
; not allocated, then we didn't allocate a semaphore.
;
clr bx
xchg bx, ds:[hugeLMem]
tst bx
je returnSpace
call HugeLMemDestroy
clr bx
xchg bx, ds:[regSem]
call ThreadFreeSem
clr bx
xchg bx, ds:[taskSem]
call ThreadFreeSem
returnSpace:
;
; Return borrowed space. Do this last!
;
clr bx
xchg bx, ds:[spaceToken]
tst bx
jz exit
call GeodeReturnSpace
exit:
ret
PPPExit endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPSuspend
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allow suspension if no connections are open.
CALLED BY: PPPStrategy
PASS: cx:dx = buffer to place reason for for refusal, if refused
RETURN: carry set if suspension refused
cx:dx = buffer filled with null terminated reason
(DRIVER_SUSPEND_ERROR_BUFFER_SIZE bytes long)
carry clear if suspension approved
DESTROYED: ax, di (allowed)
PSEUDO CODE/STRATEGY:
Find out if a connection is not closed
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPSuspend proc far
uses bx, si, ds, es
.enter
EC < Assert buffer, cxdx, DRIVER_SUSPEND_ERROR_BUFFER_SIZE >
;
; Allow suspension if PPP link is closed.
;
mov bx, handle dgroup
call MemDerefES
cmp es:[clientInfo].PCI_linkState, PLS_CLOSED
je exit ; carry clear
;
; Refuse suspension. Give reason.
;
mov bx, handle Strings
call MemLock
mov ds, ax
mov si, offset refuseSuspendString
mov si, ds:[si]
EC < push cx >
EC < movdw esdi, dssi >
EC < call LocalStringSize ; cx = size w/o null >
EC < cmp cx, DRIVER_SUSPEND_ERROR_BUFFER_SIZE >
EC < ERROR_AE PPP_REFUSE_SUSPEND_STRING_TOO_LONG >
EC < pop cx >
movdw esdi, cxdx
LocalCopyString
call MemUnlock
stc
exit:
.leave
ret
PPPSuspend endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPRegister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Register a client to use PPP.
CALLED BY: PPPStrategy
PASS: bx = domain handle of the driver
ds:si = domain name (null terminated) (ignored)
dx:bp = client entry point for SCO functions (virtual fptr)
cl = SocketDriverType (ignored)
RETURN: carry set if error
ax = SocketDrError (SDE_ALREADY_REGISTERED,
SDE_MEDIUM_BUSY)
else
bx = client handle
cl = min header size required
DESTROYED: ax, bx if not returned (di allowed)
PSEUDO CODE/STRATEGY:
Grab the reg sem
if client is already registered
if client is same client
return error with SDE_ALREADY_REGISTERED
else
return error with SDE_MEDIUM_BUSY
else
store registration info
allocate mutex for client
spawn thread
start timer
return registration info
release reg sem
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPRegister proc far
uses ds
.enter
EC < push bx, si >
EC < movdw bxsi, dxbp >
EC < call ECAssertValidFarPointerXIP >
EC < pop bx, si >
;
; Get in line for registration.
;
mov di, bx ; di = domain handle
mov bx, handle dgroup
call MemDerefDS
mov bx, ds:[regSem]
call ThreadPSem
;
; Only allow registration if not already registered.
;
test ds:[clientInfo].PCI_status, mask CS_REGISTERED
jne busy
;
; Store registration info. Allocate mutex, spawn thread and
; start timer.
;
BitSet ds:[clientInfo].PCI_status, CS_REGISTERED
mov ds:[clientInfo].PCI_domain, di
movdw ds:[clientInfo].PCI_clientEntry, dxbp
clr bx ; blocking sem
call ThreadAllocSem ; bx = semaphore
mov ax, handle 0
call HandleModifyOwner
mov ds:[clientInfo].PCI_mutex, bx
call PPPCreateThread ; di = error, if any
jc error
mov cl, PPP_MIN_HDR_SIZE
clc
jmp done
busy:
;
; If client is already registered, determine if client is
; the same or different. PPP driver can only be registered
; once. (For now because it only supports one interface.)
;
mov di, SDE_MEDIUM_BUSY
cmpdw dxbp, ds:[clientInfo].PCI_clientEntry
jne error
mov di, SDE_ALREADY_REGISTERED
error:
stc
done:
mov bx, ds:[regSem]
call ThreadVSem ; trashes AX
mov_tr ax, di ; return any error
mov bx, offset clientInfo ; return client handle
.leave
ret
PPPRegister endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPUnregister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Unregister the client.
CALLED BY: PPPStrategy
PASS: bx = client handle
RETURN: carry clear if unregisterd
bx = domain handle
DESTROYED: bx if unregister refused
di (allowed)
PSEUDO CODE/STRATEGY:
get in line before doing anything
Refuse unregistration if link state is not closed.
Else
reset client info
free mutex
destroy thread
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPUnregister proc far
uses ax, si, ds
.enter
EC < cmp bx, offset clientInfo >
EC < ERROR_NE PPP_INVALID_CLIENT_HANDLE >
;
; Get in line.
;
mov_tr si, bx
mov bx, handle dgroup
call MemDerefDS ; ds:si = client info
mov bx, ds:[regSem]
call ThreadPSem
;
; Is client even registered?
;
test ds:[si].PCI_status, mask CS_REGISTERED
je error
cmp ds:[si].PCI_linkState, PLS_CLOSED
EC < WARNING_NE PPP_CLIENT_UNREGISTERING_BEFORE_LINK_CLOSED >
jne error
;
; Reset client information. Free the mutex, stop the timer
; and destroy the thread.
;
BitClr ds:[si].PCI_status, CS_REGISTERED
clr bx
movdw ds:[si].PCI_clientEntry, bxbx
mov ds:[si].PCI_linkState, bl
mov ds:[si].PCI_timer, bx
mov ds:[si].PCI_error, bx
xchg bx, ds:[si].PCI_mutex
call ThreadFreeSem
call PPPDestroyThread
;
; Return domain handle.
;
clr di ; clears carry
xchg di, ds:[si].PCI_domain ; carry still clear
jmp exit
error:
stc
exit:
mov bx, ds:[regSem]
call ThreadVSem ; preserves flags
mov bx, di ; return domain handle
.leave
ret
PPPUnregister endp
InitCode ends
ConnectCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPAllocConnection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Assign a connection handle to client for use with
DR_SOCKET_LINK_CONNECT_REQUEST.
CALLED BY: PPPStrategy
PASS: bx = client handle
RETURN: carry set if error
ax = SocketDrError (SDE_MEDIUM_BUSY)
else carry clear
ax = connection handle
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
grab taskSem
if status shows a blocked client, a passive
connect is occurring, so return SDE_MEDIUM_BUSY
if closed, set state to OPEN
release taskSem
return connection handle
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 7/18/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPAllocConnection proc far
uses bx, es
.enter
EC < cmp bx, offset clientInfo >
EC < ERROR_NE PPP_INVALID_CLIENT_HANDLE >
;
; Get in line.
;
mov bx, handle dgroup
call MemDerefES
mov bx, es:[taskSem]
call ThreadPSem ; destroys AX
;
; if the internet dialup not registered,
; we need to launch internet dialup application and block here
; until the IDialup tells us to go
; we want to check the domain name, but it's ignored...
;
movdw es:[bytesSent], 0
movdw es:[bytesReceived], 0
tst es:[idRegistered]
jnz cont
call PPPLaunchIDial
cont:
;
; May be blocked if a passive connection is being opened.
;
mov di, SDE_MEDIUM_BUSY
test es:[clientInfo].PCI_status, mask CS_BLOCKED
stc
jnz done
;
; If CLOSED, set state to OPENING and clear error.
; Otherwise, connection is already open or will about to
; be so just return connection handle.
;
cmp es:[clientInfo].PCI_linkState, PLS_CLOSED
jne retHandle
mov es:[clientInfo].PCI_linkState, PLS_OPENING
mov es:[clientInfo].PCI_error, SDE_NO_ERROR
EC < test es:[clientInfo].PCI_status, mask CS_REGISTERED >
EC < ERROR_Z PPP_INTERNAL_ERROR >
EC < tst es:[clientInfo].PCI_accpnt >
EC < ERROR_NZ PPP_INTERNAL_ERROR >
EC < tst es:[clientInfo].PCI_timer >
EC < ERROR_NZ PPP_INTERNAL_ERROR >
;
; send notification
;
push bp
mov bp, PPP_STATUS_OPENING
call PPPSendNotice
pop bp
retHandle:
mov di, PPP_CONNECTION_HANDLE
clc
done:
;
; Release access and return result.
;
call ThreadVSem ; preserves flags
mov_tr ax, di ; ax = SDE or handle
.leave
ret
PPPAllocConnection endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPLinkConnectRequest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Open up the PPP link.
CALLED BY: PPPStrategy
PASS: cx = timeout value (in ticks)
bx = connection handle
ds:si = non-null terminated string for addr to connect to
ax = addr string size
RETURN: carry set if connect failed immediately
ax = SocketDrError with SpecSocketDrError
(SDE_LINK_OPEN_FAILED,
SDE_CONNECTION_TIMEOUT,
SDE_CONNECTION_RESET,
SDE_CONNECTION_RESET_BY_PEER,
SDE_CONNECTION_EXISTS,
SDE_INSUFFICIENT_MEMORY
possibly with
SSDE_INVALID_ACCPNT
SSDE_CANCEL
SSDE_NO_USERNAME
SSDE_DEVICE_ERROR
SSDE_DEVICE_NOT_FOUND
SSDE_DEVICE_BUSY
SSDE_CALL_FAILED
SSDE_DEVICE_TIMEOUT
SSDE_DIAL_ERROR
SSDE_LINE_BUSY
SSDE_NO_DIALTONE
SSDE_NO_ANSWER
SSDE_NO_CARRIER
SSDE_BLACKLISTED
SSDE_DELAYED
SSDE_AUTH_FAILED
SSDE_AUTH_REFUSED
SSDE_NEG_FAILED
SSDE_LQM_FAILURE)
otherwise, carry clear
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
grab taskSem
if blocked, {
release taskSem
return busy (passive opening in progress)
}
if PLS_OPENING {
convert timeout to intervals and store
queue MSG_PPP_OPEN_LINK
}
release taskSem
return connection handle
Client handle is offset to client info.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
jwu 7/18/96 Non-blocking version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPLinkConnectRequest proc far
uses bx, cx, dx, bp, si, es, ds
.enter
EC < cmp bx, PPP_CONNECTION_HANDLE >
EC < ERROR_NE PPP_INVALID_CONNECTION_HANDLE >
EC < push bx >
EC < mov bx, ds >
EC < call ECAssertValidFarPointerXIP >
EC < pop bx >
;
; Get in line.
;
mov_tr dx, ax ; dx = addr string size
mov bx, handle dgroup
call MemDerefES
mov bx, es:[taskSem]
call ThreadPSem ; destroys AX
;
; if the internet dialup not registered,
; we need to launch internet dialup application and block here
; until the IDialup tells us to go
; we want to check the domain name, but it's ignored...
;
movdw es:[bytesSent], 0
movdw es:[bytesReceived], 0
tst es:[idRegistered]
jnz cont
call PPPLaunchIDial
cont:
;
; May be blocked if a passive connection is being opened.
;
mov ax, (SSDE_DEVICE_BUSY or SDE_LINK_OPEN_FAILED)
test es:[clientInfo].PCI_status, mask CS_BLOCKED
jnz errorDone
;
; If link is already opened, return SDE_ALREADY_EXISTS
; so client won't keep waiting for a notification.
;
mov ax, SDE_CONNECTION_EXISTS
cmp es:[clientInfo].PCI_linkState, PLS_OPEN
je errorDone
;
; If beyond OPENING state, return success. Link is in process
; of opening so notification will be sent. If state is less
; than opening, connection is in process of closing so return
; connection exists.
;
CheckHack < PLS_CLOSING lt PLS_OPENING >
CheckHack < PLS_OPENING lt PLS_LOGIN >
CheckHack < PLS_LOGIN lt PLS_NEGOTIATING>
CheckHack < PLS_NEGOTIATING lt PLS_OPEN >
cmp es:[clientInfo].PCI_linkState, PLS_OPENING
ja done ; carry clear from cmp
jb errorDone ; ax = SDE_CONN_EXISTS
;
; Store timeout, converting from ticks to intervals and
; rounding up. Then queue a msg for the driver's thread
; to open the link.
;
push dx ; addr size
mov_tr ax, cx
clr dx ; dx:ax = timeout
mov cx, PPP_TIMEOUT_INTERVAL
div cx ; ax = quotient
; dx = remainder
tst dx
jz storeTime
inc ax
storeTime:
mov es:[clientInfo].PCI_timer, ax
pop cx ; cx = addr size
;
; Copy address to stack in case caller has it on their stack
; and intends to free it as soon as this routine returns.
;
mov bx, es:[pppThread]
mov di, mask MF_FORCE_QUEUE
jcxz sendMsg ; no address to copy
push es
mov dx, cx ; dx = addr size
sub sp, cx
segmov es, ss, di
mov di, sp
rep movsb
mov bp, sp ; ss:bp = address
mov cx, dx ; cx = addr size
mov di, mask MF_FORCE_QUEUE or mask MF_STACK
sendMsg:
mov ax, MSG_PPP_OPEN_LINK
call ObjMessage
jcxz wellDone
add sp, cx
pop es ; es = dgroup
wellDone:
clc
jmp done
errorDone:
stc
done:
;
; Release access and return result.
;
xchg cx, ax ; cx = result
mov bx, es:[taskSem]
call ThreadVSem ; preserves flags
xchg ax, cx ; ax = error, if any
.leave
ret
PPPLinkConnectRequest endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPStopLinkConnect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Interrupt a DR_SOCKET_LINK_CONNECT_REQUEST.
CALLED BY: PPPStrategy
PASS: bx = connection handle
RETURN: carry clear
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
grab taskSem
if state is CLOSED or CLOSING, do nothing
set state to PLS_CLOSING
store SDE_INTERRUPTED as error
if state is OPENING, do nothing
(Other code will check for cancellation and
stop the physical connection process)
else if state is LOGIN,
Notify Term to stop login process
else if state is NEGOTIATING or OPENED
queue driver MSG_PPP_CLOSE_LINK
release taskSem
NOTES:
Difference between this and PPPDisconnectRequest is that
the latter blocks until link is already closed. Also,
PPPDisconnectRequest expects the link to be either opened
or closed, but will not interrupt a partially opened link.
CANNOT queue driver MSG_PPP_MANUAL_LOGIN_COMPLETE here.
Must wait for Term to respond via the callback before
continuing because Term may still be working with the
serial port.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 7/18/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPStopLinkConnect proc far
uses ax, bx, es
.enter
EC < cmp bx, PPP_CONNECTION_HANDLE >
EC < ERROR_NE PPP_INVALID_CONNECTION_HANDLE >
;
; Gain access.
;
mov bx, handle dgroup
call MemDerefES
mov bx, es:[taskSem]
call ThreadPSem ; destroys AX
;
; If link is not opening or open, do nothing.
;
CheckHack < (PLS_CLOSED+1) eq PLS_CLOSING >
mov al, es:[clientInfo].PCI_linkState
cmp al, PLS_CLOSING
jbe done
;
; Set state and error BEFORE queuing messages for driver.
;
mov es:[clientInfo].PCI_linkState, PLS_CLOSING
mov es:[clientInfo].PCI_error, SDE_INTERRUPTED
;
; send notification
;
push bp
mov bp, PPP_STATUS_CLOSING
call PPPSendNotice
pop bp
;
; If manual login in progress, notify Term to stop it.
; Else, close link if beyond login process.
;
CheckHack <PLS_LOGIN_INIT lt PLS_OPENING>
CheckHack <PLS_OPENING lt PLS_LOGIN>
CheckHack <PLS_LOGIN lt PLS_NEGOTIATING>
CheckHack <PLS_NEGOTIATING lt PLS_OPEN>
cmp al, PLS_LOGIN_INIT
jb done
cmp al, PLS_LOGIN
ja closeLink
test es:[clientInfo].PCI_status, mask CS_MANUAL_LOGIN
jz done
call PPPStopManualLogin
jmp done
closeLink:
mov ax, MSG_PPP_CLOSE_LINK
mov bx, es:[pppThread]
mov di, mask MF_FORCE_QUEUE
call ObjMessage
done:
;
; Release access and return success.
;
mov bx, es:[taskSem]
call ThreadVSem
clc
.leave
ret
PPPStopLinkConnect endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPDisconnectRequest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Close the PPP link.
CALLED BY: PPPStrategy
PASS: bx = connection handle
ax = SocketCloseType (ignored)
RETURN: carry set if not connected
ax = SDE_NO_ERROR
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
if link is already closed, return carry set
else
set CS_BLOCKED in client status
queue message for driver thread to close link
block on mutex
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPDisconnectRequest proc far
uses bx, es
.enter
EC < cmp bx, PPP_CONNECTION_HANDLE >
EC < ERROR_NE PPP_INVALID_CONNECTION_HANDLE >
;
; Get in line.
;
mov bx, handle dgroup
call MemDerefES
mov bx, es:[taskSem]
call ThreadPSem ; destroys AX
EC < test es:[clientInfo].PCI_status, mask CS_BLOCKED >
EC < ERROR_NE PPP_TOO_MANY_TASKS >
;
; If link closed, return carry. Take advantage of PLS_CLOSED
; being less than PLS_OPEN in doing the cmp to set carry.
; Don't forget to release task sem before returning.
;
CheckHack <PLS_CLOSED lt PLS_OPEN>
cmp es:[clientInfo].PCI_linkState, PLS_OPEN
je closeIt
EC < pushf >
EC < cmp es:[clientInfo].PCI_linkState, PLS_CLOSED >
EC < ERROR_NE PPP_INTERNAL_ERROR ; use stop to interrupt >
EC < popf >
call ThreadVSem ; preserves flags
jmp exit ; carry set by cmp
closeIt:
;
; Remember that we are blocked.
;
BitSet es:[clientInfo].PCI_status, CS_BLOCKED
mov es:[clientInfo].PCI_linkState, PLS_CLOSING
call ThreadVSem ; release task sem
;
; send notification
;
push bp
mov bp, PPP_STATUS_CLOSING
call PPPSendNotice
pop bp
;
; Have driver's thread do the close and wait for task to
; complete.
;
mov bx, es:[pppThread]
mov ax, MSG_PPP_CLOSE_LINK
mov di, mask MF_FORCE_QUEUE
call ObjMessage
mov bx, es:[clientInfo].PCI_mutex
call ThreadPSem
clc
exit:
mov ax, SDE_NO_ERROR
.leave
ret
PPPDisconnectRequest endp
ConnectCode ends
PPPCODE segment public 'CODE'
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPSendDatagram
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send a packet enclosed in a PPP frame.
CALLED BY: PPPStrategy
PASS: dx:bp = optr of buffer
cx = size of data in buffer
bx = client handle
ax = size of address (ignored)
ds:si = non-null term. string for address (ignored)
RETURN: carry clear
DESTROYED: ax, di (allowed)
PSEUDO CODE/STRATEGY:
Pass buffer to driver thread to do the send.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPSendDatagram proc far
uses bx, es
.enter
EC < Assert optr, dxbp >
EC < cmp bx, offset clientInfo >
EC < ERROR_NE PPP_INVALID_CLIENT_HANDLE >
mov bx, handle dgroup
call MemDerefES
mov bx, es:[pppThread]
mov ax, MSG_PPP_SEND_FRAME
mov di, mask MF_FORCE_QUEUE
call ObjMessage
;
; increase the count - bytesSent
;
push bx
movdw axbx, es:[bytesSent]
add bx, cx
jnc done
inc ax
done:
movdw es:[bytesSent], axbx
pop bx
clc
.leave
ret
PPPSendDatagram endp
PPPCODE ends
ConnectCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPResetRequest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Reset the PPP link.
CALLED BY: PPPStrategy
PASS: ax = connection handle
RETURN: nothing
DESTROYED: di (allowed)
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/16/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPResetRequest proc far
uses ax, bx
.enter
mov_tr bx, ax ; bx = connection handle
call PPPDisconnectRequest
.leave
ret
PPPResetRequest endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get info from the driver.
CALLED BY: PPPStrategy
PASS: ax = SocketGetInfoType
if SGIT_LOCAL_ADDR
ds:bx = buffer for address
dx = size of buffer
RETURN: carry clear if info is available and
SGIT_MTU
ax = maximum packet size
SGIT_LOCAL_ADDR
ds:bx = buffer filled with address if big enough
ax = address size
SGIT_MEDIUM_AND_UNIT
cxdx = MediumType
bp = GeoworksMediumID
bl = MediumUnitType
SGIT_ADDR_CTRL
cx:dx = pointer to class
else, carry set
DESTROYED: ax if not used for return value
di (preserved by PPPStrategy)
PSEUDO CODE/ STRATEGY:
use jump table and SocketGetInfoType to jump to
a label in routine for processing.
Be careful not to destroy any registers which aren't used
as return values for that info type.
Return carry set if info is not available
NOTE:
MUST NOT grab taskSem because PPPLINKOPENED holds the
taskSem during notifications. TCP will call this routine
with the PPP thread to get info about the link.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPGetInfo proc far
uses di, es
.enter
EC < Assert etype ax, SocketGetInfoType >
push bx
mov bx, handle dgroup
call MemDerefES
pop bx
cmp ax, size infoTable
LONG jae noInfo
mov_tr di, ax
jmp cs:infoTable[di]
medAndUnit:
;
; Medium and unit. Query for info.
; XXX: Assumes MUT_INT if not GMID_CELL_MODEM!
;
if _PENELOPE
;
; PPPP connects to PAD and PAD does not have a named medium.
; We assign PAD's medium to be as follows.
;
mov cx, MANUFACTURER_ID_GEOWORKS
mov dx, GMID_CELL_MODEM ; cxdx = MediumType
clr bp ; bp = nothing
mov bl, MUT_NONE
jmp done
else
clr cx
mov bx, es:[port]
mov di, DR_SERIAL_GET_MEDIUM
call es:[serialStrategy] ; dxax = MediumType
EC < cmp dx, ManufacturerID >
EC < WARNING_A SERIAL_DRIVER_RETURNED_INVALID_MANUFACTURER_ID>
movdw cxdx, dxax
mov bp, bx ; bp = port
mov bl, MUT_INT
cmp dx, GMID_CELL_MODEM
LONG jne done
mov bl, MUT_NONE
jmp done
endif
addrCtrl:
;
; Address control. Return class for controller. Increment
; ref count of driver.
;
push bx
mov bx, handle 0
call GeodeAddReference
pop bx
mov cx, vseg PPPAddressControlClass
mov dx, offset PPPAddressControlClass
jmp done
address:
;
; Local address. Return local IP address used for link
; if negotiated. If none negotiated yet, then the info
; is not avaiable at this moment. Make sure buffer is
; big enough.
;
EC < Assert buffer dsbx, dx >
mov ax, IP_ADDR_SIZE
cmp ax, dx
ja exit ; carry already clear
push bx, cx, si, ds ; destroyed by C
segmov ds, es, ax ; ds = dgroup for C
call GetLocalIPAddr ; dxax = IP addr
pop bx, cx, si, ds
tstdw dxax
je noInfo ; none yet
;
; Convert address to network form before copying to buffer.
;
xchg dh, dl
xchg ah, al
movdw ds:[bx], axdx
mov ax, IP_ADDR_SIZE
jmp done
mtu:
;
; Ask LCP to return the negotiated MTU (aka MRU).
;
push bx, cx, dx, si, ds ; destroyed by C
segmov ds, es, ax ; ds = dgroup for C
call GetInterfaceMTU ; ax = mtu
pop bx, cx, dx, si, ds
done:
clc
jmp exit
noInfo:
stc
exit:
.leave
ret
infoTable nptr \
offset noInfo, ; SGIT_MEDIA_LIST
offset medAndUnit, ; SGIT_MEDIUM_AND_UNIT
offset addrCtrl, ; SGIT_ADDR_CTRL
offset noInfo, ; SGIT_ADDR_SIZE
offset address, ; SGIT_LOCAL_ADDRESS
offset noInfo, ; SGIT_REMOTE_ADDRESS
offset mtu, ; SGIT_MTU
offset noInfo, ; SGIT_PREF_CTRL
offset noInfo ; SGIT_MEDIUM_CONNECTION
PPPGetInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPResolveAddr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Resolve a link level address for PPP.
CALLED BY: PPPStrategy
PASS: ds:si = addr to resolve
cx = size of addr (including word for linkSize)
dx:bp = buffer for resolved address
ax = buffer size
RETURN: carry clear
dx:bp = buffer filled with address if buffer is big enough
cx = size of resolved address
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
If buffer is big enough, copy the link address to the
buffer. PPP doesn't need the address resolved.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPResolveAddr proc far
EC < Assert buffer dxbp, ax >
EC < push bx, si >
EC < mov bx, ds >
EC < call ECAssertValidFarPointerXIP >
EC < movdw bxsi, dxbp >
EC < call ECAssertValidFarPointerXIP >
EC < pop bx, si >
;
; If buffer is big enough, copy link address to buffer.
;
cmp ax, cx
jb exit
push cx, si, es
movdw esdi, dxbp
rep movsb
pop cx, si, es
exit:
clc
ret
PPPResolveAddr endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPMediumActivated
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called by lurker after it loads PPP driver or by application
detecting an incoming call.
CALLED BY: PPPStrategy
PASS: dx:bx = MediumUnitType
(port is passively opened by lurker if port used)
if RESPONDER:
cl = call ID
RETURN: carry set if error
DESTROYED: di (allowed)
PSEUDO CODE/STRATEGY:
If link isn't closed, return error
If cell modem, store medium type
else if port differs from expected port, return error
If PPP has no client,
allocate mutex
Allocate a thread for PPP driver
pretend we are registered (if we're not already)
Remember client is passive
Set PPP in passive mode
set client timer
have driver's thread open link and block
until open has completed
if successful,
if no client
get the IP client
if failed, free mutex, destroy thread
and clear register bit
else return carry clear
else just tell client link is opened and
return carry clear
if failed
if had no client
free mutex, destroy thread and
clear registered bit
return carry
NOTES:
Must P taskSem first, then regSem to avoid possible
deadlock situations. PPPLINKCLOSED also grabs both
semaphores in this order.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPMediumActivated proc far
uses ax, bx, cx, dx, si, ds, es
noClient local word
.enter
EC < push bx, si >
EC < movdw bxsi, dxbx >
EC < call ECAssertValidFarPointerXIP >
EC < pop bx, si >
;
; If link isn't closed, return error.
;
clr noClient
mov_tr di, bx ; dx:di = MediumAndUnit
mov bx, handle dgroup
call MemDerefDS ; set DS dgroup for C
mov bx, ds:[taskSem]
call ThreadPSem ; gain access
mov bx, ds:[regSem]
call ThreadPSem
cmp ds:[clientInfo].PCI_linkState, PLS_CLOSED
LONG jne errorVSem
if _RESPONDER
;
; Store call ID.
;
mov ds:[vpCallID], cl
endif
;
; Store medium type and continue if cell modem. Else verify the
; port is the same as the one PPP should be using.
;
mov es, dx ; es:di = MediumAndUnit
movdw dxcx, es:[di].MU_medium
movdw ds:[mediumType], dxcx
cmp cx, GMID_CELL_MODEM
je okayToProceed
mov cx, es:[di].MU_unit
cmp ds:[port], cx
LONG jne errorVSem
okayToProceed:
;
; The mutex and PPP driver thread aren't created until PPP
; has a client so do it now if PPP doesn't have a client already.
;
test ds:[clientInfo].PCI_status, mask CS_REGISTERED
jnz openLink ; have client
call PPPCreateThread
LONG jc errorVSem
clr bx
call ThreadAllocSem
mov ax, handle 0
call HandleModifyOwner
mov ds:[clientInfo].PCI_mutex, bx
mov noClient, bx ; bx is non-zero
openLink:
;
; Set registered bit so we don't have to worry about a client
; trying to register while we're doing this and remember PPP
; is in the passive mode. Might as well set the blocked flag
; now since we're mucking with the status.
;
ornf ds:[clientInfo].PCI_status, mask CS_REGISTERED \
or mask CS_PASSIVE or mask CS_BLOCKED
;
; send notification
;
push bp
mov bp, PPP_STATUS_OPENING
call PPPSendNotice
pop bp
mov ds:[clientInfo].PCI_linkState, PLS_OPENING
mov ds:[clientInfo].PCI_timer, PPP_DEFAULT_OPEN_TIMEOUT
call PPPPassiveMode
mov bx, ds:[regSem]
call ThreadVSem
mov bx, ds:[taskSem]
call ThreadVSem ; release access
;
; Have driver's thread open the link and wait until completed.
;
clr cx ; no address
mov bx, ds:[pppThread]
mov ax, MSG_PPP_OPEN_LINK
mov di, mask MF_FORCE_QUEUE
call ObjMessage
mov bx, ds:[clientInfo].PCI_mutex
call ThreadPSem
;
; Process result of opening the link.
;
mov bx, ds:[taskSem]
call ThreadPSem ; gain access
mov bx, ds:[regSem]
call ThreadPSem
BitClr ds:[clientInfo].PCI_status, CS_PASSIVE
cmp ds:[clientInfo].PCI_linkState, PLS_OPEN
je releaseAccess ; carry clear
;
; If no client, clear registered bit, free mutex, and destroy
; thread.
;
tst noClient
jz errorVSem
BitClr ds:[clientInfo].PCI_status, CS_REGISTERED
clr bx
xchg bx, ds:[clientInfo].PCI_mutex
call ThreadFreeSem
call PPPDestroyThread
errorVSem:
stc
if _RESPONDER
mov ds:[vpCallID], 0
endif
releaseAccess:
mov bx, ds:[regSem]
call ThreadVSem ; preserves flags
mov bx, ds:[taskSem]
call ThreadVSem ; preserves flags
exit::
.leave
ret
PPPMediumActivated endp
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PADCallTerminated
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: PAD has terminated PPP's call. We call PPPCallTerminated.
CALLED BY: PPPHandlePadStreamStatus,
PPPPClientDataProto,
PPPPClientErrorProto
PASS: ds - dgroup
RETURN: Nothing
DESTROYED: Nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 7/ 7/97 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PADCallTerminated proc near
uses ax, bx, cx
.enter
;
; Log the fact that the call was dropped as the error to return
; to the client.
;
mov bx, ds:[taskSem]
call ThreadPSem ; gain access
mov ds:[clientInfo].PCI_error, SSDE_NO_CARRIER or \
SDE_LINK_OPEN_FAILED
call ThreadVSem ; release access
;
; Reset stream so we don't call streamStrategy as
; stream might be invalid, causing PPP to crash.
;
clr ds:[padUpStream]
clr ds:[padDnStream]
movdw ds:[padStreamStrategy], 0
clr ds:[padStreamDr]
;
; Terminate protocol.
;
clr ax
push ax
call PPPCallTerminated
done:
.leave
ret
PADCallTerminated endp
endif
ConnectCode ends
InitCode segment resource
;---------------------------------------------------------------------------
; Method Handlers for PPPProcessClass
;---------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPDetach
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Intercepted to decide if detach is allowed.
CALLED BY: MSG_META_DETACH
PASS: *ds:si = PPPProcessClass object
es = segment of PPPProcessClass
cx = caller's ID
dx:bp = caller's OD
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
If PPP has a client, then do not handle this because
client will unregister us and then we can detach.
Else, call superclass.
NOTE: Caller MUST have P-ed regSem.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPDetach method dynamic PPPProcessClass,
MSG_META_DETACH
push ds
mov bx, handle dgroup
call MemDerefDS
test ds:[clientInfo].PCI_status, mask CS_REGISTERED
pop ds
jne exit
push cx, dx, si, es ; preserve around C call
call PPPReset
pop cx, dx, si, es
mov ax, MSG_META_DETACH
mov di, offset PPPProcessClass
call ObjCallSuperNoLock
exit:
ret
PPPDetach endm
InitCode ends
COMMONCODE segment public 'CODE'
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPTimeout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process interval timer expiring.
CALLED BY: MSG_PPP_TIMEOUT
PASS: nothing
RETURN: nothing
DESTROYED: ax, cx, dx, bp
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPTimeout method dynamic PPPProcessClass,
MSG_PPP_TIMEOUT
;
; Don't bother processing if the timer has been stopped since
; this event was queued.
;
mov bx, handle dgroup
call MemDerefDS ; setup dgroup for C
tst ds:[timerHandle]
jz exit
;
; Process client timer first. If client timer expires,
; LCP will stop all protocol timers and wake client.
;
tst ds:[clientInfo].PCI_timer
je doProto
dec ds:[clientInfo].PCI_timer
jnz doProto
call lcp_client_timeout
jmp exit
doProto:
;
; Process PPP protocol timers. DS already set to dgroup.
;
call PPPHandleTimeout
exit:
ret
PPPTimeout endm
COMMONCODE ends
ConnectCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPOpenLink
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Open up the PPP link.
CALLED BY: PPPLinkConnectRequest and PPPMediumActivated
via MSG_PPP_OPEN_LINK
PASS: cx = addr size
ss:bp = non-null terminated address
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
Check for interrupt throughout to catch a cancel and
stop link connection as soon as possible. Once LCP
has started, checking for interrupts is no longer
necessary.
gain access
Reset PPP protocol variables
Get access point info
if successful,
Open device to specified address
if failed
clear timer, set error, wake up client
else if not passive:
Tell LCP the lower layer is up
Signal LCP with the open event
release access
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
jwu 7/19/96 Check for interrupts and do manual login
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPOpenLink method dynamic PPPProcessClass,
MSG_PPP_OPEN_LINK
;
; Clear former PPP protocol settings. Must do this before access
; point info is set or we will erase the new settings.
;
mov bx, handle dgroup
call MemDerefDS ; setup dgroup for C
push cx
call PPPReset ; destroys all but bp
pop cx
;
; If have address, get info from access point.
;
mov bx, ds:[taskSem]
call ThreadPSem
cmp ds:[clientInfo].PCI_linkState, PLS_CLOSING
jbe interrupted
jcxz openDevice
EC < test ds:[clientInfo].PCI_status, mask CS_PASSIVE>
EC < ERROR_NE PPP_INTERNAL_ERROR ; must be active mode! >
mov dx, ss ; dx:bp = address
call PPPSetAccessInfo ; ax = error
jnc openDevice
;
; send notification
;
push bp
mov bp, PPP_STATUS_ACCPNT
call PPPSendNotice
pop bp
jmp error
openDevice:
;
; If manual login, initialize login app before continuing.
;
test ds:[clientInfo].PCI_status, mask CS_MANUAL_LOGIN
jz noLogin
mov ds:[clientInfo].PCI_linkState, PLS_LOGIN_INIT
call PPPInitManualLogin ; ax = SSDE
jc error
mov bx, ds:[taskSem]
call ThreadVSem ; release access
jmp exit
noLogin:
;
; send notification
; XXX - This use to send PPP_STATUS_DIALING notification
; but it was done WAY too early. It is now sent from
; PPPModemOpen once the initialization of the modem
; has been successful; directly BEFORE dialing.
; --JimG 8/23/99
;
call PPPDeviceOpen ; ax = error
jc error
BitSet ds:[clientInfo].PCI_status, CS_DEVICE_OPENED
;
; Begin PPP negotiation phase, releasing access first.
;
mov ds:[clientInfo].PCI_linkState, PLS_NEGOTIATING
;
; send notification
;
push bp
mov bp, PPP_STATUS_CONNECTING
call PPPSendNotice
pop bp
mov bx, ds:[taskSem]
call ThreadVSem ; release access
call PPPBeginNegotiations
jmp exit
error:
;
; Store error, reset client timer, accpnt, status and state.
;
tst al
jnz storeIt
mov al, SDE_LINK_OPEN_FAILED
storeIt:
mov ds:[clientInfo].PCI_error, ax
interrupted:
mov_tr dx, ax ; dx = SocketDrError
;
; Unlock access point if used.
;
mov ax, ds:[clientInfo].PCI_accpnt
tst ax
jz resetStuff
call PPPCleanupAccessInfo
call AccessPointUnlock
clr ax
mov ds:[clientInfo].PCI_accpnt, ax
resetStuff:
mov ds:[clientInfo].PCI_timer, ax
mov ds:[clientInfo].PCI_linkState, PLS_CLOSED
mov cl, ds:[clientInfo].PCI_status
BitClr ds:[clientInfo].PCI_status, CS_BLOCKED
mov bx, ds:[taskSem]
call ThreadVSem ; release access
;
; send notification
;
push bp
mov bp, PPP_STATUS_CLOSED
call PPPSendNotice
pop bp
;
; Wake client if blocked, else notify client.
;
test cl, mask CS_BLOCKED
jz notify
mov bx, ds:[clientInfo].PCI_mutex
call ThreadVSem ; wake client
jmp exit
notify:
mov di, SCO_CONNECT_FAILED
call PPPNotifyLinkClosed
exit:
ret
PPPOpenLink endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPCloseLink
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Close the PPP link in an orderly manner. (No fair just
closing the physical connection. Must terminate link
with consent of peer.)
CALLED BY: MSG_PPP_CLOSE_LINK
PASS: nothing
RETURN: nothing
DESTROYED: ax, cx, dx, bp
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPCloseLink method dynamic PPPProcessClass,
MSG_PPP_CLOSE_LINK
mov bx, handle dgroup
call MemDerefDS ; setup dgroup for C
clr ax
push ax ; pass unit of 0
call lcp_close
;
; send notification
; XXX - This use to send PPP_STATUS_CLOSED notification
; but it was done WAY too early. It is also sent from
; PPPLINKCLOSED, which is more appropriate, once the
; closing has completed. This makes the UI more
; accurate.
; --JimG 8/23/99
;
ret
PPPCloseLink endm
ConnectCode ends
PPPCODE segment public 'CODE'
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPSendFrame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send the buffer's data enclosed in a PPP frame.
CALLED BY: MSG_PPP_SEND_FRAME
PASS: dx:bp = optr of buffer
cx = size of data in buffer
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
Set up dgroup in DS for C code
Lock down buffer and store optr of buffer in the header
so C code can simply deal with a fptr.
Pass locked buffer to ppp_ip_output
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPSendFrame method dynamic PPPProcessClass,
MSG_PPP_SEND_FRAME
mov bx, dx
call HugeLMemLock
mov es, ax
mov di, es:[bp] ; es:di = PppPacketHeader
movdw es:[di].PPH_optr, dxbp
EC < cmp cx, es:[di].PPH_common.PH_dataSize >
EC < ERROR_NE PPP_BAD_DATA_SIZE >
EC < cmp es:[di].PPH_common.PH_dataOffset, PPP_MIN_HDR_SIZE>
EC < ERROR_B PPP_BAD_DATA_OFFSET >
mov bx, handle dgroup
call MemDerefDS ; setup dgroup for C
push ds:[clientInfo].PCI_unit ; pass unit
pushdw esdi ; pass packet
call ppp_ip_output
ret
PPPSendFrame endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPHandleDataNotification
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Data notification handler for incoming data.
CALLED BY: MSG_PPP_HANDLE_DATA_NOTIFICATION
PASS: nothing
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
Lock input buffer
Read all of the data or no further notifications will
arrive for remaining data. If too much to fit in buffer,
read again after processing some of the data.
Data is read to the input buffer.
Pass input buffer to PPPProcessInput for processing.
Safe to reset buffer when full because data is processed
each time through the loop.
If read a full buffer size, try to read again just to make
sure we get all the data.
Unlock input buffer
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 5/17/95 Initial version
jwu 7/19/96 Manual login version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPHandleDataNotification method dynamic PPPProcessClass,
MSG_PPP_HANDLE_DATA_NOTIFICATION
;
; Make sure device is still open. This message may have been
; in queue before device was closed.
;
mov bx, handle dgroup
call MemDerefES
test es:[clientInfo].PCI_status, mask CS_DEVICE_OPENED
je exit
;
; If in manual login phase, don't touch the input. It belongs
; to Term.
;
mov bx, es:[taskSem]
call ThreadPSem
cmp es:[clientInfo].PCI_linkState, PLS_LOGIN
call ThreadVSem
je exit
mov bx, es:[inputBuffer]
call MemLock
mov ds, ax
clr si ; ds:si = place for data
readLoop:
;
; Read as much as will fit in the buffer.
;
if _PENELOPE
mov bx, es:[padUpStream]
else
mov bx, es:[port]
endif
mov cx, PPP_INPUT_BUFFER_SIZE
mov ax, STREAM_NOBLOCK
mov di, DR_STREAM_READ
if _PENELOPE
tstdw es:[padStreamStrategy]
jnz streamValid
clr cx
jmp done
streamValid:
call es:[padStreamStrategy] ; cx = # bytes read
else
call es:[serialStrategy] ; cx = # bytes read
endif
jcxz done
;
; Process input data. Then try to read more if we read an
; entire buffer, in case there is more data that couldn't fit
; in the earlier read.
;
push cx, si, es, ds ; may be destroyed by C
pushdw dssi ; pass pointer to input
push cx ; pass size of input
segmov ds, es, cx ; ds = dgroup for C
call PPPProcessInput
pop cx, si, es, ds
cmp cx, PPP_INPUT_BUFFER_SIZE
je readLoop
done:
mov bx, es:[inputBuffer]
call MemUnlock
exit:
ret
PPPHandleDataNotification endm
PPPCODE ends
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPHandlePadStreamStatus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handle error generated by PAD (via RLP) to upStream.
CALLED BY: MSG_PPP_HANDLE_PAD_STREAM_STATUS
PASS: *ds:si = PPPProcessClass object
ds:di = PPPProcessClass instance data
ds:bx = PPPProcessClass object (same as *ds:si)
es = segment of PPPProcessClass
ax = message #
RETURN: Nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Initially CarrierDetect bit (0x0040) is 1.
In PPP-PAD connected mode, if the CarrierDetect
bit toggles from 0 to 1, then disconnect with ATH.
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 6/30/97 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPHandlePadStreamStatus method dynamic PPPProcessClass,
MSG_PPP_HANDLE_PAD_STREAM_STATUS
.enter
mov bx, handle dgroup
call MemDerefDS
mov bx, ds:[padUpStream]
mov ax, STREAM_READ
mov di, DR_STREAM_GET_ERROR
tstdw ds:[padStreamStrategy]
jz exit
call ds:[padStreamStrategy] ; ax = error token
;
; Deal with the error code in ax. If connected to PAD and
; carrier detect bit toggles from 0 to 1, then disconnect.
;
cmp ds:[padResponse], PAD_AT_CONNECT
jne exit
and ds:[padStatus], 0x0040
jnz keepAlive
and ax, 0x0040
jnz shutDown
keepAlive:
mov ds:[padStatus], ax ; for future toggle check
jmp exit
shutDown:
;
; Carrier detect has toggled from 0 to 1 while connected.
;
call PADCallTerminated
exit:
.leave
ret
PPPHandlePadStreamStatus endm
endif ; if _PENELOPE
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPPClientDataProto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called by PAD to send data responses to PPP. This message
is sent by PAD and serviced by PPPGetPADResponse.
CALLED BY: MSG_CLIENT_DATA_PROTO
PASS: *ds:si = PPPProcessClass object
ds:di = PPPProcessClass instance data
ds:bx = PPPProcessClass object (same as *ds:si)
es = segment of PPPProcessClass
ax = message #
cx = atTranslationType_e
dx = dataBlock, null-terminated string. NULL if no data.
RETURN: Nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
All state changes between PPP and PAD *must* happen here.
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 11/19/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPPClientDataProto method dynamic PPPProcessClass,
MSG_CLIENT_DATA_PROTO
.enter
tst dx
jz nodata
mov bx, dx
call MemFree ; no use for data.
nodata:
mov bx, handle dgroup
call MemDerefDS
;
; Save PAD response code and signal done. padSignalDone is
; used by PPPGetPADGetResponse.
;
mov ds:[padResponse], cx
mov ds:[padSignalDone], -1 ; TRUE
;
; The only good return codes we should be looking for are
; PAD_AT_OK, PAD_AT_CONNECT, and PAD_AT_RING. Anything else
; is error and we should shut down.
;
cmp cx, PAD_AT_RING
jbe exit
mov ds:[padAbnormalDisconnect], -1
;
; Set link state closed and report error to client.
;
call PADCallTerminated
exit:
.leave
ret
PPPPClientDataProto endm
endif ; if _PENELOPE
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPPClientConnectProto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called by PAD to send established data-link to PPP. This
message is sent by PAD and serviced by PPPGetPADResponse.
CALLED BY: MSG_CLIENT_CONNECT_PROTO
PASS: *ds:si = PPPProcessClass object
ds:di = PPPProcessClass instance data
ds:bx = PPPProcessClass object (same as *ds:si)
es = segment of PPPProcessClass
ax = message #
cx = GeodeHandle, stream handle from GeodeUseDriver
dx = StreamToken for upStream
bp = StreamToken for dnStream
RETURN: Nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
Save the strategy routines of PAD's stream driver.
Save upStream and dnStream. dnStream has been initialized
by PAD.
Initialize upStream.
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 11/19/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPPClientConnectProto method dynamic PPPProcessClass,
MSG_CLIENT_CONNECT_PROTO
.enter
EC < push bx >
EC < mov bx, cx >
EC < call ECCheckGeodeHandle >
EC < pop bx >
mov bx, handle dgroup
call MemDerefES
;
; We must not connect unless we are in PLS_OPENING state.
; In fact, we should not get this message at all if our state
; is not PLS_OPENING.
;
cmp es:[clientInfo].PCI_linkState, PLS_OPENING
EC < ERROR_NE PPP_PAD_CONNECTING_WHILE_NOT_OPENING >
jne exit
mov es:[padStreamDr], cx
mov bx, cx
call GeodeInfoDriver
movdw es:[padStreamStrategy], ds:[si].DIS_strategy, ax
mov es:[padUpStream], dx
mov es:[padDnStream], bp
;
; Setup data notification with upStream.
; dnStream has been initialized by PAD.
;
mov ax, StreamNotifyType <1, SNE_DATA, SNM_MESSAGE>
mov bx, es:[padUpStream]
mov cx, es:[pppThread]
mov bp, MSG_PPP_HANDLE_DATA_NOTIFICATION
mov di, DR_STREAM_SET_NOTIFY
call es:[padStreamStrategy]
;
; Setup error notification with upStream. Upstream errors are
; generated by RLP (Radio Link Protocol).
;
mov ax, StreamNotifyType <1, SNE_ERROR, SNM_MESSAGE>
mov bx, es:[padUpStream]
mov cx, es:[pppThread]
mov bp, MSG_PPP_HANDLE_PAD_STREAM_STATUS
mov di, DR_STREAM_SET_NOTIFY
call es:[padStreamStrategy]
exit:
.leave
ret
PPPPClientConnectProto endm
endif ; if _PENELOPE
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPPClientErrorProto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Called by PAD to send error codes to PPP. This message is
sent by PAD and serviced by PPPGetPADResponse.
CALLED BY: MSG_CLIENT_ERROR_PROTO
PASS: *ds:si = PPPProcessClass object
ds:di = PPPProcessClass instance data
ds:bx = PPPProcessClass object (same as *ds:si)
es = segment of PPPProcessClass
ax = message #
cx:dx = one of ERR_PAD_... error codes.
RETURN: dgroup::padSignalDone = 0 if no error.
else
dgroup::padSignalDone = -1 if error
dgroup::padResponse = atTranslationType_e
(PAD_AT_OK,
PAD_AT_ERROR)
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
PAD is shutting us down. We must unregister from PAD.
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 11/19/96 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPPClientErrorProto method dynamic PPPProcessClass,
MSG_CLIENT_ERROR_PROTO
.enter
mov bx, handle dgroup
call MemDerefDS
tst dx ; as cx is always 0.
jz exit ; no error
;
; Convert error code in cx:dx to ds:[padResponse].
;
mov ds:[padSignalDone], -1 ; a final state
mov ds:[padResponse], PAD_AT_ERROR
mov ds:[padAbnormalDisconnect], -1
;
; Set link state closed and report error to client.
;
call PADCallTerminated
exit:
.leave
ret
PPPPClientErrorProto endm
endif ; if _PENELOPE
if _PENELOPE
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPPClientModeProto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Does nothing as this message is never sent to PPP by
PAD as PAD only send it to System Bus Handler (sbh).
CALLED BY: MSG_CLIENT_MODE_PROTO
PASS: *ds:si = PPPProcessClass object
ds:di = PPPProcessClass instance data
ds:bx = PPPProcessClass object (same as *ds:si)
es = segment of PPPProcessClass
ax = message #
cx = sbgMsg, System Bus Handler message.
RETURN: Nothing
DESTROYED: Nothing
SIDE EFFECTS: Nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
kkee 3/ 5/97 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPPClientModeProto method dynamic PPPProcessClass,
MSG_CLIENT_MODE_PROTO
ret
PPPPClientModeProto endm
endif ; if _PENELOPE
IDialupCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDGetBaudRate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: PPPStrategy
PASS: nothing
RETURN: ax = baud rate
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 11/30/98 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDGetBaudRate proc far
uses es, ds, di, bx
.enter
mov bx, handle dgroup
call MemDerefES
mov ax, es:[baudRate]
clr dx
.leave
ret
PPPIDGetBaudRate endp
IDialupCode ends
COMMONCODE segment public 'CODE'
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDGetBytesSent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: PPPStrategy
PASS:
RETURN: dxax = bytes sent
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 11/30/98 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDGetBytesSent proc far
uses es, bx, cx, ds
.enter
mov bx, handle dgroup
call MemDerefES
movdw dxax, es:[bytesSent]
.leave
ret
PPPIDGetBytesSent endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDGetBytesReceived
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: PPPStrategy
PASS: nothing
RETURN: dxax = bytes received
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 11/30/98 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDGetBytesReceived proc far
uses es, bx, cx, ds
.enter
mov bx, handle dgroup
call MemDerefES
movdw dxax, es:[bytesReceived]
.leave
ret
PPPIDGetBytesReceived endp
COMMONCODE ends
IDialupCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDRegister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: PPPStrategy
PASS: nothing
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 11/30/98 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDRegister proc far
uses es, bx
.enter
mov bx, handle dgroup
call MemDerefES
mov es:[idRegistered], -1
.leave
ret
PPPIDRegister endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDUnregister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY: PPPStrategy
PASS: nothing
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 11/30/98 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDUnregister proc far
uses es, bx, ax
.enter
mov bx, handle dgroup
call MemDerefES
mov bx, es:[taskSem]
call ThreadPSem ; destroys AX
mov es:[idRegistered], 0
call ThreadVSem
.leave
ret
PPPIDUnregister endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPIDForceDisconnect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Force a disconnect. The most useful reason for this
function's existence is to abort a dial in progress.
CALLED BY: PPPStrategy
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
Calling PPPCallTerminated doesn't always cause PPP to
close (particularly if no connection is established).
Seems to work once it is established, though.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JimG 9/08/99 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPIDForceDisconnect proc far
uses ax,bx,cx,dx,si,di,bp,ds
.enter
mov bx, handle dgroup
call MemDerefDS
cmp ds:[clientInfo].PCI_linkState, PLS_CLOSING
jbe done
cmp ds:[clientInfo].PCI_linkState, PLS_OPENING ;dialing
je slamModem
terminateCall:
clr ax
push ax
call PPPCallTerminated
done:
.leave
ret
slamModem:
; Tell the modem driver to abort the dial. If it could not be
; done because the connection has already been made, then
; revert to having PPP terminate the call.
;
tst ds:[modemStrategy].handle
jz done
mov di, DR_MODEM_ABORT_DIAL
call ds:[modemStrategy]
jc terminateCall
jmp done
PPPIDForceDisconnect endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPLaunchIDial
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Launch internet dialup application.
CALLED BY: PPPOpenDevice
PASS: nothing
RETURN: carry set if error
DESTROYED: ax, cx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 12/04/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPLaunchIDial proc far
uses dx, si, es, ss, bx, cx, dx, di, ds
if DBCS_PCGEOS
idTokenString local 5 dup (TCHAR) ; 4 token chars plus null
endif
idToken local GeodeToken
.enter
push bp
; check if it's already launched
; "test xxx, 0" always gives you zero, so it will never jump to done, which
; is not what you want. --- AY
;;; test ds:[idcbfunc], 0
mov bx, handle dgroup
call MemDerefDS
; tstdw ds:[idcbfunc]
; jnz exit
; get the geode token from ini file
segmov es, ss, bx ; es:di = buffer
mov bx, handle Strings
call MemLock
mov ds, ax
mov_tr cx, ax
mov dx, ds:[idialTokenKey] ; cx:dx = key string
assume ds:Strings
mov si, ds:[pppCategory]
assume ds:nothing
if DBCS_PCGEOS
lea di, idTokenString ; es:di = token chars
else
lea di, idToken ; es:di = GeodeToken
endif
push bp
if DBCS_PCGEOS
mov bp, InitFileReadFlags \
<IFCC_INTACT, 0, 0, size idTokenString>
else
mov bp, InitFileReadFlags \
<IFCC_INTACT, 0, 0, size GeodeToken>
endif
call InitFileReadString ; carry set if none
pop bp
if DBCS_PCGEOS
lea di, idToken
mov ax, {TCHAR}idTokenString[0*(size TCHAR)]
mov es:[di].GT_chars[0], al
mov ax, {TCHAR}idTokenString[1*(size TCHAR)]
mov es:[di].GT_chars[1], al
mov ax, {TCHAR}idTokenString[2*(size TCHAR)]
mov es:[di].GT_chars[2], al
mov ax, {TCHAR}idTokenString[3*(size TCHAR)]
mov es:[di].GT_chars[3], al
endif
mov idToken.GT_manufID, MANUFACTURER_ID_GEOWORKS
jc done
; create a default launch block
mov dx, MSG_GEN_PROCESS_OPEN_APPLICATION
call IACPCreateDefaultLaunchBlock ; ^hdx = AppLaunchBlock
mov bx, dx
call MemLock
mov ds, ax
clr si
mov bx, 0
call ThreadAllocSem
mov ds:[si].ALB_extraData, bx ; send the semaphore to IDial
push bx
mov bx, dx
call MemUnlock
; launch the application
mov ax, mask IACPCF_FIRST_ONLY or \
(IACPSM_USER_INTERACTIBLE shl offset IACPCF_SERVER_MODE)
call IACPConnect ; bp = IACPConnection
; ax, bx, cx destroyed
pop bx
jc done ; something wrong
; block here till IDial release the semaphore
call ThreadPSem
call ThreadFreeSem
clr cx
call IACPShutdown
done:
mov bx, handle Strings
call MemUnlock
exit:
pop bp
.leave
ret
PPPLaunchIDial endp
IDialupCode ends
ConnectCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PPPSendNotice
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send a notification
CALLED BY:
PASS: bp - PPPStatus
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: destroys any segment pointing to block
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
mzhu 12/7/98 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PPPSendNotice proc near
uses ax, bx, cx, dx, di, si, ds
.enter
mov bx, handle dgroup
call MemDerefDS
;;
; add error message to bp
;
or bp, ds:[clientInfo].PCI_error
;
; record an event
;
mov ax, MSG_META_NOTIFY
mov cx, MANUFACTURER_ID_GEOWORKS
mov dx, GWNT_PPP_STATUS_NOTIFICATION
mov di, mask MF_RECORD
clr bx
clr si
call ObjMessage ; di = event handle
;
; dispatch the event
;
mov cx, di
clr dx
mov bx, MANUFACTURER_ID_GEOWORKS
mov ax, GCNSLT_PPP_STATUS_NOTIFICATIONS
mov bp, mask GCNLSF_FORCE_QUEUE or mask GCNLSF_SET_STATUS
call GCNListSend
.leave
ret
PPPSendNotice endp
ConnectCode ends
|
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#include "pxr/usd/usdLux/geometryLight.h"
#include "pxr/usd/usd/schemaRegistry.h"
#include "pxr/usd/usd/typed.h"
#include "pxr/usd/sdf/types.h"
#include "pxr/usd/sdf/assetPath.h"
PXR_NAMESPACE_OPEN_SCOPE
// Register the schema with the TfType system.
TF_REGISTRY_FUNCTION(TfType)
{
TfType::Define<UsdLuxGeometryLight,
TfType::Bases< UsdLuxLight > >();
// Register the usd prim typename as an alias under UsdSchemaBase. This
// enables one to call
// TfType::Find<UsdSchemaBase>().FindDerivedByName("GeometryLight")
// to find TfType<UsdLuxGeometryLight>, which is how IsA queries are
// answered.
TfType::AddAlias<UsdSchemaBase, UsdLuxGeometryLight>("GeometryLight");
}
/* virtual */
UsdLuxGeometryLight::~UsdLuxGeometryLight()
{
}
/* static */
UsdLuxGeometryLight
UsdLuxGeometryLight::Get(const UsdStagePtr &stage, const SdfPath &path)
{
if (!stage) {
TF_CODING_ERROR("Invalid stage");
return UsdLuxGeometryLight();
}
return UsdLuxGeometryLight(stage->GetPrimAtPath(path));
}
/* static */
UsdLuxGeometryLight
UsdLuxGeometryLight::Define(
const UsdStagePtr &stage, const SdfPath &path)
{
static TfToken usdPrimTypeName("GeometryLight");
if (!stage) {
TF_CODING_ERROR("Invalid stage");
return UsdLuxGeometryLight();
}
return UsdLuxGeometryLight(
stage->DefinePrim(path, usdPrimTypeName));
}
/* static */
const TfType &
UsdLuxGeometryLight::_GetStaticTfType()
{
static TfType tfType = TfType::Find<UsdLuxGeometryLight>();
return tfType;
}
/* static */
bool
UsdLuxGeometryLight::_IsTypedSchema()
{
static bool isTyped = _GetStaticTfType().IsA<UsdTyped>();
return isTyped;
}
/* virtual */
const TfType &
UsdLuxGeometryLight::_GetTfType() const
{
return _GetStaticTfType();
}
UsdRelationship
UsdLuxGeometryLight::GetGeometryRel() const
{
return GetPrim().GetRelationship(UsdLuxTokens->geometry);
}
UsdRelationship
UsdLuxGeometryLight::CreateGeometryRel() const
{
return GetPrim().CreateRelationship(UsdLuxTokens->geometry,
/* custom = */ false);
}
/*static*/
const TfTokenVector&
UsdLuxGeometryLight::GetSchemaAttributeNames(bool includeInherited)
{
static TfTokenVector localNames;
static TfTokenVector allNames =
UsdLuxLight::GetSchemaAttributeNames(true);
if (includeInherited)
return allNames;
else
return localNames;
}
PXR_NAMESPACE_CLOSE_SCOPE
// ===================================================================== //
// Feel free to add custom code below this line. It will be preserved by
// the code generator.
//
// Just remember to wrap code in the appropriate delimiters:
// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'.
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
|
#include "GuiParserManager.h"
#include "../Controls/GuiApplication.h"
namespace vl
{
namespace presentation
{
using namespace collections;
using namespace controls;
using namespace glr::xml;
using namespace glr::json;
using namespace regex;
/***********************************************************************
IGuiParserManager
***********************************************************************/
IGuiParserManager* parserManager=0;
IGuiParserManager* GetParserManager()
{
return parserManager;
}
class GuiParser_Xml : public IGuiParser<XmlDocument>
{
protected:
glr::xml::Parser parser;
public:
Ptr<XmlDocument> ParseInternal(const WString& text, List<glr::ParsingError>& errors) override
{
auto handler = glr::InstallDefaultErrorMessageGenerator(parser, errors);
auto ast = XmlParseDocument(text, parser);
parser.OnError.Remove(handler);
return ast;
}
};
class GuiParser_Json : public IGuiParser<JsonNode>
{
protected:
glr::json::Parser parser;
public:
Ptr<JsonNode> ParseInternal(const WString& text, List<glr::ParsingError>& errors) override
{
auto handler = glr::InstallDefaultErrorMessageGenerator(parser, errors);
auto ast = JsonParse(text, parser);
parser.OnError.Remove(handler);
return ast;
}
};
class GuiParserManager : public Object, public IGuiParserManager, public IGuiPlugin
{
protected:
SpinLock lock;
Dictionary<WString, Ptr<IGuiGeneralParser>> parsers;
public:
GUI_PLUGIN_NAME(GacUI_Parser)
{
}
void Load()override
{
parserManager = this;
SetParser(L"XML", new GuiParser_Xml());
SetParser(L"JSON", new GuiParser_Json());
}
void Unload()override
{
parserManager=0;
}
Ptr<IGuiGeneralParser> GetParser(const WString& name)override
{
vint index=parsers.Keys().IndexOf(name);
return index == -1 ? nullptr : parsers.Values()[index];
}
bool SetParser(const WString& name, Ptr<IGuiGeneralParser> parser)override
{
if(parsers.Keys().Contains(name)) return false;
parsers.Add(name, parser);
return true;
}
};
GUI_REGISTER_PLUGIN(GuiParserManager)
}
} |
#include "transactionrecord.h"
#include "wallet.h"
#include "base58.h"
/* Return positive answer if transaction should be shown in list.
*/
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
{
if (wtx.IsCoinBase())
{
// Ensures we show generated coins / mined transactions at depth 1
if (!wtx.IsInMainChain())
{
return false;
}
}
return true;
}
/*
* Decompose CWallet transaction to model transaction records.
*/
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
int64 nTime = wtx.GetTxTime();
int64 nCredit = wtx.GetCredit(true);
int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
if (nNet > 0 || wtx.IsCoinBase())
{
//
// Credit
//
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
if(wallet->IsMine(txout))
{
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = parts.size(); // sequence number
sub.credit = txout.nValue;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
// Received by Gatecoin Address
sub.type = TransactionRecord::RecvWithAddress;
sub.address = CBitcoinAddress(address).ToString();
}
else
{
// Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"];
}
if (wtx.IsCoinBase())
{
// Generated
sub.type = TransactionRecord::Generated;
}
parts.append(sub);
}
}
}
else
{
bool fAllFromMe = true;
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
bool fAllToMe = true;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
fAllToMe = fAllToMe && wallet->IsMine(txout);
if (fAllFromMe && fAllToMe)
{
// Payment to self
int64 nChange = wtx.GetChange();
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
}
else if (fAllFromMe)
{
//
// Debit
//
int64 nTxFee = nDebit - wtx.GetValueOut();
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
{
const CTxOut& txout = wtx.vout[nOut];
TransactionRecord sub(hash, nTime);
sub.idx = parts.size();
if(wallet->IsMine(txout))
{
// Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address.
continue;
}
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address))
{
// Sent to Gatecoin Address
sub.type = TransactionRecord::SendToAddress;
sub.address = CBitcoinAddress(address).ToString();
}
else
{
// Sent to IP, or other non-address transaction like OP_EVAL
sub.type = TransactionRecord::SendToOther;
sub.address = mapValue["to"];
}
int64 nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 0)
{
nValue += nTxFee;
nTxFee = 0;
}
sub.debit = -nValue;
parts.append(sub);
}
}
else
{
//
// Mixed debit transaction, can't break down payees
//
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
}
}
return parts;
}
void TransactionRecord::updateStatus(const CWalletTx &wtx)
{
// Determine transaction status
// Find the block the tx is in
CBlockIndex* pindex = NULL;
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(wtx.hashBlock);
if (mi != mapBlockIndex.end())
pindex = (*mi).second;
// Sort order, unrecorded transactions sort to the top
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
(pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
(wtx.IsCoinBase() ? 1 : 0),
wtx.nTimeReceived,
idx);
status.confirmed = wtx.IsConfirmed();
status.depth = wtx.GetDepthInMainChain();
status.cur_num_blocks = nBestHeight;
if (!wtx.IsFinal())
{
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
{
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = wtx.nLockTime - nBestHeight + 1;
}
else
{
status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.nLockTime;
}
}
else
{
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
{
status.status = TransactionStatus::Offline;
}
else if (status.depth < NumConfirmations)
{
status.status = TransactionStatus::Unconfirmed;
}
else
{
status.status = TransactionStatus::HaveConfirmations;
}
}
// For generated transactions, determine maturity
if(type == TransactionRecord::Generated)
{
int64 nCredit = wtx.GetCredit(true);
if (nCredit == 0)
{
status.maturity = TransactionStatus::Immature;
if (wtx.IsInMainChain())
{
status.matures_in = wtx.GetBlocksToMaturity();
// Check if the block was requested by anyone
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
status.maturity = TransactionStatus::MaturesWarning;
}
else
{
status.maturity = TransactionStatus::NotAccepted;
}
}
else
{
status.maturity = TransactionStatus::Mature;
}
}
}
bool TransactionRecord::statusUpdateNeeded()
{
return status.cur_num_blocks != nBestHeight;
}
std::string TransactionRecord::getTxID()
{
return hash.ToString() + strprintf("-%03d", idx);
}
|
/*
* Copyright 2016-2017 James Fong
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "pegr/deprecated/DirectionalLightModel.hpp"
#include <ResourceManager.hpp>
namespace pegr {
DirectionalLightModel::SharedResources::SharedResources() { }
DirectionalLightModel::SharedResources::~SharedResources() { }
DirectionalLightModel::SharedResources* DirectionalLightModel::SharedResources::getSharedInstance() {
static SharedResources instance;
return &instance;
}
void DirectionalLightModel::SharedResources::load() {
ResourceManager* resman = ResourceManager::getSingleton();
mShaderProg = resman->findShaderProgram("DirectionalLightVolume.shaderProgram");
mShaderProg->grab();
{
const std::vector<ShaderProgramResource::Control>& sampler2DControls = mShaderProg->getUniformSampler2Ds();
for(std::vector<ShaderProgramResource::Control>::const_iterator iter = sampler2DControls.begin(); iter != sampler2DControls.end(); ++ iter) {
const ShaderProgramResource::Control& entry = *iter;
if(entry.name == "normal") {
mNormalHandle = entry.handle;
}
}
const std::vector<ShaderProgramResource::Control>& vec3Controls = mShaderProg->getUniformVec3s();
for(std::vector<ShaderProgramResource::Control>::const_iterator iter = vec3Controls.begin(); iter != vec3Controls.end(); ++ iter) {
const ShaderProgramResource::Control& entry = *iter;
if(entry.name == "direction") {
mDirectionHandle = entry.handle;
}
else if(entry.name == "color") {
mColorHandle = entry.handle;
}
}
}
GLfloat vertices[] = {
-1.f, -1.f,
1.f, -1.f,
-1.f, 1.f,
1.f, 1.f
};
GLuint indices[] = {
2, 0, 3,
3, 0, 1,
};
glGenBuffers(1, &mDLightVbo);
glBindBuffer(GL_ARRAY_BUFFER, mDLightVbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &mDLightIbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mDLightIbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glGenVertexArrays(1, &mDLightVao);
glBindVertexArray(mDLightVao);
glBindBuffer(GL_ARRAY_BUFFER, mDLightVbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mDLightIbo);
glEnableVertexAttribArray(mShaderProg->getPosAttrib());
glVertexAttribPointer(mShaderProg->getPosAttrib(), 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), (void*) (0 * sizeof(GLfloat)));
glBindVertexArray(0);
}
void DirectionalLightModel::SharedResources::unload() {
mShaderProg->drop();
glDeleteBuffers(1, &mDLightIbo);
glDeleteBuffers(1, &mDLightVbo);
glDeleteVertexArrays(1, &mDLightVao);
}
void DirectionalLightModel::SharedResources::render(Renderable::Pass rendPass, const glm::mat4& modelMat, const glm::vec3& lightColor) {
if(rendPass.mType != Renderable::Pass::Type::GLOBAL_LIGHTS) {
return;
}
glm::vec3 lightDirection = glm::vec3(modelMat * glm::vec4(0.0, 0.0, 1.0, 0.0));
glUseProgram(mShaderProg->getHandle());
glUniform3fv(mColorHandle, 1, glm::value_ptr(lightColor));
glUniform3fv(mDirectionHandle, 1, glm::value_ptr(lightDirection));
glActiveTexture(GL_TEXTURE0 + 0);
glBindTexture(GL_TEXTURE_2D, rendPass.mNormalTexture);
glUniform1i(mNormalHandle, 0);
glBindVertexArray(mDLightVao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glUseProgram(0);
}
void DirectionalLightModel::setColor(const glm::vec3& color) {
mColor = color;
}
DirectionalLightModel::DirectionalLightModel(glm::vec3 color)
: mColor(color) {
}
DirectionalLightModel::~DirectionalLightModel() {
}
void DirectionalLightModel::load() {
mSharedRes = SharedResources::getSharedInstance();
mSharedRes->grab();
}
void DirectionalLightModel::unload() {
mSharedRes->drop();
}
void DirectionalLightModel::render(Renderable::Pass rendPass, const glm::mat4& modelMat) {
mSharedRes->render(rendPass, modelMat, mColor);
}
}
|
; A192979: Constant term of the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments.
; 1,1,4,9,19,36,65,113,192,321,531,872,1425,2321,3772,6121,9923,16076,26033,42145,68216,110401,178659,289104,467809,756961,1224820,1981833,3206707,5188596,8395361,13584017,21979440,35563521,57543027,93106616,150649713,243756401,394406188,638162665,1032568931,1670731676,2703300689,4374032449,7077333224,11451365761,18528699075,29980064928,48508764097,78488829121,126997593316,205486422537,332484015955,537970438596,870454454657,1408424893361,2278879348128,3687304241601,5966183589843,9653487831560
mov $2,$0
seq $0,192969 ; Constant term of the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments.
sub $0,$2
|
; A033360: [ 40/n ].
; 40,20,13,10,8,6,5,5,4,4,3,3,3,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
add $0,1
mov $1,40
div $1,$0
|
// Copyright 2017 the V8 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.
#include "src/interpreter/interpreter-generator.h"
#include <array>
#include <tuple>
#include "src/builtins/builtins-arguments-gen.h"
#include "src/builtins/builtins-constructor-gen.h"
#include "src/builtins/builtins-iterator-gen.h"
#include "src/codegen/code-factory.h"
#include "src/debug/debug.h"
#include "src/ic/accessor-assembler.h"
#include "src/ic/binary-op-assembler.h"
#include "src/ic/ic.h"
#include "src/interpreter/bytecode-flags.h"
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter-assembler.h"
#include "src/interpreter/interpreter-intrinsics-generator.h"
#include "src/objects/cell.h"
#include "src/objects/js-generator.h"
#include "src/objects/objects-inl.h"
#include "src/objects/oddball.h"
#include "src/objects/source-text-module.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
namespace interpreter {
namespace {
using compiler::Node;
using Label = CodeStubAssembler::Label;
using Variable = CodeStubAssembler::Variable;
#define IGNITION_HANDLER(Name, BaseAssembler) \
class Name##Assembler : public BaseAssembler { \
public: \
explicit Name##Assembler(compiler::CodeAssemblerState* state, \
Bytecode bytecode, OperandScale scale) \
: BaseAssembler(state, bytecode, scale) {} \
static void Generate(compiler::CodeAssemblerState* state, \
OperandScale scale); \
\
private: \
void GenerateImpl(); \
DISALLOW_COPY_AND_ASSIGN(Name##Assembler); \
}; \
void Name##Assembler::Generate(compiler::CodeAssemblerState* state, \
OperandScale scale) { \
Name##Assembler assembler(state, Bytecode::k##Name, scale); \
state->SetInitialDebugInformation(#Name, __FILE__, __LINE__); \
assembler.GenerateImpl(); \
} \
void Name##Assembler::GenerateImpl()
// LdaZero
//
// Load literal '0' into the accumulator.
IGNITION_HANDLER(LdaZero, InterpreterAssembler) {
Node* zero_value = NumberConstant(0.0);
SetAccumulator(zero_value);
Dispatch();
}
// LdaSmi <imm>
//
// Load an integer literal into the accumulator as a Smi.
IGNITION_HANDLER(LdaSmi, InterpreterAssembler) {
Node* smi_int = BytecodeOperandImmSmi(0);
SetAccumulator(smi_int);
Dispatch();
}
// LdaConstant <idx>
//
// Load constant literal at |idx| in the constant pool into the accumulator.
IGNITION_HANDLER(LdaConstant, InterpreterAssembler) {
Node* constant = LoadConstantPoolEntryAtOperandIndex(0);
SetAccumulator(constant);
Dispatch();
}
// LdaUndefined
//
// Load Undefined into the accumulator.
IGNITION_HANDLER(LdaUndefined, InterpreterAssembler) {
SetAccumulator(UndefinedConstant());
Dispatch();
}
// LdaNull
//
// Load Null into the accumulator.
IGNITION_HANDLER(LdaNull, InterpreterAssembler) {
SetAccumulator(NullConstant());
Dispatch();
}
// LdaTheHole
//
// Load TheHole into the accumulator.
IGNITION_HANDLER(LdaTheHole, InterpreterAssembler) {
SetAccumulator(TheHoleConstant());
Dispatch();
}
// LdaTrue
//
// Load True into the accumulator.
IGNITION_HANDLER(LdaTrue, InterpreterAssembler) {
SetAccumulator(TrueConstant());
Dispatch();
}
// LdaFalse
//
// Load False into the accumulator.
IGNITION_HANDLER(LdaFalse, InterpreterAssembler) {
SetAccumulator(FalseConstant());
Dispatch();
}
// Ldar <src>
//
// Load accumulator with value from register <src>.
IGNITION_HANDLER(Ldar, InterpreterAssembler) {
Node* value = LoadRegisterAtOperandIndex(0);
SetAccumulator(value);
Dispatch();
}
// Star <dst>
//
// Store accumulator to register <dst>.
IGNITION_HANDLER(Star, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
StoreRegisterAtOperandIndex(accumulator, 0);
Dispatch();
}
// Mov <src> <dst>
//
// Stores the value of register <src> to register <dst>.
IGNITION_HANDLER(Mov, InterpreterAssembler) {
Node* src_value = LoadRegisterAtOperandIndex(0);
StoreRegisterAtOperandIndex(src_value, 1);
Dispatch();
}
class InterpreterLoadGlobalAssembler : public InterpreterAssembler {
public:
InterpreterLoadGlobalAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
void LdaGlobal(int slot_operand_index, int name_operand_index,
TypeofMode typeof_mode) {
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* feedback_slot = BytecodeOperandIdx(slot_operand_index);
AccessorAssembler accessor_asm(state());
ExitPoint exit_point(this, [=](Node* result) {
SetAccumulator(result);
Dispatch();
});
LazyNode<Context> lazy_context = [=] { return CAST(GetContext()); };
LazyNode<Name> lazy_name = [=] {
Node* name = LoadConstantPoolEntryAtOperandIndex(name_operand_index);
return CAST(name);
};
ParameterMode slot_mode = CodeStubAssembler::INTPTR_PARAMETERS;
accessor_asm.LoadGlobalIC(maybe_feedback_vector, feedback_slot,
lazy_context, lazy_name, typeof_mode, &exit_point,
slot_mode);
}
};
// LdaGlobal <name_index> <slot>
//
// Load the global with name in constant pool entry <name_index> into the
// accumulator using FeedBackVector slot <slot> outside of a typeof.
IGNITION_HANDLER(LdaGlobal, InterpreterLoadGlobalAssembler) {
static const int kNameOperandIndex = 0;
static const int kSlotOperandIndex = 1;
LdaGlobal(kSlotOperandIndex, kNameOperandIndex, NOT_INSIDE_TYPEOF);
}
// LdaGlobalInsideTypeof <name_index> <slot>
//
// Load the global with name in constant pool entry <name_index> into the
// accumulator using FeedBackVector slot <slot> inside of a typeof.
IGNITION_HANDLER(LdaGlobalInsideTypeof, InterpreterLoadGlobalAssembler) {
static const int kNameOperandIndex = 0;
static const int kSlotOperandIndex = 1;
LdaGlobal(kSlotOperandIndex, kNameOperandIndex, INSIDE_TYPEOF);
}
// StaGlobal <name_index> <slot>
//
// Store the value in the accumulator into the global with name in constant pool
// entry <name_index> using FeedBackVector slot <slot>.
IGNITION_HANDLER(StaGlobal, InterpreterAssembler) {
Node* context = GetContext();
// Store the global via the StoreGlobalIC.
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* value = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(1);
Node* smi_slot = SmiTag(raw_slot);
Node* maybe_vector = LoadFeedbackVector();
Label no_feedback(this, Label::kDeferred), end(this);
GotoIf(IsUndefined(maybe_vector), &no_feedback);
CallBuiltin(Builtins::kStoreGlobalIC, context, name, value, smi_slot,
maybe_vector);
Goto(&end);
Bind(&no_feedback);
CallRuntime(Runtime::kStoreGlobalICNoFeedback_Miss, context, value, name);
Goto(&end);
Bind(&end);
Dispatch();
}
// LdaContextSlot <context> <slot_index> <depth>
//
// Load the object in |slot_index| of the context at |depth| in the context
// chain starting at |context| into the accumulator.
IGNITION_HANDLER(LdaContextSlot, InterpreterAssembler) {
Node* context = LoadRegisterAtOperandIndex(0);
Node* slot_index = BytecodeOperandIdx(1);
Node* depth = BytecodeOperandUImm(2);
Node* slot_context = GetContextAtDepth(context, depth);
Node* result = LoadContextElement(slot_context, slot_index);
SetAccumulator(result);
Dispatch();
}
// LdaImmutableContextSlot <context> <slot_index> <depth>
//
// Load the object in |slot_index| of the context at |depth| in the context
// chain starting at |context| into the accumulator.
IGNITION_HANDLER(LdaImmutableContextSlot, InterpreterAssembler) {
Node* context = LoadRegisterAtOperandIndex(0);
Node* slot_index = BytecodeOperandIdx(1);
Node* depth = BytecodeOperandUImm(2);
Node* slot_context = GetContextAtDepth(context, depth);
Node* result = LoadContextElement(slot_context, slot_index);
SetAccumulator(result);
Dispatch();
}
// LdaCurrentContextSlot <slot_index>
//
// Load the object in |slot_index| of the current context into the accumulator.
IGNITION_HANDLER(LdaCurrentContextSlot, InterpreterAssembler) {
Node* slot_index = BytecodeOperandIdx(0);
Node* slot_context = GetContext();
Node* result = LoadContextElement(slot_context, slot_index);
SetAccumulator(result);
Dispatch();
}
// LdaImmutableCurrentContextSlot <slot_index>
//
// Load the object in |slot_index| of the current context into the accumulator.
IGNITION_HANDLER(LdaImmutableCurrentContextSlot, InterpreterAssembler) {
Node* slot_index = BytecodeOperandIdx(0);
Node* slot_context = GetContext();
Node* result = LoadContextElement(slot_context, slot_index);
SetAccumulator(result);
Dispatch();
}
// StaContextSlot <context> <slot_index> <depth>
//
// Stores the object in the accumulator into |slot_index| of the context at
// |depth| in the context chain starting at |context|.
IGNITION_HANDLER(StaContextSlot, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* context = LoadRegisterAtOperandIndex(0);
Node* slot_index = BytecodeOperandIdx(1);
Node* depth = BytecodeOperandUImm(2);
Node* slot_context = GetContextAtDepth(context, depth);
StoreContextElement(slot_context, slot_index, value);
Dispatch();
}
// StaCurrentContextSlot <slot_index>
//
// Stores the object in the accumulator into |slot_index| of the current
// context.
IGNITION_HANDLER(StaCurrentContextSlot, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* slot_index = BytecodeOperandIdx(0);
Node* slot_context = GetContext();
StoreContextElement(slot_context, slot_index, value);
Dispatch();
}
// LdaLookupSlot <name_index>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically.
IGNITION_HANDLER(LdaLookupSlot, InterpreterAssembler) {
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* context = GetContext();
Node* result = CallRuntime(Runtime::kLoadLookupSlot, context, name);
SetAccumulator(result);
Dispatch();
}
// LdaLookupSlotInsideTypeof <name_index>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically without causing a NoReferenceError.
IGNITION_HANDLER(LdaLookupSlotInsideTypeof, InterpreterAssembler) {
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* context = GetContext();
Node* result =
CallRuntime(Runtime::kLoadLookupSlotInsideTypeof, context, name);
SetAccumulator(result);
Dispatch();
}
class InterpreterLookupContextSlotAssembler : public InterpreterAssembler {
public:
InterpreterLookupContextSlotAssembler(CodeAssemblerState* state,
Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
void LookupContextSlot(Runtime::FunctionId function_id) {
Node* context = GetContext();
Node* slot_index = BytecodeOperandIdx(1);
Node* depth = BytecodeOperandUImm(2);
Label slowpath(this, Label::kDeferred);
// Check for context extensions to allow the fast path.
GotoIfHasContextExtensionUpToDepth(context, depth, &slowpath);
// Fast path does a normal load context.
{
Node* slot_context = GetContextAtDepth(context, depth);
Node* result = LoadContextElement(slot_context, slot_index);
SetAccumulator(result);
Dispatch();
}
// Slow path when we have to call out to the runtime.
BIND(&slowpath);
{
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* result = CallRuntime(function_id, context, name);
SetAccumulator(result);
Dispatch();
}
}
};
// LdaLookupContextSlot <name_index>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically.
IGNITION_HANDLER(LdaLookupContextSlot, InterpreterLookupContextSlotAssembler) {
LookupContextSlot(Runtime::kLoadLookupSlot);
}
// LdaLookupContextSlotInsideTypeof <name_index>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically without causing a NoReferenceError.
IGNITION_HANDLER(LdaLookupContextSlotInsideTypeof,
InterpreterLookupContextSlotAssembler) {
LookupContextSlot(Runtime::kLoadLookupSlotInsideTypeof);
}
class InterpreterLookupGlobalAssembler : public InterpreterLoadGlobalAssembler {
public:
InterpreterLookupGlobalAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterLoadGlobalAssembler(state, bytecode, operand_scale) {}
void LookupGlobalSlot(Runtime::FunctionId function_id) {
Node* context = GetContext();
Node* depth = BytecodeOperandUImm(2);
Label slowpath(this, Label::kDeferred);
// Check for context extensions to allow the fast path
GotoIfHasContextExtensionUpToDepth(context, depth, &slowpath);
// Fast path does a normal load global
{
static const int kNameOperandIndex = 0;
static const int kSlotOperandIndex = 1;
TypeofMode typeof_mode =
function_id == Runtime::kLoadLookupSlotInsideTypeof
? INSIDE_TYPEOF
: NOT_INSIDE_TYPEOF;
LdaGlobal(kSlotOperandIndex, kNameOperandIndex, typeof_mode);
}
// Slow path when we have to call out to the runtime
BIND(&slowpath);
{
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* result = CallRuntime(function_id, context, name);
SetAccumulator(result);
Dispatch();
}
}
};
// LdaLookupGlobalSlot <name_index> <feedback_slot> <depth>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically.
IGNITION_HANDLER(LdaLookupGlobalSlot, InterpreterLookupGlobalAssembler) {
LookupGlobalSlot(Runtime::kLoadLookupSlot);
}
// LdaLookupGlobalSlotInsideTypeof <name_index> <feedback_slot> <depth>
//
// Lookup the object with the name in constant pool entry |name_index|
// dynamically without causing a NoReferenceError.
IGNITION_HANDLER(LdaLookupGlobalSlotInsideTypeof,
InterpreterLookupGlobalAssembler) {
LookupGlobalSlot(Runtime::kLoadLookupSlotInsideTypeof);
}
// StaLookupSlot <name_index> <flags>
//
// Store the object in accumulator to the object with the name in constant
// pool entry |name_index|.
IGNITION_HANDLER(StaLookupSlot, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
Node* bytecode_flags = BytecodeOperandFlag(1);
Node* context = GetContext();
Variable var_result(this, MachineRepresentation::kTagged);
Label sloppy(this), strict(this), end(this);
DCHECK_EQ(0, LanguageMode::kSloppy);
DCHECK_EQ(1, LanguageMode::kStrict);
DCHECK_EQ(0, static_cast<int>(LookupHoistingMode::kNormal));
DCHECK_EQ(1, static_cast<int>(LookupHoistingMode::kLegacySloppy));
Branch(IsSetWord32<StoreLookupSlotFlags::LanguageModeBit>(bytecode_flags),
&strict, &sloppy);
BIND(&strict);
{
CSA_ASSERT(this, IsClearWord32<StoreLookupSlotFlags::LookupHoistingModeBit>(
bytecode_flags));
var_result.Bind(
CallRuntime(Runtime::kStoreLookupSlot_Strict, context, name, value));
Goto(&end);
}
BIND(&sloppy);
{
Label hoisting(this), ordinary(this);
Branch(IsSetWord32<StoreLookupSlotFlags::LookupHoistingModeBit>(
bytecode_flags),
&hoisting, &ordinary);
BIND(&hoisting);
{
var_result.Bind(CallRuntime(Runtime::kStoreLookupSlot_SloppyHoisting,
context, name, value));
Goto(&end);
}
BIND(&ordinary);
{
var_result.Bind(
CallRuntime(Runtime::kStoreLookupSlot_Sloppy, context, name, value));
Goto(&end);
}
}
BIND(&end);
{
SetAccumulator(var_result.value());
Dispatch();
}
}
// LdaNamedProperty <object> <name_index> <slot>
//
// Calls the LoadIC at FeedBackVector slot <slot> for <object> and the name at
// constant pool entry <name_index>.
IGNITION_HANDLER(LdaNamedProperty, InterpreterAssembler) {
Node* feedback_vector = LoadFeedbackVector();
Node* feedback_slot = BytecodeOperandIdx(2);
Node* smi_slot = SmiTag(feedback_slot);
// Load receiver.
Node* recv = LoadRegisterAtOperandIndex(0);
// Load the name and context lazily.
LazyNode<Name> name = [=] {
return CAST(LoadConstantPoolEntryAtOperandIndex(1));
};
LazyNode<Context> context = [=] { return CAST(GetContext()); };
Label done(this);
Variable var_result(this, MachineRepresentation::kTagged);
ExitPoint exit_point(this, &done, &var_result);
AccessorAssembler::LazyLoadICParameters params(context, recv, name, smi_slot,
feedback_vector);
AccessorAssembler accessor_asm(state());
accessor_asm.LoadIC_BytecodeHandler(¶ms, &exit_point);
BIND(&done);
{
SetAccumulator(var_result.value());
Dispatch();
}
}
// LdaPropertyNofeedback <object> <slot>
//
// Calls the GetProperty builtin for <object> and the key in the accumulator.
IGNITION_HANDLER(LdaNamedPropertyNoFeedback, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = LoadConstantPoolEntryAtOperandIndex(1);
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kGetProperty, context, object, name);
SetAccumulator(result);
Dispatch();
}
// KeyedLoadIC <object> <slot>
//
// Calls the KeyedLoadIC at FeedBackVector slot <slot> for <object> and the key
// in the accumulator.
IGNITION_HANDLER(LdaKeyedProperty, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(1);
Node* smi_slot = SmiTag(raw_slot);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_result, MachineRepresentation::kTagged);
var_result.Bind(CallBuiltin(Builtins::kKeyedLoadIC, context, object, name,
smi_slot, feedback_vector));
SetAccumulator(var_result.value());
Dispatch();
}
class InterpreterStoreNamedPropertyAssembler : public InterpreterAssembler {
public:
InterpreterStoreNamedPropertyAssembler(CodeAssemblerState* state,
Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
void StaNamedProperty(Callable ic, NamedPropertyType property_type) {
Node* code_target = HeapConstant(ic.code());
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = LoadConstantPoolEntryAtOperandIndex(1);
Node* value = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(2);
Node* smi_slot = SmiTag(raw_slot);
Node* maybe_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_result, MachineRepresentation::kTagged);
var_result.Bind(CallStub(ic.descriptor(), code_target, context, object,
name, value, smi_slot, maybe_vector));
// To avoid special logic in the deoptimizer to re-materialize the value in
// the accumulator, we overwrite the accumulator after the IC call. It
// doesn't really matter what we write to the accumulator here, since we
// restore to the correct value on the outside. Storing the result means we
// don't need to keep unnecessary state alive across the callstub.
SetAccumulator(var_result.value());
Dispatch();
}
};
// StaNamedProperty <object> <name_index> <slot>
//
// Calls the StoreIC at FeedBackVector slot <slot> for <object> and
// the name in constant pool entry <name_index> with the value in the
// accumulator.
IGNITION_HANDLER(StaNamedProperty, InterpreterStoreNamedPropertyAssembler) {
Callable ic = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
StaNamedProperty(ic, NamedPropertyType::kNotOwn);
}
// StaNamedOwnProperty <object> <name_index> <slot>
//
// Calls the StoreOwnIC at FeedBackVector slot <slot> for <object> and
// the name in constant pool entry <name_index> with the value in the
// accumulator.
IGNITION_HANDLER(StaNamedOwnProperty, InterpreterStoreNamedPropertyAssembler) {
Callable ic = CodeFactory::StoreOwnICInOptimizedCode(isolate());
StaNamedProperty(ic, NamedPropertyType::kOwn);
}
// StaNamedPropertyNoFeedback <object> <name_index>
//
// Calls the SetPropertyBuiltin for <object> and the name in constant pool entry
// <name_index> with the value in the accumulator.
IGNITION_HANDLER(StaNamedPropertyNoFeedback,
InterpreterStoreNamedPropertyAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = LoadConstantPoolEntryAtOperandIndex(1);
Node* value = GetAccumulator();
Node* context = GetContext();
Node* result =
CallRuntime(Runtime::kSetNamedProperty, context, object, name, value);
SetAccumulator(result);
Dispatch();
}
// StaKeyedProperty <object> <key> <slot>
//
// Calls the KeyedStoreIC at FeedbackVector slot <slot> for <object> and
// the key <key> with the value in the accumulator.
IGNITION_HANDLER(StaKeyedProperty, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = LoadRegisterAtOperandIndex(1);
Node* value = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(2);
Node* smi_slot = SmiTag(raw_slot);
Node* maybe_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_result, MachineRepresentation::kTagged);
var_result.Bind(CallBuiltin(Builtins::kKeyedStoreIC, context, object, name,
value, smi_slot, maybe_vector));
// To avoid special logic in the deoptimizer to re-materialize the value in
// the accumulator, we overwrite the accumulator after the IC call. It
// doesn't really matter what we write to the accumulator here, since we
// restore to the correct value on the outside. Storing the result means we
// don't need to keep unnecessary state alive across the callstub.
SetAccumulator(var_result.value());
Dispatch();
}
// StaInArrayLiteral <array> <index> <slot>
//
// Calls the StoreInArrayLiteralIC at FeedbackVector slot <slot> for <array> and
// the key <index> with the value in the accumulator.
IGNITION_HANDLER(StaInArrayLiteral, InterpreterAssembler) {
Node* array = LoadRegisterAtOperandIndex(0);
Node* index = LoadRegisterAtOperandIndex(1);
Node* value = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(2);
Node* smi_slot = SmiTag(raw_slot);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_result, MachineRepresentation::kTagged);
var_result.Bind(CallBuiltin(Builtins::kStoreInArrayLiteralIC, context, array,
index, value, smi_slot, feedback_vector));
// To avoid special logic in the deoptimizer to re-materialize the value in
// the accumulator, we overwrite the accumulator after the IC call. It
// doesn't really matter what we write to the accumulator here, since we
// restore to the correct value on the outside. Storing the result means we
// don't need to keep unnecessary state alive across the callstub.
SetAccumulator(var_result.value());
Dispatch();
}
// StaDataPropertyInLiteral <object> <name> <flags>
//
// Define a property <name> with value from the accumulator in <object>.
// Property attributes and whether set_function_name are stored in
// DataPropertyInLiteralFlags <flags>.
//
// This definition is not observable and is used only for definitions
// in object or class literals.
IGNITION_HANDLER(StaDataPropertyInLiteral, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* name = LoadRegisterAtOperandIndex(1);
Node* value = GetAccumulator();
Node* flags = SmiFromInt32(BytecodeOperandFlag(2));
Node* vector_index = SmiTag(BytecodeOperandIdx(3));
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
CallRuntime(Runtime::kDefineDataPropertyInLiteral, context, object, name,
value, flags, feedback_vector, vector_index);
Dispatch();
}
IGNITION_HANDLER(CollectTypeProfile, InterpreterAssembler) {
Node* position = BytecodeOperandImmSmi(0);
Node* value = GetAccumulator();
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
CallRuntime(Runtime::kCollectTypeProfile, context, position, value,
feedback_vector);
Dispatch();
}
// LdaModuleVariable <cell_index> <depth>
//
// Load the contents of a module variable into the accumulator. The variable is
// identified by <cell_index>. <depth> is the depth of the current context
// relative to the module context.
IGNITION_HANDLER(LdaModuleVariable, InterpreterAssembler) {
Node* cell_index = BytecodeOperandImmIntPtr(0);
Node* depth = BytecodeOperandUImm(1);
Node* module_context = GetContextAtDepth(GetContext(), depth);
Node* module = LoadContextElement(module_context, Context::EXTENSION_INDEX);
Label if_export(this), if_import(this), end(this);
Branch(IntPtrGreaterThan(cell_index, IntPtrConstant(0)), &if_export,
&if_import);
BIND(&if_export);
{
TNode<FixedArray> regular_exports =
CAST(LoadObjectField(module, SourceTextModule::kRegularExportsOffset));
// The actual array index is (cell_index - 1).
Node* export_index = IntPtrSub(cell_index, IntPtrConstant(1));
Node* cell = LoadFixedArrayElement(regular_exports, export_index);
SetAccumulator(LoadObjectField(cell, Cell::kValueOffset));
Goto(&end);
}
BIND(&if_import);
{
TNode<FixedArray> regular_imports =
CAST(LoadObjectField(module, SourceTextModule::kRegularImportsOffset));
// The actual array index is (-cell_index - 1).
Node* import_index = IntPtrSub(IntPtrConstant(-1), cell_index);
Node* cell = LoadFixedArrayElement(regular_imports, import_index);
SetAccumulator(LoadObjectField(cell, Cell::kValueOffset));
Goto(&end);
}
BIND(&end);
Dispatch();
}
// StaModuleVariable <cell_index> <depth>
//
// Store accumulator to the module variable identified by <cell_index>.
// <depth> is the depth of the current context relative to the module context.
IGNITION_HANDLER(StaModuleVariable, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* cell_index = BytecodeOperandImmIntPtr(0);
Node* depth = BytecodeOperandUImm(1);
Node* module_context = GetContextAtDepth(GetContext(), depth);
Node* module = LoadContextElement(module_context, Context::EXTENSION_INDEX);
Label if_export(this), if_import(this), end(this);
Branch(IntPtrGreaterThan(cell_index, IntPtrConstant(0)), &if_export,
&if_import);
BIND(&if_export);
{
TNode<FixedArray> regular_exports =
CAST(LoadObjectField(module, SourceTextModule::kRegularExportsOffset));
// The actual array index is (cell_index - 1).
Node* export_index = IntPtrSub(cell_index, IntPtrConstant(1));
Node* cell = LoadFixedArrayElement(regular_exports, export_index);
StoreObjectField(cell, Cell::kValueOffset, value);
Goto(&end);
}
BIND(&if_import);
{
// Not supported (probably never).
Abort(AbortReason::kUnsupportedModuleOperation);
Goto(&end);
}
BIND(&end);
Dispatch();
}
// PushContext <context>
//
// Saves the current context in <context>, and pushes the accumulator as the
// new current context.
IGNITION_HANDLER(PushContext, InterpreterAssembler) {
Node* new_context = GetAccumulator();
Node* old_context = GetContext();
StoreRegisterAtOperandIndex(old_context, 0);
SetContext(new_context);
Dispatch();
}
// PopContext <context>
//
// Pops the current context and sets <context> as the new context.
IGNITION_HANDLER(PopContext, InterpreterAssembler) {
Node* context = LoadRegisterAtOperandIndex(0);
SetContext(context);
Dispatch();
}
class InterpreterBinaryOpAssembler : public InterpreterAssembler {
public:
InterpreterBinaryOpAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
using BinaryOpGenerator =
Node* (BinaryOpAssembler::*)(Node* context, Node* left, Node* right,
Node* slot, Node* vector, bool lhs_is_smi);
void BinaryOpWithFeedback(BinaryOpGenerator generator) {
Node* lhs = LoadRegisterAtOperandIndex(0);
Node* rhs = GetAccumulator();
Node* context = GetContext();
Node* slot_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
BinaryOpAssembler binop_asm(state());
Node* result = (binop_asm.*generator)(context, lhs, rhs, slot_index,
maybe_feedback_vector, false);
SetAccumulator(result);
Dispatch();
}
void BinaryOpSmiWithFeedback(BinaryOpGenerator generator) {
Node* lhs = GetAccumulator();
Node* rhs = BytecodeOperandImmSmi(0);
Node* context = GetContext();
Node* slot_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
BinaryOpAssembler binop_asm(state());
Node* result = (binop_asm.*generator)(context, lhs, rhs, slot_index,
maybe_feedback_vector, true);
SetAccumulator(result);
Dispatch();
}
};
// Add <src>
//
// Add register <src> to accumulator.
IGNITION_HANDLER(Add, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_AddWithFeedback);
}
// Sub <src>
//
// Subtract register <src> from accumulator.
IGNITION_HANDLER(Sub, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_SubtractWithFeedback);
}
// Mul <src>
//
// Multiply accumulator by register <src>.
IGNITION_HANDLER(Mul, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_MultiplyWithFeedback);
}
// Div <src>
//
// Divide register <src> by accumulator.
IGNITION_HANDLER(Div, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_DivideWithFeedback);
}
// Mod <src>
//
// Modulo register <src> by accumulator.
IGNITION_HANDLER(Mod, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_ModulusWithFeedback);
}
// Exp <src>
//
// Exponentiate register <src> (base) with accumulator (exponent).
IGNITION_HANDLER(Exp, InterpreterBinaryOpAssembler) {
BinaryOpWithFeedback(&BinaryOpAssembler::Generate_ExponentiateWithFeedback);
}
// AddSmi <imm>
//
// Adds an immediate value <imm> to the value in the accumulator.
IGNITION_HANDLER(AddSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(&BinaryOpAssembler::Generate_AddWithFeedback);
}
// SubSmi <imm>
//
// Subtracts an immediate value <imm> from the value in the accumulator.
IGNITION_HANDLER(SubSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(&BinaryOpAssembler::Generate_SubtractWithFeedback);
}
// MulSmi <imm>
//
// Multiplies an immediate value <imm> to the value in the accumulator.
IGNITION_HANDLER(MulSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(&BinaryOpAssembler::Generate_MultiplyWithFeedback);
}
// DivSmi <imm>
//
// Divides the value in the accumulator by immediate value <imm>.
IGNITION_HANDLER(DivSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(&BinaryOpAssembler::Generate_DivideWithFeedback);
}
// ModSmi <imm>
//
// Modulo accumulator by immediate value <imm>.
IGNITION_HANDLER(ModSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(&BinaryOpAssembler::Generate_ModulusWithFeedback);
}
// ExpSmi <imm>
//
// Exponentiate accumulator (base) with immediate value <imm> (exponent).
IGNITION_HANDLER(ExpSmi, InterpreterBinaryOpAssembler) {
BinaryOpSmiWithFeedback(
&BinaryOpAssembler::Generate_ExponentiateWithFeedback);
}
class InterpreterBitwiseBinaryOpAssembler : public InterpreterAssembler {
public:
InterpreterBitwiseBinaryOpAssembler(CodeAssemblerState* state,
Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
void BitwiseBinaryOpWithFeedback(Operation bitwise_op) {
Node* left = LoadRegisterAtOperandIndex(0);
Node* right = GetAccumulator();
Node* context = GetContext();
Node* slot_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
TVARIABLE(Smi, var_left_feedback);
TVARIABLE(Smi, var_right_feedback);
VARIABLE(var_left_word32, MachineRepresentation::kWord32);
VARIABLE(var_right_word32, MachineRepresentation::kWord32);
VARIABLE(var_left_bigint, MachineRepresentation::kTagged, left);
VARIABLE(var_right_bigint, MachineRepresentation::kTagged);
Label if_left_number(this), do_number_op(this);
Label if_left_bigint(this), do_bigint_op(this);
TaggedToWord32OrBigIntWithFeedback(context, left, &if_left_number,
&var_left_word32, &if_left_bigint,
&var_left_bigint, &var_left_feedback);
BIND(&if_left_number);
TaggedToWord32OrBigIntWithFeedback(context, right, &do_number_op,
&var_right_word32, &do_bigint_op,
&var_right_bigint, &var_right_feedback);
BIND(&do_number_op);
TNode<Number> result = BitwiseOp(var_left_word32.value(),
var_right_word32.value(), bitwise_op);
TNode<Smi> result_type = SelectSmiConstant(
TaggedIsSmi(result), BinaryOperationFeedback::kSignedSmall,
BinaryOperationFeedback::kNumber);
TNode<Smi> input_feedback =
SmiOr(var_left_feedback.value(), var_right_feedback.value());
UpdateFeedback(SmiOr(result_type, input_feedback), maybe_feedback_vector,
slot_index);
SetAccumulator(result);
Dispatch();
// BigInt cases.
BIND(&if_left_bigint);
TaggedToNumericWithFeedback(context, right, &do_bigint_op,
&var_right_bigint, &var_right_feedback);
BIND(&do_bigint_op);
SetAccumulator(
CallRuntime(Runtime::kBigIntBinaryOp, context, var_left_bigint.value(),
var_right_bigint.value(), SmiConstant(bitwise_op)));
UpdateFeedback(SmiOr(var_left_feedback.value(), var_right_feedback.value()),
maybe_feedback_vector, slot_index);
Dispatch();
}
void BitwiseBinaryOpWithSmi(Operation bitwise_op) {
Node* left = GetAccumulator();
Node* right = BytecodeOperandImmSmi(0);
Node* slot_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
TVARIABLE(Smi, var_left_feedback);
VARIABLE(var_left_word32, MachineRepresentation::kWord32);
VARIABLE(var_left_bigint, MachineRepresentation::kTagged);
Label do_smi_op(this), if_bigint_mix(this);
TaggedToWord32OrBigIntWithFeedback(context, left, &do_smi_op,
&var_left_word32, &if_bigint_mix,
&var_left_bigint, &var_left_feedback);
BIND(&do_smi_op);
TNode<Number> result =
BitwiseOp(var_left_word32.value(), SmiToInt32(right), bitwise_op);
TNode<Smi> result_type = SelectSmiConstant(
TaggedIsSmi(result), BinaryOperationFeedback::kSignedSmall,
BinaryOperationFeedback::kNumber);
UpdateFeedback(SmiOr(result_type, var_left_feedback.value()),
maybe_feedback_vector, slot_index);
SetAccumulator(result);
Dispatch();
BIND(&if_bigint_mix);
UpdateFeedback(var_left_feedback.value(), maybe_feedback_vector,
slot_index);
ThrowTypeError(context, MessageTemplate::kBigIntMixedTypes);
}
};
// BitwiseOr <src>
//
// BitwiseOr register <src> to accumulator.
IGNITION_HANDLER(BitwiseOr, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kBitwiseOr);
}
// BitwiseXor <src>
//
// BitwiseXor register <src> to accumulator.
IGNITION_HANDLER(BitwiseXor, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kBitwiseXor);
}
// BitwiseAnd <src>
//
// BitwiseAnd register <src> to accumulator.
IGNITION_HANDLER(BitwiseAnd, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kBitwiseAnd);
}
// ShiftLeft <src>
//
// Left shifts register <src> by the count specified in the accumulator.
// Register <src> is converted to an int32 and the accumulator to uint32
// before the operation. 5 lsb bits from the accumulator are used as count
// i.e. <src> << (accumulator & 0x1F).
IGNITION_HANDLER(ShiftLeft, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kShiftLeft);
}
// ShiftRight <src>
//
// Right shifts register <src> by the count specified in the accumulator.
// Result is sign extended. Register <src> is converted to an int32 and the
// accumulator to uint32 before the operation. 5 lsb bits from the accumulator
// are used as count i.e. <src> >> (accumulator & 0x1F).
IGNITION_HANDLER(ShiftRight, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kShiftRight);
}
// ShiftRightLogical <src>
//
// Right Shifts register <src> by the count specified in the accumulator.
// Result is zero-filled. The accumulator and register <src> are converted to
// uint32 before the operation 5 lsb bits from the accumulator are used as
// count i.e. <src> << (accumulator & 0x1F).
IGNITION_HANDLER(ShiftRightLogical, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithFeedback(Operation::kShiftRightLogical);
}
// BitwiseOrSmi <imm>
//
// BitwiseOrSmi accumulator with <imm>.
IGNITION_HANDLER(BitwiseOrSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kBitwiseOr);
}
// BitwiseXorSmi <imm>
//
// BitwiseXorSmi accumulator with <imm>.
IGNITION_HANDLER(BitwiseXorSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kBitwiseXor);
}
// BitwiseAndSmi <imm>
//
// BitwiseAndSmi accumulator with <imm>.
IGNITION_HANDLER(BitwiseAndSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kBitwiseAnd);
}
// BitwiseNot <feedback_slot>
//
// Perform bitwise-not on the accumulator.
IGNITION_HANDLER(BitwiseNot, InterpreterAssembler) {
Node* operand = GetAccumulator();
Node* slot_index = BytecodeOperandIdx(0);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_word32, MachineRepresentation::kWord32);
TVARIABLE(Smi, var_feedback);
VARIABLE(var_bigint, MachineRepresentation::kTagged);
Label if_number(this), if_bigint(this);
TaggedToWord32OrBigIntWithFeedback(context, operand, &if_number, &var_word32,
&if_bigint, &var_bigint, &var_feedback);
// Number case.
BIND(&if_number);
TNode<Number> result =
ChangeInt32ToTagged(Signed(Word32BitwiseNot(var_word32.value())));
TNode<Smi> result_type = SelectSmiConstant(
TaggedIsSmi(result), BinaryOperationFeedback::kSignedSmall,
BinaryOperationFeedback::kNumber);
UpdateFeedback(SmiOr(result_type, var_feedback.value()),
maybe_feedback_vector, slot_index);
SetAccumulator(result);
Dispatch();
// BigInt case.
BIND(&if_bigint);
UpdateFeedback(SmiConstant(BinaryOperationFeedback::kBigInt),
maybe_feedback_vector, slot_index);
SetAccumulator(CallRuntime(Runtime::kBigIntUnaryOp, context,
var_bigint.value(),
SmiConstant(Operation::kBitwiseNot)));
Dispatch();
}
// ShiftLeftSmi <imm>
//
// Left shifts accumulator by the count specified in <imm>.
// The accumulator is converted to an int32 before the operation. The 5
// lsb bits from <imm> are used as count i.e. <src> << (<imm> & 0x1F).
IGNITION_HANDLER(ShiftLeftSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kShiftLeft);
}
// ShiftRightSmi <imm>
//
// Right shifts accumulator by the count specified in <imm>. Result is sign
// extended. The accumulator is converted to an int32 before the operation. The
// 5 lsb bits from <imm> are used as count i.e. <src> >> (<imm> & 0x1F).
IGNITION_HANDLER(ShiftRightSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kShiftRight);
}
// ShiftRightLogicalSmi <imm>
//
// Right shifts accumulator by the count specified in <imm>. Result is zero
// extended. The accumulator is converted to an int32 before the operation. The
// 5 lsb bits from <imm> are used as count i.e. <src> >>> (<imm> & 0x1F).
IGNITION_HANDLER(ShiftRightLogicalSmi, InterpreterBitwiseBinaryOpAssembler) {
BitwiseBinaryOpWithSmi(Operation::kShiftRightLogical);
}
class UnaryNumericOpAssembler : public InterpreterAssembler {
public:
UnaryNumericOpAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
virtual ~UnaryNumericOpAssembler() = default;
// Must return a tagged value.
virtual TNode<Number> SmiOp(TNode<Smi> smi_value, Variable* var_feedback,
Label* do_float_op, Variable* var_float) = 0;
// Must return a Float64 value.
virtual Node* FloatOp(Node* float_value) = 0;
// Must return a tagged value.
virtual Node* BigIntOp(Node* bigint_value) = 0;
void UnaryOpWithFeedback() {
VARIABLE(var_value, MachineRepresentation::kTagged, GetAccumulator());
VARIABLE(var_result, MachineRepresentation::kTagged);
VARIABLE(var_float_value, MachineRepresentation::kFloat64);
TVARIABLE(Smi, var_feedback, SmiConstant(BinaryOperationFeedback::kNone));
Variable* loop_vars[] = {&var_value, &var_feedback};
Label start(this, arraysize(loop_vars), loop_vars), end(this);
Label do_float_op(this, &var_float_value);
Goto(&start);
// We might have to try again after ToNumeric conversion.
BIND(&start);
{
Label if_smi(this), if_heapnumber(this), if_oddball(this);
Label if_bigint(this, Label::kDeferred);
Label if_other(this, Label::kDeferred);
Node* value = var_value.value();
GotoIf(TaggedIsSmi(value), &if_smi);
Node* map = LoadMap(value);
GotoIf(IsHeapNumberMap(map), &if_heapnumber);
Node* instance_type = LoadMapInstanceType(map);
GotoIf(IsBigIntInstanceType(instance_type), &if_bigint);
Branch(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &if_oddball,
&if_other);
BIND(&if_smi);
{
var_result.Bind(
SmiOp(CAST(value), &var_feedback, &do_float_op, &var_float_value));
Goto(&end);
}
BIND(&if_heapnumber);
{
var_float_value.Bind(LoadHeapNumberValue(value));
Goto(&do_float_op);
}
BIND(&if_bigint);
{
var_result.Bind(BigIntOp(value));
CombineFeedback(&var_feedback, BinaryOperationFeedback::kBigInt);
Goto(&end);
}
BIND(&if_oddball);
{
// We do not require an Or with earlier feedback here because once we
// convert the value to a number, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
CSA_ASSERT(this, SmiEqual(var_feedback.value(),
SmiConstant(BinaryOperationFeedback::kNone)));
OverwriteFeedback(&var_feedback,
BinaryOperationFeedback::kNumberOrOddball);
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset));
Goto(&start);
}
BIND(&if_other);
{
// We do not require an Or with earlier feedback here because once we
// convert the value to a number, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
CSA_ASSERT(this, SmiEqual(var_feedback.value(),
SmiConstant(BinaryOperationFeedback::kNone)));
OverwriteFeedback(&var_feedback, BinaryOperationFeedback::kAny);
var_value.Bind(
CallBuiltin(Builtins::kNonNumberToNumeric, GetContext(), value));
Goto(&start);
}
}
BIND(&do_float_op);
{
CombineFeedback(&var_feedback, BinaryOperationFeedback::kNumber);
var_result.Bind(
AllocateHeapNumberWithValue(FloatOp(var_float_value.value())));
Goto(&end);
}
BIND(&end);
Node* slot_index = BytecodeOperandIdx(0);
Node* maybe_feedback_vector = LoadFeedbackVector();
UpdateFeedback(var_feedback.value(), maybe_feedback_vector, slot_index);
SetAccumulator(var_result.value());
Dispatch();
}
};
class NegateAssemblerImpl : public UnaryNumericOpAssembler {
public:
explicit NegateAssemblerImpl(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: UnaryNumericOpAssembler(state, bytecode, operand_scale) {}
TNode<Number> SmiOp(TNode<Smi> smi_value, Variable* var_feedback,
Label* do_float_op, Variable* var_float) override {
TVARIABLE(Number, var_result);
Label if_zero(this), if_min_smi(this), end(this);
// Return -0 if operand is 0.
GotoIf(SmiEqual(smi_value, SmiConstant(0)), &if_zero);
// Special-case the minimum Smi to avoid overflow.
GotoIf(SmiEqual(smi_value, SmiConstant(Smi::kMinValue)), &if_min_smi);
// Else simply subtract operand from 0.
CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
var_result = SmiSub(SmiConstant(0), smi_value);
Goto(&end);
BIND(&if_zero);
CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber);
var_result = MinusZeroConstant();
Goto(&end);
BIND(&if_min_smi);
var_float->Bind(SmiToFloat64(smi_value));
Goto(do_float_op);
BIND(&end);
return var_result.value();
}
Node* FloatOp(Node* float_value) override { return Float64Neg(float_value); }
Node* BigIntOp(Node* bigint_value) override {
return CallRuntime(Runtime::kBigIntUnaryOp, GetContext(), bigint_value,
SmiConstant(Operation::kNegate));
}
};
// Negate <feedback_slot>
//
// Perform arithmetic negation on the accumulator.
IGNITION_HANDLER(Negate, NegateAssemblerImpl) { UnaryOpWithFeedback(); }
// ToName <dst>
//
// Convert the object referenced by the accumulator to a name.
IGNITION_HANDLER(ToName, InterpreterAssembler) {
Node* object = GetAccumulator();
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kToName, context, object);
StoreRegisterAtOperandIndex(result, 0);
Dispatch();
}
// ToNumber <slot>
//
// Convert the object referenced by the accumulator to a number.
IGNITION_HANDLER(ToNumber, InterpreterAssembler) {
ToNumberOrNumeric(Object::Conversion::kToNumber);
}
// ToNumeric <slot>
//
// Convert the object referenced by the accumulator to a numeric.
IGNITION_HANDLER(ToNumeric, InterpreterAssembler) {
ToNumberOrNumeric(Object::Conversion::kToNumeric);
}
// ToObject <dst>
//
// Convert the object referenced by the accumulator to a JSReceiver.
IGNITION_HANDLER(ToObject, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kToObject, context, accumulator);
StoreRegisterAtOperandIndex(result, 0);
Dispatch();
}
// ToString
//
// Convert the accumulator to a String.
IGNITION_HANDLER(ToString, InterpreterAssembler) {
SetAccumulator(ToString_Inline(GetContext(), GetAccumulator()));
Dispatch();
}
class IncDecAssembler : public UnaryNumericOpAssembler {
public:
explicit IncDecAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: UnaryNumericOpAssembler(state, bytecode, operand_scale) {}
Operation op() {
DCHECK(op_ == Operation::kIncrement || op_ == Operation::kDecrement);
return op_;
}
TNode<Number> SmiOp(TNode<Smi> value, Variable* var_feedback,
Label* do_float_op, Variable* var_float) override {
TNode<Smi> one = SmiConstant(1);
Label if_overflow(this), if_notoverflow(this);
TNode<Smi> result = op() == Operation::kIncrement
? TrySmiAdd(value, one, &if_overflow)
: TrySmiSub(value, one, &if_overflow);
Goto(&if_notoverflow);
BIND(&if_overflow);
{
var_float->Bind(SmiToFloat64(value));
Goto(do_float_op);
}
BIND(&if_notoverflow);
CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
return result;
}
Node* FloatOp(Node* float_value) override {
return op() == Operation::kIncrement
? Float64Add(float_value, Float64Constant(1.0))
: Float64Sub(float_value, Float64Constant(1.0));
}
Node* BigIntOp(Node* bigint_value) override {
return CallRuntime(Runtime::kBigIntUnaryOp, GetContext(), bigint_value,
SmiConstant(op()));
}
void IncWithFeedback() {
op_ = Operation::kIncrement;
UnaryOpWithFeedback();
}
void DecWithFeedback() {
op_ = Operation::kDecrement;
UnaryOpWithFeedback();
}
private:
Operation op_ = Operation::kEqual; // Dummy initialization.
};
// Inc
//
// Increments value in the accumulator by one.
IGNITION_HANDLER(Inc, IncDecAssembler) { IncWithFeedback(); }
// Dec
//
// Decrements value in the accumulator by one.
IGNITION_HANDLER(Dec, IncDecAssembler) { DecWithFeedback(); }
// ToBooleanLogicalNot
//
// Perform logical-not on the accumulator, first casting the
// accumulator to a boolean value if required.
IGNITION_HANDLER(ToBooleanLogicalNot, InterpreterAssembler) {
Node* value = GetAccumulator();
Variable result(this, MachineRepresentation::kTagged);
Label if_true(this), if_false(this), end(this);
BranchIfToBooleanIsTrue(value, &if_true, &if_false);
BIND(&if_true);
{
result.Bind(FalseConstant());
Goto(&end);
}
BIND(&if_false);
{
result.Bind(TrueConstant());
Goto(&end);
}
BIND(&end);
SetAccumulator(result.value());
Dispatch();
}
// LogicalNot
//
// Perform logical-not on the accumulator, which must already be a boolean
// value.
IGNITION_HANDLER(LogicalNot, InterpreterAssembler) {
Node* value = GetAccumulator();
Variable result(this, MachineRepresentation::kTagged);
Label if_true(this), if_false(this), end(this);
Node* true_value = TrueConstant();
Node* false_value = FalseConstant();
Branch(WordEqual(value, true_value), &if_true, &if_false);
BIND(&if_true);
{
result.Bind(false_value);
Goto(&end);
}
BIND(&if_false);
{
CSA_ASSERT(this, WordEqual(value, false_value));
result.Bind(true_value);
Goto(&end);
}
BIND(&end);
SetAccumulator(result.value());
Dispatch();
}
// TypeOf
//
// Load the accumulator with the string representating type of the
// object in the accumulator.
IGNITION_HANDLER(TypeOf, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* result = Typeof(value);
SetAccumulator(result);
Dispatch();
}
// DeletePropertyStrict
//
// Delete the property specified in the accumulator from the object
// referenced by the register operand following strict mode semantics.
IGNITION_HANDLER(DeletePropertyStrict, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* key = GetAccumulator();
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kDeleteProperty, context, object, key,
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
SetAccumulator(result);
Dispatch();
}
// DeletePropertySloppy
//
// Delete the property specified in the accumulator from the object
// referenced by the register operand following sloppy mode semantics.
IGNITION_HANDLER(DeletePropertySloppy, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* key = GetAccumulator();
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kDeleteProperty, context, object, key,
SmiConstant(Smi::FromEnum(LanguageMode::kSloppy)));
SetAccumulator(result);
Dispatch();
}
// GetSuperConstructor
//
// Get the super constructor from the object referenced by the accumulator.
// The result is stored in register |reg|.
IGNITION_HANDLER(GetSuperConstructor, InterpreterAssembler) {
Node* active_function = GetAccumulator();
Node* context = GetContext();
Node* result = GetSuperConstructor(context, active_function);
StoreRegisterAtOperandIndex(result, 0);
Dispatch();
}
class InterpreterJSCallAssembler : public InterpreterAssembler {
public:
InterpreterJSCallAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
// Generates code to perform a JS call that collects type feedback.
void JSCall(ConvertReceiverMode receiver_mode) {
Node* function = LoadRegisterAtOperandIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* slot_id = BytecodeOperandIdx(3);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
// Collect the {function} feedback.
CollectCallFeedback(function, context, maybe_feedback_vector, slot_id);
// Call the function and dispatch to the next handler.
CallJSAndDispatch(function, context, args, receiver_mode);
}
// Generates code to perform a JS call without collecting feedback.
void JSCallNoFeedback(ConvertReceiverMode receiver_mode) {
Node* function = LoadRegisterAtOperandIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* context = GetContext();
// Call the function and dispatch to the next handler.
CallJSAndDispatch(function, context, args, receiver_mode);
}
// Generates code to perform a JS call with a known number of arguments that
// collects type feedback.
void JSCallN(int arg_count, ConvertReceiverMode receiver_mode) {
// Indices and counts of operands on the bytecode.
const int kFirstArgumentOperandIndex = 1;
const int kReceiverOperandCount =
(receiver_mode == ConvertReceiverMode::kNullOrUndefined) ? 0 : 1;
const int kRecieverAndArgOperandCount = kReceiverOperandCount + arg_count;
const int kSlotOperandIndex =
kFirstArgumentOperandIndex + kRecieverAndArgOperandCount;
Node* function = LoadRegisterAtOperandIndex(0);
Node* slot_id = BytecodeOperandIdx(kSlotOperandIndex);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
// Collect the {function} feedback.
CollectCallFeedback(function, context, maybe_feedback_vector, slot_id);
switch (kRecieverAndArgOperandCount) {
case 0:
CallJSAndDispatch(function, context, Int32Constant(arg_count),
receiver_mode);
break;
case 1:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex));
break;
case 2:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1));
break;
case 3:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 2));
break;
default:
UNREACHABLE();
}
}
};
// Call <callable> <receiver> <arg_count> <feedback_slot_id>
//
// Call a JSfunction or Callable in |callable| with the |receiver| and
// |arg_count| arguments in subsequent registers. Collect type feedback
// into |feedback_slot_id|
IGNITION_HANDLER(CallAnyReceiver, InterpreterJSCallAssembler) {
JSCall(ConvertReceiverMode::kAny);
}
IGNITION_HANDLER(CallProperty, InterpreterJSCallAssembler) {
JSCall(ConvertReceiverMode::kNotNullOrUndefined);
}
IGNITION_HANDLER(CallProperty0, InterpreterJSCallAssembler) {
JSCallN(0, ConvertReceiverMode::kNotNullOrUndefined);
}
IGNITION_HANDLER(CallProperty1, InterpreterJSCallAssembler) {
JSCallN(1, ConvertReceiverMode::kNotNullOrUndefined);
}
IGNITION_HANDLER(CallProperty2, InterpreterJSCallAssembler) {
JSCallN(2, ConvertReceiverMode::kNotNullOrUndefined);
}
IGNITION_HANDLER(CallUndefinedReceiver, InterpreterJSCallAssembler) {
JSCall(ConvertReceiverMode::kNullOrUndefined);
}
IGNITION_HANDLER(CallUndefinedReceiver0, InterpreterJSCallAssembler) {
JSCallN(0, ConvertReceiverMode::kNullOrUndefined);
}
IGNITION_HANDLER(CallUndefinedReceiver1, InterpreterJSCallAssembler) {
JSCallN(1, ConvertReceiverMode::kNullOrUndefined);
}
IGNITION_HANDLER(CallUndefinedReceiver2, InterpreterJSCallAssembler) {
JSCallN(2, ConvertReceiverMode::kNullOrUndefined);
}
IGNITION_HANDLER(CallNoFeedback, InterpreterJSCallAssembler) {
JSCallNoFeedback(ConvertReceiverMode::kAny);
}
// CallRuntime <function_id> <first_arg> <arg_count>
//
// Call the runtime function |function_id| with the first argument in
// register |first_arg| and |arg_count| arguments in subsequent
// registers.
IGNITION_HANDLER(CallRuntime, InterpreterAssembler) {
Node* function_id = BytecodeOperandRuntimeId(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* context = GetContext();
Node* result = CallRuntimeN(function_id, context, args);
SetAccumulator(result);
Dispatch();
}
// InvokeIntrinsic <function_id> <first_arg> <arg_count>
//
// Implements the semantic equivalent of calling the runtime function
// |function_id| with the first argument in |first_arg| and |arg_count|
// arguments in subsequent registers.
IGNITION_HANDLER(InvokeIntrinsic, InterpreterAssembler) {
Node* function_id = BytecodeOperandIntrinsicId(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* context = GetContext();
Node* result = GenerateInvokeIntrinsic(this, function_id, context, args);
SetAccumulator(result);
Dispatch();
}
// CallRuntimeForPair <function_id> <first_arg> <arg_count> <first_return>
//
// Call the runtime function |function_id| which returns a pair, with the
// first argument in register |first_arg| and |arg_count| arguments in
// subsequent registers. Returns the result in <first_return> and
// <first_return + 1>
IGNITION_HANDLER(CallRuntimeForPair, InterpreterAssembler) {
// Call the runtime function.
Node* function_id = BytecodeOperandRuntimeId(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* context = GetContext();
Node* result_pair = CallRuntimeN(function_id, context, args, 2);
// Store the results in <first_return> and <first_return + 1>
Node* result0 = Projection(0, result_pair);
Node* result1 = Projection(1, result_pair);
StoreRegisterPairAtOperandIndex(result0, result1, 3);
Dispatch();
}
// CallJSRuntime <context_index> <receiver> <arg_count>
//
// Call the JS runtime function that has the |context_index| with the receiver
// in register |receiver| and |arg_count| arguments in subsequent registers.
IGNITION_HANDLER(CallJSRuntime, InterpreterAssembler) {
Node* context_index = BytecodeOperandNativeContextIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
// Get the function to call from the native context.
Node* context = GetContext();
Node* native_context = LoadNativeContext(context);
Node* function = LoadContextElement(native_context, context_index);
// Call the function.
CallJSAndDispatch(function, context, args,
ConvertReceiverMode::kNullOrUndefined);
}
// CallWithSpread <callable> <first_arg> <arg_count>
//
// Call a JSfunction or Callable in |callable| with the receiver in
// |first_arg| and |arg_count - 1| arguments in subsequent registers. The
// final argument is always a spread.
//
IGNITION_HANDLER(CallWithSpread, InterpreterAssembler) {
Node* callable = LoadRegisterAtOperandIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* slot_id = BytecodeOperandIdx(3);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
// Call into Runtime function CallWithSpread which does everything.
CallJSWithSpreadAndDispatch(callable, context, args, slot_id,
maybe_feedback_vector);
}
// ConstructWithSpread <first_arg> <arg_count>
//
// Call the constructor in |constructor| with the first argument in register
// |first_arg| and |arg_count| arguments in subsequent registers. The final
// argument is always a spread. The new.target is in the accumulator.
//
IGNITION_HANDLER(ConstructWithSpread, InterpreterAssembler) {
Node* new_target = GetAccumulator();
Node* constructor = LoadRegisterAtOperandIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* slot_id = BytecodeOperandIdx(3);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
Node* result = ConstructWithSpread(constructor, context, new_target, args,
slot_id, feedback_vector);
SetAccumulator(result);
Dispatch();
}
// Construct <constructor> <first_arg> <arg_count>
//
// Call operator construct with |constructor| and the first argument in
// register |first_arg| and |arg_count| arguments in subsequent
// registers. The new.target is in the accumulator.
//
IGNITION_HANDLER(Construct, InterpreterAssembler) {
Node* new_target = GetAccumulator();
Node* constructor = LoadRegisterAtOperandIndex(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
Node* slot_id = BytecodeOperandIdx(3);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
Node* result = Construct(constructor, context, new_target, args, slot_id,
feedback_vector);
SetAccumulator(result);
Dispatch();
}
class InterpreterCompareOpAssembler : public InterpreterAssembler {
public:
InterpreterCompareOpAssembler(CodeAssemblerState* state, Bytecode bytecode,
OperandScale operand_scale)
: InterpreterAssembler(state, bytecode, operand_scale) {}
void CompareOpWithFeedback(Operation compare_op) {
Node* lhs = LoadRegisterAtOperandIndex(0);
Node* rhs = GetAccumulator();
Node* context = GetContext();
Variable var_type_feedback(this, MachineRepresentation::kTagged);
Node* result;
switch (compare_op) {
case Operation::kEqual:
result = Equal(lhs, rhs, context, &var_type_feedback);
break;
case Operation::kStrictEqual:
result = StrictEqual(lhs, rhs, &var_type_feedback);
break;
case Operation::kLessThan:
case Operation::kGreaterThan:
case Operation::kLessThanOrEqual:
case Operation::kGreaterThanOrEqual:
result = RelationalComparison(compare_op, lhs, rhs, context,
&var_type_feedback);
break;
default:
UNREACHABLE();
}
Node* slot_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
UpdateFeedback(var_type_feedback.value(), maybe_feedback_vector,
slot_index);
SetAccumulator(result);
Dispatch();
}
};
// TestEqual <src>
//
// Test if the value in the <src> register equals the accumulator.
IGNITION_HANDLER(TestEqual, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kEqual);
}
// TestEqualStrict <src>
//
// Test if the value in the <src> register is strictly equal to the accumulator.
IGNITION_HANDLER(TestEqualStrict, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kStrictEqual);
}
// TestLessThan <src>
//
// Test if the value in the <src> register is less than the accumulator.
IGNITION_HANDLER(TestLessThan, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kLessThan);
}
// TestGreaterThan <src>
//
// Test if the value in the <src> register is greater than the accumulator.
IGNITION_HANDLER(TestGreaterThan, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kGreaterThan);
}
// TestLessThanOrEqual <src>
//
// Test if the value in the <src> register is less than or equal to the
// accumulator.
IGNITION_HANDLER(TestLessThanOrEqual, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kLessThanOrEqual);
}
// TestGreaterThanOrEqual <src>
//
// Test if the value in the <src> register is greater than or equal to the
// accumulator.
IGNITION_HANDLER(TestGreaterThanOrEqual, InterpreterCompareOpAssembler) {
CompareOpWithFeedback(Operation::kGreaterThanOrEqual);
}
// TestReferenceEqual <src>
//
// Test if the value in the <src> register is equal to the accumulator
// by means of simple comparison. For SMIs and simple reference comparisons.
IGNITION_HANDLER(TestReferenceEqual, InterpreterAssembler) {
Node* lhs = LoadRegisterAtOperandIndex(0);
Node* rhs = GetAccumulator();
Node* result = SelectBooleanConstant(WordEqual(lhs, rhs));
SetAccumulator(result);
Dispatch();
}
// TestIn <src> <feedback_slot>
//
// Test if the object referenced by the register operand is a property of the
// object referenced by the accumulator.
IGNITION_HANDLER(TestIn, InterpreterAssembler) {
Node* name = LoadRegisterAtOperandIndex(0);
Node* object = GetAccumulator();
Node* raw_slot = BytecodeOperandIdx(1);
Node* smi_slot = SmiTag(raw_slot);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
VARIABLE(var_result, MachineRepresentation::kTagged);
var_result.Bind(CallBuiltin(Builtins::kKeyedHasIC, context, object, name,
smi_slot, feedback_vector));
SetAccumulator(var_result.value());
Dispatch();
}
// TestInstanceOf <src> <feedback_slot>
//
// Test if the object referenced by the <src> register is an an instance of type
// referenced by the accumulator.
IGNITION_HANDLER(TestInstanceOf, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* callable = GetAccumulator();
Node* slot_id = BytecodeOperandIdx(1);
Node* feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
Label feedback_done(this);
GotoIf(IsUndefined(feedback_vector), &feedback_done);
// Record feedback for the {callable} in the {feedback_vector}.
CollectCallableFeedback(callable, context, feedback_vector, slot_id);
Goto(&feedback_done);
BIND(&feedback_done);
// Perform the actual instanceof operation.
SetAccumulator(InstanceOf(object, callable, context));
Dispatch();
}
// TestUndetectable
//
// Test if the value in the accumulator is undetectable (null, undefined or
// document.all).
IGNITION_HANDLER(TestUndetectable, InterpreterAssembler) {
Label return_false(this), end(this);
Node* object = GetAccumulator();
// If the object is an Smi then return false.
SetAccumulator(FalseConstant());
GotoIf(TaggedIsSmi(object), &end);
// If it is a HeapObject, load the map and check for undetectable bit.
Node* result = SelectBooleanConstant(IsUndetectableMap(LoadMap(object)));
SetAccumulator(result);
Goto(&end);
BIND(&end);
Dispatch();
}
// TestNull
//
// Test if the value in accumulator is strictly equal to null.
IGNITION_HANDLER(TestNull, InterpreterAssembler) {
Node* object = GetAccumulator();
Node* result = SelectBooleanConstant(WordEqual(object, NullConstant()));
SetAccumulator(result);
Dispatch();
}
// TestUndefined
//
// Test if the value in the accumulator is strictly equal to undefined.
IGNITION_HANDLER(TestUndefined, InterpreterAssembler) {
Node* object = GetAccumulator();
Node* result = SelectBooleanConstant(WordEqual(object, UndefinedConstant()));
SetAccumulator(result);
Dispatch();
}
// TestTypeOf <literal_flag>
//
// Tests if the object in the <accumulator> is typeof the literal represented
// by |literal_flag|.
IGNITION_HANDLER(TestTypeOf, InterpreterAssembler) {
Node* object = GetAccumulator();
Node* literal_flag = BytecodeOperandFlag(0);
#define MAKE_LABEL(name, lower_case) Label if_##lower_case(this);
TYPEOF_LITERAL_LIST(MAKE_LABEL)
#undef MAKE_LABEL
#define LABEL_POINTER(name, lower_case) &if_##lower_case,
Label* labels[] = {TYPEOF_LITERAL_LIST(LABEL_POINTER)};
#undef LABEL_POINTER
#define CASE(name, lower_case) \
static_cast<int32_t>(TestTypeOfFlags::LiteralFlag::k##name),
int32_t cases[] = {TYPEOF_LITERAL_LIST(CASE)};
#undef CASE
Label if_true(this), if_false(this), end(this);
// We juse use the final label as the default and properly CSA_ASSERT
// that the {literal_flag} is valid here; this significantly improves
// the generated code (compared to having a default label that aborts).
unsigned const num_cases = arraysize(cases);
CSA_ASSERT(this, Uint32LessThan(literal_flag, Int32Constant(num_cases)));
Switch(literal_flag, labels[num_cases - 1], cases, labels, num_cases - 1);
BIND(&if_number);
{
Comment("IfNumber");
GotoIfNumber(object, &if_true);
Goto(&if_false);
}
BIND(&if_string);
{
Comment("IfString");
GotoIf(TaggedIsSmi(object), &if_false);
Branch(IsString(object), &if_true, &if_false);
}
BIND(&if_symbol);
{
Comment("IfSymbol");
GotoIf(TaggedIsSmi(object), &if_false);
Branch(IsSymbol(object), &if_true, &if_false);
}
BIND(&if_boolean);
{
Comment("IfBoolean");
GotoIf(WordEqual(object, TrueConstant()), &if_true);
Branch(WordEqual(object, FalseConstant()), &if_true, &if_false);
}
BIND(&if_bigint);
{
Comment("IfBigInt");
GotoIf(TaggedIsSmi(object), &if_false);
Branch(IsBigInt(object), &if_true, &if_false);
}
BIND(&if_undefined);
{
Comment("IfUndefined");
GotoIf(TaggedIsSmi(object), &if_false);
// Check it is not null and the map has the undetectable bit set.
GotoIf(IsNull(object), &if_false);
Branch(IsUndetectableMap(LoadMap(object)), &if_true, &if_false);
}
BIND(&if_function);
{
Comment("IfFunction");
GotoIf(TaggedIsSmi(object), &if_false);
// Check if callable bit is set and not undetectable.
Node* map_bitfield = LoadMapBitField(LoadMap(object));
Node* callable_undetectable =
Word32And(map_bitfield, Int32Constant(Map::IsUndetectableBit::kMask |
Map::IsCallableBit::kMask));
Branch(Word32Equal(callable_undetectable,
Int32Constant(Map::IsCallableBit::kMask)),
&if_true, &if_false);
}
BIND(&if_object);
{
Comment("IfObject");
GotoIf(TaggedIsSmi(object), &if_false);
// If the object is null then return true.
GotoIf(IsNull(object), &if_true);
// Check if the object is a receiver type and is not undefined or callable.
Node* map = LoadMap(object);
GotoIfNot(IsJSReceiverMap(map), &if_false);
Node* map_bitfield = LoadMapBitField(map);
Node* callable_undetectable =
Word32And(map_bitfield, Int32Constant(Map::IsUndetectableBit::kMask |
Map::IsCallableBit::kMask));
Branch(Word32Equal(callable_undetectable, Int32Constant(0)), &if_true,
&if_false);
}
BIND(&if_other);
{
// Typeof doesn't return any other string value.
Goto(&if_false);
}
BIND(&if_false);
{
SetAccumulator(FalseConstant());
Goto(&end);
}
BIND(&if_true);
{
SetAccumulator(TrueConstant());
Goto(&end);
}
BIND(&end);
Dispatch();
}
// Jump <imm>
//
// Jump by the number of bytes represented by the immediate operand |imm|.
IGNITION_HANDLER(Jump, InterpreterAssembler) {
Node* relative_jump = BytecodeOperandUImmWord(0);
Jump(relative_jump);
}
// JumpConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool.
IGNITION_HANDLER(JumpConstant, InterpreterAssembler) {
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
Jump(relative_jump);
}
// JumpIfTrue <imm>
//
// Jump by the number of bytes represented by an immediate operand if the
// accumulator contains true. This only works for boolean inputs, and
// will misbehave if passed arbitrary input values.
IGNITION_HANDLER(JumpIfTrue, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
CSA_ASSERT(this, TaggedIsNotSmi(accumulator));
CSA_ASSERT(this, IsBoolean(accumulator));
JumpIfWordEqual(accumulator, TrueConstant(), relative_jump);
}
// JumpIfTrueConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the accumulator contains true. This only works for boolean inputs,
// and will misbehave if passed arbitrary input values.
IGNITION_HANDLER(JumpIfTrueConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
CSA_ASSERT(this, TaggedIsNotSmi(accumulator));
CSA_ASSERT(this, IsBoolean(accumulator));
JumpIfWordEqual(accumulator, TrueConstant(), relative_jump);
}
// JumpIfFalse <imm>
//
// Jump by the number of bytes represented by an immediate operand if the
// accumulator contains false. This only works for boolean inputs, and
// will misbehave if passed arbitrary input values.
IGNITION_HANDLER(JumpIfFalse, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
CSA_ASSERT(this, TaggedIsNotSmi(accumulator));
CSA_ASSERT(this, IsBoolean(accumulator));
JumpIfWordEqual(accumulator, FalseConstant(), relative_jump);
}
// JumpIfFalseConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the accumulator contains false. This only works for boolean inputs,
// and will misbehave if passed arbitrary input values.
IGNITION_HANDLER(JumpIfFalseConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
CSA_ASSERT(this, TaggedIsNotSmi(accumulator));
CSA_ASSERT(this, IsBoolean(accumulator));
JumpIfWordEqual(accumulator, FalseConstant(), relative_jump);
}
// JumpIfToBooleanTrue <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is true when the object is cast to boolean.
IGNITION_HANDLER(JumpIfToBooleanTrue, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
Label if_true(this), if_false(this);
BranchIfToBooleanIsTrue(value, &if_true, &if_false);
BIND(&if_true);
Jump(relative_jump);
BIND(&if_false);
Dispatch();
}
// JumpIfToBooleanTrueConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is true when the object is
// cast to boolean.
IGNITION_HANDLER(JumpIfToBooleanTrueConstant, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
Label if_true(this), if_false(this);
BranchIfToBooleanIsTrue(value, &if_true, &if_false);
BIND(&if_true);
Jump(relative_jump);
BIND(&if_false);
Dispatch();
}
// JumpIfToBooleanFalse <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is false when the object is cast to boolean.
IGNITION_HANDLER(JumpIfToBooleanFalse, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
Label if_true(this), if_false(this);
BranchIfToBooleanIsTrue(value, &if_true, &if_false);
BIND(&if_true);
Dispatch();
BIND(&if_false);
Jump(relative_jump);
}
// JumpIfToBooleanFalseConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is false when the object is
// cast to boolean.
IGNITION_HANDLER(JumpIfToBooleanFalseConstant, InterpreterAssembler) {
Node* value = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
Label if_true(this), if_false(this);
BranchIfToBooleanIsTrue(value, &if_true, &if_false);
BIND(&if_true);
Dispatch();
BIND(&if_false);
Jump(relative_jump);
}
// JumpIfNull <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is the null constant.
IGNITION_HANDLER(JumpIfNull, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
JumpIfWordEqual(accumulator, NullConstant(), relative_jump);
}
// JumpIfNullConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is the null constant.
IGNITION_HANDLER(JumpIfNullConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
JumpIfWordEqual(accumulator, NullConstant(), relative_jump);
}
// JumpIfNotNull <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is not the null constant.
IGNITION_HANDLER(JumpIfNotNull, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
JumpIfWordNotEqual(accumulator, NullConstant(), relative_jump);
}
// JumpIfNotNullConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is not the null constant.
IGNITION_HANDLER(JumpIfNotNullConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
JumpIfWordNotEqual(accumulator, NullConstant(), relative_jump);
}
// JumpIfUndefined <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is the undefined constant.
IGNITION_HANDLER(JumpIfUndefined, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
JumpIfWordEqual(accumulator, UndefinedConstant(), relative_jump);
}
// JumpIfUndefinedConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is the undefined constant.
IGNITION_HANDLER(JumpIfUndefinedConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
JumpIfWordEqual(accumulator, UndefinedConstant(), relative_jump);
}
// JumpIfNotUndefined <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is not the undefined constant.
IGNITION_HANDLER(JumpIfNotUndefined, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
JumpIfWordNotEqual(accumulator, UndefinedConstant(), relative_jump);
}
// JumpIfNotUndefinedConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is not the undefined
// constant.
IGNITION_HANDLER(JumpIfNotUndefinedConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
JumpIfWordNotEqual(accumulator, UndefinedConstant(), relative_jump);
}
// JumpIfUndefinedOrNull <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is the undefined constant or the null constant.
IGNITION_HANDLER(JumpIfUndefinedOrNull, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Label do_jump(this);
GotoIf(IsUndefined(accumulator), &do_jump);
GotoIf(IsNull(accumulator), &do_jump);
Dispatch();
BIND(&do_jump);
Node* relative_jump = BytecodeOperandUImmWord(0);
Jump(relative_jump);
}
// JumpIfUndefinedOrNullConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is the undefined constant or
// the null constant.
IGNITION_HANDLER(JumpIfUndefinedOrNullConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Label do_jump(this);
GotoIf(IsUndefined(accumulator), &do_jump);
GotoIf(IsNull(accumulator), &do_jump);
Dispatch();
BIND(&do_jump);
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
Jump(relative_jump);
}
// JumpIfJSReceiver <imm>
//
// Jump by the number of bytes represented by an immediate operand if the object
// referenced by the accumulator is a JSReceiver.
IGNITION_HANDLER(JumpIfJSReceiver, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = BytecodeOperandUImmWord(0);
Label if_object(this), if_notobject(this, Label::kDeferred), if_notsmi(this);
Branch(TaggedIsSmi(accumulator), &if_notobject, &if_notsmi);
BIND(&if_notsmi);
Branch(IsJSReceiver(accumulator), &if_object, &if_notobject);
BIND(&if_object);
Jump(relative_jump);
BIND(&if_notobject);
Dispatch();
}
// JumpIfJSReceiverConstant <idx>
//
// Jump by the number of bytes in the Smi in the |idx| entry in the constant
// pool if the object referenced by the accumulator is a JSReceiver.
IGNITION_HANDLER(JumpIfJSReceiverConstant, InterpreterAssembler) {
Node* accumulator = GetAccumulator();
Node* relative_jump = LoadAndUntagConstantPoolEntryAtOperandIndex(0);
Label if_object(this), if_notobject(this), if_notsmi(this);
Branch(TaggedIsSmi(accumulator), &if_notobject, &if_notsmi);
BIND(&if_notsmi);
Branch(IsJSReceiver(accumulator), &if_object, &if_notobject);
BIND(&if_object);
Jump(relative_jump);
BIND(&if_notobject);
Dispatch();
}
// JumpLoop <imm> <loop_depth>
//
// Jump by the number of bytes represented by the immediate operand |imm|. Also
// performs a loop nesting check and potentially triggers OSR in case the
// current OSR level matches (or exceeds) the specified |loop_depth|.
IGNITION_HANDLER(JumpLoop, InterpreterAssembler) {
Node* relative_jump = BytecodeOperandUImmWord(0);
Node* loop_depth = BytecodeOperandImm(1);
Node* osr_level = LoadOsrNestingLevel();
// Check if OSR points at the given {loop_depth} are armed by comparing it to
// the current {osr_level} loaded from the header of the BytecodeArray.
Label ok(this), osr_armed(this, Label::kDeferred);
Node* condition = Int32GreaterThanOrEqual(loop_depth, osr_level);
Branch(condition, &ok, &osr_armed);
BIND(&ok);
JumpBackward(relative_jump);
BIND(&osr_armed);
{
Callable callable = CodeFactory::InterpreterOnStackReplacement(isolate());
Node* target = HeapConstant(callable.code());
Node* context = GetContext();
CallStub(callable.descriptor(), target, context);
JumpBackward(relative_jump);
}
}
// SwitchOnSmiNoFeedback <table_start> <table_length> <case_value_base>
//
// Jump by the number of bytes defined by a Smi in a table in the constant pool,
// where the table starts at |table_start| and has |table_length| entries.
// The table is indexed by the accumulator, minus |case_value_base|. If the
// case_value falls outside of the table |table_length|, fall-through to the
// next bytecode.
IGNITION_HANDLER(SwitchOnSmiNoFeedback, InterpreterAssembler) {
Node* acc = GetAccumulator();
Node* table_start = BytecodeOperandIdx(0);
Node* table_length = BytecodeOperandUImmWord(1);
Node* case_value_base = BytecodeOperandImmIntPtr(2);
Label fall_through(this);
// The accumulator must be a Smi.
// TODO(leszeks): Add a bytecode with type feedback that allows other
// accumulator values.
CSA_ASSERT(this, TaggedIsSmi(acc));
Node* case_value = IntPtrSub(SmiUntag(acc), case_value_base);
GotoIf(IntPtrLessThan(case_value, IntPtrConstant(0)), &fall_through);
GotoIf(IntPtrGreaterThanOrEqual(case_value, table_length), &fall_through);
Node* entry = IntPtrAdd(table_start, case_value);
Node* relative_jump = LoadAndUntagConstantPoolEntry(entry);
Jump(relative_jump);
BIND(&fall_through);
Dispatch();
}
// CreateRegExpLiteral <pattern_idx> <literal_idx> <flags>
//
// Creates a regular expression literal for literal index <literal_idx> with
// <flags> and the pattern in <pattern_idx>.
IGNITION_HANDLER(CreateRegExpLiteral, InterpreterAssembler) {
Node* pattern = LoadConstantPoolEntryAtOperandIndex(0);
Node* feedback_vector = LoadFeedbackVector();
Node* slot_id = BytecodeOperandIdx(1);
Node* flags = SmiFromInt32(BytecodeOperandFlag(2));
Node* context = GetContext();
VARIABLE(result, MachineRepresentation::kTagged);
ConstructorBuiltinsAssembler constructor_assembler(state());
result.Bind(constructor_assembler.EmitCreateRegExpLiteral(
feedback_vector, slot_id, pattern, flags, context));
SetAccumulator(result.value());
Dispatch();
}
// CreateArrayLiteral <element_idx> <literal_idx> <flags>
//
// Creates an array literal for literal index <literal_idx> with
// CreateArrayLiteral flags <flags> and constant elements in <element_idx>.
IGNITION_HANDLER(CreateArrayLiteral, InterpreterAssembler) {
Node* feedback_vector = LoadFeedbackVector();
Node* slot_id = BytecodeOperandIdx(1);
Node* context = GetContext();
Node* bytecode_flags = BytecodeOperandFlag(2);
Label fast_shallow_clone(this), call_runtime(this, Label::kDeferred);
// No feedback, so handle it as a slow case.
GotoIf(IsUndefined(feedback_vector), &call_runtime);
Branch(IsSetWord32<CreateArrayLiteralFlags::FastCloneSupportedBit>(
bytecode_flags),
&fast_shallow_clone, &call_runtime);
BIND(&fast_shallow_clone);
{
ConstructorBuiltinsAssembler constructor_assembler(state());
Node* result = constructor_assembler.EmitCreateShallowArrayLiteral(
feedback_vector, slot_id, context, &call_runtime,
TRACK_ALLOCATION_SITE);
SetAccumulator(result);
Dispatch();
}
BIND(&call_runtime);
{
Node* flags_raw = DecodeWordFromWord32<CreateArrayLiteralFlags::FlagsBits>(
bytecode_flags);
Node* flags = SmiTag(flags_raw);
Node* constant_elements = LoadConstantPoolEntryAtOperandIndex(0);
Node* result =
CallRuntime(Runtime::kCreateArrayLiteral, context, feedback_vector,
SmiTag(slot_id), constant_elements, flags);
SetAccumulator(result);
Dispatch();
}
}
// CreateEmptyArrayLiteral <literal_idx>
//
// Creates an empty JSArray literal for literal index <literal_idx>.
IGNITION_HANDLER(CreateEmptyArrayLiteral, InterpreterAssembler) {
Node* feedback_vector = LoadFeedbackVector();
Node* slot_id = BytecodeOperandIdx(0);
Node* context = GetContext();
Label no_feedback(this, Label::kDeferred), end(this);
VARIABLE(result, MachineRepresentation::kTagged);
GotoIf(IsUndefined(feedback_vector), &no_feedback);
ConstructorBuiltinsAssembler constructor_assembler(state());
result.Bind(constructor_assembler.EmitCreateEmptyArrayLiteral(
feedback_vector, slot_id, context));
Goto(&end);
BIND(&no_feedback);
{
TNode<Map> array_map = LoadJSArrayElementsMap(GetInitialFastElementsKind(),
LoadNativeContext(context));
result.Bind(AllocateJSArray(GetInitialFastElementsKind(), array_map,
SmiConstant(0), SmiConstant(0), nullptr,
ParameterMode::SMI_PARAMETERS));
Goto(&end);
}
BIND(&end);
SetAccumulator(result.value());
Dispatch();
}
// CreateArrayFromIterable
//
// Spread the given iterable from the accumulator into a new JSArray.
// TODO(neis): Turn this into an intrinsic when we're running out of bytecodes.
IGNITION_HANDLER(CreateArrayFromIterable, InterpreterAssembler) {
Node* iterable = GetAccumulator();
Node* context = GetContext();
Node* result =
CallBuiltin(Builtins::kIterableToListWithSymbolLookup, context, iterable);
SetAccumulator(result);
Dispatch();
}
// CreateObjectLiteral <element_idx> <literal_idx> <flags>
//
// Creates an object literal for literal index <literal_idx> with
// CreateObjectLiteralFlags <flags> and constant elements in <element_idx>.
IGNITION_HANDLER(CreateObjectLiteral, InterpreterAssembler) {
Node* feedback_vector = LoadFeedbackVector();
Node* slot_id = BytecodeOperandIdx(1);
Node* bytecode_flags = BytecodeOperandFlag(2);
Label if_fast_clone(this), if_not_fast_clone(this, Label::kDeferred);
// No feedback, so handle it as a slow case.
GotoIf(IsUndefined(feedback_vector), &if_not_fast_clone);
// Check if we can do a fast clone or have to call the runtime.
Branch(IsSetWord32<CreateObjectLiteralFlags::FastCloneSupportedBit>(
bytecode_flags),
&if_fast_clone, &if_not_fast_clone);
BIND(&if_fast_clone);
{
// If we can do a fast clone do the fast-path in CreateShallowObjectLiteral.
ConstructorBuiltinsAssembler constructor_assembler(state());
Node* result = constructor_assembler.EmitCreateShallowObjectLiteral(
feedback_vector, slot_id, &if_not_fast_clone);
SetAccumulator(result);
Dispatch();
}
BIND(&if_not_fast_clone);
{
// If we can't do a fast clone, call into the runtime.
Node* object_boilerplate_description =
LoadConstantPoolEntryAtOperandIndex(0);
Node* context = GetContext();
Node* flags_raw = DecodeWordFromWord32<CreateObjectLiteralFlags::FlagsBits>(
bytecode_flags);
Node* flags = SmiTag(flags_raw);
Node* result =
CallRuntime(Runtime::kCreateObjectLiteral, context, feedback_vector,
SmiTag(slot_id), object_boilerplate_description, flags);
SetAccumulator(result);
// TODO(klaasb) build a single dispatch once the call is inlined
Dispatch();
}
}
// CreateEmptyObjectLiteral
//
// Creates an empty JSObject literal.
IGNITION_HANDLER(CreateEmptyObjectLiteral, InterpreterAssembler) {
Node* context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
Node* result = constructor_assembler.EmitCreateEmptyObjectLiteral(context);
SetAccumulator(result);
Dispatch();
}
// CloneObject <source_idx> <flags> <feedback_slot>
//
// Allocates a new JSObject with each enumerable own property copied from
// {source}, converting getters into data properties.
IGNITION_HANDLER(CloneObject, InterpreterAssembler) {
Node* source = LoadRegisterAtOperandIndex(0);
Node* bytecode_flags = BytecodeOperandFlag(1);
Node* raw_flags =
DecodeWordFromWord32<CreateObjectLiteralFlags::FlagsBits>(bytecode_flags);
Node* smi_flags = SmiTag(raw_flags);
Node* raw_slot = BytecodeOperandIdx(2);
Node* smi_slot = SmiTag(raw_slot);
Node* maybe_feedback_vector = LoadFeedbackVector();
Node* context = GetContext();
Variable var_result(this, MachineRepresentation::kTagged);
var_result.Bind(CallBuiltin(Builtins::kCloneObjectIC, context, source,
smi_flags, smi_slot, maybe_feedback_vector));
SetAccumulator(var_result.value());
Dispatch();
}
// GetTemplateObject <descriptor_idx> <literal_idx>
//
// Creates the template to pass for tagged templates and returns it in the
// accumulator, creating and caching the site object on-demand as per the
// specification.
IGNITION_HANDLER(GetTemplateObject, InterpreterAssembler) {
Node* feedback_vector = LoadFeedbackVector();
Node* slot = BytecodeOperandIdx(1);
Label call_runtime(this, Label::kDeferred);
GotoIf(IsUndefined(feedback_vector), &call_runtime);
TNode<Object> cached_value =
CAST(LoadFeedbackVectorSlot(feedback_vector, slot, 0, INTPTR_PARAMETERS));
GotoIf(WordEqual(cached_value, SmiConstant(0)), &call_runtime);
SetAccumulator(cached_value);
Dispatch();
BIND(&call_runtime);
{
Node* description = LoadConstantPoolEntryAtOperandIndex(0);
Node* slot_smi = SmiTag(slot);
Node* closure = LoadRegister(Register::function_closure());
Node* shared_info =
LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset);
Node* context = GetContext();
Node* result = CallRuntime(Runtime::kGetTemplateObject, context,
description, shared_info, slot_smi);
Label end(this);
GotoIf(IsUndefined(feedback_vector), &end);
StoreFeedbackVectorSlot(feedback_vector, slot, result);
Goto(&end);
Bind(&end);
SetAccumulator(result);
Dispatch();
}
}
// CreateClosure <index> <slot> <flags>
//
// Creates a new closure for SharedFunctionInfo at position |index| in the
// constant pool and with pretenuring controlled by |flags|.
IGNITION_HANDLER(CreateClosure, InterpreterAssembler) {
Node* shared = LoadConstantPoolEntryAtOperandIndex(0);
Node* flags = BytecodeOperandFlag(2);
Node* context = GetContext();
Node* slot = BytecodeOperandIdx(1);
Label if_undefined(this);
TNode<FixedArray> feedback_cell_array =
LoadClosureFeedbackArray(LoadRegister(Register::function_closure()));
TNode<FeedbackCell> feedback_cell =
CAST(LoadFixedArrayElement(feedback_cell_array, slot));
Label if_fast(this), if_slow(this, Label::kDeferred);
Branch(IsSetWord32<CreateClosureFlags::FastNewClosureBit>(flags), &if_fast,
&if_slow);
BIND(&if_fast);
{
Node* result =
CallBuiltin(Builtins::kFastNewClosure, context, shared, feedback_cell);
SetAccumulator(result);
Dispatch();
}
BIND(&if_slow);
{
Label if_newspace(this), if_oldspace(this);
Branch(IsSetWord32<CreateClosureFlags::PretenuredBit>(flags), &if_oldspace,
&if_newspace);
BIND(&if_newspace);
{
Node* result =
CallRuntime(Runtime::kNewClosure, context, shared, feedback_cell);
SetAccumulator(result);
Dispatch();
}
BIND(&if_oldspace);
{
Node* result = CallRuntime(Runtime::kNewClosure_Tenured, context, shared,
feedback_cell);
SetAccumulator(result);
Dispatch();
}
}
}
// CreateBlockContext <index>
//
// Creates a new block context with the scope info constant at |index|.
IGNITION_HANDLER(CreateBlockContext, InterpreterAssembler) {
Node* scope_info = LoadConstantPoolEntryAtOperandIndex(0);
Node* context = GetContext();
SetAccumulator(CallRuntime(Runtime::kPushBlockContext, context, scope_info));
Dispatch();
}
// CreateCatchContext <exception> <scope_info_idx>
//
// Creates a new context for a catch block with the |exception| in a register
// and the ScopeInfo at |scope_info_idx|.
IGNITION_HANDLER(CreateCatchContext, InterpreterAssembler) {
Node* exception = LoadRegisterAtOperandIndex(0);
Node* scope_info = LoadConstantPoolEntryAtOperandIndex(1);
Node* context = GetContext();
SetAccumulator(
CallRuntime(Runtime::kPushCatchContext, context, exception, scope_info));
Dispatch();
}
// CreateFunctionContext <scope_info_idx> <slots>
//
// Creates a new context with number of |slots| for the function closure.
IGNITION_HANDLER(CreateFunctionContext, InterpreterAssembler) {
Node* scope_info_idx = BytecodeOperandIdx(0);
Node* scope_info = LoadConstantPoolEntry(scope_info_idx);
Node* slots = BytecodeOperandUImm(1);
Node* context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
SetAccumulator(constructor_assembler.EmitFastNewFunctionContext(
scope_info, slots, context, FUNCTION_SCOPE));
Dispatch();
}
// CreateEvalContext <scope_info_idx> <slots>
//
// Creates a new context with number of |slots| for an eval closure.
IGNITION_HANDLER(CreateEvalContext, InterpreterAssembler) {
Node* scope_info_idx = BytecodeOperandIdx(0);
Node* scope_info = LoadConstantPoolEntry(scope_info_idx);
Node* slots = BytecodeOperandUImm(1);
Node* context = GetContext();
ConstructorBuiltinsAssembler constructor_assembler(state());
SetAccumulator(constructor_assembler.EmitFastNewFunctionContext(
scope_info, slots, context, EVAL_SCOPE));
Dispatch();
}
// CreateWithContext <register> <scope_info_idx>
//
// Creates a new context with the ScopeInfo at |scope_info_idx| for a
// with-statement with the object in |register|.
IGNITION_HANDLER(CreateWithContext, InterpreterAssembler) {
Node* object = LoadRegisterAtOperandIndex(0);
Node* scope_info = LoadConstantPoolEntryAtOperandIndex(1);
Node* context = GetContext();
SetAccumulator(
CallRuntime(Runtime::kPushWithContext, context, object, scope_info));
Dispatch();
}
// CreateMappedArguments
//
// Creates a new mapped arguments object.
IGNITION_HANDLER(CreateMappedArguments, InterpreterAssembler) {
Node* closure = LoadRegister(Register::function_closure());
Node* context = GetContext();
Label if_duplicate_parameters(this, Label::kDeferred);
Label if_not_duplicate_parameters(this);
// Check if function has duplicate parameters.
// TODO(rmcilroy): Remove this check when FastNewSloppyArgumentsStub supports
// duplicate parameters.
Node* shared_info =
LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset);
Node* flags = LoadObjectField(shared_info, SharedFunctionInfo::kFlagsOffset,
MachineType::Uint32());
Node* has_duplicate_parameters =
IsSetWord32<SharedFunctionInfo::HasDuplicateParametersBit>(flags);
Branch(has_duplicate_parameters, &if_duplicate_parameters,
&if_not_duplicate_parameters);
BIND(&if_not_duplicate_parameters);
{
ArgumentsBuiltinsAssembler constructor_assembler(state());
Node* result =
constructor_assembler.EmitFastNewSloppyArguments(context, closure);
SetAccumulator(result);
Dispatch();
}
BIND(&if_duplicate_parameters);
{
Node* result =
CallRuntime(Runtime::kNewSloppyArguments_Generic, context, closure);
SetAccumulator(result);
Dispatch();
}
}
// CreateUnmappedArguments
//
// Creates a new unmapped arguments object.
IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) {
Node* context = GetContext();
Node* closure = LoadRegister(Register::function_closure());
ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result =
builtins_assembler.EmitFastNewStrictArguments(context, closure);
SetAccumulator(result);
Dispatch();
}
// CreateRestParameter
//
// Creates a new rest parameter array.
IGNITION_HANDLER(CreateRestParameter, InterpreterAssembler) {
Node* closure = LoadRegister(Register::function_closure());
Node* context = GetContext();
ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result = builtins_assembler.EmitFastNewRestParameter(context, closure);
SetAccumulator(result);
Dispatch();
}
// StackCheck
//
// Performs a stack guard check.
IGNITION_HANDLER(StackCheck, InterpreterAssembler) {
TNode<Context> context = CAST(GetContext());
PerformStackCheck(context);
Dispatch();
}
// SetPendingMessage
//
// Sets the pending message to the value in the accumulator, and returns the
// previous pending message in the accumulator.
IGNITION_HANDLER(SetPendingMessage, InterpreterAssembler) {
Node* pending_message = ExternalConstant(
ExternalReference::address_of_pending_message_obj(isolate()));
Node* previous_message = Load(MachineType::TaggedPointer(), pending_message);
Node* new_message = GetAccumulator();
StoreFullTaggedNoWriteBarrier(pending_message, new_message);
SetAccumulator(previous_message);
Dispatch();
}
// Throw
//
// Throws the exception in the accumulator.
IGNITION_HANDLER(Throw, InterpreterAssembler) {
Node* exception = GetAccumulator();
Node* context = GetContext();
CallRuntime(Runtime::kThrow, context, exception);
// We shouldn't ever return from a throw.
Abort(AbortReason::kUnexpectedReturnFromThrow);
Unreachable();
}
// ReThrow
//
// Re-throws the exception in the accumulator.
IGNITION_HANDLER(ReThrow, InterpreterAssembler) {
Node* exception = GetAccumulator();
Node* context = GetContext();
CallRuntime(Runtime::kReThrow, context, exception);
// We shouldn't ever return from a throw.
Abort(AbortReason::kUnexpectedReturnFromThrow);
Unreachable();
}
// Abort <abort_reason>
//
// Aborts execution (via a call to the runtime function).
IGNITION_HANDLER(Abort, InterpreterAssembler) {
Node* reason = BytecodeOperandIdx(0);
CallRuntime(Runtime::kAbort, NoContextConstant(), SmiTag(reason));
Unreachable();
}
// Return
//
// Return the value in the accumulator.
IGNITION_HANDLER(Return, InterpreterAssembler) {
UpdateInterruptBudgetOnReturn();
Node* accumulator = GetAccumulator();
Return(accumulator);
}
// ThrowReferenceErrorIfHole <variable_name>
//
// Throws an exception if the value in the accumulator is TheHole.
IGNITION_HANDLER(ThrowReferenceErrorIfHole, InterpreterAssembler) {
Node* value = GetAccumulator();
Label throw_error(this, Label::kDeferred);
GotoIf(WordEqual(value, TheHoleConstant()), &throw_error);
Dispatch();
BIND(&throw_error);
{
Node* name = LoadConstantPoolEntryAtOperandIndex(0);
CallRuntime(Runtime::kThrowAccessedUninitializedVariable, GetContext(),
name);
// We shouldn't ever return from a throw.
Abort(AbortReason::kUnexpectedReturnFromThrow);
Unreachable();
}
}
// ThrowSuperNotCalledIfHole
//
// Throws an exception if the value in the accumulator is TheHole.
IGNITION_HANDLER(ThrowSuperNotCalledIfHole, InterpreterAssembler) {
Node* value = GetAccumulator();
Label throw_error(this, Label::kDeferred);
GotoIf(WordEqual(value, TheHoleConstant()), &throw_error);
Dispatch();
BIND(&throw_error);
{
CallRuntime(Runtime::kThrowSuperNotCalled, GetContext());
// We shouldn't ever return from a throw.
Abort(AbortReason::kUnexpectedReturnFromThrow);
Unreachable();
}
}
// ThrowSuperAlreadyCalledIfNotHole
//
// Throws SuperAleradyCalled exception if the value in the accumulator is not
// TheHole.
IGNITION_HANDLER(ThrowSuperAlreadyCalledIfNotHole, InterpreterAssembler) {
Node* value = GetAccumulator();
Label throw_error(this, Label::kDeferred);
GotoIf(WordNotEqual(value, TheHoleConstant()), &throw_error);
Dispatch();
BIND(&throw_error);
{
CallRuntime(Runtime::kThrowSuperAlreadyCalledError, GetContext());
// We shouldn't ever return from a throw.
Abort(AbortReason::kUnexpectedReturnFromThrow);
Unreachable();
}
}
// Debugger
//
// Call runtime to handle debugger statement.
IGNITION_HANDLER(Debugger, InterpreterAssembler) {
Node* context = GetContext();
CallStub(CodeFactory::HandleDebuggerStatement(isolate()), context);
Dispatch();
}
// DebugBreak
//
// Call runtime to handle a debug break.
#define DEBUG_BREAK(Name, ...) \
IGNITION_HANDLER(Name, InterpreterAssembler) { \
Node* context = GetContext(); \
Node* accumulator = GetAccumulator(); \
Node* result_pair = \
CallRuntime(Runtime::kDebugBreakOnBytecode, context, accumulator); \
Node* return_value = Projection(0, result_pair); \
Node* original_bytecode = SmiUntag(Projection(1, result_pair)); \
MaybeDropFrames(context); \
SetAccumulator(return_value); \
DispatchToBytecode(original_bytecode, BytecodeOffset()); \
}
DEBUG_BREAK_BYTECODE_LIST(DEBUG_BREAK)
#undef DEBUG_BREAK
// IncBlockCounter <slot>
//
// Increment the execution count for the given slot. Used for block code
// coverage.
IGNITION_HANDLER(IncBlockCounter, InterpreterAssembler) {
Node* closure = LoadRegister(Register::function_closure());
Node* coverage_array_slot = BytecodeOperandIdxSmi(0);
Node* context = GetContext();
CallBuiltin(Builtins::kIncBlockCounter, context, closure,
coverage_array_slot);
Dispatch();
}
// ForInEnumerate <receiver>
//
// Enumerates the enumerable keys of the |receiver| and either returns the
// map of the |receiver| if it has a usable enum cache or a fixed array
// with the keys to enumerate in the accumulator.
IGNITION_HANDLER(ForInEnumerate, InterpreterAssembler) {
Node* receiver = LoadRegisterAtOperandIndex(0);
Node* context = GetContext();
Label if_empty(this), if_runtime(this, Label::kDeferred);
Node* receiver_map = CheckEnumCache(receiver, &if_empty, &if_runtime);
SetAccumulator(receiver_map);
Dispatch();
BIND(&if_empty);
{
Node* result = EmptyFixedArrayConstant();
SetAccumulator(result);
Dispatch();
}
BIND(&if_runtime);
{
Node* result = CallRuntime(Runtime::kForInEnumerate, context, receiver);
SetAccumulator(result);
Dispatch();
}
}
// ForInPrepare <cache_info_triple>
//
// Returns state for for..in loop execution based on the enumerator in
// the accumulator register, which is the result of calling ForInEnumerate
// on a JSReceiver object.
// The result is output in registers |cache_info_triple| to
// |cache_info_triple + 2|, with the registers holding cache_type, cache_array,
// and cache_length respectively.
IGNITION_HANDLER(ForInPrepare, InterpreterAssembler) {
Node* enumerator = GetAccumulator();
Node* vector_index = BytecodeOperandIdx(1);
Node* maybe_feedback_vector = LoadFeedbackVector();
// The {enumerator} is either a Map or a FixedArray.
CSA_ASSERT(this, TaggedIsNotSmi(enumerator));
// Check if we're using an enum cache.
Label if_fast(this), if_slow(this);
Branch(IsMap(enumerator), &if_fast, &if_slow);
BIND(&if_fast);
{
// Load the enumeration length and cache from the {enumerator}.
Node* enum_length = LoadMapEnumLength(enumerator);
CSA_ASSERT(this, WordNotEqual(enum_length,
IntPtrConstant(kInvalidEnumCacheSentinel)));
Node* descriptors = LoadMapDescriptors(enumerator);
Node* enum_cache =
LoadObjectField(descriptors, DescriptorArray::kEnumCacheOffset);
Node* enum_keys = LoadObjectField(enum_cache, EnumCache::kKeysOffset);
// Check if we have enum indices available.
Node* enum_indices = LoadObjectField(enum_cache, EnumCache::kIndicesOffset);
Node* enum_indices_length = LoadAndUntagFixedArrayBaseLength(enum_indices);
Node* feedback = SelectSmiConstant(
IntPtrLessThanOrEqual(enum_length, enum_indices_length),
ForInFeedback::kEnumCacheKeysAndIndices, ForInFeedback::kEnumCacheKeys);
UpdateFeedback(feedback, maybe_feedback_vector, vector_index);
// Construct the cache info triple.
Node* cache_type = enumerator;
Node* cache_array = enum_keys;
Node* cache_length = SmiTag(enum_length);
StoreRegisterTripleAtOperandIndex(cache_type, cache_array, cache_length, 0);
Dispatch();
}
BIND(&if_slow);
{
// The {enumerator} is a FixedArray with all the keys to iterate.
CSA_ASSERT(this, IsFixedArray(enumerator));
// Record the fact that we hit the for-in slow-path.
UpdateFeedback(SmiConstant(ForInFeedback::kAny), maybe_feedback_vector,
vector_index);
// Construct the cache info triple.
Node* cache_type = enumerator;
Node* cache_array = enumerator;
Node* cache_length = LoadFixedArrayBaseLength(enumerator);
StoreRegisterTripleAtOperandIndex(cache_type, cache_array, cache_length, 0);
Dispatch();
}
}
// ForInNext <receiver> <index> <cache_info_pair>
//
// Returns the next enumerable property in the the accumulator.
IGNITION_HANDLER(ForInNext, InterpreterAssembler) {
Node* receiver = LoadRegisterAtOperandIndex(0);
Node* index = LoadRegisterAtOperandIndex(1);
Node* cache_type;
Node* cache_array;
std::tie(cache_type, cache_array) = LoadRegisterPairAtOperandIndex(2);
Node* vector_index = BytecodeOperandIdx(3);
Node* maybe_feedback_vector = LoadFeedbackVector();
// Load the next key from the enumeration array.
Node* key = LoadFixedArrayElement(CAST(cache_array), index, 0,
CodeStubAssembler::SMI_PARAMETERS);
// Check if we can use the for-in fast path potentially using the enum cache.
Label if_fast(this), if_slow(this, Label::kDeferred);
Node* receiver_map = LoadMap(receiver);
Branch(WordEqual(receiver_map, cache_type), &if_fast, &if_slow);
BIND(&if_fast);
{
// Enum cache in use for {receiver}, the {key} is definitely valid.
SetAccumulator(key);
Dispatch();
}
BIND(&if_slow);
{
// Record the fact that we hit the for-in slow-path.
UpdateFeedback(SmiConstant(ForInFeedback::kAny), maybe_feedback_vector,
vector_index);
// Need to filter the {key} for the {receiver}.
Node* context = GetContext();
Node* result = CallBuiltin(Builtins::kForInFilter, context, key, receiver);
SetAccumulator(result);
Dispatch();
}
}
// ForInContinue <index> <cache_length>
//
// Returns false if the end of the enumerable properties has been reached.
IGNITION_HANDLER(ForInContinue, InterpreterAssembler) {
Node* index = LoadRegisterAtOperandIndex(0);
Node* cache_length = LoadRegisterAtOperandIndex(1);
// Check if {index} is at {cache_length} already.
Label if_true(this), if_false(this), end(this);
Branch(WordEqual(index, cache_length), &if_true, &if_false);
BIND(&if_true);
{
SetAccumulator(FalseConstant());
Goto(&end);
}
BIND(&if_false);
{
SetAccumulator(TrueConstant());
Goto(&end);
}
BIND(&end);
Dispatch();
}
// ForInStep <index>
//
// Increments the loop counter in register |index| and stores the result
// in the accumulator.
IGNITION_HANDLER(ForInStep, InterpreterAssembler) {
TNode<Smi> index = CAST(LoadRegisterAtOperandIndex(0));
TNode<Smi> one = SmiConstant(1);
TNode<Smi> result = SmiAdd(index, one);
SetAccumulator(result);
Dispatch();
}
// GetIterator <object>
//
// Retrieves the object[Symbol.iterator] method and stores the result
// in the accumulator
// TODO(swapnilgaikwad): Extend the functionality of the bytecode to call
// iterator method for an object
IGNITION_HANDLER(GetIterator, InterpreterAssembler) {
Node* receiver = LoadRegisterAtOperandIndex(0);
Node* context = GetContext();
Node* feedback_vector = LoadFeedbackVector();
Node* feedback_slot = BytecodeOperandIdx(1);
Node* smi_slot = SmiTag(feedback_slot);
Node* result = CallBuiltin(Builtins::kGetIteratorWithFeedback, context,
receiver, smi_slot, feedback_vector);
SetAccumulator(result);
Dispatch();
}
// Wide
//
// Prefix bytecode indicating next bytecode has wide (16-bit) operands.
IGNITION_HANDLER(Wide, InterpreterAssembler) {
DispatchWide(OperandScale::kDouble);
}
// ExtraWide
//
// Prefix bytecode indicating next bytecode has extra-wide (32-bit) operands.
IGNITION_HANDLER(ExtraWide, InterpreterAssembler) {
DispatchWide(OperandScale::kQuadruple);
}
// Illegal
//
// An invalid bytecode aborting execution if dispatched.
IGNITION_HANDLER(Illegal, InterpreterAssembler) {
Abort(AbortReason::kInvalidBytecode);
Unreachable();
}
// SuspendGenerator <generator> <first input register> <register count>
// <suspend_id>
//
// Stores the parameters and the register file in the generator. Also stores
// the current context, |suspend_id|, and the current bytecode offset
// (for debugging purposes) into the generator. Then, returns the value
// in the accumulator.
IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
Node* generator = LoadRegisterAtOperandIndex(0);
TNode<FixedArray> array = CAST(LoadObjectField(
generator, JSGeneratorObject::kParametersAndRegistersOffset));
Node* closure = LoadRegister(Register::function_closure());
Node* context = GetContext();
RegListNodePair registers = GetRegisterListAtOperandIndex(1);
Node* suspend_id = BytecodeOperandUImmSmi(3);
Node* shared =
LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset);
TNode<Int32T> formal_parameter_count = UncheckedCast<Int32T>(
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset,
MachineType::Uint16()));
ExportParametersAndRegisterFile(array, registers, formal_parameter_count);
StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
suspend_id);
// Store the bytecode offset in the [input_or_debug_pos] field, to be used by
// the inspector.
Node* offset = SmiTag(BytecodeOffset());
StoreObjectField(generator, JSGeneratorObject::kInputOrDebugPosOffset,
offset);
UpdateInterruptBudgetOnReturn();
Return(GetAccumulator());
}
// SwitchOnGeneratorState <generator> <table_start> <table_length>
//
// If |generator| is undefined, falls through. Otherwise, loads the
// generator's state (overwriting it with kGeneratorExecuting), sets the context
// to the generator's resume context, and performs state dispatch on the
// generator's state by looking up the generator state in a jump table in the
// constant pool, starting at |table_start|, and of length |table_length|.
IGNITION_HANDLER(SwitchOnGeneratorState, InterpreterAssembler) {
Node* generator = LoadRegisterAtOperandIndex(0);
Label fallthrough(this);
GotoIf(WordEqual(generator, UndefinedConstant()), &fallthrough);
Node* state =
LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
Node* new_state = SmiConstant(JSGeneratorObject::kGeneratorExecuting);
StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
new_state);
Node* context = LoadObjectField(generator, JSGeneratorObject::kContextOffset);
SetContext(context);
Node* table_start = BytecodeOperandIdx(1);
// TODO(leszeks): table_length is only used for a CSA_ASSERT, we don't
// actually need it otherwise.
Node* table_length = BytecodeOperandUImmWord(2);
// The state must be a Smi.
CSA_ASSERT(this, TaggedIsSmi(state));
Node* case_value = SmiUntag(state);
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(case_value, IntPtrConstant(0)));
CSA_ASSERT(this, IntPtrLessThan(case_value, table_length));
USE(table_length);
Node* entry = IntPtrAdd(table_start, case_value);
Node* relative_jump = LoadAndUntagConstantPoolEntry(entry);
Jump(relative_jump);
BIND(&fallthrough);
Dispatch();
}
// ResumeGenerator <generator> <first output register> <register count>
//
// Imports the register file stored in the generator and marks the generator
// state as executing.
IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
Node* generator = LoadRegisterAtOperandIndex(0);
Node* closure = LoadRegister(Register::function_closure());
RegListNodePair registers = GetRegisterListAtOperandIndex(1);
Node* shared =
LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset);
TNode<Int32T> formal_parameter_count = UncheckedCast<Int32T>(
LoadObjectField(shared, SharedFunctionInfo::kFormalParameterCountOffset,
MachineType::Uint16()));
ImportRegisterFile(
CAST(LoadObjectField(generator,
JSGeneratorObject::kParametersAndRegistersOffset)),
registers, formal_parameter_count);
// Return the generator's input_or_debug_pos in the accumulator.
SetAccumulator(
LoadObjectField(generator, JSGeneratorObject::kInputOrDebugPosOffset));
Dispatch();
}
} // namespace
Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
OperandScale operand_scale,
int builtin_index,
const AssemblerOptions& options) {
Zone zone(isolate->allocator(), ZONE_NAME);
compiler::CodeAssemblerState state(
isolate, &zone, InterpreterDispatchDescriptor{}, Code::BYTECODE_HANDLER,
Bytecodes::ToString(bytecode),
FLAG_untrusted_code_mitigations
? PoisoningMitigationLevel::kPoisonCriticalOnly
: PoisoningMitigationLevel::kDontPoison,
builtin_index);
switch (bytecode) {
#define CALL_GENERATOR(Name, ...) \
case Bytecode::k##Name: \
Name##Assembler::Generate(&state, operand_scale); \
break;
BYTECODE_LIST(CALL_GENERATOR);
#undef CALL_GENERATOR
}
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state, options);
#ifdef ENABLE_DISASSEMBLER
if (FLAG_trace_ignition_codegen) {
StdoutStream os;
code->Disassemble(Bytecodes::ToString(bytecode), os);
os << std::flush;
}
#endif // ENABLE_DISASSEMBLER
return code;
}
} // namespace interpreter
} // namespace internal
} // namespace v8
|
; A276602: Values of n such that n^2 + 10 is a triangular number (A000217).
; 0,9,54,315,1836,10701,62370,363519,2118744,12348945,71974926,419500611,2445028740,14250671829,83059002234,484103341575,2821561047216,16445262941721,95850016603110,558654836676939,3256079003458524,18977819184074205,110610836100986706,644687197421846031,3757512348430089480,21900386893158690849,127644809010522055614,743968467169973642835,4336165994009319801396,25273027496885945165541,147301998987306351191850,858538966426952161985559,5003931799574406620721504,29165051831019487562343465,169986379186542518753339286,990753223288235624957692251,5774532960542871230992814220,33656444539968991760999193069,196164134279271079335002344194,1143328361135657484249014872095,6663806032534673826159086888376,38839507834072385472705506458161,226373240971899639010073951860590,1319399937997325448587738204705379,7690026387012053052516355276371684,44820758384074992866510393453524725,261234523917437904146546005444776666
mov $2,9
lpb $0
sub $0,1
add $3,$2
add $1,$3
mov $2,$1
mul $2,4
lpe
mov $0,$1
|
bits 64
nop
o64 nop
pause
o64 pause
xchg ax,ax
xchg eax,eax
xchg rax,rax
rep xchg ax,ax
rep xchg eax,eax
rep xchg rax,rax
|
; SBASIC Version 1993 Tony Tebby
section sbas
xdef sb_vers
xdef sb.vers
sb.vers equ 'HBA '
sb_vers dc.w 3
dc.l sb.vers
end
|
; A093986: a(1) = 1, a(2) = 1, a(n+1) = 2n*a(n) - a(n-1). Symmetrically a(n) = (a(n-1) + a(n+1))/((n-1) + (n+1)).
; Submitted by Jamie Morken(s2)
; 1,1,3,17,133,1313,15623,217409,3462921,62115169,1238840459,27192374929,651378157837,16908639728833,472790534249487,14166807387755777,452865045873935377,15383244752326047041,553343946037863758099,21011686704686496760721,839914124241422006670741,35255381531435037783410401,1550396873258900240463386903,71283000788377976023532387137,3420033640968883948889091195673,170930399047655819468431027396513,8884960716837133728409524333423003,479616948310157565514645882977445649
mov $2,1
lpb $0
mul $3,$0
sub $0,1
mul $3,2
add $2,$3
add $1,$2
mov $3,$1
lpe
mov $0,$2
|
; A119281: Number of counting rods to represent n in the ancient Chinese rod numeral system.
; 0,1,2,3,4,5,2,3,4,5,1,2,3,4,5,6,3,4,5,6,2,3,4,5,6,7,4,5,6,7,3,4,5,6,7,8,5,6,7,8,4,5,6,7,8,9,6,7,8,9,5,6,7,8,9,10,7,8,9,10,2,3,4,5,6,7,4,5,6,7,3,4,5,6,7,8,5,6,7,8,4,5,6,7,8,9,6,7,8,9,5,6,7,8,9,10,7,8,9,10
lpb $0
mov $2,$0
mod $2,10
lpb $2
add $1,1
sub $2,1
dif $2,5
lpe
div $0,10
lpe
mov $0,$1
|
; ModuleID = 'ELL'
source_filename = "ELL"
define void @predict(double* %input0, double* %output0) {
entry:
%0 = getelementptr double, double* %input0, i32 0
%1 = load double, double* %0
%2 = getelementptr double, double* %output0, i32 0
store double %1, double* %2
%3 = getelementptr double, double* %input0, i32 1
%4 = load double, double* %3
%5 = getelementptr double, double* %output0, i32 1
store double %4, double* %5
%6 = getelementptr double, double* %input0, i32 2
%7 = load double, double* %6
%8 = getelementptr double, double* %output0, i32 2
store double %7, double* %8
ret void
}
|
!to "via11.prg", cbm
TESTID = 11
tmp=$fc
addr=$fd
add2=$f9
ERRBUF = $1f00
TMP = $2000 ; measured data on C64 side
DATA = $3000 ; reference data
TESTLEN = $40
NUMTESTS = 16 - 8
TESTSLOC = $1800
DTMP=screenmem
!src "common.asm"
* = TESTSLOC
;------------------------------------------
; - output timer A at PB7 and read back PB
!macro TEST .DDRB,.PRB,.CR,.TIMER,.THIFL {
.test
lda #.DDRB
sta viabase+$2 ; port B ddr input
lda #.PRB
sta viabase+$0 ; port B data
lda #1
sta viabase+$4+(.TIMER*4)+.THIFL
lda #.CR ; control reg
sta viabase+$b+.TIMER
ldx #0
.t1b lda viabase+$0 ; port B data
sta DTMP,x
inx
bne .t1b
rts
* = .test+TESTLEN
}
+TEST $80,$00,$00,0,0
+TEST $80,$00,$00,0,1
+TEST $80,$00,$80,0,0
+TEST $80,$00,$80,0,1
+TEST $80,$00,$40,0,0
+TEST $80,$00,$40,0,1
+TEST $80,$00,$c0,0,0
+TEST $80,$00,$c0,0,1
* = DATA
!bin "via11ref.bin", NUMTESTS * $0100, 2
|
; A041779: Denominators of continued fraction convergents to sqrt(410).
; Submitted by Christian Krause
; 1,4,161,648,26081,104972,4224961,17004816,684417601,2754675220,110871426401,446240380824,17960486659361,72288187018268,2909487967390081,11710240056578592,471319090230533761,1896986600978713636,76350783129379079201,307300119118495030440,12368355547869180296801,49780722310595216217644,2003597247971677829002561,8064169714197306532227888,324570385815863939118118081,1306345712977653063004700212,52578398904921986459306126561,211619941332665598900229206456,8517376052211545942468474384801
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,5
dif $2,2
mul $2,20
add $3,$2
lpe
mov $0,$2
div $0,20
|
; A301710: Coordination sequence for node of type V2 in "krc" 2-D tiling (or net).
; 1,5,11,17,22,27,33,39,44,49,55,61,66,71,77,83,88,93,99,105,110,115,121,127,132,137,143,149,154,159,165,171,176,181,187,193,198,203,209,215,220,225,231,237,242,247,253,259,264,269,275,281,286,291,297,303,308,313,319,325,330,335,341,347,352,357,363,369,374,379,385,391,396,401,407,413,418,423,429,435,440,445,451,457,462,467,473,479,484,489,495,501,506,511,517,523,528,533,539,545
mov $1,11
mul $1,$0
mov $2,$1
seq $2,263449 ; Permutation of the natural numbers: [4k+1, 4k+4, 4k+3, 4k+2, ...].
add $1,$2
mov $0,$1
sub $0,4
div $0,4
add $0,1
|
// Copyright (c) 2021 MIT Digital Currency Initiative,
// Federal Reserve Bank of Boston
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "atomizer_client.hpp"
#include "bech32/bech32.h"
#include "bech32/util/strencodings.h"
#include "client.hpp"
#include "crypto/sha256.h"
#include "twophase_client.hpp"
#include "uhs/transaction/messages.hpp"
#include "util/common/config.hpp"
#include "util/serialization/util.hpp"
#include <future>
#include <iostream>
static constexpr auto bits_per_byte = 8;
static constexpr auto bech32_bits_per_symbol = 5;
auto mint_command(cbdc::client& client, const std::vector<std::string>& args)
-> bool {
static constexpr auto min_mint_arg_count = 7;
if(args.size() < min_mint_arg_count) {
std::cerr << "Mint requires args <n outputs> <output value>"
<< std::endl;
return false;
}
const auto n_outputs = std::stoull(args[5]);
const auto output_val = std::stoul(args[6]);
const auto mint_tx
= client.mint(n_outputs, static_cast<uint32_t>(output_val));
std::cout << cbdc::to_string(cbdc::transaction::tx_id(mint_tx))
<< std::endl;
return true;
}
auto decode_address(const std::string& addr_str)
-> std::optional<cbdc::hash_t> {
// TODO: if/when bech32m is merged into Bitcoin Core, switch to that.
// see: https://github.com/bitcoin/bitcoin/pull/20861
// TODO: move address encoding/decoding into cbdc::client.
const auto [hrp, enc_data] = bech32::Decode(addr_str);
if(hrp != cbdc::config::bech32_hrp) {
std::cout << "Invalid address encoding" << std::endl;
return std::nullopt;
}
auto data = std::vector<uint8_t>();
ConvertBits<bech32_bits_per_symbol, bits_per_byte, false>(
[&](uint8_t c) {
data.push_back(c);
},
enc_data.begin(),
enc_data.end());
auto pubkey = cbdc::hash_t();
if(data[0] != static_cast<uint8_t>(cbdc::client::address_type::public_key)
|| data.size() != pubkey.size() + 1) {
std::cout << "Address is not a supported type" << std::endl;
return std::nullopt;
}
data.erase(data.begin());
std::copy_n(data.begin(), pubkey.size(), pubkey.begin());
return pubkey;
}
void print_tx_result(
const std::optional<cbdc::transaction::full_tx>& tx,
const std::optional<cbdc::sentinel::execute_response>& resp,
const cbdc::hash_t& pubkey) {
std::cout << "tx_id:" << std::endl
<< cbdc::to_string(cbdc::transaction::tx_id(tx.value()))
<< std::endl;
const auto inputs = cbdc::client::export_send_inputs(tx.value(), pubkey);
for(const auto& inp : inputs) {
auto buf = cbdc::make_buffer(inp);
std::cout << "Data for recipient importinput:" << std::endl
<< buf.to_hex() << std::endl;
}
if(resp.has_value()) {
std::cout << "Sentinel responded: "
<< cbdc::sentinel::to_string(resp.value().m_tx_status)
<< std::endl;
if(resp.value().m_tx_error.has_value()) {
std::cout << "Validation error: "
<< cbdc::transaction::validation::to_string(
resp.value().m_tx_error.value())
<< std::endl;
}
}
}
auto send_command(cbdc::client& client, const std::vector<std::string>& args)
-> bool {
static constexpr auto min_send_arg_count = 7;
if(args.size() < min_send_arg_count) {
std::cerr << "Send requires args <value> <pubkey>" << std::endl;
return false;
}
const auto value = std::stoul(args[5]);
static constexpr auto address_arg_idx = 6;
auto pubkey = decode_address(args[address_arg_idx]);
if(!pubkey.has_value()) {
std::cout << "Could not decode address" << std::endl;
return false;
}
const auto [tx, resp]
= client.send(static_cast<uint32_t>(value), pubkey.value());
if(!tx.has_value()) {
std::cout << "Could not generate valid send tx." << std::endl;
return false;
}
print_tx_result(tx, resp, pubkey.value());
return true;
}
auto fan_command(cbdc::client& client, const std::vector<std::string>& args)
-> bool {
static constexpr auto min_fan_arg_count = 8;
if(args.size() < min_fan_arg_count) {
std::cerr << "Fan requires args <count> <value> <pubkey>" << std::endl;
return false;
}
const auto value = std::stoul(args[6]);
const auto count = std::stoul(args[5]);
static constexpr auto address_arg_idx = 7;
auto pubkey = decode_address(args[address_arg_idx]);
if(!pubkey.has_value()) {
std::cout << "Could not decode address" << std::endl;
return false;
}
const auto [tx, resp] = client.fan(static_cast<uint32_t>(count),
static_cast<uint32_t>(value),
pubkey.value());
if(!tx.has_value()) {
std::cout << "Could not generate valid send tx." << std::endl;
return false;
}
print_tx_result(tx, resp, pubkey.value());
return true;
}
void newaddress_command(cbdc::client& client) {
const auto addr = client.new_address();
auto addr_vec
= std::vector<uint8_t>(sizeof(cbdc::client::address_type::public_key)
+ std::tuple_size<decltype(addr)>::value);
addr_vec[0] = static_cast<uint8_t>(cbdc::client::address_type::public_key);
std::copy_n(addr.begin(),
addr.size(),
addr_vec.begin()
+ sizeof(cbdc::client::address_type::public_key));
auto data = std::vector<uint8_t>();
ConvertBits<bits_per_byte, bech32_bits_per_symbol, true>(
[&](uint8_t c) {
data.push_back(c);
},
addr_vec.begin(),
addr_vec.end());
std::cout << bech32::Encode(cbdc::config::bech32_hrp, data) << std::endl;
}
auto importinput_command(cbdc::client& client,
const std::vector<std::string>& args) -> bool {
static constexpr auto input_arg_idx = 5;
auto buffer = cbdc::buffer::from_hex(args[input_arg_idx]);
if(!buffer.has_value()) {
std::cout << "Invalid input encoding." << std::endl;
return false;
}
auto in = cbdc::from_buffer<cbdc::transaction::input>(buffer.value());
if(!in.has_value()) {
std::cout << "Invalid input" << std::endl;
return false;
}
client.import_send_input(in.value());
return true;
}
auto confirmtx_command(cbdc::client& client,
const std::vector<std::string>& args) -> bool {
const auto tx_id = cbdc::hash_from_hex(args[5]);
auto success = client.confirm_transaction(tx_id);
if(!success) {
std::cout << "Unknown TXID" << std::endl;
return false;
}
std::cout << "Confirmed. Balance: "
<< cbdc::client::print_amount(client.balance())
<< " UTXOs: " << client.utxo_count() << std::endl;
return true;
}
// LCOV_EXCL_START
auto main(int argc, char** argv) -> int {
auto args = cbdc::config::get_args(argc, argv);
static constexpr auto min_arg_count = 5;
if(args.size() < min_arg_count) {
std::cerr << "Usage: " << args[0]
<< " <config file> <client file> <wallet file> <command>"
<< " <args...>" << std::endl;
return 0;
}
auto cfg_or_err = cbdc::config::load_options(args[1]);
if(std::holds_alternative<std::string>(cfg_or_err)) {
std::cerr << "Error loading config file: "
<< std::get<std::string>(cfg_or_err) << std::endl;
return -1;
}
auto opts = std::get<cbdc::config::options>(cfg_or_err);
SHA256AutoDetect();
const auto wallet_file = args[3];
const auto client_file = args[2];
auto logger = std::make_shared<cbdc::logging::log>(
cbdc::config::defaults::log_level);
auto client = std::unique_ptr<cbdc::client>();
if(opts.m_twophase_mode) {
client = std::make_unique<cbdc::twophase_client>(opts,
logger,
wallet_file,
client_file);
} else {
client = std::make_unique<cbdc::atomizer_client>(opts,
logger,
wallet_file,
client_file);
}
if(!client->init()) {
return -1;
}
const auto command = std::string(args[4]);
if(command == "mint") {
if(!mint_command(*client, args)) {
return -1;
}
} else if(command == "send") {
if(!send_command(*client, args)) {
return -1;
}
} else if(command == "fan") {
if(!fan_command(*client, args)) {
return -1;
}
} else if(command == "sync") {
client->sync();
} else if(command == "newaddress") {
newaddress_command(*client);
} else if(command == "info") {
const auto balance = client->balance();
const auto n_txos = client->utxo_count();
std::cout << "Balance: " << cbdc::client::print_amount(balance)
<< ", UTXOs: " << n_txos
<< ", pending TXs: " << client->pending_tx_count()
<< std::endl;
} else if(command == "importinput") {
if(!importinput_command(*client, args)) {
return -1;
}
} else if(command == "confirmtx") {
if(!confirmtx_command(*client, args)) {
return -1;
}
} else {
std::cerr << "Unknown command" << std::endl;
}
// TODO: check that the send queue has drained before closing
// the network. For now, just sleep.
static constexpr auto shutdown_delay = std::chrono::milliseconds(100);
std::this_thread::sleep_for(shutdown_delay);
return 0;
}
// LCOV_EXCL_STOP
|
include xlibproc.inc
include Wintab.inc
PROC_TEMPLATE WTOverlap, 2, Wintab, -, 41
|
; A216443: a(n) = n!! mod !n.
; 0,1,8,15,48,105,384,945,3840,10395,46080,135135,645120,2027025,10321920,34459425,185794560,654729075,3715891200,13749310575,81749606400,316234143225,1961990553600,7905853580625,51011754393600,213458046676875,1428329123020800,6190283353629375,42849873690624000,191898783962510625,1371195958099968000,6332659870762850625,46620662575398912000,221643095476699771875,1678343852714360832000,8200794532637891559375,63777066403145711616000,319830986772877770815625,2551082656125828464640000
mov $2,$0
mov $3,2
mov $4,$0
mov $5,2
lpb $2
add $0,$3
lpb $4
mul $0,$4
sub $4,$5
lpe
mov $2,1
lpe
|
section .text
global allergic_to
allergic_to:
mov rcx, rdi
mov rax, 1
shl rax, cl
and rax, rsi
ret
global list
list:
and rdi, 0xff
popcnt rax, rdi
mov dword [rsi], eax
mov rcx, 1
mov rdx, 0
loop:
test rdi, rdi
jz end
test rdi, 1
jz continue
mov dword [rsi + 4*rcx], edx
inc rcx
continue:
inc rdx
shr rdi, 1
jmp loop
end:
ret
|
Music_Mom:
musicheader 3, 2, Music_Mom_Ch2
musicheader 1, 3, Music_Mom_Ch3
musicheader 1, 4, Music_Mom_Ch4
Music_Mom_Ch2:
tempo 144
volume $77
stereopanning $f
dutycycle $2
notetype $6, $b3
octave 3
note B_, 1
octave 4
note E_, 1
note G#, 1
note A_, 1
note B_, 8
Music_Mom_branch_f6c0e:
notetype $c, $b1
note __, 4
octave 3
note C#, 6
note D_, 4
note C_, 2
note __, 2
note C#, 6
octave 2
note E_, 4
note A#, 2
note B_, 2
loopchannel 0, Music_Mom_branch_f6c0e
Music_Mom_Ch3:
stereopanning $f0
notetype $6, $25
octave 3
note E_, 1
note D_, 1
octave 2
note B_, 1
note G#, 1
note E_, 8
intensity $23
Music_Mom_branch_f6c2e:
octave 2
note A_, 2
note __, 6
octave 4
note E_, 2
note __, 2
octave 2
note A_, 2
note __, 2
octave 3
note D_, 2
note __, 2
octave 4
note F#, 8
note D#, 2
note __, 2
octave 2
note A_, 2
note __, 2
octave 4
note E_, 2
note __, 6
octave 2
note A_, 2
note __, 2
octave 4
note D_, 2
note __, 6
note C#, 4
note D_, 2
note __, 2
loopchannel 0, Music_Mom_branch_f6c2e
Music_Mom_Ch4:
togglenoise $3
notetype $c
note __, 6
Music_Mom_branch_f6c56:
note D#, 1
note __, 1
note F#, 2
note D_, 1
note __, 1
note G_, 1
note __, 1
note G_, 1
note __, 1
note F#, 4
note D_, 1
note __, 1
note D#, 1
note __, 1
note F#, 4
note D_, 1
note __, 1
note G_, 1
note __, 1
note G_, 1
note __, 1
note D_, 2
note D#, 1
note __, 1
loopchannel 0, Music_Mom_branch_f6c56
|
/**
* ProcessMaker API
* This ProcessMaker Core API provide access to the new generation engine with BPMN 2.0 support. The current Alpha 1.0 version supports the part of BPM system functionality like process import, process execution, task assignment
*
* OpenAPI spec version: 1.0.0
* Contact: alpha-program@processmaker.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TaskRemoveGroupsItem.h"
namespace io {
namespace swagger {
namespace client {
namespace model {
TaskRemoveGroupsItem::TaskRemoveGroupsItem()
{
}
TaskRemoveGroupsItem::~TaskRemoveGroupsItem()
{
}
void TaskRemoveGroupsItem::validate()
{
// TODO: implement validation
}
web::json::value TaskRemoveGroupsItem::toJson() const
{
web::json::value val = web::json::value::object();
val[U("data")] = ModelBase::toJson(m_Data);
return val;
}
void TaskRemoveGroupsItem::fromJson(web::json::value& val)
{
std::shared_ptr<GroupIds> newData(new GroupIds());
newData->fromJson(val[U("data")]);
setData( newItem );
}
void TaskRemoveGroupsItem::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.'))
{
namePrefix += U(".");
}
m_Data->toMultipart(multipart, U("data."));
}
void TaskRemoveGroupsItem::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.'))
{
namePrefix += U(".");
}
std::shared_ptr<GroupIds> newData(new GroupIds());
newData->fromMultiPart(multipart, U("data."));
setData( newData );
}
std::shared_ptr<GroupIds> TaskRemoveGroupsItem::getData() const
{
return m_Data;
}
void TaskRemoveGroupsItem::setData(std::shared_ptr<GroupIds> value)
{
m_Data = value;
}
}
}
}
}
|
// Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
#include "extern/beatsaber-hook/shared/utils/byref.hpp"
// Including type: UnityEngine.UI.GraphicRaycaster
#include "UnityEngine/UI/GraphicRaycaster.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "extern/beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System
namespace System {
// Forward declaring type: Comparison`1<T>
template<typename T>
class Comparison_1;
}
// Forward declaring namespace: UnityEngine::UI
namespace UnityEngine::UI {
// Forward declaring type: Graphic
class Graphic;
}
// Completed forward declares
// Type namespace: UnityEngine.UI
namespace UnityEngine::UI {
// Size: 0x10
#pragma pack(push, 1)
// Autogenerated type: UnityEngine.UI.GraphicRaycaster/UnityEngine.UI.<>c
// [TokenAttribute] Offset: FFFFFFFF
// [CompilerGeneratedAttribute] Offset: FFFFFFFF
class GraphicRaycaster::$$c : public ::Il2CppObject {
public:
// Creating value type constructor for type: $$c
$$c() noexcept {}
// Get static field: static public readonly UnityEngine.UI.GraphicRaycaster/UnityEngine.UI.<>c <>9
static UnityEngine::UI::GraphicRaycaster::$$c* _get_$$9();
// Set static field: static public readonly UnityEngine.UI.GraphicRaycaster/UnityEngine.UI.<>c <>9
static void _set_$$9(UnityEngine::UI::GraphicRaycaster::$$c* value);
// Get static field: static public System.Comparison`1<UnityEngine.UI.Graphic> <>9__24_0
static System::Comparison_1<UnityEngine::UI::Graphic*>* _get_$$9__24_0();
// Set static field: static public System.Comparison`1<UnityEngine.UI.Graphic> <>9__24_0
static void _set_$$9__24_0(System::Comparison_1<UnityEngine::UI::Graphic*>* value);
// static private System.Void .cctor()
// Offset: 0x15BBFA0
static void _cctor();
// System.Int32 <Raycast>b__24_0(UnityEngine.UI.Graphic g1, UnityEngine.UI.Graphic g2)
// Offset: 0x15BC00C
int $Raycast$b__24_0(UnityEngine::UI::Graphic* g1, UnityEngine::UI::Graphic* g2);
// public System.Void .ctor()
// Offset: 0x15BC004
// Implemented from: System.Object
// Base method: System.Void Object::.ctor()
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static GraphicRaycaster::$$c* New_ctor() {
static auto ___internal__logger = ::Logger::get().WithContext("UnityEngine::UI::GraphicRaycaster::$$c::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<GraphicRaycaster::$$c*, creationType>()));
}
}; // UnityEngine.UI.GraphicRaycaster/UnityEngine.UI.<>c
#pragma pack(pop)
}
DEFINE_IL2CPP_ARG_TYPE(UnityEngine::UI::GraphicRaycaster::$$c*, "UnityEngine.UI", "GraphicRaycaster/<>c");
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: UnityEngine::UI::GraphicRaycaster::$$c::_cctor
// Il2CppName: .cctor
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (*)()>(&UnityEngine::UI::GraphicRaycaster::$$c::_cctor)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(UnityEngine::UI::GraphicRaycaster::$$c*), ".cctor", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: UnityEngine::UI::GraphicRaycaster::$$c::$Raycast$b__24_0
// Il2CppName: <Raycast>b__24_0
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<int (UnityEngine::UI::GraphicRaycaster::$$c::*)(UnityEngine::UI::Graphic*, UnityEngine::UI::Graphic*)>(&UnityEngine::UI::GraphicRaycaster::$$c::$Raycast$b__24_0)> {
static const MethodInfo* get() {
static auto* g1 = &::il2cpp_utils::GetClassFromName("UnityEngine.UI", "Graphic")->byval_arg;
static auto* g2 = &::il2cpp_utils::GetClassFromName("UnityEngine.UI", "Graphic")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(UnityEngine::UI::GraphicRaycaster::$$c*), "<Raycast>b__24_0", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{g1, g2});
}
};
// Writing MetadataGetter for method: UnityEngine::UI::GraphicRaycaster::$$c::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
|
;
; Enterprise 64/128 C Library
;
; puts_cons
;
; Stefano Bodrato - 2011
;
;
; $Id: puts_cons.asm,v 1.2 2015/01/19 01:33:20 pauloscustodio Exp $
;
PUBLIC puts_cons
;
; Entry: hl = points text
;
.puts_cons
pop bc
pop hl
push hl
push bc
push hl
ld b,255
ld c,b
xor a
cpir ; Locate the string termination
pop de
push de
scf
sbc hl,de ; Compute the number of chars to be printed
pop de ; block address
ld b,h
ld c,l ; block length
ld a,66h ; output channel (video)
rst 30h ; EXOS
defb 8 ; write block
ret
|
; A164394: Number of binary strings of length n with no substrings equal to 0001 or 0100.
; 1,2,4,8,14,24,42,74,130,228,400,702,1232,2162,3794,6658,11684,20504,35982,63144,110810,194458,341250,598852,1050912,1844222,3236384,5679458,9966754,17490434,30693572,53863464,94523790,165877688,291095050,510836202,896455042,1573168932,2760719024,4844724158,8501898224,14919791314,26182408562,45946924034,80631230820,141497946168,248311585550,435756455752,764699272122,1341953674042,2354964531714,4132674661508,7252338465344,12726966800894,22334269797952,39193911260354,68780519523650,120701397584898
mov $2,1
mov $3,1
mov $4,1
lpb $0
sub $0,1
add $1,$4
mov $4,$2
add $2,$3
mov $3,$1
lpe
add $1,$3
mov $0,$1
|
; A028163: Expansion of 1/((1-4x)(1-9x)(1-11x)(1-12x)).
; Submitted by Christian Krause
; 1,36,829,15576,260425,4039212,59479093,843439392,11625297409,156744987828,2076870835117,27134173366248,350447396932153,4483154549898684,56894676264296101,717171756670960944
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,19722 ; Expansion of 1/((1-4x)(1-9x)(1-12x)).
sub $0,$1
mul $1,12
add $1,$0
lpe
mov $0,$1
|
; A010975: a(n) = binomial(n,22).
; 1,23,276,2300,14950,80730,376740,1560780,5852925,20160075,64512240,193536720,548354040,1476337800,3796297200,9364199760,22239974430,51021117810,113380261800,244662670200,513791607420,1052049481860,2104098963720,4116715363800,7890371113950,14833897694226,27385657281648,49699896548176,88749815264600,156077261327400,270533919634160,462525733568080,780512175396135,1300853625660225,2142582442263900,3489348548829780,5621728217559090,8964377427999630,14154280149473100,22138745874816900,34315056105966195,52728013040874885,80347448443237920,121455445321173600,182183167981760400,271250494550621040,400978991944396320,588671286046028640,858478958817125100,1243918491347262900,1791242627540058576,2563935525694593648,3648677478873075576,5163222847461899400,7266758081613043600,10173461314258261040,14170178259145435020,19639369867938409940,27088786024742634400,37189689288205989600,50825908693881519120,69156564288396165360,93695990326214159520,126415225043304818400,169870458651940849725,227365075426443906555,303153433901925208740,402696352496587217580,532980466539600729150,702916267465270526850,923832808668641263860,1210090862058924472380,1579840847688040283385,2055957267539230505775,2667187806537380115600,3449562896455011616176,4448120577007778136648,5719012170438571889976,7332066885177656269200,9373908296239788394800,11951733077705730203370,15197882802514693962310,19275363554408880147320,24384496062806414644200,30770911698303332765300,38735147667275960069260,48644138930997717296280,60944955672169553853960,76181194590211942317450,95012501118129501092550,118237779169227823581840,146822736770579605107120,181932521650500815024040,224970322471049394922200,277622951134486487350800,341914581923525463368880,420270006947666715390915,515588977595591125067205,631333441953785051102700,771629762387959506903300
add $0,22
bin $0,22
|
;*****************************************************************************
;* pixel.asm: h264 encoder library
;*****************************************************************************
;* Copyright (C) 2003-2008 x264 project
;*
;* Authors: Loren Merritt <lorenm@u.washington.edu>
;* Holger Lubitz <holger@lubitz.org>
;* Laurent Aimar <fenrir@via.ecp.fr>
;* Alex Izvorski <aizvorksi@gmail.com>
;* Jason Garrett-Glaser <darkshikari@gmail.com>
;*
;* This program is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License as published by
;* the Free Software Foundation; either version 2 of the License, or
;* (at your option) any later version.
;*
;* This program is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;* GNU General Public License for more details.
;*
;* You should have received a copy of the GNU General Public License
;* along with this program; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
;*****************************************************************************
%include "x86inc.asm"
%include "x86util.asm"
SECTION_RODATA
pw_1: times 8 dw 1
pw_00ff: times 8 dw 0xff
ssim_c1: times 4 dd 416 ; .01*.01*255*255*64
ssim_c2: times 4 dd 235963 ; .03*.03*255*255*64*63
mask_ff: times 16 db 0xff
times 16 db 0
mask_ac4: dw 0, -1, -1, -1, 0, -1, -1, -1
mask_ac4b: dw 0, -1, 0, -1, -1, -1, -1, -1
mask_ac8: dw 0, -1, -1, -1, -1, -1, -1, -1
hsub_mul: times 8 db 1, -1
hmul_4p: times 2 db 1, 1, 1, 1, 1, -1, 1, -1
hmul_8p: times 8 db 1
times 4 db 1, -1
mask_10: times 4 dw 0, -1
mask_1100: times 2 dd 0, -1
SECTION .text
%macro HADDD 2 ; sum junk
%if mmsize == 16
movhlps %2, %1
paddd %1, %2
pshuflw %2, %1, 0xE
paddd %1, %2
%else
pshufw %2, %1, 0xE
paddd %1, %2
%endif
%endmacro
%macro HADDW 2
pmaddwd %1, [pw_1 GLOBAL]
HADDD %1, %2
%endmacro
%macro HADDUW 2
mova %2, %1
pslld %1, 16
psrld %2, 16
psrld %1, 16
paddd %1, %2
HADDD %1, %2
%endmacro
;=============================================================================
; SSD
;=============================================================================
%macro SSD_LOAD_FULL 5
mova m1, [t0+%1]
mova m2, [t2+%2]
mova m3, [t0+%3]
mova m4, [t2+%4]
%if %5==1
add t0, t1
add t2, t3
%elif %5==2
lea t0, [t0+2*t1]
lea t2, [t2+2*t3]
%endif
%endmacro
%macro LOAD 5
movh m%1, %3
movh m%2, %4
%if %5
lea t0, [t0+2*t1]
%endif
%endmacro
%macro JOIN 7
movh m%3, %5
movh m%4, %6
%if %7
lea t2, [t2+2*t3]
%endif
punpcklbw m%1, m7
punpcklbw m%3, m7
psubw m%1, m%3
punpcklbw m%2, m7
punpcklbw m%4, m7
psubw m%2, m%4
%endmacro
%macro JOIN_SSE2 7
movh m%3, %5
movh m%4, %6
%if %7
lea t2, [t2+2*t3]
%endif
punpcklqdq m%1, m%2
punpcklqdq m%3, m%4
DEINTB %2, %1, %4, %3, 7
psubw m%2, m%4
psubw m%1, m%3
%endmacro
%macro JOIN_SSSE3 7
movh m%3, %5
movh m%4, %6
%if %7
lea t2, [t2+2*t3]
%endif
punpcklbw m%1, m%3
punpcklbw m%2, m%4
%endmacro
%macro SSD_LOAD_HALF 5
LOAD 1, 2, [t0+%1], [t0+%3], 1
JOIN 1, 2, 3, 4, [t2+%2], [t2+%4], 1
LOAD 3, 4, [t0+%1], [t0+%3], %5
JOIN 3, 4, 5, 6, [t2+%2], [t2+%4], %5
%endmacro
%macro SSD_CORE 7-8
%ifidn %8, FULL
mova m%6, m%2
mova m%7, m%4
psubusb m%2, m%1
psubusb m%4, m%3
psubusb m%1, m%6
psubusb m%3, m%7
por m%1, m%2
por m%3, m%4
mova m%2, m%1
mova m%4, m%3
punpckhbw m%1, m%5
punpcklbw m%2, m%5
punpckhbw m%3, m%5
punpcklbw m%4, m%5
%endif
pmaddwd m%1, m%1
pmaddwd m%2, m%2
pmaddwd m%3, m%3
pmaddwd m%4, m%4
%endmacro
%macro SSD_CORE_SSE2 7-8
%ifidn %8, FULL
DEINTB %6, %1, %7, %2, %5
psubw m%6, m%7
psubw m%1, m%2
SWAP %6, %2, %1
DEINTB %6, %3, %7, %4, %5
psubw m%6, m%7
psubw m%3, m%4
SWAP %6, %4, %3
%endif
pmaddwd m%1, m%1
pmaddwd m%2, m%2
pmaddwd m%3, m%3
pmaddwd m%4, m%4
%endmacro
%macro SSD_CORE_SSSE3 7-8
%ifidn %8, FULL
mova m%6, m%1
mova m%7, m%3
punpcklbw m%1, m%2
punpcklbw m%3, m%4
punpckhbw m%6, m%2
punpckhbw m%7, m%4
SWAP %6, %2, %3
SWAP %7, %4
%endif
pmaddubsw m%1, m%5
pmaddubsw m%2, m%5
pmaddubsw m%3, m%5
pmaddubsw m%4, m%5
pmaddwd m%1, m%1
pmaddwd m%2, m%2
pmaddwd m%3, m%3
pmaddwd m%4, m%4
%endmacro
%macro SSD_ITER 6
SSD_LOAD_%1 %2,%3,%4,%5,%6
SSD_CORE 1, 2, 3, 4, 7, 5, 6, %1
paddd m1, m2
paddd m3, m4
paddd m0, m1
paddd m0, m3
%endmacro
;-----------------------------------------------------------------------------
; int x264_pixel_ssd_16x16_mmx( uint8_t *, int, uint8_t *, int )
;-----------------------------------------------------------------------------
%macro SSD 3-4 0
%if %1 != %2
%assign function_align 8
%else
%assign function_align 16
%endif
cglobal x264_pixel_ssd_%1x%2_%3, 0,0,0
mov al, %1*%2/mmsize/2
%if %1 != %2
jmp mangle(x264_pixel_ssd_%1x%1_%3.startloop)
%else
.startloop:
%ifdef ARCH_X86_64
DECLARE_REG_TMP 0,1,2,3
%else
PROLOGUE 0,5
DECLARE_REG_TMP 1,2,3,4
mov t0, r0m
mov t1, r1m
mov t2, r2m
mov t3, r3m
%endif
%ifidn %3, ssse3
mova m7, [hsub_mul GLOBAL]
%elifidn %3, sse2
mova m7, [pw_00ff GLOBAL]
%elif %1 >= mmsize
pxor m7, m7
%endif
pxor m0, m0
ALIGN 16
.loop:
%if %1 > mmsize
SSD_ITER FULL, 0, 0, mmsize, mmsize, 1
%elif %1 == mmsize
SSD_ITER FULL, 0, 0, t1, t3, 2
%else
SSD_ITER HALF, 0, 0, t1, t3, 2
%endif
dec al
jg .loop
HADDD m0, m1
movd eax, m0
RET
%endif
%endmacro
INIT_MMX
SSD 16, 16, mmx
SSD 16, 8, mmx
SSD 8, 8, mmx
SSD 8, 16, mmx
SSD 4, 4, mmx
SSD 8, 4, mmx
SSD 4, 8, mmx
INIT_XMM
SSD 16, 16, sse2slow, 8
SSD 8, 8, sse2slow, 8
SSD 16, 8, sse2slow, 8
SSD 8, 16, sse2slow, 8
SSD 8, 4, sse2slow, 8
%define SSD_CORE SSD_CORE_SSE2
%define JOIN JOIN_SSE2
SSD 16, 16, sse2, 8
SSD 8, 8, sse2, 8
SSD 16, 8, sse2, 8
SSD 8, 16, sse2, 8
SSD 8, 4, sse2, 8
%define SSD_CORE SSD_CORE_SSSE3
%define JOIN JOIN_SSSE3
SSD 16, 16, ssse3, 8
SSD 8, 8, ssse3, 8
SSD 16, 8, ssse3, 8
SSD 8, 16, ssse3, 8
SSD 8, 4, ssse3, 8
INIT_MMX
SSD 4, 4, ssse3
SSD 4, 8, ssse3
%assign function_align 16
;=============================================================================
; variance
;=============================================================================
%macro VAR_START 1
pxor m5, m5 ; sum
pxor m6, m6 ; sum squared
%if %1
mova m7, [pw_00ff GLOBAL]
%else
pxor m7, m7 ; zero
%endif
%endmacro
%macro VAR_END 1
HADDW m5, m7
movd r1d, m5
imul r1d, r1d
HADDD m6, m1
shr r1d, %1
movd eax, m6
sub eax, r1d ; sqr - (sum * sum >> shift)
RET
%endmacro
%macro VAR_CORE 0
paddw m5, m0
paddw m5, m3
paddw m5, m1
paddw m5, m4
pmaddwd m0, m0
pmaddwd m3, m3
pmaddwd m1, m1
pmaddwd m4, m4
paddd m6, m0
paddd m6, m3
paddd m6, m1
paddd m6, m4
%endmacro
%macro VAR_2ROW 2
mov r2d, %2
.loop:
mova m0, [r0]
mova m1, m0
mova m3, [r0+%1]
mova m4, m3
punpcklbw m0, m7
punpckhbw m1, m7
%ifidn %1, r1
lea r0, [r0+%1*2]
%else
add r0, r1
%endif
punpcklbw m3, m7
punpckhbw m4, m7
dec r2d
VAR_CORE
jg .loop
%endmacro
;-----------------------------------------------------------------------------
; int x264_pixel_var_wxh_mmxext( uint8_t *, int )
;-----------------------------------------------------------------------------
INIT_MMX
cglobal x264_pixel_var_16x16_mmxext, 2,3
VAR_START 0
VAR_2ROW 8, 16
VAR_END 8
cglobal x264_pixel_var_8x8_mmxext, 2,3
VAR_START 0
VAR_2ROW r1, 4
VAR_END 6
INIT_XMM
cglobal x264_pixel_var_16x16_sse2, 2,3,8
VAR_START 1
mov r2d, 8
.loop:
mova m0, [r0]
mova m3, [r0+r1]
DEINTB 1, 0, 4, 3, 7
lea r0, [r0+r1*2]
VAR_CORE
dec r2d
jg .loop
VAR_END 8
cglobal x264_pixel_var_8x8_sse2, 2,4,8
VAR_START 1
mov r2d, 2
lea r3, [r1*3]
.loop:
movh m0, [r0]
movh m3, [r0+r1]
movhps m0, [r0+r1*2]
movhps m3, [r0+r3]
DEINTB 1, 0, 4, 3, 7
lea r0, [r0+r1*4]
VAR_CORE
dec r2d
jg .loop
VAR_END 6
%macro VAR2_END 0
HADDW m5, m7
movd r1d, m5
imul r1d, r1d
HADDD m6, m1
shr r1d, 6
movd eax, m6
mov [r4], eax
sub eax, r1d ; sqr - (sum * sum >> shift)
RET
%endmacro
;-----------------------------------------------------------------------------
; int x264_pixel_var2_8x8_mmxext( uint8_t *, int, uint8_t *, int, int * )
;-----------------------------------------------------------------------------
%ifndef ARCH_X86_64
INIT_MMX
cglobal x264_pixel_var2_8x8_mmxext, 5,6
VAR_START 0
mov r5d, 8
.loop:
movq m0, [r0]
movq m1, m0
movq m4, m0
movq m2, [r2]
movq m3, m2
punpcklbw m0, m7
punpckhbw m1, m7
punpcklbw m2, m7
punpckhbw m3, m7
psubw m0, m2
psubw m1, m3
paddw m5, m0
paddw m5, m1
pmaddwd m0, m0
pmaddwd m1, m1
paddd m6, m0
paddd m6, m1
add r0, r1
add r2, r3
dec r5d
jg .loop
VAR2_END
RET
%endif
INIT_XMM
cglobal x264_pixel_var2_8x8_sse2, 5,6,8
VAR_START 1
mov r5d, 4
.loop:
movq m1, [r0]
movhps m1, [r0+r1]
movq m3, [r2]
movhps m3, [r2+r3]
DEINTB 0, 1, 2, 3, 7
psubw m0, m2
psubw m1, m3
paddw m5, m0
paddw m5, m1
pmaddwd m0, m0
pmaddwd m1, m1
paddd m6, m0
paddd m6, m1
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
dec r5d
jg .loop
VAR2_END
RET
cglobal x264_pixel_var2_8x8_ssse3, 5,6,8
pxor m5, m5 ; sum
pxor m6, m6 ; sum squared
mova m7, [hsub_mul GLOBAL]
mov r5d, 2
.loop:
movq m0, [r0]
movq m2, [r2]
movq m1, [r0+r1]
movq m3, [r2+r3]
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
punpcklbw m0, m2
punpcklbw m1, m3
movq m2, [r0]
movq m3, [r2]
punpcklbw m2, m3
movq m3, [r0+r1]
movq m4, [r2+r3]
punpcklbw m3, m4
pmaddubsw m0, m7
pmaddubsw m1, m7
pmaddubsw m2, m7
pmaddubsw m3, m7
paddw m5, m0
paddw m5, m1
paddw m5, m2
paddw m5, m3
pmaddwd m0, m0
pmaddwd m1, m1
pmaddwd m2, m2
pmaddwd m3, m3
paddd m6, m0
paddd m6, m1
paddd m6, m2
paddd m6, m3
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
dec r5d
jg .loop
VAR2_END
RET
;=============================================================================
; SATD
;=============================================================================
%define TRANS TRANS_SSE2
%macro JDUP_SSE2 2
punpckldq %1, %2
; doesn't need to dup. sse2 does things by zero extending to words and full h_2d
%endmacro
%macro JDUP_CONROE 2
; join 2x 32 bit and duplicate them
; emulating shufps is faster on conroe
punpcklqdq %1, %2
movsldup %1, %1
%endmacro
%macro JDUP_PENRYN 2
; just use shufps on anything post conroe
shufps %1, %2, 0
%endmacro
%macro HSUMSUB 5
pmaddubsw m%2, m%5
pmaddubsw m%1, m%5
pmaddubsw m%4, m%5
pmaddubsw m%3, m%5
%endmacro
%macro DIFF_UNPACK_SSE2 5
punpcklbw m%1, m%5
punpcklbw m%2, m%5
punpcklbw m%3, m%5
punpcklbw m%4, m%5
psubw m%1, m%2
psubw m%3, m%4
%endmacro
%macro DIFF_SUMSUB_SSSE3 5
HSUMSUB %1, %2, %3, %4, %5
psubw m%1, m%2
psubw m%3, m%4
%endmacro
%macro LOAD_DUP_2x4P 4 ; dst, tmp, 2* pointer
movd %1, %3
movd %2, %4
JDUP %1, %2
%endmacro
%macro LOAD_DUP_4x8P_CONROE 8 ; 4*dst, 4*pointer
movddup m%3, %6
movddup m%4, %8
movddup m%1, %5
movddup m%2, %7
%endmacro
%macro LOAD_DUP_4x8P_PENRYN 8
; penryn and nehalem run punpcklqdq and movddup in different units
movh m%3, %6
movh m%4, %8
punpcklqdq m%3, m%3
movddup m%1, %5
punpcklqdq m%4, m%4
movddup m%2, %7
%endmacro
%macro LOAD_SUMSUB_8x2P 9
LOAD_DUP_4x8P %1, %2, %3, %4, %6, %7, %8, %9
DIFF_SUMSUB_SSSE3 %1, %3, %2, %4, %5
%endmacro
%macro LOAD_SUMSUB_8x4P_SSSE3 7-10 r0, r2, 0
; 4x dest, 2x tmp, 1x mul, [2* ptr], [increment?]
LOAD_SUMSUB_8x2P %1, %2, %5, %6, %7, [%8], [%9], [%8+r1], [%9+r3]
LOAD_SUMSUB_8x2P %3, %4, %5, %6, %7, [%8+2*r1], [%9+2*r3], [%8+r4], [%9+r5]
%if %10
lea %8, [%8+4*r1]
lea %9, [%9+4*r3]
%endif
%endmacro
%macro LOAD_SUMSUB_16P_SSSE3 7 ; 2*dst, 2*tmp, mul, 2*ptr
movddup m%1, [%7]
movddup m%2, [%7+8]
mova m%4, [%6]
movddup m%3, m%4
punpckhqdq m%4, m%4
DIFF_SUMSUB_SSSE3 %1, %3, %2, %4, %5
%endmacro
%macro LOAD_SUMSUB_16P_SSE2 7 ; 2*dst, 2*tmp, mask, 2*ptr
movu m%4, [%7]
mova m%2, [%6]
DEINTB %1, %2, %3, %4, %5
psubw m%1, m%3
psubw m%2, m%4
SUMSUB_BA m%1, m%2, m%3
%endmacro
%macro LOAD_SUMSUB_16x4P 10-13 r0, r2, none
; 8x dest, 1x tmp, 1x mul, [2* ptr] [2nd tmp]
LOAD_SUMSUB_16P %1, %5, %2, %3, %10, %11, %12
LOAD_SUMSUB_16P %2, %6, %3, %4, %10, %11+r1, %12+r3
LOAD_SUMSUB_16P %3, %7, %4, %9, %10, %11+2*r1, %12+2*r3
LOAD_SUMSUB_16P %4, %8, %13, %9, %10, %11+r4, %12+r5
%endmacro
; in: r4=3*stride1, r5=3*stride2
; in: %2 = horizontal offset
; in: %3 = whether we need to increment pix1 and pix2
; clobber: m3..m7
; out: %1 = satd
%macro SATD_4x4_MMX 3
%xdefine %%n n%1
LOAD_DIFF m4, m3, none, [r0+%2], [r2+%2]
LOAD_DIFF m5, m3, none, [r0+r1+%2], [r2+r3+%2]
LOAD_DIFF m6, m3, none, [r0+2*r1+%2], [r2+2*r3+%2]
LOAD_DIFF m7, m3, none, [r0+r4+%2], [r2+r5+%2]
%if %3
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
%endif
HADAMARD4_2D 4, 5, 6, 7, 3, %%n
paddw m4, m6
SWAP %%n, 4
%endmacro
%macro SATD_8x4_SSE 8-9
%ifidn %1, sse2
HADAMARD4_2D_SSE %2, %3, %4, %5, %6, amax
%else
HADAMARD4_V m%2, m%3, m%4, m%5, m%6
; doing the abs first is a slight advantage
ABS4 m%2, m%4, m%3, m%5, m%6, m%7
HADAMARD 1, max, %2, %4, %6, %7
%endif
%ifnidn %9, swap
paddw m%8, m%2
%else
SWAP %8, %2
%endif
%ifidn %1, sse2
paddw m%8, m%4
%else
HADAMARD 1, max, %3, %5, %6, %7
paddw m%8, m%3
%endif
%endmacro
%macro SATD_START_MMX 0
lea r4, [3*r1] ; 3*stride1
lea r5, [3*r3] ; 3*stride2
%endmacro
%macro SATD_END_MMX 0
pshufw m1, m0, 01001110b
paddw m0, m1
pshufw m1, m0, 10110001b
paddw m0, m1
movd eax, m0
and eax, 0xffff
RET
%endmacro
; FIXME avoid the spilling of regs to hold 3*stride.
; for small blocks on x86_32, modify pixel pointer instead.
;-----------------------------------------------------------------------------
; int x264_pixel_satd_16x16_mmxext (uint8_t *, int, uint8_t *, int )
;-----------------------------------------------------------------------------
INIT_MMX
cglobal x264_pixel_satd_16x4_internal_mmxext
SATD_4x4_MMX m2, 0, 0
SATD_4x4_MMX m1, 4, 0
paddw m0, m2
SATD_4x4_MMX m2, 8, 0
paddw m0, m1
SATD_4x4_MMX m1, 12, 0
paddw m0, m2
paddw m0, m1
ret
cglobal x264_pixel_satd_8x8_internal_mmxext
SATD_4x4_MMX m2, 0, 0
SATD_4x4_MMX m1, 4, 1
paddw m0, m2
paddw m0, m1
x264_pixel_satd_8x4_internal_mmxext:
SATD_4x4_MMX m2, 0, 0
SATD_4x4_MMX m1, 4, 0
paddw m0, m2
paddw m0, m1
ret
cglobal x264_pixel_satd_16x16_mmxext, 4,6
SATD_START_MMX
pxor m0, m0
%rep 3
call x264_pixel_satd_16x4_internal_mmxext
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
%endrep
call x264_pixel_satd_16x4_internal_mmxext
HADDUW m0, m1
movd eax, m0
RET
cglobal x264_pixel_satd_16x8_mmxext, 4,6
SATD_START_MMX
pxor m0, m0
call x264_pixel_satd_16x4_internal_mmxext
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
call x264_pixel_satd_16x4_internal_mmxext
SATD_END_MMX
cglobal x264_pixel_satd_8x16_mmxext, 4,6
SATD_START_MMX
pxor m0, m0
call x264_pixel_satd_8x8_internal_mmxext
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
call x264_pixel_satd_8x8_internal_mmxext
SATD_END_MMX
cglobal x264_pixel_satd_8x8_mmxext, 4,6
SATD_START_MMX
pxor m0, m0
call x264_pixel_satd_8x8_internal_mmxext
SATD_END_MMX
cglobal x264_pixel_satd_8x4_mmxext, 4,6
SATD_START_MMX
pxor m0, m0
call x264_pixel_satd_8x4_internal_mmxext
SATD_END_MMX
cglobal x264_pixel_satd_4x8_mmxext, 4,6
SATD_START_MMX
SATD_4x4_MMX m0, 0, 1
SATD_4x4_MMX m1, 0, 0
paddw m0, m1
SATD_END_MMX
cglobal x264_pixel_satd_4x4_mmxext, 4,6
SATD_START_MMX
SATD_4x4_MMX m0, 0, 0
SATD_END_MMX
%macro SATD_START_SSE2 3
%ifnidn %1, sse2
mova %3, [hmul_8p GLOBAL]
%endif
lea r4, [3*r1]
lea r5, [3*r3]
pxor %2, %2
%endmacro
%macro SATD_END_SSE2 2
HADDW %2, m7
movd eax, %2
RET
%endmacro
%macro BACKUP_POINTERS 0
%ifdef ARCH_X86_64
mov r10, r0
mov r11, r2
%endif
%endmacro
%macro RESTORE_AND_INC_POINTERS 0
%ifdef ARCH_X86_64
lea r0, [r10+8]
lea r2, [r11+8]
%else
mov r0, r0mp
mov r2, r2mp
add r0, 8
add r2, 8
%endif
%endmacro
;-----------------------------------------------------------------------------
; int x264_pixel_satd_8x4_sse2 (uint8_t *, int, uint8_t *, int )
;-----------------------------------------------------------------------------
%macro SATDS_SSE2 1
INIT_XMM
%ifnidn %1, sse2
cglobal x264_pixel_satd_4x4_%1, 4, 6, 6
SATD_START_MMX
mova m4, [hmul_4p GLOBAL]
LOAD_DUP_2x4P m2, m5, [r2], [r2+r3]
LOAD_DUP_2x4P m3, m5, [r2+2*r3], [r2+r5]
LOAD_DUP_2x4P m0, m5, [r0], [r0+r1]
LOAD_DUP_2x4P m1, m5, [r0+2*r1], [r0+r4]
DIFF_SUMSUB_SSSE3 0, 2, 1, 3, 4
HADAMARD 0, sumsub, 0, 1, 2, 3
HADAMARD 4, sumsub, 0, 1, 2, 3
HADAMARD 1, amax, 0, 1, 2, 3
HADDW m0, m1
movd eax, m0
RET
%endif
cglobal x264_pixel_satd_4x8_%1, 4, 6, 8
SATD_START_MMX
%ifnidn %1, sse2
mova m7, [hmul_4p GLOBAL]
%endif
movd m4, [r2]
movd m5, [r2+r3]
movd m6, [r2+2*r3]
add r2, r5
movd m0, [r0]
movd m1, [r0+r1]
movd m2, [r0+2*r1]
add r0, r4
movd m3, [r2+r3]
JDUP m4, m3
movd m3, [r0+r1]
JDUP m0, m3
movd m3, [r2+2*r3]
JDUP m5, m3
movd m3, [r0+2*r1]
JDUP m1, m3
DIFFOP 0, 4, 1, 5, 7
movd m5, [r2]
add r2, r5
movd m3, [r0]
add r0, r4
movd m4, [r2]
JDUP m6, m4
movd m4, [r0]
JDUP m2, m4
movd m4, [r2+r3]
JDUP m5, m4
movd m4, [r0+r1]
JDUP m3, m4
DIFFOP 2, 6, 3, 5, 7
SATD_8x4_SSE %1, 0, 1, 2, 3, 4, 5, 6, swap
HADDW m6, m1
movd eax, m6
RET
cglobal x264_pixel_satd_8x8_internal_%1
LOAD_SUMSUB_8x4P 0, 1, 2, 3, 4, 5, 7, r0, r2, 1
SATD_8x4_SSE %1, 0, 1, 2, 3, 4, 5, 6
x264_pixel_satd_8x4_internal_%1:
LOAD_SUMSUB_8x4P 0, 1, 2, 3, 4, 5, 7, r0, r2, 1
SATD_8x4_SSE %1, 0, 1, 2, 3, 4, 5, 6
ret
%ifdef UNIX64 ; 16x8 regresses on phenom win64, 16x16 is almost the same
cglobal x264_pixel_satd_16x4_internal_%1
LOAD_SUMSUB_16x4P 0, 1, 2, 3, 4, 8, 5, 9, 6, 7, r0, r2, 11
lea r2, [r2+4*r3]
lea r0, [r0+4*r1]
SATD_8x4_SSE ssse3, 0, 1, 2, 3, 6, 11, 10
SATD_8x4_SSE ssse3, 4, 8, 5, 9, 6, 3, 10
ret
cglobal x264_pixel_satd_16x8_%1, 4,6,12
SATD_START_SSE2 %1, m10, m7
%ifidn %1, sse2
mova m7, [pw_00ff GLOBAL]
%endif
jmp x264_pixel_satd_16x8_internal_%1
cglobal x264_pixel_satd_16x16_%1, 4,6,12
SATD_START_SSE2 %1, m10, m7
%ifidn %1, sse2
mova m7, [pw_00ff GLOBAL]
%endif
call x264_pixel_satd_16x4_internal_%1
call x264_pixel_satd_16x4_internal_%1
x264_pixel_satd_16x8_internal_%1:
call x264_pixel_satd_16x4_internal_%1
call x264_pixel_satd_16x4_internal_%1
SATD_END_SSE2 %1, m10
%else
cglobal x264_pixel_satd_16x8_%1, 4,6,8
SATD_START_SSE2 %1, m6, m7
BACKUP_POINTERS
call x264_pixel_satd_8x8_internal_%1
RESTORE_AND_INC_POINTERS
call x264_pixel_satd_8x8_internal_%1
SATD_END_SSE2 %1, m6
cglobal x264_pixel_satd_16x16_%1, 4,6,8
SATD_START_SSE2 %1, m6, m7
BACKUP_POINTERS
call x264_pixel_satd_8x8_internal_%1
call x264_pixel_satd_8x8_internal_%1
RESTORE_AND_INC_POINTERS
call x264_pixel_satd_8x8_internal_%1
call x264_pixel_satd_8x8_internal_%1
SATD_END_SSE2 %1, m6
%endif
cglobal x264_pixel_satd_8x16_%1, 4,6,8
SATD_START_SSE2 %1, m6, m7
call x264_pixel_satd_8x8_internal_%1
call x264_pixel_satd_8x8_internal_%1
SATD_END_SSE2 %1, m6
cglobal x264_pixel_satd_8x8_%1, 4,6,8
SATD_START_SSE2 %1, m6, m7
call x264_pixel_satd_8x8_internal_%1
SATD_END_SSE2 %1, m6
cglobal x264_pixel_satd_8x4_%1, 4,6,8
SATD_START_SSE2 %1, m6, m7
call x264_pixel_satd_8x4_internal_%1
SATD_END_SSE2 %1, m6
%endmacro ; SATDS_SSE2
%macro SA8D 1
%ifdef ARCH_X86_64
;-----------------------------------------------------------------------------
; int x264_pixel_sa8d_8x8_sse2( uint8_t *, int, uint8_t *, int )
;-----------------------------------------------------------------------------
cglobal x264_pixel_sa8d_8x8_internal_%1
lea r10, [r0+4*r1]
lea r11, [r2+4*r3]
LOAD_SUMSUB_8x4P 0, 1, 2, 8, 5, 6, 7, r0, r2
LOAD_SUMSUB_8x4P 4, 5, 3, 9, 11, 6, 7, r10, r11
%ifidn %1, sse2 ; sse2 doesn't seem to like the horizontal way of doing things
HADAMARD8_2D 0, 1, 2, 8, 4, 5, 3, 9, 6, amax
%else ; non-sse2
HADAMARD4_V m0, m1, m2, m8, m6
HADAMARD4_V m4, m5, m3, m9, m6
SUMSUB_BADC m0, m4, m1, m5, m6
HADAMARD 2, sumsub, 0, 4, 6, 11
HADAMARD 2, sumsub, 1, 5, 6, 11
SUMSUB_BADC m2, m3, m8, m9, m6
HADAMARD 2, sumsub, 2, 3, 6, 11
HADAMARD 2, sumsub, 8, 9, 6, 11
HADAMARD 1, amax, 0, 4, 6, 11
HADAMARD 1, amax, 1, 5, 6, 4
HADAMARD 1, amax, 2, 3, 6, 4
HADAMARD 1, amax, 8, 9, 6, 4
%endif
paddw m0, m1
paddw m0, m2
paddw m0, m8
SAVE_MM_PERMUTATION x264_pixel_sa8d_8x8_internal_%1
ret
cglobal x264_pixel_sa8d_8x8_%1, 4,6,12
lea r4, [3*r1]
lea r5, [3*r3]
%ifnidn %1, sse2
mova m7, [hmul_8p GLOBAL]
%endif
call x264_pixel_sa8d_8x8_internal_%1
HADDW m0, m1
movd eax, m0
add eax, 1
shr eax, 1
RET
cglobal x264_pixel_sa8d_16x16_%1, 4,6,12
lea r4, [3*r1]
lea r5, [3*r3]
%ifnidn %1, sse2
mova m7, [hmul_8p GLOBAL]
%endif
call x264_pixel_sa8d_8x8_internal_%1 ; pix[0]
add r2, 8
add r0, 8
mova m10, m0
call x264_pixel_sa8d_8x8_internal_%1 ; pix[8]
lea r2, [r2+8*r3]
lea r0, [r0+8*r1]
paddusw m10, m0
call x264_pixel_sa8d_8x8_internal_%1 ; pix[8*stride+8]
sub r2, 8
sub r0, 8
paddusw m10, m0
call x264_pixel_sa8d_8x8_internal_%1 ; pix[8*stride]
paddusw m0, m10
HADDUW m0, m1
movd eax, m0
add eax, 1
shr eax, 1
RET
%else ; ARCH_X86_32
%ifnidn %1, mmxext
cglobal x264_pixel_sa8d_8x8_internal_%1
%define spill0 [esp+4]
%define spill1 [esp+20]
%define spill2 [esp+36]
%ifidn %1, sse2
LOAD_DIFF_8x4P 0, 1, 2, 3, 4, 5, 6, r0, r2, 1
HADAMARD4_2D 0, 1, 2, 3, 4
movdqa spill0, m3
LOAD_DIFF_8x4P 4, 5, 6, 7, 3, 3, 2, r0, r2, 1
HADAMARD4_2D 4, 5, 6, 7, 3
HADAMARD2_2D 0, 4, 1, 5, 3, qdq, amax
movdqa m3, spill0
paddw m0, m1
HADAMARD2_2D 2, 6, 3, 7, 5, qdq, amax
%else ; non-sse2
mova m7, [hmul_8p GLOBAL]
LOAD_SUMSUB_8x4P 0, 1, 2, 3, 5, 6, 7, r0, r2, 1
; could do first HADAMARD4_V here to save spilling later
; surprisingly, not a win on conroe or even p4
mova spill0, m2
mova spill1, m3
mova spill2, m1
SWAP 1, 7
LOAD_SUMSUB_8x4P 4, 5, 6, 7, 2, 3, 1, r0, r2, 1
HADAMARD4_V m4, m5, m6, m7, m3
mova m1, spill2
mova m2, spill0
mova m3, spill1
mova spill0, m6
mova spill1, m7
HADAMARD4_V m0, m1, m2, m3, m7
SUMSUB_BADC m0, m4, m1, m5, m7
HADAMARD 2, sumsub, 0, 4, 7, 6
HADAMARD 2, sumsub, 1, 5, 7, 6
HADAMARD 1, amax, 0, 4, 7, 6
HADAMARD 1, amax, 1, 5, 7, 6
mova m6, spill0
mova m7, spill1
paddw m0, m1
SUMSUB_BADC m2, m6, m3, m7, m4
HADAMARD 2, sumsub, 2, 6, 4, 5
HADAMARD 2, sumsub, 3, 7, 4, 5
HADAMARD 1, amax, 2, 6, 4, 5
HADAMARD 1, amax, 3, 7, 4, 5
%endif ; sse2/non-sse2
paddw m0, m2
paddw m0, m3
ret
%endif ; ifndef mmxext
cglobal x264_pixel_sa8d_8x8_%1, 4,7
mov r6, esp
and esp, ~15
sub esp, 48
lea r4, [3*r1]
lea r5, [3*r3]
call x264_pixel_sa8d_8x8_internal_%1
HADDW m0, m1
movd eax, m0
add eax, 1
shr eax, 1
mov esp, r6
RET
cglobal x264_pixel_sa8d_16x16_%1, 4,7
mov r6, esp
and esp, ~15
sub esp, 64
lea r4, [3*r1]
lea r5, [3*r3]
call x264_pixel_sa8d_8x8_internal_%1
%ifidn %1, mmxext
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
%endif
mova [esp+48], m0
call x264_pixel_sa8d_8x8_internal_%1
mov r0, [r6+20]
mov r2, [r6+28]
add r0, 8
add r2, 8
paddusw m0, [esp+48]
mova [esp+48], m0
call x264_pixel_sa8d_8x8_internal_%1
%ifidn %1, mmxext
lea r0, [r0+4*r1]
lea r2, [r2+4*r3]
%endif
%if mmsize == 16
paddusw m0, [esp+48]
%endif
mova [esp+64-mmsize], m0
call x264_pixel_sa8d_8x8_internal_%1
paddusw m0, [esp+64-mmsize]
%if mmsize == 16
HADDUW m0, m1
%else
mova m2, [esp+48]
pxor m7, m7
mova m1, m0
mova m3, m2
punpcklwd m0, m7
punpckhwd m1, m7
punpcklwd m2, m7
punpckhwd m3, m7
paddd m0, m1
paddd m2, m3
paddd m0, m2
HADDD m0, m1
%endif
movd eax, m0
add eax, 1
shr eax, 1
mov esp, r6
RET
%endif ; !ARCH_X86_64
%endmacro ; SA8D
;=============================================================================
; INTRA SATD
;=============================================================================
%macro INTRA_SA8D_SSE2 1
%ifdef ARCH_X86_64
INIT_XMM
;-----------------------------------------------------------------------------
; void x264_intra_sa8d_x3_8x8_core_sse2( uint8_t *fenc, int16_t edges[2][8], int *res )
;-----------------------------------------------------------------------------
cglobal x264_intra_sa8d_x3_8x8_core_%1, 3,3,16
; 8x8 hadamard
pxor m8, m8
movq m0, [r0+0*FENC_STRIDE]
movq m1, [r0+1*FENC_STRIDE]
movq m2, [r0+2*FENC_STRIDE]
movq m3, [r0+3*FENC_STRIDE]
movq m4, [r0+4*FENC_STRIDE]
movq m5, [r0+5*FENC_STRIDE]
movq m6, [r0+6*FENC_STRIDE]
movq m7, [r0+7*FENC_STRIDE]
punpcklbw m0, m8
punpcklbw m1, m8
punpcklbw m2, m8
punpcklbw m3, m8
punpcklbw m4, m8
punpcklbw m5, m8
punpcklbw m6, m8
punpcklbw m7, m8
HADAMARD8_2D 0, 1, 2, 3, 4, 5, 6, 7, 8
; dc
movzx r0d, word [r1+0]
add r0w, word [r1+16]
add r0d, 8
and r0d, -16
shl r0d, 2
pxor m15, m15
movdqa m8, m2
movdqa m9, m3
movdqa m10, m4
movdqa m11, m5
ABS4 m8, m9, m10, m11, m12, m13
paddusw m8, m10
paddusw m9, m11
%ifidn %1, ssse3
pabsw m10, m6
pabsw m11, m7
pabsw m15, m1
%else
movdqa m10, m6
movdqa m11, m7
movdqa m15, m1
ABS2 m10, m11, m13, m14
ABS1 m15, m13
%endif
paddusw m10, m11
paddusw m8, m9
paddusw m15, m10
paddusw m15, m8
movdqa m14, m15 ; 7x8 sum
movdqa m8, [r1+0] ; left edge
movd m9, r0d
psllw m8, 3
psubw m8, m0
psubw m9, m0
ABS1 m8, m10
ABS1 m9, m11 ; 1x8 sum
paddusw m14, m8
paddusw m15, m9
punpcklwd m0, m1
punpcklwd m2, m3
punpcklwd m4, m5
punpcklwd m6, m7
punpckldq m0, m2
punpckldq m4, m6
punpcklqdq m0, m4 ; transpose
movdqa m1, [r1+16] ; top edge
movdqa m2, m15
psllw m1, 3
psrldq m2, 2 ; 8x7 sum
psubw m0, m1 ; 8x1 sum
ABS1 m0, m1
paddusw m2, m0
; 3x HADDW
movdqa m7, [pw_1 GLOBAL]
pmaddwd m2, m7
pmaddwd m14, m7
pmaddwd m15, m7
movdqa m3, m2
punpckldq m2, m14
punpckhdq m3, m14
pshufd m5, m15, 0xf5
paddd m2, m3
paddd m5, m15
movdqa m3, m2
punpcklqdq m2, m5
punpckhqdq m3, m5
pavgw m3, m2
pxor m0, m0
pavgw m3, m0
movq [r2], m3 ; i8x8_v, i8x8_h
psrldq m3, 8
movd [r2+8], m3 ; i8x8_dc
RET
%endif ; ARCH_X86_64
%endmacro ; INTRA_SA8D_SSE2
; in: r0 = fenc
; out: m0..m3 = hadamard coefs
INIT_MMX
ALIGN 16
load_hadamard:
pxor m7, m7
movd m0, [r0+0*FENC_STRIDE]
movd m1, [r0+1*FENC_STRIDE]
movd m2, [r0+2*FENC_STRIDE]
movd m3, [r0+3*FENC_STRIDE]
punpcklbw m0, m7
punpcklbw m1, m7
punpcklbw m2, m7
punpcklbw m3, m7
HADAMARD4_2D 0, 1, 2, 3, 4
SAVE_MM_PERMUTATION load_hadamard
ret
%macro SCALAR_SUMSUB 4
add %1, %2
add %3, %4
add %2, %2
add %4, %4
sub %2, %1
sub %4, %3
%endmacro
%macro SCALAR_HADAMARD_LEFT 5 ; y, 4x tmp
%ifnidn %1, 0
shl %1d, 5 ; log(FDEC_STRIDE)
%endif
movzx %2d, byte [r1+%1-1+0*FDEC_STRIDE]
movzx %3d, byte [r1+%1-1+1*FDEC_STRIDE]
movzx %4d, byte [r1+%1-1+2*FDEC_STRIDE]
movzx %5d, byte [r1+%1-1+3*FDEC_STRIDE]
%ifnidn %1, 0
shr %1d, 5
%endif
SCALAR_SUMSUB %2d, %3d, %4d, %5d
SCALAR_SUMSUB %2d, %4d, %3d, %5d
mov [left_1d+2*%1+0], %2w
mov [left_1d+2*%1+2], %3w
mov [left_1d+2*%1+4], %4w
mov [left_1d+2*%1+6], %5w
%endmacro
%macro SCALAR_HADAMARD_TOP 5 ; x, 4x tmp
movzx %2d, byte [r1+%1-FDEC_STRIDE+0]
movzx %3d, byte [r1+%1-FDEC_STRIDE+1]
movzx %4d, byte [r1+%1-FDEC_STRIDE+2]
movzx %5d, byte [r1+%1-FDEC_STRIDE+3]
SCALAR_SUMSUB %2d, %3d, %4d, %5d
SCALAR_SUMSUB %2d, %4d, %3d, %5d
mov [top_1d+2*%1+0], %2w
mov [top_1d+2*%1+2], %3w
mov [top_1d+2*%1+4], %4w
mov [top_1d+2*%1+6], %5w
%endmacro
%macro SUM_MM_X3 8 ; 3x sum, 4x tmp, op
pxor %7, %7
pshufw %4, %1, 01001110b
pshufw %5, %2, 01001110b
pshufw %6, %3, 01001110b
paddw %1, %4
paddw %2, %5
paddw %3, %6
punpcklwd %1, %7
punpcklwd %2, %7
punpcklwd %3, %7
pshufw %4, %1, 01001110b
pshufw %5, %2, 01001110b
pshufw %6, %3, 01001110b
%8 %1, %4
%8 %2, %5
%8 %3, %6
%endmacro
%macro CLEAR_SUMS 0
%ifdef ARCH_X86_64
mov qword [sums+0], 0
mov qword [sums+8], 0
mov qword [sums+16], 0
%else
pxor m7, m7
movq [sums+0], m7
movq [sums+8], m7
movq [sums+16], m7
%endif
%endmacro
; in: m1..m3
; out: m7
; clobber: m4..m6
%macro SUM3x4 1
%ifidn %1, ssse3
pabsw m4, m1
pabsw m5, m2
pabsw m7, m3
paddw m4, m5
%else
movq m4, m1
movq m5, m2
ABS2 m4, m5, m6, m7
movq m7, m3
paddw m4, m5
ABS1 m7, m6
%endif
paddw m7, m4
%endmacro
; in: m0..m3 (4x4), m7 (3x4)
; out: m0 v, m4 h, m5 dc
; clobber: m6
%macro SUM4x3 3 ; dc, left, top
movq m4, %2
movd m5, %1
psllw m4, 2
psubw m4, m0
psubw m5, m0
punpcklwd m0, m1
punpcklwd m2, m3
punpckldq m0, m2 ; transpose
movq m1, %3
psllw m1, 2
psubw m0, m1
ABS2 m4, m5, m2, m3 ; 1x4 sum
ABS1 m0, m1 ; 4x1 sum
%endmacro
%macro INTRA_SATDS_MMX 1
INIT_MMX
;-----------------------------------------------------------------------------
; void x264_intra_satd_x3_4x4_mmxext( uint8_t *fenc, uint8_t *fdec, int *res )
;-----------------------------------------------------------------------------
cglobal x264_intra_satd_x3_4x4_%1, 2,6
%ifdef ARCH_X86_64
; stack is 16 byte aligned because abi says so
%define top_1d rsp-8 ; size 8
%define left_1d rsp-16 ; size 8
%define t0 r10
%else
; stack is 16 byte aligned at least in gcc, and we've pushed 3 regs + return address, so it's still aligned
SUB esp, 16
%define top_1d esp+8
%define left_1d esp
%define t0 r2
%endif
call load_hadamard
SCALAR_HADAMARD_LEFT 0, r0, r3, r4, r5
mov t0d, r0d
SCALAR_HADAMARD_TOP 0, r0, r3, r4, r5
lea t0d, [t0d + r0d + 4]
and t0d, -8
shl t0d, 1 ; dc
SUM3x4 %1
SUM4x3 t0d, [left_1d], [top_1d]
paddw m4, m7
paddw m5, m7
movq m1, m5
psrlq m1, 16 ; 4x3 sum
paddw m0, m1
SUM_MM_X3 m0, m4, m5, m1, m2, m3, m6, pavgw
%ifndef ARCH_X86_64
mov r2, r2mp
%endif
movd [r2+0], m0 ; i4x4_v satd
movd [r2+4], m4 ; i4x4_h satd
movd [r2+8], m5 ; i4x4_dc satd
%ifndef ARCH_X86_64
ADD esp, 16
%endif
RET
%ifdef ARCH_X86_64
%define t0 r10
%define t2 r11
%else
%define t0 r0
%define t2 r2
%endif
;-----------------------------------------------------------------------------
; void x264_intra_satd_x3_16x16_mmxext( uint8_t *fenc, uint8_t *fdec, int *res )
;-----------------------------------------------------------------------------
cglobal x264_intra_satd_x3_16x16_%1, 0,7
%ifdef ARCH_X86_64
%assign stack_pad 88
%else
%assign stack_pad 88 + ((stack_offset+88+4)&15)
%endif
; not really needed on x86_64, just shuts up valgrind about storing data below the stack across a function call
SUB rsp, stack_pad
%define sums rsp+64 ; size 24
%define top_1d rsp+32 ; size 32
%define left_1d rsp ; size 32
movifnidn r1, r1mp
CLEAR_SUMS
; 1D hadamards
xor t2d, t2d
mov t0d, 12
.loop_edge:
SCALAR_HADAMARD_LEFT t0, r3, r4, r5, r6
add t2d, r3d
SCALAR_HADAMARD_TOP t0, r3, r4, r5, r6
add t2d, r3d
sub t0d, 4
jge .loop_edge
shr t2d, 1
add t2d, 8
and t2d, -16 ; dc
; 2D hadamards
movifnidn r0, r0mp
xor r3d, r3d
.loop_y:
xor r4d, r4d
.loop_x:
call load_hadamard
SUM3x4 %1
SUM4x3 t2d, [left_1d+8*r3], [top_1d+8*r4]
pavgw m4, m7
pavgw m5, m7
paddw m0, [sums+0] ; i16x16_v satd
paddw m4, [sums+8] ; i16x16_h satd
paddw m5, [sums+16] ; i16x16_dc satd
movq [sums+0], m0
movq [sums+8], m4
movq [sums+16], m5
add r0, 4
inc r4d
cmp r4d, 4
jl .loop_x
add r0, 4*FENC_STRIDE-16
inc r3d
cmp r3d, 4
jl .loop_y
; horizontal sum
movifnidn r2, r2mp
movq m2, [sums+16]
movq m1, [sums+8]
movq m0, [sums+0]
movq m7, m2
SUM_MM_X3 m0, m1, m2, m3, m4, m5, m6, paddd
psrld m0, 1
pslld m7, 16
psrld m7, 16
paddd m0, m2
psubd m0, m7
movd [r2+8], m2 ; i16x16_dc satd
movd [r2+4], m1 ; i16x16_h satd
movd [r2+0], m0 ; i16x16_v satd
ADD rsp, stack_pad
RET
;-----------------------------------------------------------------------------
; void x264_intra_satd_x3_8x8c_mmxext( uint8_t *fenc, uint8_t *fdec, int *res )
;-----------------------------------------------------------------------------
cglobal x264_intra_satd_x3_8x8c_%1, 0,6
; not really needed on x86_64, just shuts up valgrind about storing data below the stack across a function call
SUB rsp, 72
%define sums rsp+48 ; size 24
%define dc_1d rsp+32 ; size 16
%define top_1d rsp+16 ; size 16
%define left_1d rsp ; size 16
movifnidn r1, r1mp
CLEAR_SUMS
; 1D hadamards
mov t0d, 4
.loop_edge:
SCALAR_HADAMARD_LEFT t0, t2, r3, r4, r5
SCALAR_HADAMARD_TOP t0, t2, r3, r4, r5
sub t0d, 4
jge .loop_edge
; dc
movzx t2d, word [left_1d+0]
movzx r3d, word [top_1d+0]
movzx r4d, word [left_1d+8]
movzx r5d, word [top_1d+8]
add t2d, r3d
lea r3, [r4 + r5]
lea t2, [2*t2 + 8]
lea r3, [2*r3 + 8]
lea r4, [4*r4 + 8]
lea r5, [4*r5 + 8]
and t2d, -16 ; tl
and r3d, -16 ; br
and r4d, -16 ; bl
and r5d, -16 ; tr
mov [dc_1d+ 0], t2d ; tl
mov [dc_1d+ 4], r5d ; tr
mov [dc_1d+ 8], r4d ; bl
mov [dc_1d+12], r3d ; br
lea r5, [dc_1d]
; 2D hadamards
movifnidn r0, r0mp
movifnidn r2, r2mp
xor r3d, r3d
.loop_y:
xor r4d, r4d
.loop_x:
call load_hadamard
SUM3x4 %1
SUM4x3 [r5+4*r4], [left_1d+8*r3], [top_1d+8*r4]
pavgw m4, m7
pavgw m5, m7
paddw m0, [sums+16] ; i4x4_v satd
paddw m4, [sums+8] ; i4x4_h satd
paddw m5, [sums+0] ; i4x4_dc satd
movq [sums+16], m0
movq [sums+8], m4
movq [sums+0], m5
add r0, 4
inc r4d
cmp r4d, 2
jl .loop_x
add r0, 4*FENC_STRIDE-8
add r5, 8
inc r3d
cmp r3d, 2
jl .loop_y
; horizontal sum
movq m0, [sums+0]
movq m1, [sums+8]
movq m2, [sums+16]
movq m7, m0
psrlq m7, 15
paddw m2, m7
SUM_MM_X3 m0, m1, m2, m3, m4, m5, m6, paddd
psrld m2, 1
movd [r2+0], m0 ; i8x8c_dc satd
movd [r2+4], m1 ; i8x8c_h satd
movd [r2+8], m2 ; i8x8c_v satd
ADD rsp, 72
RET
%endmacro ; INTRA_SATDS_MMX
%macro ABS_MOV_SSSE3 2
pabsw %1, %2
%endmacro
%macro ABS_MOV_MMX 2
pxor %1, %1
psubw %1, %2
pmaxsw %1, %2
%endmacro
%define ABS_MOV ABS_MOV_MMX
; in: r0=pix, r1=stride, r2=stride*3, r3=tmp, m6=mask_ac4, m7=0
; out: [tmp]=hadamard4, m0=satd
cglobal x264_hadamard_ac_4x4_mmxext
movh m0, [r0]
movh m1, [r0+r1]
movh m2, [r0+r1*2]
movh m3, [r0+r2]
punpcklbw m0, m7
punpcklbw m1, m7
punpcklbw m2, m7
punpcklbw m3, m7
HADAMARD4_2D 0, 1, 2, 3, 4
mova [r3], m0
mova [r3+8], m1
mova [r3+16], m2
mova [r3+24], m3
ABS1 m0, m4
ABS1 m1, m4
pand m0, m6
ABS1 m2, m4
ABS1 m3, m4
paddw m0, m1
paddw m2, m3
paddw m0, m2
SAVE_MM_PERMUTATION x264_hadamard_ac_4x4_mmxext
ret
cglobal x264_hadamard_ac_2x2max_mmxext
mova m0, [r3+0x00]
mova m1, [r3+0x20]
mova m2, [r3+0x40]
mova m3, [r3+0x60]
sub r3, 8
SUMSUB_BADC m0, m1, m2, m3, m4
ABS4 m0, m2, m1, m3, m4, m5
HADAMARD 0, max, 0, 2, 4, 5
HADAMARD 0, max, 1, 3, 4, 5
paddw m7, m0
paddw m7, m1
SAVE_MM_PERMUTATION x264_hadamard_ac_2x2max_mmxext
ret
cglobal x264_hadamard_ac_8x8_mmxext
mova m6, [mask_ac4 GLOBAL]
pxor m7, m7
call x264_hadamard_ac_4x4_mmxext
add r0, 4
add r3, 32
mova m5, m0
call x264_hadamard_ac_4x4_mmxext
lea r0, [r0+4*r1]
add r3, 64
paddw m5, m0
call x264_hadamard_ac_4x4_mmxext
sub r0, 4
sub r3, 32
paddw m5, m0
call x264_hadamard_ac_4x4_mmxext
paddw m5, m0
sub r3, 40
mova [rsp+gprsize+8], m5 ; save satd
%rep 3
call x264_hadamard_ac_2x2max_mmxext
%endrep
mova m0, [r3+0x00]
mova m1, [r3+0x20]
mova m2, [r3+0x40]
mova m3, [r3+0x60]
SUMSUB_BADC m0, m1, m2, m3, m4
HADAMARD 0, sumsub, 0, 2, 4, 5
ABS4 m1, m3, m0, m2, m4, m5
HADAMARD 0, max, 1, 3, 4, 5
pand m6, m0
paddw m7, m1
paddw m6, m2
paddw m7, m7
paddw m6, m7
mova [rsp+gprsize], m6 ; save sa8d
SWAP m0, m6
SAVE_MM_PERMUTATION x264_hadamard_ac_8x8_mmxext
ret
%macro HADAMARD_AC_WXH_MMX 2
cglobal x264_pixel_hadamard_ac_%1x%2_mmxext, 2,4
%assign pad 16-gprsize-(stack_offset&15)
%define ysub r1
sub rsp, 16+128+pad
lea r2, [r1*3]
lea r3, [rsp+16]
call x264_hadamard_ac_8x8_mmxext
%if %2==16
%define ysub r2
lea r0, [r0+r1*4]
sub rsp, 16
call x264_hadamard_ac_8x8_mmxext
%endif
%if %1==16
neg ysub
sub rsp, 16
lea r0, [r0+ysub*4+8]
neg ysub
call x264_hadamard_ac_8x8_mmxext
%if %2==16
lea r0, [r0+r1*4]
sub rsp, 16
call x264_hadamard_ac_8x8_mmxext
%endif
%endif
mova m1, [rsp+0x08]
%if %1*%2 >= 128
paddusw m0, [rsp+0x10]
paddusw m1, [rsp+0x18]
%endif
%if %1*%2 == 256
mova m2, [rsp+0x20]
paddusw m1, [rsp+0x28]
paddusw m2, [rsp+0x30]
mova m3, m0
paddusw m1, [rsp+0x38]
pxor m3, m2
pand m3, [pw_1 GLOBAL]
pavgw m0, m2
psubusw m0, m3
HADDUW m0, m2
%else
psrlw m0, 1
HADDW m0, m2
%endif
psrlw m1, 1
HADDW m1, m3
movd edx, m0
movd eax, m1
shr edx, 1
%ifdef ARCH_X86_64
shl rdx, 32
add rax, rdx
%endif
add rsp, 128+%1*%2/4+pad
RET
%endmacro ; HADAMARD_AC_WXH_MMX
HADAMARD_AC_WXH_MMX 16, 16
HADAMARD_AC_WXH_MMX 8, 16
HADAMARD_AC_WXH_MMX 16, 8
HADAMARD_AC_WXH_MMX 8, 8
%macro LOAD_INC_8x4W_SSE2 5
movh m%1, [r0]
movh m%2, [r0+r1]
movh m%3, [r0+r1*2]
movh m%4, [r0+r2]
%ifidn %1, 0
lea r0, [r0+r1*4]
%endif
punpcklbw m%1, m%5
punpcklbw m%2, m%5
punpcklbw m%3, m%5
punpcklbw m%4, m%5
%endmacro
%macro LOAD_INC_8x4W_SSSE3 5
LOAD_DUP_4x8P %3, %4, %1, %2, [r0+r1*2], [r0+r2], [r0], [r0+r1]
%ifidn %1, 0
lea r0, [r0+r1*4]
%endif
HSUMSUB %1, %2, %3, %4, %5
%endmacro
%macro HADAMARD_AC_SSE2 1
INIT_XMM
; in: r0=pix, r1=stride, r2=stride*3
; out: [esp+16]=sa8d, [esp+32]=satd, r0+=stride*4
cglobal x264_hadamard_ac_8x8_%1
%ifdef ARCH_X86_64
%define spill0 m8
%define spill1 m9
%define spill2 m10
%else
%define spill0 [rsp+gprsize]
%define spill1 [rsp+gprsize+16]
%define spill2 [rsp+gprsize+32]
%endif
%ifnidn %1, sse2
;LOAD_INC loads sumsubs
mova m7, [hmul_8p GLOBAL]
%else
;LOAD_INC only unpacks to words
pxor m7, m7
%endif
LOAD_INC_8x4W 0, 1, 2, 3, 7
%ifidn %1, sse2
HADAMARD4_2D_SSE 0, 1, 2, 3, 4
%else
HADAMARD4_V m0, m1, m2, m3, m4
%endif
mova spill0, m1
SWAP 1, 7
LOAD_INC_8x4W 4, 5, 6, 7, 1
%ifidn %1, sse2
HADAMARD4_2D_SSE 4, 5, 6, 7, 1
%else
HADAMARD4_V m4, m5, m6, m7, m1
%endif
%ifnidn %1, sse2
mova m1, spill0
mova spill0, m6
mova spill1, m7
HADAMARD 1, sumsub, 0, 1, 6, 7
HADAMARD 1, sumsub, 2, 3, 6, 7
mova m6, spill0
mova m7, spill1
mova spill0, m1
mova spill1, m0
HADAMARD 1, sumsub, 4, 5, 1, 0
HADAMARD 1, sumsub, 6, 7, 1, 0
mova m0, spill1
%endif
mova spill1, m2
mova spill2, m3
ABS_MOV m1, m0
ABS_MOV m2, m4
ABS_MOV m3, m5
paddw m1, m2
SUMSUB_BA m0, m4; m2
%ifnidn %1, sse2
pand m1, [mask_ac4b GLOBAL]
%else
pand m1, [mask_ac4 GLOBAL]
%endif
ABS_MOV m2, spill0
paddw m1, m3
ABS_MOV m3, spill1
paddw m1, m2
ABS_MOV m2, spill2
paddw m1, m3
ABS_MOV m3, m6
paddw m1, m2
ABS_MOV m2, m7
paddw m1, m3
mova m3, m7
paddw m1, m2
mova m2, m6
psubw m7, spill2
paddw m3, spill2
mova [rsp+gprsize+32], m1 ; save satd
mova m1, m5
psubw m6, spill1
paddw m2, spill1
psubw m5, spill0
paddw m1, spill0
%ifnidn %1, sse2
mova spill1, m4
HADAMARD 2, amax, 3, 7, 4
HADAMARD 2, amax, 2, 6, 7, 4
mova m4, spill1
HADAMARD 2, amax, 1, 5, 6, 7
HADAMARD 2, sumsub, 0, 4, 5, 6
%else
mova spill1, m4
HADAMARD 4, amax, 3, 7, 4
HADAMARD 4, amax, 2, 6, 7, 4
mova m4, spill1
HADAMARD 4, amax, 1, 5, 6, 7
HADAMARD 4, sumsub, 0, 4, 5, 6
%endif
paddw m2, m3
paddw m2, m1
paddw m2, m2
ABS1 m4, m7
pand m0, [mask_ac8 GLOBAL]
ABS1 m0, m7
paddw m2, m4
paddw m0, m2
mova [rsp+gprsize+16], m0 ; save sa8d
SAVE_MM_PERMUTATION x264_hadamard_ac_8x8_%1
ret
HADAMARD_AC_WXH_SSE2 16, 16, %1
HADAMARD_AC_WXH_SSE2 8, 16, %1
HADAMARD_AC_WXH_SSE2 16, 8, %1
HADAMARD_AC_WXH_SSE2 8, 8, %1
%endmacro ; HADAMARD_AC_SSE2
; struct { int satd, int sa8d; } x264_pixel_hadamard_ac_16x16( uint8_t *pix, int stride )
%macro HADAMARD_AC_WXH_SSE2 3
cglobal x264_pixel_hadamard_ac_%1x%2_%3, 2,3,11
%assign pad 16-gprsize-(stack_offset&15)
%define ysub r1
sub rsp, 48+pad
lea r2, [r1*3]
call x264_hadamard_ac_8x8_%3
%if %2==16
%define ysub r2
lea r0, [r0+r1*4]
sub rsp, 32
call x264_hadamard_ac_8x8_%3
%endif
%if %1==16
neg ysub
sub rsp, 32
lea r0, [r0+ysub*4+8]
neg ysub
call x264_hadamard_ac_8x8_%3
%if %2==16
lea r0, [r0+r1*4]
sub rsp, 32
call x264_hadamard_ac_8x8_%3
%endif
%endif
mova m1, [rsp+0x20]
%if %1*%2 >= 128
paddusw m0, [rsp+0x30]
paddusw m1, [rsp+0x40]
%endif
%if %1*%2 == 256
paddusw m0, [rsp+0x50]
paddusw m1, [rsp+0x60]
paddusw m0, [rsp+0x70]
paddusw m1, [rsp+0x80]
psrlw m0, 1
%endif
HADDW m0, m2
HADDW m1, m3
movd edx, m0
movd eax, m1
shr edx, 2 - (%1*%2 >> 8)
shr eax, 1
%ifdef ARCH_X86_64
shl rdx, 32
add rax, rdx
%endif
add rsp, 16+%1*%2/2+pad
RET
%endmacro ; HADAMARD_AC_WXH_SSE2
; instantiate satds
%ifndef ARCH_X86_64
cextern x264_pixel_sa8d_8x8_internal_mmxext
SA8D mmxext
%endif
%define TRANS TRANS_SSE2
%define ABS1 ABS1_MMX
%define ABS2 ABS2_MMX
%define DIFFOP DIFF_UNPACK_SSE2
%define JDUP JDUP_SSE2
%define LOAD_INC_8x4W LOAD_INC_8x4W_SSE2
%define LOAD_SUMSUB_8x4P LOAD_DIFF_8x4P
%define LOAD_SUMSUB_16P LOAD_SUMSUB_16P_SSE2
%define movdqa movaps ; doesn't hurt pre-nehalem, might as well save size
%define movdqu movups
%define punpcklqdq movlhps
INIT_XMM
SA8D sse2
SATDS_SSE2 sse2
INTRA_SA8D_SSE2 sse2
INTRA_SATDS_MMX mmxext
HADAMARD_AC_SSE2 sse2
%define ABS1 ABS1_SSSE3
%define ABS2 ABS2_SSSE3
%define ABS_MOV ABS_MOV_SSSE3
%define DIFFOP DIFF_SUMSUB_SSSE3
%define JDUP JDUP_CONROE
%define LOAD_DUP_4x8P LOAD_DUP_4x8P_CONROE
%define LOAD_INC_8x4W LOAD_INC_8x4W_SSSE3
%define LOAD_SUMSUB_8x4P LOAD_SUMSUB_8x4P_SSSE3
%define LOAD_SUMSUB_16P LOAD_SUMSUB_16P_SSSE3
SATDS_SSE2 ssse3
SA8D ssse3
HADAMARD_AC_SSE2 ssse3
%undef movdqa ; nehalem doesn't like movaps
%undef movdqu ; movups
%undef punpcklqdq ; or movlhps
INTRA_SA8D_SSE2 ssse3
INTRA_SATDS_MMX ssse3
%define TRANS TRANS_SSE4
%define JDUP JDUP_PENRYN
%define LOAD_DUP_4x8P LOAD_DUP_4x8P_PENRYN
SATDS_SSE2 sse4
SA8D sse4
HADAMARD_AC_SSE2 sse4
;=============================================================================
; SSIM
;=============================================================================
;-----------------------------------------------------------------------------
; void x264_pixel_ssim_4x4x2_core_sse2( const uint8_t *pix1, int stride1,
; const uint8_t *pix2, int stride2, int sums[2][4] )
;-----------------------------------------------------------------------------
%macro SSIM_ITER 1
movq m5, [r0+(%1&1)*r1]
movq m6, [r2+(%1&1)*r3]
punpcklbw m5, m0
punpcklbw m6, m0
%if %1==1
lea r0, [r0+r1*2]
lea r2, [r2+r3*2]
%endif
%if %1==0
movdqa m1, m5
movdqa m2, m6
%else
paddw m1, m5
paddw m2, m6
%endif
movdqa m7, m5
pmaddwd m5, m5
pmaddwd m7, m6
pmaddwd m6, m6
%if %1==0
SWAP m3, m5
SWAP m4, m7
%else
paddd m3, m5
paddd m4, m7
%endif
paddd m3, m6
%endmacro
cglobal x264_pixel_ssim_4x4x2_core_sse2, 4,4,8
pxor m0, m0
SSIM_ITER 0
SSIM_ITER 1
SSIM_ITER 2
SSIM_ITER 3
; PHADDW m1, m2
; PHADDD m3, m4
movdqa m7, [pw_1 GLOBAL]
pshufd m5, m3, 0xb1
pmaddwd m1, m7
pmaddwd m2, m7
pshufd m6, m4, 0xb1
packssdw m1, m2
paddd m3, m5
pshufd m1, m1, 0xd8
paddd m4, m6
pmaddwd m1, m7
movdqa m5, m3
punpckldq m3, m4
punpckhdq m5, m4
%ifdef UNIX64
%define t0 r4
%else
%define t0 rax
mov t0, r4mp
%endif
movq [t0+ 0], m1
movq [t0+ 8], m3
movhps [t0+16], m1
movq [t0+24], m5
RET
;-----------------------------------------------------------------------------
; float x264_pixel_ssim_end_sse2( int sum0[5][4], int sum1[5][4], int width )
;-----------------------------------------------------------------------------
cglobal x264_pixel_ssim_end4_sse2, 3,3,7
movdqa m0, [r0+ 0]
movdqa m1, [r0+16]
movdqa m2, [r0+32]
movdqa m3, [r0+48]
movdqa m4, [r0+64]
paddd m0, [r1+ 0]
paddd m1, [r1+16]
paddd m2, [r1+32]
paddd m3, [r1+48]
paddd m4, [r1+64]
paddd m0, m1
paddd m1, m2
paddd m2, m3
paddd m3, m4
movdqa m5, [ssim_c1 GLOBAL]
movdqa m6, [ssim_c2 GLOBAL]
TRANSPOSE4x4D 0, 1, 2, 3, 4
; s1=m0, s2=m1, ss=m2, s12=m3
movdqa m4, m1
pslld m1, 16
pmaddwd m4, m0 ; s1*s2
por m0, m1
pmaddwd m0, m0 ; s1*s1 + s2*s2
pslld m4, 1
pslld m3, 7
pslld m2, 6
psubd m3, m4 ; covar*2
psubd m2, m0 ; vars
paddd m0, m5
paddd m4, m5
paddd m3, m6
paddd m2, m6
cvtdq2ps m0, m0 ; (float)(s1*s1 + s2*s2 + ssim_c1)
cvtdq2ps m4, m4 ; (float)(s1*s2*2 + ssim_c1)
cvtdq2ps m3, m3 ; (float)(covar*2 + ssim_c2)
cvtdq2ps m2, m2 ; (float)(vars + ssim_c2)
mulps m4, m3
mulps m0, m2
divps m4, m0 ; ssim
cmp r2d, 4
je .skip ; faster only if this is the common case; remove branch if we use ssim on a macroblock level
neg r2
%ifdef PIC
lea r3, [mask_ff + 16 GLOBAL]
movdqu m1, [r3 + r2*4]
%else
movdqu m1, [mask_ff + r2*4 + 16 GLOBAL]
%endif
pand m4, m1
.skip:
movhlps m0, m4
addps m0, m4
pshuflw m4, m0, 0xE
addss m0, m4
%ifndef ARCH_X86_64
movd r0m, m0
fld dword r0m
%endif
RET
;=============================================================================
; Successive Elimination ADS
;=============================================================================
%macro ADS_START 1 ; unroll_size
%ifdef ARCH_X86_64
%define t0 r6
%ifdef WIN64
mov r4, r4mp
movsxd r5, dword r5m
%endif
mov r10, rsp
%else
%define t0 r4
mov rbp, rsp
%endif
mov r0d, r5m
sub rsp, r0
sub rsp, %1*4-1
and rsp, ~15
mov t0, rsp
shl r2d, 1
%endmacro
%macro ADS_END 1
add r1, 8*%1
add r3, 8*%1
add t0, 4*%1
sub r0d, 4*%1
jg .loop
%ifdef WIN64
RESTORE_XMM r10
%endif
jmp ads_mvs
%endmacro
%define ABS1 ABS1_MMX
;-----------------------------------------------------------------------------
; int x264_pixel_ads4_mmxext( int enc_dc[4], uint16_t *sums, int delta,
; uint16_t *cost_mvx, int16_t *mvs, int width, int thresh )
;-----------------------------------------------------------------------------
cglobal x264_pixel_ads4_mmxext, 4,7
movq mm6, [r0]
movq mm4, [r0+8]
pshufw mm7, mm6, 0
pshufw mm6, mm6, 0xAA
pshufw mm5, mm4, 0
pshufw mm4, mm4, 0xAA
ADS_START 1
.loop:
movq mm0, [r1]
movq mm1, [r1+16]
psubw mm0, mm7
psubw mm1, mm6
ABS1 mm0, mm2
ABS1 mm1, mm3
movq mm2, [r1+r2]
movq mm3, [r1+r2+16]
psubw mm2, mm5
psubw mm3, mm4
paddw mm0, mm1
ABS1 mm2, mm1
ABS1 mm3, mm1
paddw mm0, mm2
paddw mm0, mm3
%ifdef WIN64
pshufw mm1, [r10+stack_offset+56], 0
%elifdef ARCH_X86_64
pshufw mm1, [r10+8], 0
%else
pshufw mm1, [ebp+stack_offset+28], 0
%endif
paddusw mm0, [r3]
psubusw mm1, mm0
packsswb mm1, mm1
movd [t0], mm1
ADS_END 1
cglobal x264_pixel_ads2_mmxext, 4,7
movq mm6, [r0]
pshufw mm5, r6m, 0
pshufw mm7, mm6, 0
pshufw mm6, mm6, 0xAA
ADS_START 1
.loop:
movq mm0, [r1]
movq mm1, [r1+r2]
psubw mm0, mm7
psubw mm1, mm6
ABS1 mm0, mm2
ABS1 mm1, mm3
paddw mm0, mm1
paddusw mm0, [r3]
movq mm4, mm5
psubusw mm4, mm0
packsswb mm4, mm4
movd [t0], mm4
ADS_END 1
cglobal x264_pixel_ads1_mmxext, 4,7
pshufw mm7, [r0], 0
pshufw mm6, r6m, 0
ADS_START 2
.loop:
movq mm0, [r1]
movq mm1, [r1+8]
psubw mm0, mm7
psubw mm1, mm7
ABS1 mm0, mm2
ABS1 mm1, mm3
paddusw mm0, [r3]
paddusw mm1, [r3+8]
movq mm4, mm6
movq mm5, mm6
psubusw mm4, mm0
psubusw mm5, mm1
packsswb mm4, mm5
movq [t0], mm4
ADS_END 2
%macro ADS_SSE2 1
cglobal x264_pixel_ads4_%1, 4,7,12
movdqa xmm4, [r0]
pshuflw xmm7, xmm4, 0
pshuflw xmm6, xmm4, 0xAA
pshufhw xmm5, xmm4, 0
pshufhw xmm4, xmm4, 0xAA
punpcklqdq xmm7, xmm7
punpcklqdq xmm6, xmm6
punpckhqdq xmm5, xmm5
punpckhqdq xmm4, xmm4
%ifdef ARCH_X86_64
pshuflw xmm8, r6m, 0
punpcklqdq xmm8, xmm8
ADS_START 2
movdqu xmm10, [r1]
movdqu xmm11, [r1+r2]
.loop:
movdqa xmm0, xmm10
movdqu xmm1, [r1+16]
movdqa xmm10, xmm1
psubw xmm0, xmm7
psubw xmm1, xmm6
ABS1 xmm0, xmm2
ABS1 xmm1, xmm3
movdqa xmm2, xmm11
movdqu xmm3, [r1+r2+16]
movdqa xmm11, xmm3
psubw xmm2, xmm5
psubw xmm3, xmm4
paddw xmm0, xmm1
movdqu xmm9, [r3]
ABS1 xmm2, xmm1
ABS1 xmm3, xmm1
paddw xmm0, xmm2
paddw xmm0, xmm3
paddusw xmm0, xmm9
movdqa xmm1, xmm8
psubusw xmm1, xmm0
packsswb xmm1, xmm1
movq [t0], xmm1
%else
ADS_START 2
.loop:
movdqu xmm0, [r1]
movdqu xmm1, [r1+16]
psubw xmm0, xmm7
psubw xmm1, xmm6
ABS1 xmm0, xmm2
ABS1 xmm1, xmm3
movdqu xmm2, [r1+r2]
movdqu xmm3, [r1+r2+16]
psubw xmm2, xmm5
psubw xmm3, xmm4
paddw xmm0, xmm1
ABS1 xmm2, xmm1
ABS1 xmm3, xmm1
paddw xmm0, xmm2
paddw xmm0, xmm3
movd xmm1, [ebp+stack_offset+28]
movdqu xmm2, [r3]
pshuflw xmm1, xmm1, 0
punpcklqdq xmm1, xmm1
paddusw xmm0, xmm2
psubusw xmm1, xmm0
packsswb xmm1, xmm1
movq [t0], xmm1
%endif ; ARCH
ADS_END 2
cglobal x264_pixel_ads2_%1, 4,7,8
movq xmm6, [r0]
movd xmm5, r6m
pshuflw xmm7, xmm6, 0
pshuflw xmm6, xmm6, 0xAA
pshuflw xmm5, xmm5, 0
punpcklqdq xmm7, xmm7
punpcklqdq xmm6, xmm6
punpcklqdq xmm5, xmm5
ADS_START 2
.loop:
movdqu xmm0, [r1]
movdqu xmm1, [r1+r2]
psubw xmm0, xmm7
psubw xmm1, xmm6
movdqu xmm4, [r3]
ABS1 xmm0, xmm2
ABS1 xmm1, xmm3
paddw xmm0, xmm1
paddusw xmm0, xmm4
movdqa xmm1, xmm5
psubusw xmm1, xmm0
packsswb xmm1, xmm1
movq [t0], xmm1
ADS_END 2
cglobal x264_pixel_ads1_%1, 4,7,8
movd xmm7, [r0]
movd xmm6, r6m
pshuflw xmm7, xmm7, 0
pshuflw xmm6, xmm6, 0
punpcklqdq xmm7, xmm7
punpcklqdq xmm6, xmm6
ADS_START 4
.loop:
movdqu xmm0, [r1]
movdqu xmm1, [r1+16]
psubw xmm0, xmm7
psubw xmm1, xmm7
movdqu xmm2, [r3]
movdqu xmm3, [r3+16]
ABS1 xmm0, xmm4
ABS1 xmm1, xmm5
paddusw xmm0, xmm2
paddusw xmm1, xmm3
movdqa xmm4, xmm6
movdqa xmm5, xmm6
psubusw xmm4, xmm0
psubusw xmm5, xmm1
packsswb xmm4, xmm5
movdqa [t0], xmm4
ADS_END 4
%endmacro
ADS_SSE2 sse2
%define ABS1 ABS1_SSSE3
ADS_SSE2 ssse3
; int x264_pixel_ads_mvs( int16_t *mvs, uint8_t *masks, int width )
; {
; int nmv=0, i, j;
; *(uint32_t*)(masks+width) = 0;
; for( i=0; i<width; i+=8 )
; {
; uint64_t mask = *(uint64_t*)(masks+i);
; if( !mask ) continue;
; for( j=0; j<8; j++ )
; if( mask & (255<<j*8) )
; mvs[nmv++] = i+j;
; }
; return nmv;
; }
cglobal x264_pixel_ads_mvs, 0,7,0
ads_mvs:
%ifdef ARCH_X86_64
; mvs = r4
; masks = rsp
; width = r5
; clear last block in case width isn't divisible by 8. (assume divisible by 4, so clearing 4 bytes is enough.)
%ifdef WIN64
mov r8, r4
mov r9, r5
%endif
xor eax, eax
xor esi, esi
mov dword [rsp+r9], 0
jmp .loopi
.loopi0:
add esi, 8
cmp esi, r9d
jge .end
.loopi:
mov rdi, [rsp+rsi]
test rdi, rdi
jz .loopi0
xor ecx, ecx
%macro TEST 1
mov [r8+rax*2], si
test edi, 0xff<<(%1*8)
setne cl
add eax, ecx
inc esi
%endmacro
TEST 0
TEST 1
TEST 2
TEST 3
shr rdi, 32
TEST 0
TEST 1
TEST 2
TEST 3
cmp esi, r9d
jl .loopi
.end:
mov rsp, r10
RET
%else
xor eax, eax
xor esi, esi
mov ebx, [ebp+stack_offset+20] ; mvs
mov edi, [ebp+stack_offset+24] ; width
mov dword [esp+edi], 0
push ebp
jmp .loopi
.loopi0:
add esi, 8
cmp esi, edi
jge .end
.loopi:
mov ebp, [esp+esi+4]
mov edx, [esp+esi+8]
mov ecx, ebp
or ecx, edx
jz .loopi0
xor ecx, ecx
%macro TEST 2
mov [ebx+eax*2], si
test %2, 0xff<<(%1*8)
setne cl
add eax, ecx
inc esi
%endmacro
TEST 0, ebp
TEST 1, ebp
TEST 2, ebp
TEST 3, ebp
TEST 0, edx
TEST 1, edx
TEST 2, edx
TEST 3, edx
cmp esi, edi
jl .loopi
.end:
pop esp
RET
%endif ; ARCH
|
; A159290: A generalized Jacobsthal sequence.
; 3,5,13,25,53,105,213,425,853,1705,3413,6825,13653,27305,54613,109225,218453,436905,873813,1747625,3495253,6990505,13981013,27962025,55924053,111848105,223696213,447392425,894784853,1789569705,3579139413,7158278825,14316557653,28633115305,57266230613,114532461225,229064922453,458129844905,916259689813,1832519379625,3665038759253,7330077518505,14660155037013,29320310074025,58640620148053,117281240296105,234562480592213,469124961184425,938249922368853,1876499844737705,3752999689475413
mov $1,2
pow $1,$0
mul $1,5
sub $1,5
div $1,3
mul $1,2
add $1,3
mov $0,$1
|
;;
;; Copyright (c) 2019, 2020, 2021 Antti Tiihala
;;
;; Permission to use, copy, modify, and/or distribute this software for any
;; purpose with or without fee is hereby granted, provided that the above
;; copyright notice and this permission notice appear in all copies.
;;
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;;
;; lib/a32/cpu.asm
;; Miscellaneous assembly functions (32-bit)
;;
bits 32
section .text
global _cpu_id
global _cpu_halt
global _cpu_ints
global _cpu_invlpg
global _cpu_wbinvd
global _cpu_rdtsc
global _cpu_rdtsc_delay
global _cpu_rdtsc_diff
global _cpu_rdmsr
global _cpu_wrmsr
global _cpu_add32
global _cpu_sub32
global _cpu_in8
global _cpu_in16
global _cpu_in32
global _cpu_out8
global _cpu_out16
global _cpu_out32
global _cpu_read8
global _cpu_read16
global _cpu_read32
global _cpu_read64
global _cpu_read_cr0
global _cpu_read_cr2
global _cpu_read_cr3
global _cpu_read_cr4
global _cpu_read_flags
global _cpu_write8
global _cpu_write16
global _cpu_write32
global _cpu_write64
global _cpu_write_cr0
global _cpu_write_cr2
global _cpu_write_cr3
global _cpu_write_cr4
global _cpu_xchg
align 16
; void cpu_id(uint32_t *a, uint32_t *c, uint32_t *d, uint32_t *b)
_cpu_id:
push ebx ; save register ebx
push esi ; save register esi
mov esi, [esp+12] ; esi = a
mov eax, [esi] ; eax = *a
mov esi, [esp+16] ; esi = c
mov ecx, [esi] ; ecx = *c
mov esi, [esp+20] ; esi = d
mov edx, [esi] ; edx = *d
mov esi, [esp+24] ; esi = b
mov ebx, [esi] ; ebx = *b
cpuid ; cpu identification
mov esi, [esp+12] ; esi = a
mov [esi], eax ; *a = eax
mov esi, [esp+16] ; esi = c
mov [esi], ecx ; *c = ecx
mov esi, [esp+20] ; esi = d
mov [esi], edx ; *d = edx
mov esi, [esp+24] ; esi = b
mov [esi], ebx ; *b = ebx
pop esi ; restore register esi
pop ebx ; restore register ebx
ret
align 16
; void cpu_halt(uint32_t counter)
_cpu_halt:
mov ecx, [esp+4] ; ecx = counter
call __serialize_execution ; (registers preserved)
test ecx, ecx ; zero is infinite
jnz short .spin2
.spin1: hlt ; halt instruction
jmp short .spin1
.spin2: hlt ; halt instruction
dec ecx ; decrement counter
jnz short .spin2
ret
align 16
; int cpu_ints(int enable)
_cpu_ints:
pushfd ; push eflags
mov eax, [esp] ; eax = eflags
and eax, 0x00000200 ; eax = current interrupt flag << 9
shr eax, 9 ; eax = current interrupt flag
or dword [esp], 0x00000200 ; set interrupt flag
cmp dword [esp+8], 0 ; check input
jne short .end
xor dword [esp], 0x00000200 ; clear interrupt flag
.end: popfd ; pop eflags
ret
align 16
; void cpu_invlpg(const void *address)
_cpu_invlpg:
mov ecx, [esp+4] ; ecx = address
invlpg [ecx] ; invalidate tlb entry
ret
align 16
; void cpu_wbinvd(void)
_cpu_wbinvd:
wbinvd ; write back and invalidate cache
ret
align 16
; void cpu_rdtsc(uint32_t *a, uint32_t *d)
_cpu_rdtsc:
rdtsc ; read time-stamp counter
mov ecx, [esp+4] ; ecx = a
mov [ecx], eax ; *a = eax
mov ecx, [esp+8] ; ecx = d
mov [ecx], edx ; *d = edx
ret
align 16
; void cpu_rdtsc_delay(uint32_t a, uint32_t d)
_cpu_rdtsc_delay:
push ebx ; save register ebx
test dword [esp+12], 0x80000000 ; test highest bit (input d)
jnz short .end
rdtsc ; read time-stamp counter
mov ecx, eax ; ecx = counter (low dword)
mov ebx, edx ; ebx = counter (high dword)
.spin: rdtsc ; read time-stamp counter
sub eax, ecx ; eax = difference (low dword)
sbb edx, ebx ; edx = difference (high dword)
sub eax, [esp+8] ; compare to input a
sbb edx, [esp+12] ; compare to input d
jc short .spin
.end: pop ebx ; restore register ebx
ret
align 16
; void cpu_rdtsc_diff(uint32_t *a, uint32_t *d)
_cpu_rdtsc_diff:
rdtsc ; read time-stamp counter
mov ecx, [esp+4] ; ecx = a
sub eax, [ecx] ; eax -= *a
mov [ecx], eax ; *a = eax
mov ecx, [esp+8] ; ecx = d
sbb edx, [ecx] ; edx -= *d
mov [ecx], edx ; *d = edx
ret
align 16
; void cpu_rdmsr(uint32_t msr, uint32_t *a, uint32_t *d)
_cpu_rdmsr:
mov ecx, [esp+4] ; ecx = model specific register
rdmsr ; read the register
mov ecx, [esp+8] ; ecx = a
mov [ecx], eax ; *a = eax
mov ecx, [esp+12] ; ecx = d
mov [ecx], edx ; *d = edx
ret
align 16
; void cpu_wrmsr(uint32_t msr, uint32_t a, uint32_t d)
_cpu_wrmsr:
mov ecx, [esp+4] ; ecx = model specific register
mov eax, [esp+8] ; eax = a
mov edx, [esp+12] ; edx = d
wrmsr ; write the register
ret
align 16
; uint32_t cpu_add32(void *address, uint32_t value)
_cpu_add32:
push ebx ; save register ebx
mov ebx, [esp+8] ; ebx = address
mov edx, [esp+12] ; edx = value
.L1: mov eax, [ebx] ; eax = *((uint32_t *)address)
mov ecx, eax ; ecx = current
add ecx, edx ; ecx = current + value
lock cmpxchg [ebx], ecx ; try to update
jnz short .L1 ; retry if needed
mov eax, ecx ; eax = latest value
pop ebx ; restore register ebx
ret
align 16
; uint32_t cpu_sub32(void *address, uint32_t value)
_cpu_sub32:
push ebx ; save register ebx
mov ebx, [esp+8] ; ebx = address
mov edx, [esp+12] ; edx = value
.L1: mov eax, [ebx] ; eax = *((uint32_t *)address)
mov ecx, eax ; ecx = current
sub ecx, edx ; ecx = current - value
lock cmpxchg [ebx], ecx ; try to update
jnz short .L1 ; retry if needed
mov eax, ecx ; eax = latest value
pop ebx ; restore register ebx
ret
align 16
; uint8_t cpu_in8(uint16_t port)
_cpu_in8:
mov edx, [esp+4] ; dx = port
in al, dx ; input from port
and eax, 0xFF ; clear upper bits
ret
align 16
; uint16_t cpu_in16(uint16_t port)
_cpu_in16:
mov edx, [esp+4] ; dx = port
in ax, dx ; input from port
and eax, 0xFFFF ; clear upper bits
ret
align 16
; uint32_t cpu_in32(uint16_t port)
_cpu_in32:
mov edx, [esp+4] ; dx = port
in eax, dx ; input from port
ret
align 16
; void cpu_out8(uint16_t port, uint8_t value)
_cpu_out8:
mov edx, [esp+4] ; dx = port
mov eax, [esp+8] ; al = value
out dx, al ; output to port
ret
align 16
; void cpu_out16(uint16_t port, uint16_t value)
_cpu_out16:
mov edx, [esp+4] ; dx = port
mov eax, [esp+8] ; ax = value
out dx, ax ; output to port
ret
align 16
; void cpu_out32(uint16_t port, uint32_t value)
_cpu_out32:
mov edx, [esp+4] ; dx = port
mov eax, [esp+8] ; eax = value
out dx, eax ; output to port
ret
align 16
; uint8_t cpu_read8(const void *address)
_cpu_read8:
mov ecx, [esp+4] ; ecx = address
call __serialize_execution ; (registers preserved)
mov al, [ecx] ; al = value
and eax, 0xFF ; clear upper bits
ret
align 16
; uint16_t cpu_read16(const void *address)
_cpu_read16:
mov ecx, [esp+4] ; ecx = address
call __serialize_execution ; (registers preserved)
mov ax, [ecx] ; ax = value
and eax, 0xFFFF ; clear upper bits
ret
align 16
; uint32_t cpu_read32(const void *address)
_cpu_read32:
mov ecx, [esp+4] ; ecx = address
call __serialize_execution ; (registers preserved)
mov eax, [ecx] ; eax = value
ret
align 16
; uint64_t cpu_read64(const void *address)
_cpu_read64:
mov ecx, [esp+4] ; ecx = address
call __serialize_execution ; (registers preserved)
mov eax, [ecx+0] ; eax = value (low dword)
mov edx, [ecx+4] ; edx = value (high dword)
ret
align 16
; cpu_native_t cpu_read_cr0(void)
_cpu_read_cr0:
mov eax, cr0 ; eax = control register cr0
ret
align 16
; cpu_native_t cpu_read_cr2(void)
_cpu_read_cr2:
mov eax, cr2 ; eax = control register cr2
ret
align 16
; cpu_native_t cpu_read_cr3(void)
_cpu_read_cr3:
mov eax, cr3 ; eax = control register cr3
ret
align 16
; cpu_native_t cpu_read_cr4(void)
_cpu_read_cr4:
mov eax, cr4 ; eax = control register cr4
ret
align 16
; cpu_native_t cpu_read_flags(void)
_cpu_read_flags:
pushfd ; push eflags
pop eax ; eax = eflags
ret
align 16
; void cpu_write8(void *address, uint8_t value)
_cpu_write8:
mov ecx, [esp+4] ; ecx = address
mov dl, [esp+8] ; dl = value
call __serialize_execution ; (registers preserved)
mov [ecx], dl ; write
call __serialize_execution ; (registers preserved)
ret
align 16
; void cpu_write16(void *address, uint16_t value)
_cpu_write16:
mov ecx, [esp+4] ; ecx = address
mov dx, [esp+8] ; dx = value
call __serialize_execution ; (registers preserved)
mov [ecx], dx ; write
call __serialize_execution ; (registers preserved)
ret
align 16
; void cpu_write32(void *address, uint32_t value)
_cpu_write32:
mov ecx, [esp+4] ; ecx = address
mov edx, [esp+8] ; edx = value
call __serialize_execution ; (registers preserved)
mov [ecx], edx ; write
call __serialize_execution ; (registers preserved)
ret
align 16
; void cpu_write64(void *address, uint64_t value)
_cpu_write64:
mov ecx, [esp+4] ; ecx = address
mov eax, [esp+8] ; eax = value (low dword)
mov edx, [esp+12] ; edx = value (high dword)
call __serialize_execution ; (registers preserved)
mov [ecx+0], eax ; write (low dword)
mov [ecx+4], edx ; write (high dword)
call __serialize_execution ; (registers preserved)
ret
align 16
; void cpu_write_cr0(cpu_native_t value)
_cpu_write_cr0:
mov ecx, [esp+4] ; ecx = value
mov cr0, ecx ; cr0 = value
ret
align 16
; void cpu_write_cr2(cpu_native_t value)
_cpu_write_cr2:
mov ecx, [esp+4] ; ecx = value
mov cr2, ecx ; cr2 = value
ret
align 16
; void cpu_write_cr3(cpu_native_t value)
_cpu_write_cr3:
mov ecx, [esp+4] ; ecx = value
mov cr3, ecx ; cr3 = value
ret
align 16
; void cpu_write_cr4(cpu_native_t value)
_cpu_write_cr4:
mov ecx, [esp+4] ; ecx = value
mov cr4, ecx ; cr4 = value
ret
align 16
; cpu_native_t cpu_xchg(cpu_native_t *address, cpu_native_t value)
_cpu_xchg:
mov ecx, [esp+4] ; ecx = address
mov eax, [esp+8] ; eax = value
xchg [ecx], eax ; exchange memory with register
ret
align 16
; Internal procedure for serializing instruction execution
;
; All registers are preserved.
__serialize_execution:
push eax ; save register eax
push ecx ; save register ecx
push edx ; save register edx
push ebx ; save register ebx
xor eax, eax ; eax = 0
cpuid ; serializing instruction
pop ebx ; restore register ebx
pop edx ; restore register edx
pop ecx ; restore register ecx
pop eax ; restore register eax
ret
|
/* Copyright (c) 2018 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/
#include "meta/processors/partsMan/GetPartsAllocProcessor.h"
namespace nebula {
namespace meta {
void GetPartsAllocProcessor::process(const cpp2::GetPartsAllocReq& req) {
folly::SharedMutex::ReadHolder rHolder(LockUtils::spaceLock());
auto spaceId = req.get_space_id();
auto prefix = MetaServiceUtils::partPrefix(spaceId);
std::unique_ptr<kvstore::KVIterator> iter;
auto ret = kvstore_->prefix(kDefaultSpaceId, kDefaultPartId, prefix, &iter);
handleErrorCode(MetaCommon::to(ret));
if (ret != kvstore::ResultCode::SUCCEEDED) {
onFinished();
return;
}
decltype(resp_.parts) parts;
while (iter->valid()) {
auto key = iter->key();
PartitionID partId;
memcpy(&partId, key.data() + prefix.size(), sizeof(PartitionID));
std::vector<nebula::cpp2::HostAddr> partHosts = MetaServiceUtils::parsePartVal(iter->val());
parts.emplace(partId, std::move(partHosts));
iter->next();
}
resp_.set_parts(std::move(parts));
onFinished();
}
} // namespace meta
} // namespace nebula
|
; A248522: Beatty sequence for 1/(1-exp(-1/3)): a(n) = floor(n/(1-exp(-1/3))).
; 3,7,10,14,17,21,24,28,31,35,38,42,45,49,52,56,59,63,67,70,74,77,81,84,88,91,95,98,102,105,109,112,116,119,123,126,130,134,137,141,144,148,151,155,158,162,165,169,172,176,179,183,186,190,194,197,201
mov $5,$0
lpb $0,1
add $1,$0
sub $0,1
mul $0,3
add $3,6
div $1,$3
add $1,$0
div $1,6
trn $4,$0
mul $0,$4
add $1,1
lpe
add $1,3
mov $2,$5
mul $2,3
add $1,$2
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r15
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x183c5, %rbp
nop
nop
inc %r13
movb (%rbp), %r12b
nop
nop
nop
nop
nop
cmp $6012, %rdx
lea addresses_normal_ht+0xd245, %r10
nop
dec %r15
mov (%r10), %r9d
nop
nop
nop
nop
nop
sub $25035, %r9
lea addresses_WC_ht+0x1ae45, %rsi
lea addresses_D_ht+0x13645, %rdi
nop
xor $50748, %r13
mov $37, %rcx
rep movsw
nop
nop
nop
cmp %r9, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r15
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r9
push %rax
push %rbx
// Faulty Load
lea addresses_PSE+0x10e45, %rax
nop
nop
nop
sub $21489, %r13
mov (%rax), %r14w
lea oracles, %r13
and $0xff, %r14
shlq $12, %r14
mov (%r13,%r14,1), %r14
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_PSE', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_PSE', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': True}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; A020083: a(n) = floor( Gamma(n + 3/5)/Gamma(3/5) ).
; Submitted by Jamie Morken(s3)
; 1,0,0,2,8,41,231,1527,11610,99850,958561,10160755,117864768,1485096081,20197306708,294880677941,4600138575887,76362300359740,1343976486331425,24997962645764522,489960067856984638,10093177397853883551,218012631793643884711,4927085478536351794475,116279217293457902349617,2860468745419064397800587,73227999882728048583695046,1947864796880566092326288239,53761068393903624148205555413,1537566556065643650638678884812,45511970059543052058904894990446,1392666283822017393002489786707662
mov $2,1
mov $3,$0
mul $3,5
lpb $3
sub $3,4
mov $5,$3
mul $5,2
add $5,4
mul $2,$5
sub $3,1
lpe
mov $4,10
pow $4,$0
div $2,$4
mov $0,$2
|
; A052147: a(n) = prime(n) + 2.
; Submitted by Jamie Morken(s3)
; 4,5,7,9,13,15,19,21,25,31,33,39,43,45,49,55,61,63,69,73,75,81,85,91,99,103,105,109,111,115,129,133,139,141,151,153,159,165,169,175,181,183,193,195,199,201,213,225,229,231,235,241,243,253,259,265,271,273,279,283,285,295,309,313,315,319,333,339,349,351,355,361,369,375,381,385,391,399,403,411,421,423,433,435,441,445,451,459,463,465,469,481,489,493,501,505,511,523,525,543
mul $0,2
max $0,1
seq $0,173919 ; Numbers that are prime or one less than a prime.
add $0,2
|
.cpu "6502"
.format "flat"
* = $F000
COLUBK = $09
INT_RESERVED_0 = $80
BackgroundColor = $81
TYPE_VCSFramework_V2_Nothing = 0
SIZE_VCSFramework_V2_Nothing = 0
TYPE_System_Byte = 100
SIZE_System_Byte = 1
.include "../../../VCSCompiler/vil.h"
// Repeatedly increments COLUBK without making any effort to handle scanlines, perform VSYNC,
// etc. Result is a rapidly scrolling screen that changes color multiple times mid-scanline.
// Only tested on emulator, not on TVs.
// This is not a proper VCS program. It's just meant to see how stripped down of a program
// we can make that still displays something on the screen.
Start
SEI
CLD
// Not doing any scanline/VSYNC/VBLANK/anything handling messes up the NTSC/PAL/SECAM
// detection, so use $0E, which shows up as white for all of them.
LDA #0
STA BackgroundColor
MainLoop
.let STACK_TYPEOF = [TYPE_VCSFramework_V2_Nothing, TYPE_VCSFramework_V2_Nothing]
.let STACK_SIZEOF = [SIZE_VCSFramework_V2_Nothing, SIZE_VCSFramework_V2_Nothing]
.pushGlobal BackgroundColor, TYPE_System_Byte, SIZE_System_Byte
.let STACK_TYPEOF = [TYPE_System_Byte, STACK_TYPEOF[0]]
.let STACK_SIZEOF = [SIZE_System_Byte, STACK_SIZEOF[0]]
.pushConstant 1, TYPE_System_Byte, SIZE_System_Byte
.let STACK_TYPEOF = [TYPE_System_Byte, STACK_TYPEOF[0]]
.let STACK_SIZEOF = [SIZE_System_Byte, STACK_SIZEOF[0]]
.addFromStack STACK_TYPEOF[0], STACK_SIZEOF[0], STACK_TYPEOF[1], STACK_SIZEOF[1]
.let STACK_TYPEOF = [getAddResultType(STACK_TYPEOF[0], STACK_TYPEOF[1]), TYPE_VCSFramework_V2_Nothing]
.let STACK_SIZEOF = [getSizeFromBuiltInType(STACK_TYPEOF[0]), SIZE_VCSFramework_V2_Nothing]
PLA
STA BackgroundColor
STA COLUBK
JMP MainLoop
// Special memory locations. Tells the 6502 where to go.
* = $FFFC
.word Start
.word Start |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0xc4d7, %rsi
lea addresses_WT_ht+0xe2c7, %rdi
nop
mfence
mov $91, %rcx
rep movsb
dec %r8
lea addresses_A_ht+0xe73, %rsi
lea addresses_WC_ht+0xe1ff, %rdi
nop
nop
nop
xor $45418, %rdx
mov $86, %rcx
rep movsl
nop
nop
nop
add %rdx, %rdx
lea addresses_normal_ht+0x997, %rsi
nop
nop
nop
nop
xor $5386, %r11
mov (%rsi), %edi
nop
and $65487, %rdx
lea addresses_WT_ht+0x19485, %rsi
lea addresses_UC_ht+0x109d7, %rdi
nop
nop
nop
nop
inc %r10
mov $102, %rcx
rep movsb
nop
nop
nop
nop
nop
dec %r8
lea addresses_A_ht+0x1480d, %r11
inc %r8
movl $0x61626364, (%r11)
xor %rdi, %rdi
lea addresses_WT_ht+0xc0a7, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
add %r13, %r13
movw $0x6162, (%rsi)
nop
nop
add $25176, %r11
lea addresses_WT_ht+0x6d7, %rsi
lea addresses_A_ht+0x11279, %rdi
nop
nop
nop
nop
cmp $52955, %r8
mov $78, %rcx
rep movsb
nop
nop
nop
nop
nop
xor $60214, %rdi
lea addresses_D_ht+0x1937, %r10
xor $60696, %rdx
vmovups (%r10), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %r8
nop
dec %rdx
lea addresses_D_ht+0x81b7, %rsi
sub %r11, %r11
movl $0x61626364, (%rsi)
nop
nop
cmp %rsi, %rsi
lea addresses_normal_ht+0xdad7, %r13
nop
nop
nop
add %rcx, %rcx
movb $0x61, (%r13)
nop
nop
nop
nop
sub $54951, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r8
push %rax
push %rdx
// Faulty Load
lea addresses_D+0x16ad7, %r12
clflush (%r12)
nop
nop
nop
mfence
mov (%r12), %r8w
lea oracles, %rdx
and $0xff, %r8
shlq $12, %r8
mov (%rdx,%r8,1), %r8
pop %rdx
pop %rax
pop %r8
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': True, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': True, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
INCLUDE "config_private.inc"
SECTION data_arch
PUBLIC _GLOBAL_SMS_VRAM_SPRITE_PATTERN_BASE_ADDRESS
_GLOBAL_SMS_VRAM_SPRITE_PATTERN_BASE_ADDRESS:
defw __SMS_VRAM_SPRITE_PATTERN_BASE_ADDRESS
|
.size 8000
.text@48
ld a, ff
ldff(45), a
jp lstatint
.text@100
jp lbegin
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 03
call lwaitly_b
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
ei
ld a, b
inc a
inc a
ldff(45), a
ld c, 41
ld a, 05
ldff(43), a
.text@1000
lstatint:
xor a, a
ldff(c), a
ldff(0f), a
.text@10a1
ldff(c), a
ldff a, (0f)
and a, b
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
_DepositPKMN:
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
ld [wVramState], a
ldh a, [hInMenu]
push af
ld a, $1
ldh [hInMenu], a
xor a
ldh [hMapAnims], a
call BillsPC_InitRAM
xor a
ld [wBillsPC_LoadedBox], a
call DelayFrame
.loop
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .done
call .RunJumptable
call DelayFrame
jr .loop
.done
call ClearSprites
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
pop af
ld [wOptions], a
ret
.RunJumptable:
ld a, [wJumptableIndex]
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
.Jumptable:
dw .Init
dw .HandleJoypad
dw .WhatsUp
dw .Submenu
dw BillsPC_EndJumptableLoop
.Init:
xor a
ldh [hBGMapMode], a
call ClearSprites
call CopyBoxmonSpecies
call BillsPC_BoxName
ld de, PCString_ChooseaPKMN
call BillsPC_PlaceString
ld a, $5
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call PCMonInfo
ld a, $ff
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
call WaitBGMap
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
ret
.HandleJoypad:
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b_button
ld a, [hl]
and A_BUTTON
jr nz, .a_button
call Withdraw_UpDown
and a
ret z
call BillsPC_UpdateSelectionCursor
xor a
ldh [hBGMapMode], a
call BillsPC_RefreshTextboxes
call PCMonInfo
ld a, $1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
.a_button
call BillsPC_GetSelectedPokemonSpecies
and a
ret z
cp -1
jr z, .b_button
ld a, $2
ld [wJumptableIndex], a
ret
.go_back
ld hl, wJumptableIndex
dec [hl]
ret
.b_button
ld a, $4
ld [wJumptableIndex], a
ret
.WhatsUp:
xor a
ldh [hBGMapMode], a
call ClearSprites
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ld de, PCString_WhatsUp
call BillsPC_PlaceString
ld a, $1
ld [wMenuCursorY], a
call BillsPC_IncrementJumptableIndex
ret
.Submenu:
ld hl, BillsPCDepositMenuHeader
call CopyMenuHeader
ld a, [wMenuCursorY]
call StoreTo_wMenuCursorBuffer
call VerticalMenu
jp c, BillsPCDepositFuncCancel
ld a, [wMenuCursorY]
dec a
and %11
ld e, a
ld d, 0
ld hl, BillsPCDepositJumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
BillsPCDepositJumptable:
dw BillsPCDepositFuncDeposit ; Deposit Pokemon
dw BillsPCDepositFuncStats ; Pokemon Stats
dw BillsPCDepositFuncRelease ; Release Pokemon
dw BillsPCDepositFuncCancel ; Cancel
BillsPCDepositFuncDeposit:
call BillsPC_CheckMail_PreventBlackout
jp c, BillsPCDepositFuncCancel
call DepositPokemon
jr c, .box_full
ld a, $0
ld [wJumptableIndex], a
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ret
.box_full
ld de, PCString_WhatsUp
call BillsPC_PlaceString
ret
BillsPCDepositFuncStats:
call LoadStandardMenuHeader
call BillsPC_StatsScreen
call ExitMenu
call PCMonInfo
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ret
BillsPCDepositFuncRelease:
call BillsPC_CheckMail_PreventBlackout
jr c, BillsPCDepositFuncCancel
call BillsPC_IsMonAnEgg
jr c, BillsPCDepositFuncCancel
ld a, [wMenuCursorY]
push af
ld de, PCString_ReleasePKMN
call BillsPC_PlaceString
call LoadStandardMenuHeader
lb bc, 14, 11
call PlaceYesNoBox
ld a, [wMenuCursorY]
dec a
call ExitMenu
and a
jr nz, .failed_release
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
call ReleasePKMN_ByePKMN
ld a, $0
ld [wJumptableIndex], a
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
pop af
ret
.failed_release
ld de, PCString_WhatsUp
call BillsPC_PlaceString
pop af
ld [wMenuCursorY], a
ret
BillsPCDepositFuncCancel:
ld a, $0
ld [wJumptableIndex], a
ret
BillsPCDepositMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 4 ; items
db "DEPOSIT@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
Unreferenced_BillsPCClearThreeBoxes:
hlcoord 0, 0
ld b, 4
ld c, 8
call ClearBox
hlcoord 0, 4
ld b, 10
ld c, 9
call ClearBox
hlcoord 0, 14
ld b, 2
ld c, 8
call ClearBox
ret
_WithdrawPKMN:
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
ld [wVramState], a
ldh a, [hInMenu]
push af
ld a, $1
ldh [hInMenu], a
xor a
ldh [hMapAnims], a
call BillsPC_InitRAM
ld a, NUM_BOXES + 1
ld [wBillsPC_LoadedBox], a
call DelayFrame
.loop
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .done
call .RunJumptable
call DelayFrame
jr .loop
.done
call ClearSprites
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
pop af
ld [wOptions], a
ret
.RunJumptable:
ld a, [wJumptableIndex]
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
.Jumptable:
dw .Init
dw .Joypad
dw .PrepSubmenu
dw BillsPC_Withdraw
dw BillsPC_EndJumptableLoop
.Init:
ld a, NUM_BOXES + 1
ld [wBillsPC_LoadedBox], a
xor a
ldh [hBGMapMode], a
call ClearSprites
call CopyBoxmonSpecies
call BillsPC_BoxName
ld de, PCString_ChooseaPKMN
call BillsPC_PlaceString
ld a, $5
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call PCMonInfo
ld a, $ff
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
call WaitBGMap
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
ret
.Joypad:
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b_button
ld a, [hl]
and A_BUTTON
jr nz, .a_button
call Withdraw_UpDown
and a
ret z
call BillsPC_UpdateSelectionCursor
xor a
ldh [hBGMapMode], a
call BillsPC_RefreshTextboxes
call PCMonInfo
ld a, $1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
.a_button
call BillsPC_GetSelectedPokemonSpecies
and a
ret z
cp -1
jr z, .b_button
ld a, $2
ld [wJumptableIndex], a
ret
.unused
ld hl, wJumptableIndex
dec [hl]
ret
.b_button
ld a, $4
ld [wJumptableIndex], a
ret
.PrepSubmenu:
xor a
ldh [hBGMapMode], a
call ClearSprites
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ld de, PCString_WhatsUp
call BillsPC_PlaceString
ld a, $1
ld [wMenuCursorY], a
call BillsPC_IncrementJumptableIndex
ret
BillsPC_Withdraw:
ld hl, .MenuHeader
call CopyMenuHeader
ld a, [wMenuCursorY]
call StoreTo_wMenuCursorBuffer
call VerticalMenu
jp c, .cancel
ld a, [wMenuCursorY]
dec a
and %11
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
.dw
dw .withdraw ; Withdraw
dw .stats ; Stats
dw .release ; Release
dw .cancel ; Cancel
.withdraw
call BillsPC_CheckMail_PreventBlackout
jp c, .cancel
call TryWithdrawPokemon
jr c, .FailedWithdraw
ld a, $0
ld [wJumptableIndex], a
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ret
.FailedWithdraw:
ld de, PCString_WhatsUp
call BillsPC_PlaceString
ret
.stats
call LoadStandardMenuHeader
call BillsPC_StatsScreen
call ExitMenu
call PCMonInfo
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ret
.release
ld a, [wMenuCursorY]
push af
call BillsPC_IsMonAnEgg
jr c, .FailedRelease
ld de, PCString_ReleasePKMN
call BillsPC_PlaceString
call LoadStandardMenuHeader
lb bc, 14, 11
call PlaceYesNoBox
ld a, [wMenuCursorY]
dec a
call ExitMenu
and a
jr nz, .FailedRelease
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
ld a, REMOVE_BOX
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
call ReleasePKMN_ByePKMN
ld a, $0
ld [wJumptableIndex], a
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
pop af
ret
.FailedRelease:
ld de, PCString_WhatsUp
call BillsPC_PlaceString
pop af
ld [wMenuCursorY], a
ret
.cancel
ld a, $0
ld [wJumptableIndex], a
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 4 ; items
db "WITHDRAW@"
db "STATS@"
db "RELEASE@"
db "CANCEL@"
_MovePKMNWithoutMail:
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
ld [wVramState], a
ldh a, [hInMenu]
push af
ld a, $1
ldh [hInMenu], a
xor a
ldh [hMapAnims], a
call BillsPC_InitRAM
ld a, [wCurBox]
and $f
inc a
ld [wBillsPC_LoadedBox], a
call DelayFrame
.asm_e2781
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .asm_e2793
call .RunJumptable
call DelayFrame
jr .asm_e2781
.asm_e2793
call ClearSprites
pop af
ldh [hInMenu], a
pop af
ld [wVramState], a
pop af
ld [wOptions], a
ret
.RunJumptable:
ld a, [wJumptableIndex]
ld hl, .Jumptable
call BillsPC_Jumptable
jp hl
.Jumptable:
dw .Init
dw .Joypad
dw .PrepSubmenu
dw .MoveMonWOMailSubmenu
dw .PrepInsertCursor
dw .Joypad2
dw BillsPC_EndJumptableLoop
.Init:
xor a
ldh [hBGMapMode], a
call ClearSprites
call CopyBoxmonSpecies
ld de, PCString_ChooseaPKMN
call BillsPC_PlaceString
ld a, 5
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call BillsPC_MoveMonWOMail_BoxNameAndArrows
call PCMonInfo
ld a, $ff
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
call WaitBGMap
call BillsPC_UpdateSelectionCursor
call BillsPC_IncrementJumptableIndex
ret
.Joypad:
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b_button
ld a, [hl]
and A_BUTTON
jr nz, .a_button
call MoveMonWithoutMail_DPad
jr c, .d_pad
and a
ret z
call BillsPC_UpdateSelectionCursor
xor a
ldh [hBGMapMode], a
call BillsPC_RefreshTextboxes
call PCMonInfo
ld a, $1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
.d_pad
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ld a, $0
ld [wJumptableIndex], a
ret
.a_button
call BillsPC_GetSelectedPokemonSpecies
and a
ret z
cp -1
jr z, .b_button
ld a, $2
ld [wJumptableIndex], a
ret
.unused
ld hl, wJumptableIndex
dec [hl]
ret
.b_button
ld a, $6
ld [wJumptableIndex], a
ret
.PrepSubmenu:
xor a
ldh [hBGMapMode], a
call ClearSprites
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ld de, PCString_WhatsUp
call BillsPC_PlaceString
ld a, $1
ld [wMenuCursorY], a
call BillsPC_IncrementJumptableIndex
ret
.MoveMonWOMailSubmenu:
ld hl, .MenuHeader
call CopyMenuHeader
ld a, [wMenuCursorY]
call StoreTo_wMenuCursorBuffer
call VerticalMenu
jp c, .Cancel
ld a, [wMenuCursorY]
dec a
and %11
ld e, a
ld d, 0
ld hl, .Jumptable2
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
.Jumptable2:
dw .Move
dw .Stats
dw .Cancel
.Move:
call BillsPC_CheckMail_PreventBlackout
jp c, .Cancel
ld a, [wBillsPC_ScrollPosition]
ld [wBillsPC_BackupScrollPosition], a
ld a, [wBillsPC_CursorPosition]
ld [wBillsPC_BackupCursorPosition], a
ld a, [wBillsPC_LoadedBox]
ld [wBillsPC_BackupLoadedBox], a
ld a, $4
ld [wJumptableIndex], a
ret
.Stats:
call LoadStandardMenuHeader
call BillsPC_StatsScreen
call ExitMenu
call PCMonInfo
call BillsPC_GetSelectedPokemonSpecies
ld [wCurPartySpecies], a
ld a, SCGB_BILLS_PC
call BillsPC_ApplyPalettes
ret
.Cancel:
ld a, $0
ld [wJumptableIndex], a
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 9, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 3 ; items
db "MOVE@"
db "STATS@"
db "CANCEL@"
.PrepInsertCursor:
xor a
ldh [hBGMapMode], a
call CopyBoxmonSpecies
ld de, PCString_MoveToWhere
call BillsPC_PlaceString
ld a, $5
ld [wBillsPC_NumMonsOnScreen], a
call BillsPC_RefreshTextboxes
call BillsPC_MoveMonWOMail_BoxNameAndArrows
call ClearSprites
call BillsPC_UpdateInsertCursor
call WaitBGMap
call BillsPC_IncrementJumptableIndex
ret
.Joypad2:
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
jr nz, .b_button_2
ld a, [hl]
and A_BUTTON
jr nz, .a_button_2
call MoveMonWithoutMail_DPad_2
jr c, .dpad_2
and a
ret z
call BillsPC_UpdateInsertCursor
xor a
ldh [hBGMapMode], a
call BillsPC_RefreshTextboxes
ld a, $1
ldh [hBGMapMode], a
call DelayFrame
call DelayFrame
ret
.dpad_2
xor a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ld a, $4
ld [wJumptableIndex], a
ret
.a_button_2
call BillsPC_CheckSpaceInDestination
jr c, .no_space
call MovePKMNWitoutMail_InsertMon
ld a, $0
ld [wJumptableIndex], a
ret
.no_space
ld hl, wJumptableIndex
dec [hl]
ret
.b_button_2
ld a, [wBillsPC_BackupScrollPosition]
ld [wBillsPC_ScrollPosition], a
ld a, [wBillsPC_BackupCursorPosition]
ld [wBillsPC_CursorPosition], a
ld a, [wBillsPC_BackupLoadedBox]
ld [wBillsPC_LoadedBox], a
ld a, $0
ld [wJumptableIndex], a
ret
BillsPC_InitRAM:
call ClearBGPalettes
call ClearSprites
call ClearTileMap
call BillsPC_InitGFX
ld hl, wBillsPCData
ld bc, wBillsPCDataEnd - wBillsPCData
xor a
call ByteFill
xor a
ld [wJumptableIndex], a
ld [wcf64], a
ld [wcf65], a
ld [wcf66], a
ld [wBillsPC_CursorPosition], a
ld [wBillsPC_ScrollPosition], a
ret
BillsPC_IncrementJumptableIndex:
ld hl, wJumptableIndex
inc [hl]
ret
BillsPC_EndJumptableLoop:
ld hl, wJumptableIndex
set 7, [hl]
ret
_StatsScreenDPad:
ld a, [wBillsPC_NumMonsOnScreen]
ld d, a
ld a, [wBillsPC_NumMonsInBox]
and a
jr z, .empty
dec a
cp $1
jr z, .empty
ld e, a
ld a, [hl]
and D_UP
jr nz, BillsPC_PressUp
ld a, [hl]
and D_DOWN
jr nz, BillsPC_PressDown
.empty
jp BillsPC_JoypadDidNothing
Withdraw_UpDown:
ld hl, hJoyLast
ld a, [wBillsPC_NumMonsOnScreen]
ld d, a
ld a, [wBillsPC_NumMonsInBox]
ld e, a
and a
jr z, .empty
ld a, [hl]
and D_UP
jr nz, BillsPC_PressUp
ld a, [hl]
and D_DOWN
jr nz, BillsPC_PressDown
.empty
jp BillsPC_JoypadDidNothing
MoveMonWithoutMail_DPad:
ld hl, hJoyLast
ld a, [wBillsPC_NumMonsOnScreen]
ld d, a
ld a, [wBillsPC_NumMonsInBox]
ld e, a
and a
jr z, .check_left_right
ld a, [hl]
and D_UP
jr nz, BillsPC_PressUp
ld a, [hl]
and D_DOWN
jr nz, BillsPC_PressDown
.check_left_right
ld a, [hl]
and D_LEFT
jr nz, BillsPC_PressLeft
ld a, [hl]
and D_RIGHT
jr nz, BillsPC_PressRight
jr BillsPC_JoypadDidNothing
MoveMonWithoutMail_DPad_2:
ld hl, hJoyLast
ld a, [wBillsPC_NumMonsOnScreen]
ld d, a
ld a, [wBillsPC_NumMonsInBox]
ld e, a
and a
jr z, .check_left_right
ld a, [hl]
and D_UP
jr nz, BillsPC_PressUp
ld a, [hl]
and D_DOWN
jr nz, BillsPC_PressDown
.check_left_right
ld a, [hl]
and D_LEFT
jr nz, BillsPC_PressLeft
ld a, [hl]
and D_RIGHT
jr nz, BillsPC_PressRight
jr BillsPC_JoypadDidNothing
BillsPC_PressUp:
ld hl, wBillsPC_CursorPosition
ld a, [hl]
and a
jr z, .top
dec [hl]
jr BillsPC_UpDownDidSomething
.top
ld hl, wBillsPC_ScrollPosition
ld a, [hl]
and a
jr z, BillsPC_JoypadDidNothing
dec [hl]
jr BillsPC_UpDownDidSomething
BillsPC_PressDown:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
inc a
cp e
jr nc, BillsPC_JoypadDidNothing
ld hl, wBillsPC_CursorPosition
ld a, [hl]
inc a
cp d
jr nc, .not_bottom
inc [hl]
jr BillsPC_UpDownDidSomething
.not_bottom
ld hl, wBillsPC_ScrollPosition
inc [hl]
jr BillsPC_UpDownDidSomething
BillsPC_PressLeft:
ld hl, wBillsPC_LoadedBox
ld a, [hl]
and a
jr z, .wrap_around
dec [hl]
jr BillsPC_LeftRightDidSomething
.wrap_around
ld [hl], NUM_BOXES
jr BillsPC_LeftRightDidSomething
BillsPC_PressRight:
ld hl, wBillsPC_LoadedBox
ld a, [hl]
cp NUM_BOXES
jr z, .wrap_around
inc [hl]
jr BillsPC_LeftRightDidSomething
.wrap_around
ld [hl], 0
jr BillsPC_LeftRightDidSomething
BillsPC_JoypadDidNothing:
xor a
and a
ret
BillsPC_UpDownDidSomething:
ld a, TRUE
and a
ret
BillsPC_LeftRightDidSomething:
scf
ret
BillsPC_PlaceString:
push de
hlcoord 0, 15
lb bc, 1, 18
call Textbox
pop de
hlcoord 1, 16
call PlaceString
ret
BillsPC_MoveMonWOMail_BoxNameAndArrows:
call BillsPC_BoxName
hlcoord 8, 1
ld [hl], $5f
hlcoord 19, 1
ld [hl], $5e
ret
BillsPC_BoxName:
hlcoord 8, 0
lb bc, 1, 10
call Textbox
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
cp NUM_BOXES + 1
jr nz, .gotbox
ld a, [wCurBox]
inc a
.gotbox
dec a
ld hl, wBoxNames
ld bc, BOX_NAME_LENGTH
call AddNTimes
ld e, l
ld d, h
jr .print
.party
ld de, .PartyPKMN
.print
hlcoord 10, 1
call PlaceString
ret
.PartyPKMN:
db "PARTY <PK><MN>@"
PCMonInfo:
; Display a monster's pic and
; attributes when highlighting
; it in a PC menu.
; Includes the neat cascading
; effect when showing the pic.
; Example: Species, level, gender,
; whether it's holding an item.
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
call BillsPC_GetSelectedPokemonSpecies
and a
ret z
cp -1
ret z
ld [wTempSpecies], a
hlcoord 1, 4
xor a
ld b, 7
.row
ld c, 7
push af
push hl
.col
ld [hli], a
add 7
dec c
jr nz, .col
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop af
inc a
dec b
jr nz, .row
call BillsPC_LoadMonStats
ld a, [wTempSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld hl, wTempMonDVs
predef GetUnownLetter
call GetBaseData
ld de, vTiles2 tile $00
predef GetMonFrontpic
xor a
ld [wBillsPC_MonHasMail], a
ld a, [wCurPartySpecies]
ld [wTempSpecies], a
cp EGG
ret z
call GetBasePokemonName
hlcoord 1, 14
call PlaceString
hlcoord 1, 12
call PrintLevel
ld a, $3
ld [wMonType], a
farcall GetGender
jr c, .skip_gender
ld a, "♂"
jr nz, .printgender
ld a, "♀"
.printgender
hlcoord 5, 12
ld [hl], a
.skip_gender
ld a, [wTempMonItem]
and a
ret z
ld d, a
callfar ItemIsMail
jr c, .mail
ld a, $5d ; item icon
jr .printitem
.mail
ld a, $1
ld [wBillsPC_MonHasMail], a
ld a, $5c ; mail icon
.printitem
hlcoord 7, 12
ld [hl], a
ret
BillsPC_LoadMonStats:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld e, a
ld d, $0
ld hl, wBillsPCPokemonList + 1 ; box number
add hl, de
add hl, de
add hl, de
ld a, [hl]
and a
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
ld b, a
call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
ld bc, sBoxMon1Level - sBox
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonLevel], a
pop hl
push hl
ld bc, sBoxMon1Item - sBox
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonItem], a
pop hl
ld bc, sBoxMon1DVs - sBox
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, wTempMonDVs
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
call CloseSRAM
ret
.party
ld hl, wPartyMon1Level
ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonLevel], a
ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonItem], a
ld hl, wPartyMon1DVs
ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, wTempMonDVs
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ret
.sBox
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxMon1Level
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonLevel], a
ld hl, sBoxMon1Item
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [wTempMonItem], a
ld hl, sBoxMon1DVs
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, wTempMonDVs
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
call CloseSRAM
ret
BillsPC_RefreshTextboxes:
hlcoord 8, 2
lb bc, 10, 10
call Textbox
hlcoord 8, 2
ld [hl], "└"
hlcoord 19, 2
ld [hl], "┘"
ld a, [wBillsPC_ScrollPosition]
ld e, a
ld d, 0
ld hl, wBillsPCPokemonList
add hl, de
add hl, de
add hl, de
ld e, l
ld d, h
hlcoord 9, 4
ld a, [wBillsPC_NumMonsOnScreen]
.loop
push af
push de
push hl
call .PlaceNickname
pop hl
ld de, 2 * SCREEN_WIDTH
add hl, de
pop de
inc de
inc de
inc de
pop af
dec a
jr nz, .loop
ret
.CancelString:
db "CANCEL@"
.PlaceNickname:
ld a, [de]
and a
ret z
cp -1
jr nz, .get_nickname
ld de, .CancelString
call PlaceString
ret
.get_nickname
inc de
ld a, [de]
ld b, a
inc de
ld a, [de]
ld e, a
ld a, b
and a
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
push hl
call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
ld bc, sBoxMons - sBox
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
pop hl
and a
jr z, .boxfail
ld bc, sBoxMonNicknames - sBox
add hl, bc
ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, wStringBuffer1
ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
pop hl
ld de, wStringBuffer1
call PlaceString
ret
.boxfail
call CloseSRAM
pop hl
jr .placeholder_string
.party
push hl
ld hl, wPartySpecies
ld d, $0
add hl, de
ld a, [hl]
and a
jr z, .partyfail
ld hl, wPartyMonNicknames
ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, wStringBuffer1
ld bc, MON_NAME_LENGTH
call CopyBytes
pop hl
ld de, wStringBuffer1
call PlaceString
ret
.partyfail
pop hl
jr .placeholder_string
.sBox
push hl
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
ld d, $0
add hl, de
ld a, [hl]
and a
jr z, .sBoxFail
ld hl, sBoxMonNicknames
ld bc, MON_NAME_LENGTH
ld a, e
call AddNTimes
ld de, wStringBuffer1
ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
pop hl
ld de, wStringBuffer1
call PlaceString
ret
.sBoxFail
call CloseSRAM
pop hl
.placeholder_string
ld de, .Placeholder
call PlaceString
ret
.Placeholder:
db "-----@"
copy_box_data: MACRO
.loop\@
ld a, [hl]
cp -1
jr z, .done\@
and a
jr z, .done\@
ld [de], a
inc de
ld a, [wBillsPC_LoadedBox]
ld [de], a
inc de
ld a, [wd003]
ld [de], a
inc a
ld [wd003], a
inc de
inc hl
ld a, [wd004]
inc a
ld [wd004], a
jr .loop\@
.done\@
if \1
call CloseSRAM
endc
ld a, -1
ld [de], a
ld a, [wd004]
inc a
ld [wBillsPC_NumMonsInBox], a
ENDM
CopyBoxmonSpecies:
xor a
ld hl, wBillsPCPokemonList
ld bc, 3 * 30
call ByteFill
ld de, wBillsPCPokemonList
xor a
ld [wd003], a
ld [wd004], a
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
cp NUM_BOXES + 1
jr z, .sBox
ld b, a
call GetBoxPointer
ld a, b
call GetSRAMBank
inc hl
copy_box_data 1
ret
.party
ld hl, wPartySpecies
copy_box_data 0
ret
.sBox
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
copy_box_data 1
ret
BillsPC_GetSelectedPokemonSpecies:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld e, a
ld d, $0
ld hl, wBillsPCPokemonList
add hl, de
add hl, de
add hl, de
ld a, [hl]
ret
BillsPC_UpdateSelectionCursor:
ld a, [wBillsPC_NumMonsInBox]
and a
jr nz, .place_cursor
call ClearSprites
ret
.place_cursor
ld hl, .OAM
ld de, wVirtualOAMSprite00
.loop
ld a, [hl]
cp -1
ret z
ld a, [wBillsPC_CursorPosition]
and $7
swap a
add [hl]
inc hl
ld [de], a ; y
inc de
rept SPRITEOAMSTRUCT_LENGTH + -1
ld a, [hli]
ld [de], a
inc de
endr
jr .loop
.OAM:
dsprite 4, 6, 10, 0, $00, 0
dsprite 4, 6, 11, 0, $00, 0
dsprite 4, 6, 12, 0, $00, 0
dsprite 4, 6, 13, 0, $00, 0
dsprite 4, 6, 14, 0, $00, 0
dsprite 4, 6, 15, 0, $00, 0
dsprite 4, 6, 16, 0, $00, 0
dsprite 4, 6, 17, 0, $00, 0
dsprite 4, 6, 18, 0, $00, 0
dsprite 4, 6, 18, 7, $00, 0
dsprite 7, 1, 10, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 11, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 12, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 13, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 14, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 15, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 16, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 17, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 18, 0, $00, 0 | Y_FLIP
dsprite 7, 1, 18, 7, $00, 0 | Y_FLIP
dsprite 5, 6, 9, 6, $01, 0
dsprite 6, 1, 9, 6, $01, 0 | Y_FLIP
dsprite 5, 6, 19, 1, $01, 0 | X_FLIP
dsprite 6, 1, 19, 1, $01, 0 | X_FLIP | Y_FLIP
db -1
BillsPC_UpdateInsertCursor:
ld hl, .OAM
ld de, wVirtualOAMSprite00
.loop
ld a, [hl]
cp -1
ret z
ld a, [wBillsPC_CursorPosition]
and $7
swap a
add [hl]
inc hl
ld [de], a ; y
inc de
rept SPRITEOAMSTRUCT_LENGTH + -1
ld a, [hli]
ld [de], a
inc de
endr
jr .loop
.OAM:
dsprite 4, 7, 10, 0, $06, 0
dsprite 5, 3, 11, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 12, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 13, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 14, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 15, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 16, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 17, 0, $00, 0 | Y_FLIP
dsprite 5, 3, 18, 0, $00, 0 | Y_FLIP
dsprite 4, 7, 19, 0, $07, 0
db -1
Unreferenced_BillsPC_FillBox:
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .row
ret
BillsPC_CheckSpaceInDestination:
; If moving within a box, no need to be here.
ld hl, wBillsPC_LoadedBox
ld a, [wBillsPC_BackupLoadedBox]
cp [hl]
jr z, .same_box
; Exceeding box or party capacity is a big no-no.
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
ld e, MONS_PER_BOX + 1
jr .compare
.party
ld e, PARTY_LENGTH + 1
.compare
ld a, [wBillsPC_NumMonsInBox]
cp e
jr nc, .no_room
.same_box
and a
ret
.no_room
ld de, PCString_TheresNoRoom
call BillsPC_PlaceString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
BillsPC_CheckMail_PreventBlackout:
ld a, [wBillsPC_LoadedBox]
and a
jr nz, .Okay
ld a, [wBillsPC_NumMonsInBox]
cp $3
jr c, .ItsYourLastPokemon
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
farcall CheckCurPartyMonFainted
jr c, .AllOthersFainted
ld a, [wBillsPC_MonHasMail]
and a
jr nz, .HasMail
.Okay:
and a
ret
.HasMail:
ld de, PCString_RemoveMail
jr .NotOkay
.AllOthersFainted:
ld de, PCString_NoMoreUsablePKMN
jr .NotOkay
.ItsYourLastPokemon:
ld de, PCString_ItsYourLastPKMN
.NotOkay:
call BillsPC_PlaceString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
BillsPC_IsMonAnEgg:
ld a, [wCurPartySpecies]
cp EGG
jr z, .egg
and a
ret
.egg
ld de, PCString_NoReleasingEGGS
call BillsPC_PlaceString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
BillsPC_StatsScreen:
call LowVolume
call BillsPC_CopyMon
ld a, $3
ld [wMonType], a
predef StatsScreenInit
call BillsPC_InitGFX
call MaxVolume
ret
StatsScreenDPad:
ld hl, hJoyPressed
ld a, [hl]
and A_BUTTON | B_BUTTON | D_RIGHT | D_LEFT
ld [wMenuJoypad], a
jr nz, .pressed_a_b_right_left
ld a, [hl]
and D_DOWN | D_UP
ld [wMenuJoypad], a
jr nz, .pressed_down_up
jr .pressed_a_b_right_left
.pressed_down_up
call _StatsScreenDPad
and a
jr z, .did_nothing
call BillsPC_GetSelectedPokemonSpecies
ld [wTempSpecies], a
call BillsPC_LoadMonStats
ld a, [wTempSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld hl, wTempMonDVs
predef GetUnownLetter
call GetBaseData
call BillsPC_CopyMon
.pressed_a_b_right_left
ret
.did_nothing
xor a
ld [wMenuJoypad], a
ret
BillsPC_CopyMon:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
ld a, [wBillsPC_LoadedBox]
and a
jr z, .party
cp NUM_BOXES + 1
jr nz, .box
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
call CopySpeciesToTemp
ld hl, sBoxMonNicknames
call CopyNicknameToTemp
ld hl, sBoxMonOT
call CopyOTNameToTemp
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld de, wBufferMon
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
call CloseSRAM
farcall CalcBufferMonStats
ret
.party
ld hl, wPartySpecies
call CopySpeciesToTemp
ld hl, wPartyMonNicknames
call CopyNicknameToTemp
ld hl, wPartyMonOT
call CopyOTNameToTemp
ld hl, wPartyMon1
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld de, wBufferMon
ld bc, PARTYMON_STRUCT_LENGTH
call CopyBytes
ret
.box
ld b, a
call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
inc hl
call CopySpeciesToTemp
pop hl
push hl
ld bc, sBoxMonNicknames - sBox
add hl, bc
call CopyNicknameToTemp
pop hl
push hl
ld bc, sBoxMonOT - sBox
add hl, bc
call CopyOTNameToTemp
pop hl
ld bc, sBoxMons - sBox
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
call CopyMonToTemp
call CloseSRAM
farcall CalcBufferMonStats
ret
DepositPokemon:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
ld hl, wPartyMonNicknames
ld a, [wCurPartyMon]
call GetNick
ld a, PC_DEPOSIT
ld [wPokemonWithdrawDepositParameter], a
predef SendGetMonIntoFromBox
jr c, .asm_boxisfull
xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ld a, [wCurPartySpecies]
call PlayMonCry
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call Textbox
call WaitBGMap
hlcoord 1, 16
ld de, PCString_Stored
call PlaceString
ld l, c
ld h, b
ld de, wStringBuffer1
call PlaceString
ld a, "!"
ld [bc], a
ld c, 50
call DelayFrames
and a
ret
.asm_boxisfull
ld de, PCString_BoxFull
call BillsPC_PlaceString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
TryWithdrawPokemon:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
ld a, BANK(sBoxMonNicknames)
call GetSRAMBank
ld a, [wCurPartyMon]
ld hl, sBoxMonNicknames
call GetNick
call CloseSRAM
xor a
ld [wPokemonWithdrawDepositParameter], a
predef SendGetMonIntoFromBox
jr c, .PartyFull
ld a, REMOVE_BOX
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ld a, [wCurPartySpecies]
call PlayMonCry
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call Textbox
call WaitBGMap
hlcoord 1, 16
ld de, PCString_Got
call PlaceString
ld l, c
ld h, b
ld de, wStringBuffer1
call PlaceString
ld a, "!"
ld [bc], a
ld c, 50
call DelayFrames
and a
ret
.PartyFull:
ld de, PCString_PartyFull
call BillsPC_PlaceString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
scf
ret
ReleasePKMN_ByePKMN:
hlcoord 0, 0
lb bc, 15, 8
call ClearBox
hlcoord 8, 14
lb bc, 1, 3
call ClearBox
hlcoord 0, 15
lb bc, 1, 18
call Textbox
call WaitBGMap
ld a, [wCurPartySpecies]
call GetCryIndex
jr c, .skip_cry
ld e, c
ld d, b
call PlayCry
.skip_cry
ld a, [wCurPartySpecies]
ld [wTempSpecies], a
call GetPokemonName
hlcoord 1, 16
ld de, PCString_ReleasedPKMN
call PlaceString
ld c, 80
call DelayFrames
hlcoord 0, 15
lb bc, 1, 18
call Textbox
hlcoord 1, 16
ld de, PCString_Bye
call PlaceString
ld l, c
ld h, b
inc hl
ld de, wStringBuffer1
call PlaceString
ld l, c
ld h, b
ld [hl], "!"
ld c, 50
call DelayFrames
ret
MovePKMNWitoutMail_InsertMon:
push hl
push de
push bc
push af
hlcoord 0, 15
lb bc, 1, 18
call Textbox
hlcoord 1, 16
ld de, .Saving_LeaveOn
call PlaceString
pop af
pop bc
pop de
pop hl
ld a, [wCurBox]
push af
ld bc, 0
ld a, [wBillsPC_BackupLoadedBox]
and a
jr nz, .moving_from_box
set 0, c
.moving_from_box
ld a, [wBillsPC_LoadedBox]
and a
jr nz, .moving_to_box
set 1, c
.moving_to_box
ld hl, .Jumptable
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .dw_return
push de
jp hl
.dw_return
pop af
ld e, a
farcall MoveMonWOMail_InsertMon_SaveGame
ret
.Saving_LeaveOn:
db "Saving… Leave ON!@"
.Jumptable:
dw .BoxToBox
dw .PartyToBox
dw .BoxToParty
dw .PartyToParty
.BoxToBox:
ld hl, wBillsPC_BackupLoadedBox
ld a, [wBillsPC_LoadedBox]
cp [hl]
jr z, .same_box
call .CopyFromBox
call .CopyToBox
ret
.same_box
call .CopyFromBox
call .CheckTrivialMove
call .CopyToBox
ret
.PartyToBox:
call .CopyFromParty
ld a, $1
ld [wGameLogicPaused], a
farcall SaveGameData
xor a
ld [wGameLogicPaused], a
call .CopyToBox
ret
.BoxToParty:
call .CopyFromBox
call .CopyToParty
ret
.PartyToParty:
call .CopyFromParty
call .CheckTrivialMove
call .CopyToParty
ret
.CheckTrivialMove:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld e, a
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
add [hl]
cp e
ret nc
ld hl, wBillsPC_CursorPosition
ld a, [hl]
and a
jr z, .top_of_screen
dec [hl]
ret
.top_of_screen
ld hl, wBillsPC_ScrollPosition
ld a, [hl]
and a
ret z
dec [hl]
ret
.CopyFromBox:
ld a, [wBillsPC_BackupLoadedBox]
dec a
ld e, a
farcall MoveMonWOMail_SaveGame
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
add [hl]
ld [wCurPartyMon], a
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
call CopySpeciesToTemp
ld hl, sBoxMonNicknames
call CopyNicknameToTemp
ld hl, sBoxMonOT
call CopyOTNameToTemp
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
call CopyMonToTemp
call CloseSRAM
farcall CalcBufferMonStats
ld a, REMOVE_BOX
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ret
.CopyToBox:
ld a, [wBillsPC_LoadedBox]
dec a
ld e, a
farcall MoveMonWOMail_SaveGame
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
farcall InsertPokemonIntoBox
ret
.CopyFromParty:
ld a, [wBillsPC_BackupCursorPosition]
ld hl, wBillsPC_BackupScrollPosition
add [hl]
ld [wCurPartyMon], a
ld hl, wPartySpecies
call CopySpeciesToTemp
ld hl, wPartyMonNicknames
call CopyNicknameToTemp
ld hl, wPartyMonOT
call CopyOTNameToTemp
ld hl, wPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
call CopyMonToTemp
xor a ; REMOVE_PARTY
ld [wPokemonWithdrawDepositParameter], a
farcall RemoveMonFromPartyOrBox
ret
.CopyToParty:
ld a, [wBillsPC_CursorPosition]
ld hl, wBillsPC_ScrollPosition
add [hl]
ld [wCurPartyMon], a
farcall InsertPokemonIntoParty
ret
CopySpeciesToTemp:
ld a, [wCurPartyMon]
ld c, a
ld b, $0
add hl, bc
ld a, [hl]
ld [wCurPartySpecies], a
ret
CopyNicknameToTemp:
ld bc, MON_NAME_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld de, wBufferMonNick
ld bc, MON_NAME_LENGTH
call CopyBytes
ret
CopyOTNameToTemp:
ld bc, NAME_LENGTH
ld a, [wCurPartyMon]
call AddNTimes
ld de, wBufferMonOT
ld bc, NAME_LENGTH
call CopyBytes
ret
CopyMonToTemp:
ld a, [wCurPartyMon]
call AddNTimes
ld de, wBufferMon
call CopyBytes
ret
GetBoxPointer:
dec b
ld c, b
ld b, 0
ld hl, .boxes
add hl, bc
add hl, bc
add hl, bc
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
ret
.boxes
; bank, address
dba sBox1
dba sBox2
dba sBox3
dba sBox4
dba sBox5
dba sBox6
dba sBox7
dba sBox8
dba sBox9
dba sBox10
dba sBox11
dba sBox12
dba sBox13
dba sBox14
BillsPC_ApplyPalettes:
ld b, a
call GetSGBLayout
ld a, %11100100
call DmgToCgbBGPals
ld a, %11111100
call DmgToCgbObjPal0
ret
BillsPC_Jumptable:
ld e, a
ld d, $0
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ret
BillsPC_InitGFX:
call DisableLCD
ld hl, vTiles2 tile $00
ld bc, $31 tiles
xor a
call ByteFill
call LoadStandardFont
call LoadFontsBattleExtra
ld hl, PCMailGFX
ld de, vTiles2 tile $5c
ld bc, 4 tiles
call CopyBytes
ld hl, PCSelectLZ
ld de, vTiles0 tile $00
call Decompress
ld a, 6
call SkipMusic
call EnableLCD
ret
PCSelectLZ: INCBIN "gfx/pc/pc.2bpp.lz"
PCMailGFX: INCBIN "gfx/pc/pc_mail.2bpp"
PCString_ChooseaPKMN: db "Choose a <PK><MN>.@"
PCString_WhatsUp: db "What's up?@"
PCString_ReleasePKMN: db "Release <PK><MN>?@"
PCString_MoveToWhere: db "Move to where?@"
PCString_ItsYourLastPKMN: db "It's your last <PK><MN>!@"
PCString_TheresNoRoom: db "There's no room!@"
PCString_NoMoreUsablePKMN: db "No more usable <PK><MN>!@"
PCString_RemoveMail: db "Remove MAIL.@"
PCString_ReleasedPKMN: db "Released <PK><MN>.@"
PCString_Bye: db "Bye,@"
PCString_Stored: db "Stored @"
PCString_Got: db "Got @"
PCString_Non: db "Non.@"
PCString_BoxFull: db "The BOX is full.@"
PCString_PartyFull: db "The party's full!@"
PCString_NoReleasingEGGS: db "No releasing EGGS!@"
_ChangeBox:
call LoadStandardMenuHeader
call BillsPC_ClearTilemap
.loop
xor a
ldh [hBGMapMode], a
call BillsPC_PrintBoxName
call BillsPC_PlaceChooseABoxString
ld hl, _ChangeBox_MenuHeader
call CopyMenuHeader
xor a
ld [wMenuScrollPosition], a
hlcoord 0, 4
lb bc, 8, 9
call Textbox
call ScrollingMenu
ld a, [wMenuJoypad]
cp B_BUTTON
jr z, .done
call BillsPC_PlaceWhatsUpString
call BillsPC_ChangeBoxSubmenu
jr .loop
.done
call CloseWindow
ret
BillsPC_ClearTilemap:
xor a
ldh [hBGMapMode], a
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
call ByteFill
ret
_ChangeBox_MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 1, 5, 9, 12
dw .MenuData
db 1 ; default option
.MenuData
db SCROLLINGMENU_CALL_FUNCTION3_NO_SWITCH | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
db 4, 0 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
dba .boxes
dba .boxnames
dba NULL
dba BillsPC_PrintBoxCountAndCapacity
.boxes
db NUM_BOXES
x = 1
rept NUM_BOXES
db x
x = x + 1
endr
db -1
.boxnames
push de
ld a, [wMenuSelection]
dec a
call GetBoxName
pop hl
call PlaceString
ret
GetBoxName:
ld bc, BOX_NAME_LENGTH
ld hl, wBoxNames
call AddNTimes
ld d, h
ld e, l
ret
BillsPC_PrintBoxCountAndCapacity:
hlcoord 11, 7
lb bc, 5, 7
call Textbox
ld a, [wMenuSelection]
cp -1
ret z
hlcoord 12, 9
ld de, .Pokemon
call PlaceString
call GetBoxCount
ld [wDeciramBuffer], a
hlcoord 13, 11
ld de, wDeciramBuffer
lb bc, 1, 2
call PrintNum
ld de, .out_of_20
call PlaceString
ret
.Pokemon:
db "#MON@"
.out_of_20
; db "/20@"
db "/"
db "0" + MONS_PER_BOX / 10 ; "2"
db "0" + MONS_PER_BOX % 10 ; "0"
db "@"
GetBoxCount:
ld a, [wCurBox]
ld c, a
ld a, [wMenuSelection]
dec a
cp c
jr z, .activebox
ld c, a
ld b, 0
ld hl, .boxbanks
add hl, bc
add hl, bc
add hl, bc
ld a, [hli]
ld b, a
call GetSRAMBank
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hl]
call CloseSRAM
ld c, a
ld a, [wSavedAtLeastOnce]
and a
jr z, .newfile
ld a, c
ret
.newfile
xor a
ret
.activebox
ld a, BANK(sBoxCount)
ld b, a
call GetSRAMBank
ld hl, sBoxCount
ld a, [hl]
call CloseSRAM
ret
.boxbanks
dba sBox1
dba sBox2
dba sBox3
dba sBox4
dba sBox5
dba sBox6
dba sBox7
dba sBox8
dba sBox9
dba sBox10
dba sBox11
dba sBox12
dba sBox13
dba sBox14
BillsPC_PrintBoxName:
hlcoord 0, 0
ld b, 2
ld c, 18
call Textbox
hlcoord 1, 2
ld de, .Current
call PlaceString
ld a, [wCurBox]
and $f
call GetBoxName
hlcoord 11, 2
call PlaceString
ret
.Current:
db "CURRENT@"
BillsPC_ChangeBoxSubmenu:
ld hl, .MenuHeader
call LoadMenuHeader
call VerticalMenu
call ExitMenu
ret c
ld a, [wMenuCursorY]
cp $1
jr z, .Switch
cp $2
jr z, .Name
cp $3
jr z, .Print
and a
ret
.Print:
call GetBoxCount
and a
jr z, .EmptyBox
ld e, l
ld d, h
ld a, [wMenuSelection]
dec a
ld c, a
farcall PrintPCBox
call BillsPC_ClearTilemap
and a
ret
.EmptyBox:
call BillsPC_PlaceEmptyBoxString_SFX
and a
ret
.Switch:
ld a, [wMenuSelection]
dec a
ld e, a
ld a, [wCurBox]
cp e
ret z
farcall ChangeBoxSaveGame
ret
.Name:
ld b, NAME_BOX
ld de, wd002
farcall NamingScreen
call ClearTileMap
call LoadStandardFont
call LoadFontsBattleExtra
ld a, [wMenuSelection]
dec a
call GetBoxName
ld e, l
ld d, h
ld hl, wd002
ld c, BOX_NAME_LENGTH - 1
call InitString
ld a, [wMenuSelection]
dec a
call GetBoxName
ld de, wd002
call CopyName2
ret
hlcoord 11, 7 ; unused
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 11, 4, SCREEN_WIDTH - 1, 13
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 4 ; items
db "SWITCH@"
db "NAME@"
db "PRINT@"
db "QUIT@"
BillsPC_PlaceChooseABoxString:
ld de, .ChooseABox
jr BillsPC_PlaceChangeBoxString
.ChooseABox:
db "Choose a BOX.@"
BillsPC_PlaceWhatsUpString:
ld de, .WhatsUp
jr BillsPC_PlaceChangeBoxString
.WhatsUp:
db "What's up?@"
BillsPC_PlaceEmptyBoxString_SFX:
ld de, .NoMonString
call BillsPC_PlaceChangeBoxString
ld de, SFX_WRONG
call WaitPlaySFX
call WaitSFX
ld c, 50
call DelayFrames
ret
.NoMonString:
db "There's no #MON.@"
BillsPC_PlaceChangeBoxString:
push de
hlcoord 0, 14
lb bc, 2, 18
call Textbox
pop de
hlcoord 1, 16
call PlaceString
ld a, $1
ldh [hBGMapMode], a
ret
|
SFX_Battle_0D_Ch1:
unknownnoise0x20 15, 143, 52
unknownnoise0x20 8, 242, 53
unknownnoise0x20 10, 241, 85
endchannel
|
; Auto-generated file, do not edit
_TEXT_CN_TEMPLATE SEGMENT PAGE READ EXECUTE
PUBLIC CryptonightR_instruction0
PUBLIC CryptonightR_instruction1
PUBLIC CryptonightR_instruction2
PUBLIC CryptonightR_instruction3
PUBLIC CryptonightR_instruction4
PUBLIC CryptonightR_instruction5
PUBLIC CryptonightR_instruction6
PUBLIC CryptonightR_instruction7
PUBLIC CryptonightR_instruction8
PUBLIC CryptonightR_instruction9
PUBLIC CryptonightR_instruction10
PUBLIC CryptonightR_instruction11
PUBLIC CryptonightR_instruction12
PUBLIC CryptonightR_instruction13
PUBLIC CryptonightR_instruction14
PUBLIC CryptonightR_instruction15
PUBLIC CryptonightR_instruction16
PUBLIC CryptonightR_instruction17
PUBLIC CryptonightR_instruction18
PUBLIC CryptonightR_instruction19
PUBLIC CryptonightR_instruction20
PUBLIC CryptonightR_instruction21
PUBLIC CryptonightR_instruction22
PUBLIC CryptonightR_instruction23
PUBLIC CryptonightR_instruction24
PUBLIC CryptonightR_instruction25
PUBLIC CryptonightR_instruction26
PUBLIC CryptonightR_instruction27
PUBLIC CryptonightR_instruction28
PUBLIC CryptonightR_instruction29
PUBLIC CryptonightR_instruction30
PUBLIC CryptonightR_instruction31
PUBLIC CryptonightR_instruction32
PUBLIC CryptonightR_instruction33
PUBLIC CryptonightR_instruction34
PUBLIC CryptonightR_instruction35
PUBLIC CryptonightR_instruction36
PUBLIC CryptonightR_instruction37
PUBLIC CryptonightR_instruction38
PUBLIC CryptonightR_instruction39
PUBLIC CryptonightR_instruction40
PUBLIC CryptonightR_instruction41
PUBLIC CryptonightR_instruction42
PUBLIC CryptonightR_instruction43
PUBLIC CryptonightR_instruction44
PUBLIC CryptonightR_instruction45
PUBLIC CryptonightR_instruction46
PUBLIC CryptonightR_instruction47
PUBLIC CryptonightR_instruction48
PUBLIC CryptonightR_instruction49
PUBLIC CryptonightR_instruction50
PUBLIC CryptonightR_instruction51
PUBLIC CryptonightR_instruction52
PUBLIC CryptonightR_instruction53
PUBLIC CryptonightR_instruction54
PUBLIC CryptonightR_instruction55
PUBLIC CryptonightR_instruction56
PUBLIC CryptonightR_instruction57
PUBLIC CryptonightR_instruction58
PUBLIC CryptonightR_instruction59
PUBLIC CryptonightR_instruction60
PUBLIC CryptonightR_instruction61
PUBLIC CryptonightR_instruction62
PUBLIC CryptonightR_instruction63
PUBLIC CryptonightR_instruction64
PUBLIC CryptonightR_instruction65
PUBLIC CryptonightR_instruction66
PUBLIC CryptonightR_instruction67
PUBLIC CryptonightR_instruction68
PUBLIC CryptonightR_instruction69
PUBLIC CryptonightR_instruction70
PUBLIC CryptonightR_instruction71
PUBLIC CryptonightR_instruction72
PUBLIC CryptonightR_instruction73
PUBLIC CryptonightR_instruction74
PUBLIC CryptonightR_instruction75
PUBLIC CryptonightR_instruction76
PUBLIC CryptonightR_instruction77
PUBLIC CryptonightR_instruction78
PUBLIC CryptonightR_instruction79
PUBLIC CryptonightR_instruction80
PUBLIC CryptonightR_instruction81
PUBLIC CryptonightR_instruction82
PUBLIC CryptonightR_instruction83
PUBLIC CryptonightR_instruction84
PUBLIC CryptonightR_instruction85
PUBLIC CryptonightR_instruction86
PUBLIC CryptonightR_instruction87
PUBLIC CryptonightR_instruction88
PUBLIC CryptonightR_instruction89
PUBLIC CryptonightR_instruction90
PUBLIC CryptonightR_instruction91
PUBLIC CryptonightR_instruction92
PUBLIC CryptonightR_instruction93
PUBLIC CryptonightR_instruction94
PUBLIC CryptonightR_instruction95
PUBLIC CryptonightR_instruction96
PUBLIC CryptonightR_instruction97
PUBLIC CryptonightR_instruction98
PUBLIC CryptonightR_instruction99
PUBLIC CryptonightR_instruction100
PUBLIC CryptonightR_instruction101
PUBLIC CryptonightR_instruction102
PUBLIC CryptonightR_instruction103
PUBLIC CryptonightR_instruction104
PUBLIC CryptonightR_instruction105
PUBLIC CryptonightR_instruction106
PUBLIC CryptonightR_instruction107
PUBLIC CryptonightR_instruction108
PUBLIC CryptonightR_instruction109
PUBLIC CryptonightR_instruction110
PUBLIC CryptonightR_instruction111
PUBLIC CryptonightR_instruction112
PUBLIC CryptonightR_instruction113
PUBLIC CryptonightR_instruction114
PUBLIC CryptonightR_instruction115
PUBLIC CryptonightR_instruction116
PUBLIC CryptonightR_instruction117
PUBLIC CryptonightR_instruction118
PUBLIC CryptonightR_instruction119
PUBLIC CryptonightR_instruction120
PUBLIC CryptonightR_instruction121
PUBLIC CryptonightR_instruction122
PUBLIC CryptonightR_instruction123
PUBLIC CryptonightR_instruction124
PUBLIC CryptonightR_instruction125
PUBLIC CryptonightR_instruction126
PUBLIC CryptonightR_instruction127
PUBLIC CryptonightR_instruction128
PUBLIC CryptonightR_instruction129
PUBLIC CryptonightR_instruction130
PUBLIC CryptonightR_instruction131
PUBLIC CryptonightR_instruction132
PUBLIC CryptonightR_instruction133
PUBLIC CryptonightR_instruction134
PUBLIC CryptonightR_instruction135
PUBLIC CryptonightR_instruction136
PUBLIC CryptonightR_instruction137
PUBLIC CryptonightR_instruction138
PUBLIC CryptonightR_instruction139
PUBLIC CryptonightR_instruction140
PUBLIC CryptonightR_instruction141
PUBLIC CryptonightR_instruction142
PUBLIC CryptonightR_instruction143
PUBLIC CryptonightR_instruction144
PUBLIC CryptonightR_instruction145
PUBLIC CryptonightR_instruction146
PUBLIC CryptonightR_instruction147
PUBLIC CryptonightR_instruction148
PUBLIC CryptonightR_instruction149
PUBLIC CryptonightR_instruction150
PUBLIC CryptonightR_instruction151
PUBLIC CryptonightR_instruction152
PUBLIC CryptonightR_instruction153
PUBLIC CryptonightR_instruction154
PUBLIC CryptonightR_instruction155
PUBLIC CryptonightR_instruction156
PUBLIC CryptonightR_instruction157
PUBLIC CryptonightR_instruction158
PUBLIC CryptonightR_instruction159
PUBLIC CryptonightR_instruction160
PUBLIC CryptonightR_instruction161
PUBLIC CryptonightR_instruction162
PUBLIC CryptonightR_instruction163
PUBLIC CryptonightR_instruction164
PUBLIC CryptonightR_instruction165
PUBLIC CryptonightR_instruction166
PUBLIC CryptonightR_instruction167
PUBLIC CryptonightR_instruction168
PUBLIC CryptonightR_instruction169
PUBLIC CryptonightR_instruction170
PUBLIC CryptonightR_instruction171
PUBLIC CryptonightR_instruction172
PUBLIC CryptonightR_instruction173
PUBLIC CryptonightR_instruction174
PUBLIC CryptonightR_instruction175
PUBLIC CryptonightR_instruction176
PUBLIC CryptonightR_instruction177
PUBLIC CryptonightR_instruction178
PUBLIC CryptonightR_instruction179
PUBLIC CryptonightR_instruction180
PUBLIC CryptonightR_instruction181
PUBLIC CryptonightR_instruction182
PUBLIC CryptonightR_instruction183
PUBLIC CryptonightR_instruction184
PUBLIC CryptonightR_instruction185
PUBLIC CryptonightR_instruction186
PUBLIC CryptonightR_instruction187
PUBLIC CryptonightR_instruction188
PUBLIC CryptonightR_instruction189
PUBLIC CryptonightR_instruction190
PUBLIC CryptonightR_instruction191
PUBLIC CryptonightR_instruction192
PUBLIC CryptonightR_instruction193
PUBLIC CryptonightR_instruction194
PUBLIC CryptonightR_instruction195
PUBLIC CryptonightR_instruction196
PUBLIC CryptonightR_instruction197
PUBLIC CryptonightR_instruction198
PUBLIC CryptonightR_instruction199
PUBLIC CryptonightR_instruction200
PUBLIC CryptonightR_instruction201
PUBLIC CryptonightR_instruction202
PUBLIC CryptonightR_instruction203
PUBLIC CryptonightR_instruction204
PUBLIC CryptonightR_instruction205
PUBLIC CryptonightR_instruction206
PUBLIC CryptonightR_instruction207
PUBLIC CryptonightR_instruction208
PUBLIC CryptonightR_instruction209
PUBLIC CryptonightR_instruction210
PUBLIC CryptonightR_instruction211
PUBLIC CryptonightR_instruction212
PUBLIC CryptonightR_instruction213
PUBLIC CryptonightR_instruction214
PUBLIC CryptonightR_instruction215
PUBLIC CryptonightR_instruction216
PUBLIC CryptonightR_instruction217
PUBLIC CryptonightR_instruction218
PUBLIC CryptonightR_instruction219
PUBLIC CryptonightR_instruction220
PUBLIC CryptonightR_instruction221
PUBLIC CryptonightR_instruction222
PUBLIC CryptonightR_instruction223
PUBLIC CryptonightR_instruction224
PUBLIC CryptonightR_instruction225
PUBLIC CryptonightR_instruction226
PUBLIC CryptonightR_instruction227
PUBLIC CryptonightR_instruction228
PUBLIC CryptonightR_instruction229
PUBLIC CryptonightR_instruction230
PUBLIC CryptonightR_instruction231
PUBLIC CryptonightR_instruction232
PUBLIC CryptonightR_instruction233
PUBLIC CryptonightR_instruction234
PUBLIC CryptonightR_instruction235
PUBLIC CryptonightR_instruction236
PUBLIC CryptonightR_instruction237
PUBLIC CryptonightR_instruction238
PUBLIC CryptonightR_instruction239
PUBLIC CryptonightR_instruction240
PUBLIC CryptonightR_instruction241
PUBLIC CryptonightR_instruction242
PUBLIC CryptonightR_instruction243
PUBLIC CryptonightR_instruction244
PUBLIC CryptonightR_instruction245
PUBLIC CryptonightR_instruction246
PUBLIC CryptonightR_instruction247
PUBLIC CryptonightR_instruction248
PUBLIC CryptonightR_instruction249
PUBLIC CryptonightR_instruction250
PUBLIC CryptonightR_instruction251
PUBLIC CryptonightR_instruction252
PUBLIC CryptonightR_instruction253
PUBLIC CryptonightR_instruction254
PUBLIC CryptonightR_instruction255
PUBLIC CryptonightR_instruction256
PUBLIC CryptonightR_instruction_mov0
PUBLIC CryptonightR_instruction_mov1
PUBLIC CryptonightR_instruction_mov2
PUBLIC CryptonightR_instruction_mov3
PUBLIC CryptonightR_instruction_mov4
PUBLIC CryptonightR_instruction_mov5
PUBLIC CryptonightR_instruction_mov6
PUBLIC CryptonightR_instruction_mov7
PUBLIC CryptonightR_instruction_mov8
PUBLIC CryptonightR_instruction_mov9
PUBLIC CryptonightR_instruction_mov10
PUBLIC CryptonightR_instruction_mov11
PUBLIC CryptonightR_instruction_mov12
PUBLIC CryptonightR_instruction_mov13
PUBLIC CryptonightR_instruction_mov14
PUBLIC CryptonightR_instruction_mov15
PUBLIC CryptonightR_instruction_mov16
PUBLIC CryptonightR_instruction_mov17
PUBLIC CryptonightR_instruction_mov18
PUBLIC CryptonightR_instruction_mov19
PUBLIC CryptonightR_instruction_mov20
PUBLIC CryptonightR_instruction_mov21
PUBLIC CryptonightR_instruction_mov22
PUBLIC CryptonightR_instruction_mov23
PUBLIC CryptonightR_instruction_mov24
PUBLIC CryptonightR_instruction_mov25
PUBLIC CryptonightR_instruction_mov26
PUBLIC CryptonightR_instruction_mov27
PUBLIC CryptonightR_instruction_mov28
PUBLIC CryptonightR_instruction_mov29
PUBLIC CryptonightR_instruction_mov30
PUBLIC CryptonightR_instruction_mov31
PUBLIC CryptonightR_instruction_mov32
PUBLIC CryptonightR_instruction_mov33
PUBLIC CryptonightR_instruction_mov34
PUBLIC CryptonightR_instruction_mov35
PUBLIC CryptonightR_instruction_mov36
PUBLIC CryptonightR_instruction_mov37
PUBLIC CryptonightR_instruction_mov38
PUBLIC CryptonightR_instruction_mov39
PUBLIC CryptonightR_instruction_mov40
PUBLIC CryptonightR_instruction_mov41
PUBLIC CryptonightR_instruction_mov42
PUBLIC CryptonightR_instruction_mov43
PUBLIC CryptonightR_instruction_mov44
PUBLIC CryptonightR_instruction_mov45
PUBLIC CryptonightR_instruction_mov46
PUBLIC CryptonightR_instruction_mov47
PUBLIC CryptonightR_instruction_mov48
PUBLIC CryptonightR_instruction_mov49
PUBLIC CryptonightR_instruction_mov50
PUBLIC CryptonightR_instruction_mov51
PUBLIC CryptonightR_instruction_mov52
PUBLIC CryptonightR_instruction_mov53
PUBLIC CryptonightR_instruction_mov54
PUBLIC CryptonightR_instruction_mov55
PUBLIC CryptonightR_instruction_mov56
PUBLIC CryptonightR_instruction_mov57
PUBLIC CryptonightR_instruction_mov58
PUBLIC CryptonightR_instruction_mov59
PUBLIC CryptonightR_instruction_mov60
PUBLIC CryptonightR_instruction_mov61
PUBLIC CryptonightR_instruction_mov62
PUBLIC CryptonightR_instruction_mov63
PUBLIC CryptonightR_instruction_mov64
PUBLIC CryptonightR_instruction_mov65
PUBLIC CryptonightR_instruction_mov66
PUBLIC CryptonightR_instruction_mov67
PUBLIC CryptonightR_instruction_mov68
PUBLIC CryptonightR_instruction_mov69
PUBLIC CryptonightR_instruction_mov70
PUBLIC CryptonightR_instruction_mov71
PUBLIC CryptonightR_instruction_mov72
PUBLIC CryptonightR_instruction_mov73
PUBLIC CryptonightR_instruction_mov74
PUBLIC CryptonightR_instruction_mov75
PUBLIC CryptonightR_instruction_mov76
PUBLIC CryptonightR_instruction_mov77
PUBLIC CryptonightR_instruction_mov78
PUBLIC CryptonightR_instruction_mov79
PUBLIC CryptonightR_instruction_mov80
PUBLIC CryptonightR_instruction_mov81
PUBLIC CryptonightR_instruction_mov82
PUBLIC CryptonightR_instruction_mov83
PUBLIC CryptonightR_instruction_mov84
PUBLIC CryptonightR_instruction_mov85
PUBLIC CryptonightR_instruction_mov86
PUBLIC CryptonightR_instruction_mov87
PUBLIC CryptonightR_instruction_mov88
PUBLIC CryptonightR_instruction_mov89
PUBLIC CryptonightR_instruction_mov90
PUBLIC CryptonightR_instruction_mov91
PUBLIC CryptonightR_instruction_mov92
PUBLIC CryptonightR_instruction_mov93
PUBLIC CryptonightR_instruction_mov94
PUBLIC CryptonightR_instruction_mov95
PUBLIC CryptonightR_instruction_mov96
PUBLIC CryptonightR_instruction_mov97
PUBLIC CryptonightR_instruction_mov98
PUBLIC CryptonightR_instruction_mov99
PUBLIC CryptonightR_instruction_mov100
PUBLIC CryptonightR_instruction_mov101
PUBLIC CryptonightR_instruction_mov102
PUBLIC CryptonightR_instruction_mov103
PUBLIC CryptonightR_instruction_mov104
PUBLIC CryptonightR_instruction_mov105
PUBLIC CryptonightR_instruction_mov106
PUBLIC CryptonightR_instruction_mov107
PUBLIC CryptonightR_instruction_mov108
PUBLIC CryptonightR_instruction_mov109
PUBLIC CryptonightR_instruction_mov110
PUBLIC CryptonightR_instruction_mov111
PUBLIC CryptonightR_instruction_mov112
PUBLIC CryptonightR_instruction_mov113
PUBLIC CryptonightR_instruction_mov114
PUBLIC CryptonightR_instruction_mov115
PUBLIC CryptonightR_instruction_mov116
PUBLIC CryptonightR_instruction_mov117
PUBLIC CryptonightR_instruction_mov118
PUBLIC CryptonightR_instruction_mov119
PUBLIC CryptonightR_instruction_mov120
PUBLIC CryptonightR_instruction_mov121
PUBLIC CryptonightR_instruction_mov122
PUBLIC CryptonightR_instruction_mov123
PUBLIC CryptonightR_instruction_mov124
PUBLIC CryptonightR_instruction_mov125
PUBLIC CryptonightR_instruction_mov126
PUBLIC CryptonightR_instruction_mov127
PUBLIC CryptonightR_instruction_mov128
PUBLIC CryptonightR_instruction_mov129
PUBLIC CryptonightR_instruction_mov130
PUBLIC CryptonightR_instruction_mov131
PUBLIC CryptonightR_instruction_mov132
PUBLIC CryptonightR_instruction_mov133
PUBLIC CryptonightR_instruction_mov134
PUBLIC CryptonightR_instruction_mov135
PUBLIC CryptonightR_instruction_mov136
PUBLIC CryptonightR_instruction_mov137
PUBLIC CryptonightR_instruction_mov138
PUBLIC CryptonightR_instruction_mov139
PUBLIC CryptonightR_instruction_mov140
PUBLIC CryptonightR_instruction_mov141
PUBLIC CryptonightR_instruction_mov142
PUBLIC CryptonightR_instruction_mov143
PUBLIC CryptonightR_instruction_mov144
PUBLIC CryptonightR_instruction_mov145
PUBLIC CryptonightR_instruction_mov146
PUBLIC CryptonightR_instruction_mov147
PUBLIC CryptonightR_instruction_mov148
PUBLIC CryptonightR_instruction_mov149
PUBLIC CryptonightR_instruction_mov150
PUBLIC CryptonightR_instruction_mov151
PUBLIC CryptonightR_instruction_mov152
PUBLIC CryptonightR_instruction_mov153
PUBLIC CryptonightR_instruction_mov154
PUBLIC CryptonightR_instruction_mov155
PUBLIC CryptonightR_instruction_mov156
PUBLIC CryptonightR_instruction_mov157
PUBLIC CryptonightR_instruction_mov158
PUBLIC CryptonightR_instruction_mov159
PUBLIC CryptonightR_instruction_mov160
PUBLIC CryptonightR_instruction_mov161
PUBLIC CryptonightR_instruction_mov162
PUBLIC CryptonightR_instruction_mov163
PUBLIC CryptonightR_instruction_mov164
PUBLIC CryptonightR_instruction_mov165
PUBLIC CryptonightR_instruction_mov166
PUBLIC CryptonightR_instruction_mov167
PUBLIC CryptonightR_instruction_mov168
PUBLIC CryptonightR_instruction_mov169
PUBLIC CryptonightR_instruction_mov170
PUBLIC CryptonightR_instruction_mov171
PUBLIC CryptonightR_instruction_mov172
PUBLIC CryptonightR_instruction_mov173
PUBLIC CryptonightR_instruction_mov174
PUBLIC CryptonightR_instruction_mov175
PUBLIC CryptonightR_instruction_mov176
PUBLIC CryptonightR_instruction_mov177
PUBLIC CryptonightR_instruction_mov178
PUBLIC CryptonightR_instruction_mov179
PUBLIC CryptonightR_instruction_mov180
PUBLIC CryptonightR_instruction_mov181
PUBLIC CryptonightR_instruction_mov182
PUBLIC CryptonightR_instruction_mov183
PUBLIC CryptonightR_instruction_mov184
PUBLIC CryptonightR_instruction_mov185
PUBLIC CryptonightR_instruction_mov186
PUBLIC CryptonightR_instruction_mov187
PUBLIC CryptonightR_instruction_mov188
PUBLIC CryptonightR_instruction_mov189
PUBLIC CryptonightR_instruction_mov190
PUBLIC CryptonightR_instruction_mov191
PUBLIC CryptonightR_instruction_mov192
PUBLIC CryptonightR_instruction_mov193
PUBLIC CryptonightR_instruction_mov194
PUBLIC CryptonightR_instruction_mov195
PUBLIC CryptonightR_instruction_mov196
PUBLIC CryptonightR_instruction_mov197
PUBLIC CryptonightR_instruction_mov198
PUBLIC CryptonightR_instruction_mov199
PUBLIC CryptonightR_instruction_mov200
PUBLIC CryptonightR_instruction_mov201
PUBLIC CryptonightR_instruction_mov202
PUBLIC CryptonightR_instruction_mov203
PUBLIC CryptonightR_instruction_mov204
PUBLIC CryptonightR_instruction_mov205
PUBLIC CryptonightR_instruction_mov206
PUBLIC CryptonightR_instruction_mov207
PUBLIC CryptonightR_instruction_mov208
PUBLIC CryptonightR_instruction_mov209
PUBLIC CryptonightR_instruction_mov210
PUBLIC CryptonightR_instruction_mov211
PUBLIC CryptonightR_instruction_mov212
PUBLIC CryptonightR_instruction_mov213
PUBLIC CryptonightR_instruction_mov214
PUBLIC CryptonightR_instruction_mov215
PUBLIC CryptonightR_instruction_mov216
PUBLIC CryptonightR_instruction_mov217
PUBLIC CryptonightR_instruction_mov218
PUBLIC CryptonightR_instruction_mov219
PUBLIC CryptonightR_instruction_mov220
PUBLIC CryptonightR_instruction_mov221
PUBLIC CryptonightR_instruction_mov222
PUBLIC CryptonightR_instruction_mov223
PUBLIC CryptonightR_instruction_mov224
PUBLIC CryptonightR_instruction_mov225
PUBLIC CryptonightR_instruction_mov226
PUBLIC CryptonightR_instruction_mov227
PUBLIC CryptonightR_instruction_mov228
PUBLIC CryptonightR_instruction_mov229
PUBLIC CryptonightR_instruction_mov230
PUBLIC CryptonightR_instruction_mov231
PUBLIC CryptonightR_instruction_mov232
PUBLIC CryptonightR_instruction_mov233
PUBLIC CryptonightR_instruction_mov234
PUBLIC CryptonightR_instruction_mov235
PUBLIC CryptonightR_instruction_mov236
PUBLIC CryptonightR_instruction_mov237
PUBLIC CryptonightR_instruction_mov238
PUBLIC CryptonightR_instruction_mov239
PUBLIC CryptonightR_instruction_mov240
PUBLIC CryptonightR_instruction_mov241
PUBLIC CryptonightR_instruction_mov242
PUBLIC CryptonightR_instruction_mov243
PUBLIC CryptonightR_instruction_mov244
PUBLIC CryptonightR_instruction_mov245
PUBLIC CryptonightR_instruction_mov246
PUBLIC CryptonightR_instruction_mov247
PUBLIC CryptonightR_instruction_mov248
PUBLIC CryptonightR_instruction_mov249
PUBLIC CryptonightR_instruction_mov250
PUBLIC CryptonightR_instruction_mov251
PUBLIC CryptonightR_instruction_mov252
PUBLIC CryptonightR_instruction_mov253
PUBLIC CryptonightR_instruction_mov254
PUBLIC CryptonightR_instruction_mov255
PUBLIC CryptonightR_instruction_mov256
INCLUDE CryptonightWOW_template_win.inc
INCLUDE CryptonightR_template_win.inc
CryptonightR_instruction0:
imul rbx, rbx
CryptonightR_instruction1:
imul rbx, rbx
CryptonightR_instruction2:
imul rbx, rbx
CryptonightR_instruction3:
add rbx, r9
add rbx, 2147483647
CryptonightR_instruction4:
sub rbx, r9
CryptonightR_instruction5:
ror ebx, cl
CryptonightR_instruction6:
rol ebx, cl
CryptonightR_instruction7:
xor rbx, r9
CryptonightR_instruction8:
imul rsi, rbx
CryptonightR_instruction9:
imul rsi, rbx
CryptonightR_instruction10:
imul rsi, rbx
CryptonightR_instruction11:
add rsi, rbx
add rsi, 2147483647
CryptonightR_instruction12:
sub rsi, rbx
CryptonightR_instruction13:
ror esi, cl
CryptonightR_instruction14:
rol esi, cl
CryptonightR_instruction15:
xor rsi, rbx
CryptonightR_instruction16:
imul rdi, rbx
CryptonightR_instruction17:
imul rdi, rbx
CryptonightR_instruction18:
imul rdi, rbx
CryptonightR_instruction19:
add rdi, rbx
add rdi, 2147483647
CryptonightR_instruction20:
sub rdi, rbx
CryptonightR_instruction21:
ror edi, cl
CryptonightR_instruction22:
rol edi, cl
CryptonightR_instruction23:
xor rdi, rbx
CryptonightR_instruction24:
imul rbp, rbx
CryptonightR_instruction25:
imul rbp, rbx
CryptonightR_instruction26:
imul rbp, rbx
CryptonightR_instruction27:
add rbp, rbx
add rbp, 2147483647
CryptonightR_instruction28:
sub rbp, rbx
CryptonightR_instruction29:
ror ebp, cl
CryptonightR_instruction30:
rol ebp, cl
CryptonightR_instruction31:
xor rbp, rbx
CryptonightR_instruction32:
imul rbx, rsi
CryptonightR_instruction33:
imul rbx, rsi
CryptonightR_instruction34:
imul rbx, rsi
CryptonightR_instruction35:
add rbx, rsi
add rbx, 2147483647
CryptonightR_instruction36:
sub rbx, rsi
CryptonightR_instruction37:
ror ebx, cl
CryptonightR_instruction38:
rol ebx, cl
CryptonightR_instruction39:
xor rbx, rsi
CryptonightR_instruction40:
imul rsi, rsi
CryptonightR_instruction41:
imul rsi, rsi
CryptonightR_instruction42:
imul rsi, rsi
CryptonightR_instruction43:
add rsi, r9
add rsi, 2147483647
CryptonightR_instruction44:
sub rsi, r9
CryptonightR_instruction45:
ror esi, cl
CryptonightR_instruction46:
rol esi, cl
CryptonightR_instruction47:
xor rsi, r9
CryptonightR_instruction48:
imul rdi, rsi
CryptonightR_instruction49:
imul rdi, rsi
CryptonightR_instruction50:
imul rdi, rsi
CryptonightR_instruction51:
add rdi, rsi
add rdi, 2147483647
CryptonightR_instruction52:
sub rdi, rsi
CryptonightR_instruction53:
ror edi, cl
CryptonightR_instruction54:
rol edi, cl
CryptonightR_instruction55:
xor rdi, rsi
CryptonightR_instruction56:
imul rbp, rsi
CryptonightR_instruction57:
imul rbp, rsi
CryptonightR_instruction58:
imul rbp, rsi
CryptonightR_instruction59:
add rbp, rsi
add rbp, 2147483647
CryptonightR_instruction60:
sub rbp, rsi
CryptonightR_instruction61:
ror ebp, cl
CryptonightR_instruction62:
rol ebp, cl
CryptonightR_instruction63:
xor rbp, rsi
CryptonightR_instruction64:
imul rbx, rdi
CryptonightR_instruction65:
imul rbx, rdi
CryptonightR_instruction66:
imul rbx, rdi
CryptonightR_instruction67:
add rbx, rdi
add rbx, 2147483647
CryptonightR_instruction68:
sub rbx, rdi
CryptonightR_instruction69:
ror ebx, cl
CryptonightR_instruction70:
rol ebx, cl
CryptonightR_instruction71:
xor rbx, rdi
CryptonightR_instruction72:
imul rsi, rdi
CryptonightR_instruction73:
imul rsi, rdi
CryptonightR_instruction74:
imul rsi, rdi
CryptonightR_instruction75:
add rsi, rdi
add rsi, 2147483647
CryptonightR_instruction76:
sub rsi, rdi
CryptonightR_instruction77:
ror esi, cl
CryptonightR_instruction78:
rol esi, cl
CryptonightR_instruction79:
xor rsi, rdi
CryptonightR_instruction80:
imul rdi, rdi
CryptonightR_instruction81:
imul rdi, rdi
CryptonightR_instruction82:
imul rdi, rdi
CryptonightR_instruction83:
add rdi, r9
add rdi, 2147483647
CryptonightR_instruction84:
sub rdi, r9
CryptonightR_instruction85:
ror edi, cl
CryptonightR_instruction86:
rol edi, cl
CryptonightR_instruction87:
xor rdi, r9
CryptonightR_instruction88:
imul rbp, rdi
CryptonightR_instruction89:
imul rbp, rdi
CryptonightR_instruction90:
imul rbp, rdi
CryptonightR_instruction91:
add rbp, rdi
add rbp, 2147483647
CryptonightR_instruction92:
sub rbp, rdi
CryptonightR_instruction93:
ror ebp, cl
CryptonightR_instruction94:
rol ebp, cl
CryptonightR_instruction95:
xor rbp, rdi
CryptonightR_instruction96:
imul rbx, rbp
CryptonightR_instruction97:
imul rbx, rbp
CryptonightR_instruction98:
imul rbx, rbp
CryptonightR_instruction99:
add rbx, rbp
add rbx, 2147483647
CryptonightR_instruction100:
sub rbx, rbp
CryptonightR_instruction101:
ror ebx, cl
CryptonightR_instruction102:
rol ebx, cl
CryptonightR_instruction103:
xor rbx, rbp
CryptonightR_instruction104:
imul rsi, rbp
CryptonightR_instruction105:
imul rsi, rbp
CryptonightR_instruction106:
imul rsi, rbp
CryptonightR_instruction107:
add rsi, rbp
add rsi, 2147483647
CryptonightR_instruction108:
sub rsi, rbp
CryptonightR_instruction109:
ror esi, cl
CryptonightR_instruction110:
rol esi, cl
CryptonightR_instruction111:
xor rsi, rbp
CryptonightR_instruction112:
imul rdi, rbp
CryptonightR_instruction113:
imul rdi, rbp
CryptonightR_instruction114:
imul rdi, rbp
CryptonightR_instruction115:
add rdi, rbp
add rdi, 2147483647
CryptonightR_instruction116:
sub rdi, rbp
CryptonightR_instruction117:
ror edi, cl
CryptonightR_instruction118:
rol edi, cl
CryptonightR_instruction119:
xor rdi, rbp
CryptonightR_instruction120:
imul rbp, rbp
CryptonightR_instruction121:
imul rbp, rbp
CryptonightR_instruction122:
imul rbp, rbp
CryptonightR_instruction123:
add rbp, r9
add rbp, 2147483647
CryptonightR_instruction124:
sub rbp, r9
CryptonightR_instruction125:
ror ebp, cl
CryptonightR_instruction126:
rol ebp, cl
CryptonightR_instruction127:
xor rbp, r9
CryptonightR_instruction128:
imul rbx, rsp
CryptonightR_instruction129:
imul rbx, rsp
CryptonightR_instruction130:
imul rbx, rsp
CryptonightR_instruction131:
add rbx, rsp
add rbx, 2147483647
CryptonightR_instruction132:
sub rbx, rsp
CryptonightR_instruction133:
ror ebx, cl
CryptonightR_instruction134:
rol ebx, cl
CryptonightR_instruction135:
xor rbx, rsp
CryptonightR_instruction136:
imul rsi, rsp
CryptonightR_instruction137:
imul rsi, rsp
CryptonightR_instruction138:
imul rsi, rsp
CryptonightR_instruction139:
add rsi, rsp
add rsi, 2147483647
CryptonightR_instruction140:
sub rsi, rsp
CryptonightR_instruction141:
ror esi, cl
CryptonightR_instruction142:
rol esi, cl
CryptonightR_instruction143:
xor rsi, rsp
CryptonightR_instruction144:
imul rdi, rsp
CryptonightR_instruction145:
imul rdi, rsp
CryptonightR_instruction146:
imul rdi, rsp
CryptonightR_instruction147:
add rdi, rsp
add rdi, 2147483647
CryptonightR_instruction148:
sub rdi, rsp
CryptonightR_instruction149:
ror edi, cl
CryptonightR_instruction150:
rol edi, cl
CryptonightR_instruction151:
xor rdi, rsp
CryptonightR_instruction152:
imul rbp, rsp
CryptonightR_instruction153:
imul rbp, rsp
CryptonightR_instruction154:
imul rbp, rsp
CryptonightR_instruction155:
add rbp, rsp
add rbp, 2147483647
CryptonightR_instruction156:
sub rbp, rsp
CryptonightR_instruction157:
ror ebp, cl
CryptonightR_instruction158:
rol ebp, cl
CryptonightR_instruction159:
xor rbp, rsp
CryptonightR_instruction160:
imul rbx, r15
CryptonightR_instruction161:
imul rbx, r15
CryptonightR_instruction162:
imul rbx, r15
CryptonightR_instruction163:
add rbx, r15
add rbx, 2147483647
CryptonightR_instruction164:
sub rbx, r15
CryptonightR_instruction165:
ror ebx, cl
CryptonightR_instruction166:
rol ebx, cl
CryptonightR_instruction167:
xor rbx, r15
CryptonightR_instruction168:
imul rsi, r15
CryptonightR_instruction169:
imul rsi, r15
CryptonightR_instruction170:
imul rsi, r15
CryptonightR_instruction171:
add rsi, r15
add rsi, 2147483647
CryptonightR_instruction172:
sub rsi, r15
CryptonightR_instruction173:
ror esi, cl
CryptonightR_instruction174:
rol esi, cl
CryptonightR_instruction175:
xor rsi, r15
CryptonightR_instruction176:
imul rdi, r15
CryptonightR_instruction177:
imul rdi, r15
CryptonightR_instruction178:
imul rdi, r15
CryptonightR_instruction179:
add rdi, r15
add rdi, 2147483647
CryptonightR_instruction180:
sub rdi, r15
CryptonightR_instruction181:
ror edi, cl
CryptonightR_instruction182:
rol edi, cl
CryptonightR_instruction183:
xor rdi, r15
CryptonightR_instruction184:
imul rbp, r15
CryptonightR_instruction185:
imul rbp, r15
CryptonightR_instruction186:
imul rbp, r15
CryptonightR_instruction187:
add rbp, r15
add rbp, 2147483647
CryptonightR_instruction188:
sub rbp, r15
CryptonightR_instruction189:
ror ebp, cl
CryptonightR_instruction190:
rol ebp, cl
CryptonightR_instruction191:
xor rbp, r15
CryptonightR_instruction192:
imul rbx, rax
CryptonightR_instruction193:
imul rbx, rax
CryptonightR_instruction194:
imul rbx, rax
CryptonightR_instruction195:
add rbx, rax
add rbx, 2147483647
CryptonightR_instruction196:
sub rbx, rax
CryptonightR_instruction197:
ror ebx, cl
CryptonightR_instruction198:
rol ebx, cl
CryptonightR_instruction199:
xor rbx, rax
CryptonightR_instruction200:
imul rsi, rax
CryptonightR_instruction201:
imul rsi, rax
CryptonightR_instruction202:
imul rsi, rax
CryptonightR_instruction203:
add rsi, rax
add rsi, 2147483647
CryptonightR_instruction204:
sub rsi, rax
CryptonightR_instruction205:
ror esi, cl
CryptonightR_instruction206:
rol esi, cl
CryptonightR_instruction207:
xor rsi, rax
CryptonightR_instruction208:
imul rdi, rax
CryptonightR_instruction209:
imul rdi, rax
CryptonightR_instruction210:
imul rdi, rax
CryptonightR_instruction211:
add rdi, rax
add rdi, 2147483647
CryptonightR_instruction212:
sub rdi, rax
CryptonightR_instruction213:
ror edi, cl
CryptonightR_instruction214:
rol edi, cl
CryptonightR_instruction215:
xor rdi, rax
CryptonightR_instruction216:
imul rbp, rax
CryptonightR_instruction217:
imul rbp, rax
CryptonightR_instruction218:
imul rbp, rax
CryptonightR_instruction219:
add rbp, rax
add rbp, 2147483647
CryptonightR_instruction220:
sub rbp, rax
CryptonightR_instruction221:
ror ebp, cl
CryptonightR_instruction222:
rol ebp, cl
CryptonightR_instruction223:
xor rbp, rax
CryptonightR_instruction224:
imul rbx, rdx
CryptonightR_instruction225:
imul rbx, rdx
CryptonightR_instruction226:
imul rbx, rdx
CryptonightR_instruction227:
add rbx, rdx
add rbx, 2147483647
CryptonightR_instruction228:
sub rbx, rdx
CryptonightR_instruction229:
ror ebx, cl
CryptonightR_instruction230:
rol ebx, cl
CryptonightR_instruction231:
xor rbx, rdx
CryptonightR_instruction232:
imul rsi, rdx
CryptonightR_instruction233:
imul rsi, rdx
CryptonightR_instruction234:
imul rsi, rdx
CryptonightR_instruction235:
add rsi, rdx
add rsi, 2147483647
CryptonightR_instruction236:
sub rsi, rdx
CryptonightR_instruction237:
ror esi, cl
CryptonightR_instruction238:
rol esi, cl
CryptonightR_instruction239:
xor rsi, rdx
CryptonightR_instruction240:
imul rdi, rdx
CryptonightR_instruction241:
imul rdi, rdx
CryptonightR_instruction242:
imul rdi, rdx
CryptonightR_instruction243:
add rdi, rdx
add rdi, 2147483647
CryptonightR_instruction244:
sub rdi, rdx
CryptonightR_instruction245:
ror edi, cl
CryptonightR_instruction246:
rol edi, cl
CryptonightR_instruction247:
xor rdi, rdx
CryptonightR_instruction248:
imul rbp, rdx
CryptonightR_instruction249:
imul rbp, rdx
CryptonightR_instruction250:
imul rbp, rdx
CryptonightR_instruction251:
add rbp, rdx
add rbp, 2147483647
CryptonightR_instruction252:
sub rbp, rdx
CryptonightR_instruction253:
ror ebp, cl
CryptonightR_instruction254:
rol ebp, cl
CryptonightR_instruction255:
xor rbp, rdx
CryptonightR_instruction256:
imul rbx, rbx
CryptonightR_instruction_mov0:
CryptonightR_instruction_mov1:
CryptonightR_instruction_mov2:
CryptonightR_instruction_mov3:
CryptonightR_instruction_mov4:
CryptonightR_instruction_mov5:
mov rcx, rbx
CryptonightR_instruction_mov6:
mov rcx, rbx
CryptonightR_instruction_mov7:
CryptonightR_instruction_mov8:
CryptonightR_instruction_mov9:
CryptonightR_instruction_mov10:
CryptonightR_instruction_mov11:
CryptonightR_instruction_mov12:
CryptonightR_instruction_mov13:
mov rcx, rbx
CryptonightR_instruction_mov14:
mov rcx, rbx
CryptonightR_instruction_mov15:
CryptonightR_instruction_mov16:
CryptonightR_instruction_mov17:
CryptonightR_instruction_mov18:
CryptonightR_instruction_mov19:
CryptonightR_instruction_mov20:
CryptonightR_instruction_mov21:
mov rcx, rbx
CryptonightR_instruction_mov22:
mov rcx, rbx
CryptonightR_instruction_mov23:
CryptonightR_instruction_mov24:
CryptonightR_instruction_mov25:
CryptonightR_instruction_mov26:
CryptonightR_instruction_mov27:
CryptonightR_instruction_mov28:
CryptonightR_instruction_mov29:
mov rcx, rbx
CryptonightR_instruction_mov30:
mov rcx, rbx
CryptonightR_instruction_mov31:
CryptonightR_instruction_mov32:
CryptonightR_instruction_mov33:
CryptonightR_instruction_mov34:
CryptonightR_instruction_mov35:
CryptonightR_instruction_mov36:
CryptonightR_instruction_mov37:
mov rcx, rsi
CryptonightR_instruction_mov38:
mov rcx, rsi
CryptonightR_instruction_mov39:
CryptonightR_instruction_mov40:
CryptonightR_instruction_mov41:
CryptonightR_instruction_mov42:
CryptonightR_instruction_mov43:
CryptonightR_instruction_mov44:
CryptonightR_instruction_mov45:
mov rcx, rsi
CryptonightR_instruction_mov46:
mov rcx, rsi
CryptonightR_instruction_mov47:
CryptonightR_instruction_mov48:
CryptonightR_instruction_mov49:
CryptonightR_instruction_mov50:
CryptonightR_instruction_mov51:
CryptonightR_instruction_mov52:
CryptonightR_instruction_mov53:
mov rcx, rsi
CryptonightR_instruction_mov54:
mov rcx, rsi
CryptonightR_instruction_mov55:
CryptonightR_instruction_mov56:
CryptonightR_instruction_mov57:
CryptonightR_instruction_mov58:
CryptonightR_instruction_mov59:
CryptonightR_instruction_mov60:
CryptonightR_instruction_mov61:
mov rcx, rsi
CryptonightR_instruction_mov62:
mov rcx, rsi
CryptonightR_instruction_mov63:
CryptonightR_instruction_mov64:
CryptonightR_instruction_mov65:
CryptonightR_instruction_mov66:
CryptonightR_instruction_mov67:
CryptonightR_instruction_mov68:
CryptonightR_instruction_mov69:
mov rcx, rdi
CryptonightR_instruction_mov70:
mov rcx, rdi
CryptonightR_instruction_mov71:
CryptonightR_instruction_mov72:
CryptonightR_instruction_mov73:
CryptonightR_instruction_mov74:
CryptonightR_instruction_mov75:
CryptonightR_instruction_mov76:
CryptonightR_instruction_mov77:
mov rcx, rdi
CryptonightR_instruction_mov78:
mov rcx, rdi
CryptonightR_instruction_mov79:
CryptonightR_instruction_mov80:
CryptonightR_instruction_mov81:
CryptonightR_instruction_mov82:
CryptonightR_instruction_mov83:
CryptonightR_instruction_mov84:
CryptonightR_instruction_mov85:
mov rcx, rdi
CryptonightR_instruction_mov86:
mov rcx, rdi
CryptonightR_instruction_mov87:
CryptonightR_instruction_mov88:
CryptonightR_instruction_mov89:
CryptonightR_instruction_mov90:
CryptonightR_instruction_mov91:
CryptonightR_instruction_mov92:
CryptonightR_instruction_mov93:
mov rcx, rdi
CryptonightR_instruction_mov94:
mov rcx, rdi
CryptonightR_instruction_mov95:
CryptonightR_instruction_mov96:
CryptonightR_instruction_mov97:
CryptonightR_instruction_mov98:
CryptonightR_instruction_mov99:
CryptonightR_instruction_mov100:
CryptonightR_instruction_mov101:
mov rcx, rbp
CryptonightR_instruction_mov102:
mov rcx, rbp
CryptonightR_instruction_mov103:
CryptonightR_instruction_mov104:
CryptonightR_instruction_mov105:
CryptonightR_instruction_mov106:
CryptonightR_instruction_mov107:
CryptonightR_instruction_mov108:
CryptonightR_instruction_mov109:
mov rcx, rbp
CryptonightR_instruction_mov110:
mov rcx, rbp
CryptonightR_instruction_mov111:
CryptonightR_instruction_mov112:
CryptonightR_instruction_mov113:
CryptonightR_instruction_mov114:
CryptonightR_instruction_mov115:
CryptonightR_instruction_mov116:
CryptonightR_instruction_mov117:
mov rcx, rbp
CryptonightR_instruction_mov118:
mov rcx, rbp
CryptonightR_instruction_mov119:
CryptonightR_instruction_mov120:
CryptonightR_instruction_mov121:
CryptonightR_instruction_mov122:
CryptonightR_instruction_mov123:
CryptonightR_instruction_mov124:
CryptonightR_instruction_mov125:
mov rcx, rbp
CryptonightR_instruction_mov126:
mov rcx, rbp
CryptonightR_instruction_mov127:
CryptonightR_instruction_mov128:
CryptonightR_instruction_mov129:
CryptonightR_instruction_mov130:
CryptonightR_instruction_mov131:
CryptonightR_instruction_mov132:
CryptonightR_instruction_mov133:
mov rcx, rsp
CryptonightR_instruction_mov134:
mov rcx, rsp
CryptonightR_instruction_mov135:
CryptonightR_instruction_mov136:
CryptonightR_instruction_mov137:
CryptonightR_instruction_mov138:
CryptonightR_instruction_mov139:
CryptonightR_instruction_mov140:
CryptonightR_instruction_mov141:
mov rcx, rsp
CryptonightR_instruction_mov142:
mov rcx, rsp
CryptonightR_instruction_mov143:
CryptonightR_instruction_mov144:
CryptonightR_instruction_mov145:
CryptonightR_instruction_mov146:
CryptonightR_instruction_mov147:
CryptonightR_instruction_mov148:
CryptonightR_instruction_mov149:
mov rcx, rsp
CryptonightR_instruction_mov150:
mov rcx, rsp
CryptonightR_instruction_mov151:
CryptonightR_instruction_mov152:
CryptonightR_instruction_mov153:
CryptonightR_instruction_mov154:
CryptonightR_instruction_mov155:
CryptonightR_instruction_mov156:
CryptonightR_instruction_mov157:
mov rcx, rsp
CryptonightR_instruction_mov158:
mov rcx, rsp
CryptonightR_instruction_mov159:
CryptonightR_instruction_mov160:
CryptonightR_instruction_mov161:
CryptonightR_instruction_mov162:
CryptonightR_instruction_mov163:
CryptonightR_instruction_mov164:
CryptonightR_instruction_mov165:
mov rcx, r15
CryptonightR_instruction_mov166:
mov rcx, r15
CryptonightR_instruction_mov167:
CryptonightR_instruction_mov168:
CryptonightR_instruction_mov169:
CryptonightR_instruction_mov170:
CryptonightR_instruction_mov171:
CryptonightR_instruction_mov172:
CryptonightR_instruction_mov173:
mov rcx, r15
CryptonightR_instruction_mov174:
mov rcx, r15
CryptonightR_instruction_mov175:
CryptonightR_instruction_mov176:
CryptonightR_instruction_mov177:
CryptonightR_instruction_mov178:
CryptonightR_instruction_mov179:
CryptonightR_instruction_mov180:
CryptonightR_instruction_mov181:
mov rcx, r15
CryptonightR_instruction_mov182:
mov rcx, r15
CryptonightR_instruction_mov183:
CryptonightR_instruction_mov184:
CryptonightR_instruction_mov185:
CryptonightR_instruction_mov186:
CryptonightR_instruction_mov187:
CryptonightR_instruction_mov188:
CryptonightR_instruction_mov189:
mov rcx, r15
CryptonightR_instruction_mov190:
mov rcx, r15
CryptonightR_instruction_mov191:
CryptonightR_instruction_mov192:
CryptonightR_instruction_mov193:
CryptonightR_instruction_mov194:
CryptonightR_instruction_mov195:
CryptonightR_instruction_mov196:
CryptonightR_instruction_mov197:
mov rcx, rax
CryptonightR_instruction_mov198:
mov rcx, rax
CryptonightR_instruction_mov199:
CryptonightR_instruction_mov200:
CryptonightR_instruction_mov201:
CryptonightR_instruction_mov202:
CryptonightR_instruction_mov203:
CryptonightR_instruction_mov204:
CryptonightR_instruction_mov205:
mov rcx, rax
CryptonightR_instruction_mov206:
mov rcx, rax
CryptonightR_instruction_mov207:
CryptonightR_instruction_mov208:
CryptonightR_instruction_mov209:
CryptonightR_instruction_mov210:
CryptonightR_instruction_mov211:
CryptonightR_instruction_mov212:
CryptonightR_instruction_mov213:
mov rcx, rax
CryptonightR_instruction_mov214:
mov rcx, rax
CryptonightR_instruction_mov215:
CryptonightR_instruction_mov216:
CryptonightR_instruction_mov217:
CryptonightR_instruction_mov218:
CryptonightR_instruction_mov219:
CryptonightR_instruction_mov220:
CryptonightR_instruction_mov221:
mov rcx, rax
CryptonightR_instruction_mov222:
mov rcx, rax
CryptonightR_instruction_mov223:
CryptonightR_instruction_mov224:
CryptonightR_instruction_mov225:
CryptonightR_instruction_mov226:
CryptonightR_instruction_mov227:
CryptonightR_instruction_mov228:
CryptonightR_instruction_mov229:
mov rcx, rdx
CryptonightR_instruction_mov230:
mov rcx, rdx
CryptonightR_instruction_mov231:
CryptonightR_instruction_mov232:
CryptonightR_instruction_mov233:
CryptonightR_instruction_mov234:
CryptonightR_instruction_mov235:
CryptonightR_instruction_mov236:
CryptonightR_instruction_mov237:
mov rcx, rdx
CryptonightR_instruction_mov238:
mov rcx, rdx
CryptonightR_instruction_mov239:
CryptonightR_instruction_mov240:
CryptonightR_instruction_mov241:
CryptonightR_instruction_mov242:
CryptonightR_instruction_mov243:
CryptonightR_instruction_mov244:
CryptonightR_instruction_mov245:
mov rcx, rdx
CryptonightR_instruction_mov246:
mov rcx, rdx
CryptonightR_instruction_mov247:
CryptonightR_instruction_mov248:
CryptonightR_instruction_mov249:
CryptonightR_instruction_mov250:
CryptonightR_instruction_mov251:
CryptonightR_instruction_mov252:
CryptonightR_instruction_mov253:
mov rcx, rdx
CryptonightR_instruction_mov254:
mov rcx, rdx
CryptonightR_instruction_mov255:
CryptonightR_instruction_mov256:
_TEXT_CN_TEMPLATE ENDS
END
|
#include "il2cpp-config.h"
#include <stddef.h>
#include "icalls/mscorlib/System.Reflection/MonoField.h"
#include "utils/StringUtils.h"
#include "vm/Class.h"
#include "vm/Field.h"
#include "vm/Object.h"
#include "vm/Reflection.h"
#include "vm/Runtime.h"
#include "vm/Type.h"
#include "vm/Exception.h"
#include "il2cpp-class-internals.h"
#include "il2cpp-tabledefs.h"
#include "vm-utils/BlobReader.h"
using namespace il2cpp::vm;
using il2cpp::utils::StringUtils;
namespace il2cpp
{
namespace icalls
{
namespace mscorlib
{
namespace System
{
namespace Reflection
{
Il2CppReflectionType * MonoField::GetParentType(Il2CppReflectionField * field, bool declaring)
{
Il2CppClass *parent;
parent = declaring ? field->field->parent : field->klass;
return il2cpp::vm::Reflection::GetTypeObject(&parent->byval_arg);
}
int32_t MonoField::GetFieldOffset(Il2CppReflectionField * field)
{
return field->field->offset - sizeof(Il2CppObject);
}
Il2CppObject* MonoField::GetValueInternal(Il2CppReflectionField * field, Il2CppObject * obj)
{
return vm::Field::GetValueObject(field->field, obj);
}
void MonoField::SetValueInternal(Il2CppReflectionField* field, Il2CppObject* obj, Il2CppObject* value)
{
FieldInfo* fieldInfo = field->field;
Il2CppClass* fieldType = Class::FromIl2CppType(fieldInfo->type);
#ifndef NET_4_0 //This check is done in managed code in .NET 4.5+
if (value != NULL && !Class::IsAssignableFrom(fieldType, value->klass))
{
Exception::Raise(Exception::GetArgumentException("value",
utils::StringUtils::Printf("Object of type '%s' cannot be converted to type '%s'.",
Type::GetName(&value->klass->byval_arg, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME).c_str(),
Type::GetName(fieldInfo->type, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME).c_str()
).c_str()));
}
#endif
uint8_t* fieldAddress;
if (fieldInfo->type->attrs & FIELD_ATTRIBUTE_STATIC)
{
if (fieldInfo->offset == THREAD_STATIC_FIELD_OFFSET)
{
IL2CPP_NOT_IMPLEMENTED(Field::StaticSetValue);
}
Runtime::ClassInit(fieldInfo->parent);
fieldAddress = static_cast<uint8_t*>(fieldInfo->parent->static_fields) + fieldInfo->offset;
}
else
{
IL2CPP_ASSERT(obj);
fieldAddress = reinterpret_cast<uint8_t*>(obj) + fieldInfo->offset;
}
if (fieldType->valuetype)
{
if (!Class::IsNullable(fieldType))
{
uint32_t fieldSize = Class::GetInstanceSize(fieldType) - sizeof(Il2CppObject);
if (value != NULL)
{
memcpy(fieldAddress, Object::Unbox(value), fieldSize);
}
else
{
// Setting value type to null is defined to zero it out
memset(fieldAddress, 0, fieldSize);
}
}
else
{
Il2CppClass* nullableArg = Class::GetNullableArgument(fieldType);
uint32_t valueSize = Class::GetInstanceSize(nullableArg) - sizeof(Il2CppObject);
if (value != NULL)
{
memcpy(fieldAddress, Object::Unbox(value), valueSize);
*(fieldAddress + valueSize) = true;
}
else
{
*(fieldAddress + valueSize) = false;
}
}
}
else
{
memcpy(fieldAddress, &value, sizeof(Il2CppObject*));
}
}
Il2CppObject* MonoField::GetRawConstantValue(Il2CppReflectionField* field)
{
FieldInfo* fieldInfo = field->field;
if (!(fieldInfo->type->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT))
Exception::Raise(Exception::GetInvalidOperationException(NULL));
const Il2CppType* type = NULL;
const char* data = Class::GetFieldDefaultValue(fieldInfo, &type);
switch (type->type)
{
case IL2CPP_TYPE_U1:
case IL2CPP_TYPE_I1:
case IL2CPP_TYPE_BOOLEAN:
case IL2CPP_TYPE_U2:
case IL2CPP_TYPE_I2:
case IL2CPP_TYPE_CHAR:
case IL2CPP_TYPE_U4:
case IL2CPP_TYPE_I4:
case IL2CPP_TYPE_R4:
case IL2CPP_TYPE_U8:
case IL2CPP_TYPE_I8:
case IL2CPP_TYPE_R8:
{
Il2CppObject* obj = Object::New(Class::FromIl2CppType(type));
utils::BlobReader::GetConstantValueFromBlob(type->type, data, Object::Unbox(obj));
return obj;
}
case IL2CPP_TYPE_STRING:
case IL2CPP_TYPE_CLASS:
case IL2CPP_TYPE_OBJECT:
case IL2CPP_TYPE_GENERICINST:
{
Il2CppObject* obj = NULL;
utils::BlobReader::GetConstantValueFromBlob(type->type, data, &obj);
return obj;
}
default:
Exception::Raise(Exception::GetInvalidOperationException(StringUtils::Printf("Attempting to get raw constant value for field of type %d", type).c_str()));
}
return NULL;
}
#if NET_4_0
int32_t MonoField::get_core_clr_security_level(Il2CppObject* _this)
{
IL2CPP_NOT_IMPLEMENTED_ICALL(MonoField::get_core_clr_security_level);
IL2CPP_UNREACHABLE;
return 0;
}
Il2CppObject* MonoField::ResolveType(Il2CppObject* _this)
{
IL2CPP_NOT_IMPLEMENTED_ICALL(MonoField::ResolveType);
IL2CPP_UNREACHABLE;
return NULL;
}
#endif
} /* namespace Reflection */
} /* namespace System */
} /* namespace mscorlib */
} /* namespace icalls */
} /* namespace il2cpp */
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "invokeserviceimpl.h"
#include <cassert>
namespace vespalib {
InvokeServiceImpl::InvokeServiceImpl(duration napTime)
: _naptime(napTime),
_lock(),
_currId(0),
_closed(false),
_toInvoke(),
_thread()
{
}
InvokeServiceImpl::~InvokeServiceImpl()
{
{
std::lock_guard guard(_lock);
assert(_toInvoke.empty());
_closed = true;
}
if (_thread) {
_thread->join();
}
}
class InvokeServiceImpl::Registration : public IDestructorCallback {
public:
Registration(InvokeServiceImpl * service, uint64_t id) noexcept
: _service(service),
_id(id)
{ }
Registration(const Registration &) = delete;
Registration & operator=(const Registration &) = delete;
~Registration() override{
_service->unregister(_id);
}
private:
InvokeServiceImpl * _service;
uint64_t _id;
};
std::unique_ptr<IDestructorCallback>
InvokeServiceImpl::registerInvoke(VoidFunc func) {
std::lock_guard guard(_lock);
uint64_t id = _currId++;
_toInvoke.emplace_back(id, std::move(func));
if ( ! _thread) {
_thread = std::make_unique<std::thread>([this]() { runLoop(); });
}
return std::make_unique<Registration>(this, id);
}
void
InvokeServiceImpl::unregister(uint64_t id) {
std::lock_guard guard(_lock);
auto found = std::find_if(_toInvoke.begin(), _toInvoke.end(), [id](const std::pair<uint64_t, VoidFunc> & a) {
return id == a.first;
});
assert (found != _toInvoke.end());
_toInvoke.erase(found);
}
void
InvokeServiceImpl::runLoop() {
bool done = false;
while ( ! done ) {
{
std::lock_guard guard(_lock);
for (auto & func: _toInvoke) {
func.second();
}
done = _closed;
}
if ( ! done) {
std::this_thread::sleep_for(_naptime);
}
}
}
}
|
// Savestates 3.0
constant Buttons(0x80349C30)
constant MemoryStart(0x80339E00)
constant MemoryEnd(0x80360928)
constant MarioSlot(0x8036FDE8)
constant CamPointer(0x8033B860)
origin 0x0856E0
base 0x802CA6E0
scope Savestates: {
or v0, ra, r0
lui t0, 0x8033 // Temp register
lui t1, 0x8036 // Temp register
lui t2, 0x8042 // Temp register
lui t3, 0x8034 // Check buttons
lh t8, Buttons (t3) // Check buttons
Save:
ori t7, r0, 0x1000 // Save button(s)
and t9, t8, t7 // Save button check
lui a0, 0x8040 // Memory destination start (Save) 80400000
ori a1, t2, 0x6B28 // Memory destination end (Save) 80426B28
beq t9, t7, Copy // Branch to memory copy
ori a2, t0, MemoryStart // Memory source start (Save)
Load:
ori t7, r0, 0x000F // Load button(s)
and t9, t8, t7 // Load button check
ori a0, t0, MemoryStart // Memory destination start (Load)
ori a1, t1, MemoryEnd // Memory destination end (Load)
bne t9, t7, End // Branch to end if neither button(s) pressed
lui a2, 0x8040 // Memory source start (Load) 80400000
Check:
lw t4, 0x5FE8 (t2) // Mario slot pointer in state 80425FE8
lw t5, MarioSlot (t1) // Mario slot pointer
bne t5, t4, End // Branch to end if Mario slots don't match
Camera:
lw t6, CamPointer (t3)
sb r0, 0x0030 (t6)
Copy:
lw a3, $0000 (a2) // Memory copy
sw a3, $0000 (a0)
addiu a0, a0, 0x0004
bne a1, a0, Copy
addiu a2, a2, 0x0004
End:
jr v0
nop
}
|
#include "d3d9_format.h"
#include "../util/misc_helpers.h"
namespace dxup {
UINT bitsPerPixel(DXGI_FORMAT fmt) {
switch (fmt) {
case DXGI_FORMAT_R32G32B32A32_TYPELESS:
case DXGI_FORMAT_R32G32B32A32_FLOAT:
case DXGI_FORMAT_R32G32B32A32_UINT:
case DXGI_FORMAT_R32G32B32A32_SINT:
return 128;
case DXGI_FORMAT_R32G32B32_TYPELESS:
case DXGI_FORMAT_R32G32B32_FLOAT:
case DXGI_FORMAT_R32G32B32_UINT:
case DXGI_FORMAT_R32G32B32_SINT:
return 96;
case DXGI_FORMAT_R16G16B16A16_TYPELESS:
case DXGI_FORMAT_R16G16B16A16_FLOAT:
case DXGI_FORMAT_R16G16B16A16_UNORM:
case DXGI_FORMAT_R16G16B16A16_UINT:
case DXGI_FORMAT_R16G16B16A16_SNORM:
case DXGI_FORMAT_R16G16B16A16_SINT:
case DXGI_FORMAT_R32G32_TYPELESS:
case DXGI_FORMAT_R32G32_FLOAT:
case DXGI_FORMAT_R32G32_UINT:
case DXGI_FORMAT_R32G32_SINT:
case DXGI_FORMAT_R32G8X24_TYPELESS:
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
case DXGI_FORMAT_Y416:
case DXGI_FORMAT_Y210:
case DXGI_FORMAT_Y216:
return 64;
case DXGI_FORMAT_R10G10B10A2_TYPELESS:
case DXGI_FORMAT_R10G10B10A2_UNORM:
case DXGI_FORMAT_R10G10B10A2_UINT:
case DXGI_FORMAT_R11G11B10_FLOAT:
case DXGI_FORMAT_R8G8B8A8_TYPELESS:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_R8G8B8A8_SNORM:
case DXGI_FORMAT_R8G8B8A8_SINT:
case DXGI_FORMAT_R16G16_TYPELESS:
case DXGI_FORMAT_R16G16_FLOAT:
case DXGI_FORMAT_R16G16_UNORM:
case DXGI_FORMAT_R16G16_UINT:
case DXGI_FORMAT_R16G16_SNORM:
case DXGI_FORMAT_R16G16_SINT:
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_R32_UINT:
case DXGI_FORMAT_R32_SINT:
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP:
case DXGI_FORMAT_R8G8_B8G8_UNORM:
case DXGI_FORMAT_G8R8_G8B8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
case DXGI_FORMAT_B8G8R8A8_TYPELESS:
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
case DXGI_FORMAT_B8G8R8X8_TYPELESS:
case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB:
case DXGI_FORMAT_AYUV:
case DXGI_FORMAT_Y410:
case DXGI_FORMAT_YUY2:
//case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT:
//case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT:
//case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
return 32;
case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
//case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT:
//case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
//case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT:
//case WIN10_DXGI_FORMAT_V408:
return 24;
case DXGI_FORMAT_R8G8_TYPELESS:
case DXGI_FORMAT_R8G8_UNORM:
case DXGI_FORMAT_R8G8_UINT:
case DXGI_FORMAT_R8G8_SNORM:
case DXGI_FORMAT_R8G8_SINT:
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R16_FLOAT:
case DXGI_FORMAT_D16_UNORM:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_R16_UINT:
case DXGI_FORMAT_R16_SNORM:
case DXGI_FORMAT_R16_SINT:
case DXGI_FORMAT_B5G6R5_UNORM:
case DXGI_FORMAT_B5G5R5A1_UNORM:
case DXGI_FORMAT_A8P8:
case DXGI_FORMAT_B4G4R4A4_UNORM:
//case WIN10_DXGI_FORMAT_P208:
//case WIN10_DXGI_FORMAT_V208:
return 16;
case DXGI_FORMAT_NV12:
case DXGI_FORMAT_420_OPAQUE:
case DXGI_FORMAT_NV11:
return 12;
case DXGI_FORMAT_R8_TYPELESS:
case DXGI_FORMAT_R8_UNORM:
case DXGI_FORMAT_R8_UINT:
case DXGI_FORMAT_R8_SNORM:
case DXGI_FORMAT_R8_SINT:
case DXGI_FORMAT_A8_UNORM:
case DXGI_FORMAT_AI44:
case DXGI_FORMAT_IA44:
case DXGI_FORMAT_P8:
//case XBOX_DXGI_FORMAT_R4G4_UNORM:
return 8;
case DXGI_FORMAT_R1_UNORM:
return 1;
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
return 4;
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return 8;
default:
return 0;
}
}
UINT alignment(DXGI_FORMAT fmt) {
switch (fmt) {
case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
case DXGI_FORMAT_BC4_TYPELESS:
case DXGI_FORMAT_BC4_UNORM:
case DXGI_FORMAT_BC4_SNORM:
case DXGI_FORMAT_BC2_TYPELESS:
case DXGI_FORMAT_BC2_UNORM:
case DXGI_FORMAT_BC2_UNORM_SRGB:
case DXGI_FORMAT_BC3_TYPELESS:
case DXGI_FORMAT_BC3_UNORM:
case DXGI_FORMAT_BC3_UNORM_SRGB:
case DXGI_FORMAT_BC5_TYPELESS:
case DXGI_FORMAT_BC5_UNORM:
case DXGI_FORMAT_BC5_SNORM:
case DXGI_FORMAT_BC6H_TYPELESS:
case DXGI_FORMAT_BC6H_UF16:
case DXGI_FORMAT_BC6H_SF16:
case DXGI_FORMAT_BC7_TYPELESS:
case DXGI_FORMAT_BC7_UNORM:
case DXGI_FORMAT_BC7_UNORM_SRGB:
return 4;
default:
return 1;
}
}
uint32_t alignRectForFormat(bool down, DXGI_FORMAT format, uint32_t measure) {
UINT block = alignment(format);
if (down)
return alignDown(measure, block);
else
return alignTo(measure, block);
}
} |
; Internal library routine for openwindow, opentitled & openpopup
; 26/3/00 GWL
SECTION code_clib
PUBLIC opwin
include "stdio.def"
.opwin ld hl,windef
call_oz(gn_sop)
ld a,(ix+10) ; window ID
add a,'0'
call_oz(os_out)
ld a,(ix+8) ; tlx
add a,$20
call_oz(os_out)
ld a,(ix+6) ; tly
add a,$20
call_oz(os_out)
ld a,(ix+4) ; width
add a,$20
call_oz(os_out)
ld a,(ix+2) ; height
add a,$20
call_oz(os_out)
ld a,b ; type
call_oz(os_out)
ld hl,winclr
call_oz(gn_sop)
ld a,(ix+10)
add a,'0'
call_oz(os_out) ; clear & select window
ld hl,winmod
call_oz(gn_sop) ; set default modes
ret
.windef defb 1 ;wndow definer
defm "7#"
defb 0
.winclr defb 1 ;window clear + reset modes
defm "2C"
defb 0
.winmod defb 1 ;set default modes (cursor + scroll)
defm "3+CS"
defb 0
|
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, 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.
*/
L0:
(W&~f0.1)jmpi L416
L16:
mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud
add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC100:ud
mov (1|M0) r16.2<1>:ud 0xE000:ud
mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f
mov (1|M0) r17.3<1>:f r10.3<0;1,0>:f
send (1|M0) r96:uw r16:ub 0x2 a0.0
mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f
mov (1|M0) r17.3<1>:f r10.3<0;1,0>:f
send (1|M0) r104:uw r16:ub 0x2 a0.0
add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EC201:ud
mov (1|M0) r16.2<1>:ud 0xC000:ud
mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f
mov (1|M0) r17.3<1>:f r10.3<0;1,0>:f
send (1|M0) r100:uw r16:ub 0x2 a0.0
mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f
mov (1|M0) r17.3<1>:f r10.3<0;1,0>:f
send (1|M0) r108:uw r16:ub 0x2 a0.0
mov (16|M0) r98.0<1>:uw 0xFFFF:uw
mov (16|M0) r99.0<1>:uw 0xFFFF:uw
mov (16|M0) r106.0<1>:uw 0xFFFF:uw
mov (16|M0) r107.0<1>:uw 0xFFFF:uw
mov (1|M0) a0.8<1>:uw 0xC00:uw
mov (1|M0) a0.9<1>:uw 0xC80:uw
mov (1|M0) a0.10<1>:uw 0xCC0:uw
add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw
L416:
nop
|
//$Id$
//------------------------------------------------------------------------------
// SubscriberFactory
//------------------------------------------------------------------------------
// GMAT: General Mission Analysis Tool
//
// Copyright (c) 2002 - 2017 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration.
// All Other Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// http://www.apache.org/licenses/LICENSE-2.0.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language
// governing permissions and limitations under the License.
//
// Developed jointly by NASA/GSFC and Thinking Systems, Inc. under contract
// number S-67573-G
//
// Author: Wendy Shoan
// Created: 2003/10/22
//
/**
* Implementation code for the SubscriberFactory class, responsible for
* creating Subscriber objects.
*/
//------------------------------------------------------------------------------
#include "gmatdefs.hpp"
#include "Factory.hpp"
#include "SubscriberFactory.hpp"
#include "ReportFile.hpp"
#include "TextEphemFile.hpp"
#include "MessageWindow.hpp"
#include "OpenGlPlot.hpp"
#include "XyPlot.hpp"
#include "EphemerisFile.hpp"
#include "OrbitView.hpp"
#include "GroundTrackPlot.hpp"
#include "OwnedPlot.hpp"
//#include "LocatorView.hpp"
//---------------------------------
// public methods
//---------------------------------
//------------------------------------------------------------------------------
// CreateObject(const std::string &ofType, const std::string &withName)
//------------------------------------------------------------------------------
/**
* This method creates and returns an object of the requested Subscriber class
* in generic way.
*
* @param <ofType> the Subscriber object to create and return.
* @param <withName> the name to give the newly-created Subscriber object.
*
*/
//------------------------------------------------------------------------------
GmatBase* SubscriberFactory::CreateObject(const std::string &ofType,
const std::string &withName)
{
return CreateSubscriber(ofType, withName);
}
//------------------------------------------------------------------------------
// CreateSubscriber(const std::string &ofType, const std::string &withName)
//------------------------------------------------------------------------------
/**
* This method creates and returns an object of the requested Subscriber class
*
* @param <ofType> the Subscriber object to create and return.
* @param <withName> the name to give the newly-created Subscriber object.
*
*/
//------------------------------------------------------------------------------
Subscriber* SubscriberFactory::CreateSubscriber(const std::string &ofType,
const std::string &withName)
{
if (ofType == "ReportFile")
return new ReportFile(ofType, withName);
else if (ofType == "TextEphemFile")
return new TextEphemFile(ofType, withName);
else if (ofType == "MessageWindow")
return new MessageWindow(withName);
else if (ofType == "XYPlot")
return new XyPlot(withName);
else if (ofType == "EphemerisFile")
return new EphemerisFile(withName);
else if (ofType == "OpenGLPlot")
return new OrbitView(withName);
else if (ofType == "Enhanced3DView")
return new OrbitView(withName);
else if (ofType == "OrbitView")
return new OrbitView(withName);
else if (ofType == "GroundTrackPlot")
return new GroundTrackPlot(withName);
// These are "owned" Subscribers
else if (ofType == "OwnedPlot")
return new OwnedPlot(withName);
// else if (ofType == "LocatorView")
// return new LocatorView(withName);
return NULL;
}
//------------------------------------------------------------------------------
// SubscriberFactory()
//------------------------------------------------------------------------------
/**
* This method creates an object of the class SubscriberFactory
* (default constructor).
*
*
*/
//------------------------------------------------------------------------------
SubscriberFactory::SubscriberFactory() :
Factory(Gmat::SUBSCRIBER)
{
if (creatables.empty())
{
creatables.push_back("ReportFile");
creatables.push_back("TextEphemFile");
creatables.push_back("MessageWindow");
creatables.push_back("XYPlot");
creatables.push_back("EphemerisFile");
creatables.push_back("OpenGLPlot");
creatables.push_back("Enhanced3DView");
creatables.push_back("OrbitView");
creatables.push_back("GroundTrackPlot");
creatables.push_back("OwnedPlot");
// creatables.push_back("LocatorView");
}
// Now fill in unviewable subscribers
// We don't want to show these items in the ResourceTree menu
if (unviewables.empty())
{
// These commands do nothing
unviewables.push_back("OpenGLPlot");
unviewables.push_back("Enhanced3DView");
// These are managed by other objects rather than from the tree
// unviewables.push_back("LocatorView");
unviewables.push_back("OwnedPlot");
}
}
//------------------------------------------------------------------------------
// SubscriberFactory(StringArray createList)
//------------------------------------------------------------------------------
/**
* This method creates an object of the class SubscriberFactory
* (constructor).
*
* @param <createList> initial list of creatable objects for this factory.
*
*/
//------------------------------------------------------------------------------
SubscriberFactory::SubscriberFactory(StringArray createList) :
Factory(createList,Gmat::SUBSCRIBER)
{
}
//------------------------------------------------------------------------------
// SubscriberFactory(const SubscriberFactory& fact)
//------------------------------------------------------------------------------
/**
* This method creates an object of the class SubscriberFactory
* (copy constructor).
*
* @param <fact> the factory object to copy to "this" factory.
*/
//------------------------------------------------------------------------------
SubscriberFactory::SubscriberFactory(const SubscriberFactory& fact) :
Factory(fact)
{
}
//------------------------------------------------------------------------------
// SubscriberFactory& operator= (const SubscriberFactory& fact)
//------------------------------------------------------------------------------
/**
* Assignment operator for the SubscriberFactory class.
*
* @param <fact> the SubscriberFactory object whose data to assign to "this"
* factory.
*
* @return "this" SubscriberFactory with data of input factory fact.
*/
//------------------------------------------------------------------------------
SubscriberFactory& SubscriberFactory::operator= (const SubscriberFactory& fact)
{
Factory::operator=(fact);
return *this;
}
//------------------------------------------------------------------------------
// ~SubscriberFactory()
//------------------------------------------------------------------------------
/**
* Destructor for the SubscriberFactory base class.
*
*/
//------------------------------------------------------------------------------
SubscriberFactory::~SubscriberFactory()
{
// deletes handled by Factory destructor
}
|
; COPYRIGHT (c) 1995,99,2002 XDS. All Rights Reserved.
; Implementation for arctan2 & arctan2ll functions
cpu 386
bits 32
%ifdef OS2
group DGROUP _DATA
section _DATA use32 align=4 FLAT public 'DATA'
%else
group DGROUP _DATA
section _DATA use32 align=4 public 'DATA'
%endif
%ifdef OS2
section .text use32 align=4 FLAT public 'CODE'
%else
section .text use32 align=16 public 'CODE'
%endif
; assume cs: .text, ds: DGROUP, gs: nothing, fs: nothing
;PROCEDURE ["StdCall"] X2C_arctan2(y,x: REAL): REAL;
global X2C_arctan2
X2C_arctan2:
fld dword [esp+4] ; load "y"
fld dword [esp+8] ; load "x"
L0: fpatan
ret 8H
;X2C_arctan2 endp
;PROCEDURE ["StdCall] X2C_arctan(x: REAL): REAL
global X2C_arctan
X2C_arctan:
fld dword [esp+4]
fld1
fpatan
ret 4H
;X2C_arctan endp
;PROCEDURE ["StdCall"] X2C_arctan2l(y,x: LONGREAL): LONGREAL;
global X2C_arctan2l
X2C_arctan2l:
fld qword [esp+4] ; load "y"
fld qword [esp+0ch] ; load "x"
LL0: fpatan
ret 10H
;X2C_arctan2l endp
;PROCEDURE [2] X2C_arctanl(x: LONGREAL): LONGREAL
global X2C_arctanl
X2C_arctanl:
fld qword [esp+4]
fld1
fpatan
ret 8H
;X2C_arctanl endp
|
; A251366: Number of (n+1) X (1+1) 0..2 arrays with every 2 X 2 subblock summing to 1 2 3 4 5 6 or 7.
; Submitted by Jamie Morken(s4)
; 79,695,6113,53769,472943,4159927,36590017,321839625,2830847119,24899654327,219013164449,1926402895881,16944315318191,149039342816695,1310924949760897,11530674997804041,101421874630758607,892089722030697143,7846670898660887393,69017995243501979145,607070658238642044911,5339691232613650213303,46967024468579696020801,413114034376933119659529,3633681446295522829421839,31961249811002714472991415,281125768612090375589884193,2472734897573742006030013449,21749759560874568677369296943
add $0,3
mov $1,1
lpb $0
sub $0,1
mul $1,7
add $3,$1
add $2,$3
mov $1,$2
mov $2,$3
lpe
mov $0,$1
div $0,7
|
; A108872: Sums of ordinal references for a triangular table read by columns, top to bottom.
; 2,3,4,4,5,6,5,6,7,8,6,7,8,9,10,7,8,9,10,11,12,8,9,10,11,12,13,14,9,10,11,12,13,14,15,16,10,11,12,13,14,15,16,17,18,11,12,13,14,15,16,17,18,19,20,12,13,14,15,16,17,18,19,20,21,22,13,14,15,16,17,18,19,20,21,22,23,24,14,15,16,17,18,19,20,21,22,23,24,25,26,15,16,17,18,19,20,21,22,23,24,25,26,27,28,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41
lpb $0,1
sub $0,1
mov $2,$0
add $3,1
trn $0,$3
lpe
mov $1,$2
add $3,2
add $1,$3
|
; Reads input until return is pressed, storing it at X, null-terminating it,
; and returning X to its original location.
get_string:
pushx ; Store the original X for later
get_string_loop:
pushi 1 ; Set blocking mode
syscall GETCH ; Grab a keypress
swap ; The LSB is on the top of the stack, and we want the MSB
pushi 0 ; Check if printable
cmp
beq gs_handle_ascii ; Go add this character to the string
pop ; Pop the non-printable character
b get_string_loop
gs_handle_ascii:
dup ; Check if it's a newline
pushi 0x0D
cmp
beq gs_end_of_line ; If it's a newline we'll go return the string
gs_handle_char:
dup
syscall SETCH
pull [x+] ; Save the character and increment X
b get_string_loop
gs_end_of_line:
syscall SETCH
pushi 0 ; 0 terminate the string
pull [x]
pullx ; Restore X
rts
; Pseudocode
;get_string(x)
;{
; saved_x = x;
; word char;
; do
; {
; char = getch(blocking = 1); // syscall GETCH
; if (char.bytes[1] == 0)
; {
; setch(char.bytes[0]); // syscall SETCH
; memory[x++] = char.bytes[0];
; }
; } while (char[0] != '\n');
;
; memory[x] = 0;
;
; x = saved_x;
; return;
;}
|
#include <iostream>
#include "tools.h"
using Eigen::VectorXd;
using Eigen::MatrixXd;
using std::vector;
Tools::Tools() {}
Tools::~Tools() {}
VectorXd Tools::CalculateRMSE(const vector<VectorXd> &estimations,
const vector<VectorXd> &ground_truth) {
// Create an initial value of the rmse vector, set all values to zero
VectorXd rmse(4);
rmse << 0, 0, 0, 0;
// Estimations and ground truth need to match in terms of size
if (estimations.size() != ground_truth.size() || estimations.size() == 0) {
std::cout << "CalculateRMSE: Invalid estimation or ground_truth data" << std::endl;
return rmse;
}
// For each data point, calculate the residual and add to the rmse vector
for (unsigned int i = 0; i < estimations.size(); i++) {
VectorXd residual = estimations[i] - ground_truth[i];
residual = residual.array() * residual.array();
rmse += residual;
}
// Normalize and calculate square root to get the final rmse value
rmse = rmse / estimations.size();
rmse = rmse.array().sqrt();
return rmse;
}
MatrixXd Tools::CalculateJacobian(const VectorXd& x_state) {
MatrixXd Hj(3,4);
float px = x_state(0);
float py = x_state(1);
float vx = x_state(2);
float vy = x_state(3);
if (px == 0 && py == 0) {
// If both px and py are zero, we have division by zero, cannot proceed
std::cout << "CalculateJacobian: Division by zero" << std::endl;
} else {
// Calculate the Jacobian matrix based on the equations from the
// Udacity lectures on Extended Kalman Filter
Hj(0,2) = 0;
Hj(0,3) = 0;
Hj(1,2) = 0;
Hj(1,3) = 0;
float px_sq = px * px;
float py_sq = py * py;
float sum_sq = px_sq + py_sq;
float sqrt_sum_sq = sqrt(sum_sq);
float pow_sum_sq = pow(sum_sq, 1.5);
Hj(0,0) = px / sqrt_sum_sq;
Hj(0,1) = py / sqrt_sum_sq;
Hj(1,0) = -1 * py / sum_sq;;
Hj(1,1) = px / sum_sq;;
Hj(2,0) = py * (vx * py - vy * px) / pow_sum_sq;
Hj(2,1) = px * (vx * py + vy * px) / pow_sum_sq;
Hj(2,2) = Hj(0,0);
Hj(2,3) = Hj(0,1);
}
return Hj;
}
float Tools::NormalizeAngle(float angle) {
// Normalize angle to be in the range from
// -pi to +pi
while (angle > M_PI || angle < -1 * M_PI) {
if (angle > M_PI) {
// If angle > pi, deduct 2*pi
angle -= 2 * M_PI;
} else {
// If angle < -pi, add 2*pi
angle += 2 * M_PI;
}
}
return angle;
}
VectorXd Tools::CalculateRadarHFunction(const VectorXd& x_state) {
float px = x_state(0);
float py = x_state(1);
float vx = x_state(2);
float vy = x_state(3);
// Calculate translaion from the state vector to the radar coordinates
float rho = sqrt(px * px + py * py);
float phi = atan2(py, px);
float rho_dot = (px * vx + py * vy) / rho;
// Normalize the angle phi to be within the range -pi to +pi
float phi_norm = this->NormalizeAngle(phi);
VectorXd h = VectorXd(3);
h << rho, phi_norm, rho_dot;
return h;
}
void Tools::PrintDebug(const std::string s) {
// Print the string if the debug flag is set to true, otherwise do nothing
if (Tools::print_flag_ == true) {
std::cout << s << std::endl;
}
}
void Tools::PrintDebugMatrix(const std::string s, const MatrixXd mat) {
// Print the matrix if the debug flag is set to true, otherwise do nothing
if (Tools::print_flag_ == true) {
std::cout << s << ":" << std::endl << mat << std::endl;
}
}
void Tools::PrintDebugVector(const std::string s, const VectorXd vec) {
// Print the vector if the debug flag is set to true, otherwise do nothing
if (Tools::print_flag_ == true) {
std::cout << s << ":" << std::endl << vec << std::endl;
}
}
|
.size 8000
.data@0
01
.text@48
jp ff81
.data@9c
02 03 04 05
.text@100
jp lbegin
.data@143
80 00 00 00 1a 00 03
.text@150
lbegin:
ld hl, ff81
ld a, 0e
ld(hl++), a
ld a, 37
ld(hl++), a
ld a, 3e
ld(hl++), a
ld a, ff
ld(hl++), a
ld a, e0
ld(hl++), a
ld a, 46
ld(hl++), a
ld a, 0d
ld(hl++), a
ld a, 20
ld(hl++), a
ld a, fd
ld(hl++), a
xor a, a
ld(hl++), a
ld(hl++), a
ld a, fa
ld(hl++), a
ld a, 45
ld(hl++), a
ld a, fe
ld(hl++), a
ld a, 3c
ld(hl++), a
ld a, e0
ld(hl++), a
ld a, 80
ld(hl++), a
ld a, 0e
ld(hl++), a
ld a, 28
ld(hl++), a
ld a, 0d
ld(hl++), a
ld a, 20
ld(hl++), a
ld a, fd
ld(hl++), a
ld a, c3
ld(hl++), a
xor a, a
ld(hl++), a
ld a, 70
ld(hl++), a
ld b, 90
call lwaitly_b
ld a, 0a
ld(0000), a
ld a, 01
ld(8000), a
ld hl, c09c
inc a
ld(hl++), a
inc a
ld(hl++), a
inc a
ld(hl++), a
inc a
ld(hl++), a
ld hl, fe00
ld c, a0
ld a, 06
lbegin_fill_oam:
ld(hl++), a
dec c
jrnz lbegin_fill_oam
ld a, 90
ldff(45), a
ld a, 40
ldff(41), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ei
ld a, 01
ld(a000), a
ld(ff00), a
halt
.text@7000
lprint_ff80:
ld b, 91
call lwaitly_b
xor a, a
ldff(40), 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
ldff a, (80)
ld(9800), a
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 2019 Zhihao Zhang License MIT
#ifndef SHAPE_BASE_HPP_
#define SHAPE_BASE_HPP_
#include "interfaces.hpp"
#include "visualization_msgs/msg/marker.hpp"
#include "visualization_msgs/msg/marker_array.hpp"
#include <iostream>
#include <memory>
#include <string>
#include <tuple>
#include <vector>
namespace shapes {
// ReSharper disable once CppClassCanBeFinal
class ShapeBase : public ShapeCommonInterface {
public:
explicit ShapeBase(int id);
protected:
ZAxis heading_;
std::string parent_frame_name_;
std::shared_ptr<std::vector<visualization_msgs::msg::Marker>>
shapes_list_ptr_;
auto resize_imple(AllAxis new_size) -> void override;
auto rescale_imple(AnyAxis factor) -> void override;
auto set_colour_imple(Colour c) -> void override;
[[nodiscard]] auto get_colour_imple() const -> Colour override;
auto set_parent_frame_name_imple(std::string frame_name) -> void override;
[[nodiscard]] auto get_location_imple() const
-> std::tuple<XAxis, YAxis, ZAxis> override;
auto move_to_imple(XAxis) -> void override;
auto move_to_imple(YAxis) -> void override;
auto move_to_imple(ZAxis) -> void override;
auto move_to_imple(XAxis, YAxis, ZAxis) -> void override;
auto move_by_imple(XAxis) -> void override;
auto move_by_imple(YAxis) -> void override;
auto move_by_imple(ZAxis) -> void override;
auto move_by_imple(XAxis, YAxis, ZAxis) -> void override;
auto get_display_markers_imple()
-> std::shared_ptr<std::vector<visualization_msgs::msg::Marker>> override;
auto rotate_about_axis_to_imple(ZAxis radians) -> void override;
[[nodiscard]] auto get_orientation_imple() const -> ZAxis override;
auto create_shape_base(int id, std::int32_t type)
-> visualization_msgs::msg::Marker;
};
} // namespace shapes
#endif // SHAPE_BASE_HPP_
|
SFX_Shrink_1_Ch5:
duty_cycle 1
pitch_sweep 1, 7
square_note 15, 13, 7, 1536
square_note 15, 11, 7, 1408
square_note 15, 8, 7, 1280
square_note 15, 4, 7, 1152
square_note 15, 1, 7, 1024
pitch_sweep 0, 8
sound_ret
|
; A168667: a(n) = n^7*(n^10 + 1)/2.
; 0,1,65600,64571175,8589942784,381469765625,8463329862336,116315257405375,1125899907891200,8338590852224769,50000000005000000,252723514259390471,1109305553388134400,4325207959722043225,15245673364718304704,49263062667932109375,147573952589810630656,413620130943373551425,1092955779869654376000,2740193428892848028839,6553600000000640000000,15020971247541746491641,33124976459730963755200,70525019780333186875775,145398897491343571943424,291038304567340087890625,566913657692579378682176
mov $1,$0
pow $0,7
mov $2,$1
pow $2,10
mul $2,$0
add $0,$2
div $0,2
|
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
| See: http://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See details in http://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#include "img-precomp.h" // Precompiled headers
#include <mrpt/img/CMappedImage.h>
#include <mrpt/core/round.h>
using namespace mrpt;
using namespace mrpt::img;
using namespace mrpt::math;
/*---------------------------------------------------------------
Constructor
---------------------------------------------------------------*/
CMappedImage::CMappedImage(
CImage::Ptr img, double x0, double x1, double y0, double y1,
TInterpolationMethod method)
: m_img(img),
m_x0(x0),
m_x1(x1),
m_y0(y0),
m_y1(y1),
m_pixel_size(0),
m_method(method)
{
m_img->grayscale();
if (m_img->isColor())
{
auto* new_img = new CImage();
m_img->grayscale(*new_img);
m_img = CImage::Ptr(new_img);
}
changeCoordinates(x0, x1, y0, y1);
}
/*---------------------------------------------------------------
changeCoordinates
---------------------------------------------------------------*/
void CMappedImage::changeCoordinates(double x0, double x1, double y0, double y1)
{
MRPT_START
ASSERT_(x0 != x1);
ASSERT_(y0 != y1);
m_x0 = x0;
m_x1 = x1;
m_y0 = y0;
m_y1 = y1;
if (y1 < 0 || x1 < 0)
{
m_x1 = m_img->getWidth() - 1;
m_y1 = m_img->getHeight() - 1;
}
ASSERT_(m_img->getWidth() > 0 && m_img->getHeight());
m_pixel_size = (m_x1 - m_x0) / m_img->getWidth();
MRPT_END
}
/*---------------------------------------------------------------
getPixel
---------------------------------------------------------------*/
double CMappedImage::getPixel(double x, double y) const
{
// Image size:
const size_t W = m_img->getWidth();
const size_t H = m_img->getHeight();
// the sub-pixel pixel coordinates:
const double px = (x - m_x0) / m_pixel_size;
const double py = (y - m_y0) / m_pixel_size;
if (px < 0 || py < 0 || px > W || py > H)
{
return 0;
} // Out of image
switch (m_method)
{
case IMG_INTERP_NN:
{
// The closest pixel:
const unsigned int px0 = mrpt::round(px);
const unsigned int py0 = mrpt::round(py);
return static_cast<double>((*m_img).at<uint8_t>(px0, py0));
}
break;
case IMG_INTERP_LINEAR:
{
// See: http://en.wikipedia.org/wiki/Bilinear_interpolation
// The four pixels around:
const int px0 = (int)floor(px);
const int px1 = (int)ceil(px);
const int py0 = (int)floor(py);
const int py1 = (int)ceil(py);
const auto P11 =
static_cast<double>((*m_img).at<uint8_t>(px0, py0));
const auto P12 =
static_cast<double>((*m_img).at<uint8_t>(px0, py1));
const auto P21 =
static_cast<double>((*m_img).at<uint8_t>(px1, py0));
const auto P22 =
static_cast<double>((*m_img).at<uint8_t>(px1, py1));
const double R1 = P11 * (px1 - px) /* /(px1-px0)*/ +
P21 * (px - px0) /* /(px1-px0) */;
const double R2 = P12 * (px1 - px) /* /(px1-px0)*/ +
P22 * (px - px0) /* /(px1-px0) */;
return R1 * (py1 - py) + R2 * (py - py0);
}
break;
case IMG_INTERP_CUBIC:
case IMG_INTERP_AREA:
default:
THROW_EXCEPTION(
"The selected interpolation method is not supported in this "
"method.");
};
}
|
/*
* Copyright (c) 2003-2021 Rony Shapiro <ronys@pwsafe.org>.
* All rights reserved. Use of the code is allowed under the
* Artistic License 2.0 terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
/** \file MenuViewHandlers.cpp
* This file contains implementations of PasswordSafeFrame
* member functions corresponding to actions under the 'View'
* menubar menu.
*/
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#ifdef __WXMSW__
#include <wx/msw/msvcrt.h>
#endif
#include "core/core.h"
#include "core/PWSprefs.h"
#include "core/StringX.h"
#include "DragBarCtrl.h"
#include "GridCtrl.h"
#include "PasswordSafeFrame.h"
#include "PasswordSafeSearch.h"
#include "TreeCtrl.h"
#include "ViewReportDlg.h"
#include "core/PWSFilters.h"
#include "SetFiltersDlg.h"
#include "ManageFiltersDlg.h"
void PasswordSafeFrame::OnChangeToolbarType(wxCommandEvent& evt)
{
//This assumes the menu item is checked before it comes here
if (GetMenuBar()->IsChecked(evt.GetId())) {
PWSprefs::GetInstance()->SetPref(PWSprefs::UseNewToolbar, evt.GetId() == ID_TOOLBAR_NEW);
RefreshToolbarButtons();
DragBarCtrl* dragbar = GetDragBar();
wxCHECK_RET(dragbar, wxT("Could not find dragbar"));
dragbar->RefreshButtons();
wxCHECK_RET(m_search, wxT("Search object not created as expected"));
m_search->RefreshButtons();
}
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_LIST_VIEW
*/
void PasswordSafeFrame::OnListViewClick(wxCommandEvent& WXUNUSED(evt))
{
PWSprefs::GetInstance()->SetPref(PWSprefs::LastView, _T("list"));
// Unregister the active view at core to not get notifications anymore
m_core.UnregisterObserver(m_tree);
ShowTree(false);
ShowGrid(true);
SetViewType(ViewType::GRID);
// Register view at core as new observer for notifications
m_core.RegisterObserver(m_grid);
UpdateTreeSortMenu();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_TREE_VIEW
*/
void PasswordSafeFrame::OnTreeViewClick(wxCommandEvent& WXUNUSED(evt))
{
PWSprefs::GetInstance()->SetPref(PWSprefs::LastView, _T("tree"));
// Unregister the active view at core to not get notifications anymore
m_core.UnregisterObserver(m_grid);
ShowGrid(false);
ShowTree(true);
SetViewType(ViewType::TREE);
// Register view at core as new observer for notifications
m_core.RegisterObserver(m_tree);
UpdateTreeSortMenu();
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_SORT_TREE_BY_GROUP
*/
void PasswordSafeFrame::OnSortByGroupClick(wxCommandEvent& WXUNUSED(evt))
{
const TreeSortType oldSortType = m_currentSort;
PWSprefs::GetInstance()->SetPref(PWSprefs::TreeSort, _T("group"));
SetTreeSortType(TreeSortType::GROUP);
UpdateTreeSortMenu();
m_tree->SetSortingGroup();
m_tree->SetShowGroup(false);
if (oldSortType != m_currentSort) {
ShowTree(IsTreeView());
}
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_SORT_TREE_BY_NAME
*/
void PasswordSafeFrame::OnSortByNameClick(wxCommandEvent& WXUNUSED(evt))
{
const TreeSortType oldSortType = m_currentSort;
PWSprefs::GetInstance()->SetPref(PWSprefs::TreeSort, _T("name"));
SetTreeSortType(TreeSortType::NAME);
UpdateTreeSortMenu();
m_tree->SetSortingName();
m_tree->SetShowGroup(true);
if (oldSortType != m_currentSort) {
ShowTree(IsTreeView());
}
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_SORT_TREE_BY_DATE
*/
void PasswordSafeFrame::OnSortByDateClick(wxCommandEvent& WXUNUSED(evt))
{
const TreeSortType oldSortType = m_currentSort;
PWSprefs::GetInstance()->SetPref(PWSprefs::TreeSort, _T("date"));
SetTreeSortType(TreeSortType::DATE);
UpdateTreeSortMenu();
m_tree->SetSortingDate();
m_tree->SetShowGroup(true);
if (oldSortType != m_currentSort) {
ShowTree(IsTreeView());
}
}
/*!
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_SHOW_EMPTY_GROUP_IN_FILTER
*/
void PasswordSafeFrame::OnShowGroupInFilterClick(wxCommandEvent& WXUNUSED(evt))
{
m_bShowEmptyGroupsInFilter = !m_bShowEmptyGroupsInFilter; // Toggle value
GetMenuBar()->Check(ID_SHOW_EMPTY_GROUP_IN_FILTER, m_bShowEmptyGroupsInFilter);
if(IsTreeView())
ShowTree();
}
void PasswordSafeFrame::OnExpandAll(wxCommandEvent& WXUNUSED(evt))
{
wxASSERT(IsTreeView());
if (!m_tree->IsEmpty()) {
m_tree->ExpandAll();
}
}
void PasswordSafeFrame::OnCollapseAll(wxCommandEvent& WXUNUSED(evt))
{
wxASSERT(IsTreeView());
if (m_tree->IsEmpty()) {
return;
}
//we cannot just call wxTreeCtrl::CollapseAll(), since it tries to
//collapse the invisible root item also, and thus ASSERTs
wxTreeItemIdValue cookie;
for ( wxTreeItemId root = m_tree->GetRootItem(), idCurr = m_tree->GetFirstChild(root, cookie);
idCurr.IsOk();
idCurr = m_tree->GetNextChild(root, cookie) )
{
m_tree->CollapseAllChildren(idCurr);
}
}
void PasswordSafeFrame::OnChangeTreeFont(wxCommandEvent& WXUNUSED(evt))
{
ChangeFontPreference(PWSprefs::TreeFont);
}
void PasswordSafeFrame::OnChangeAddEditFont(wxCommandEvent& WXUNUSED(evt))
{
ChangeFontPreference(PWSprefs::AddEditFont);
}
void PasswordSafeFrame::OnChangePasswordFont(wxCommandEvent& WXUNUSED(evt))
{
ChangeFontPreference(PWSprefs::PasswordFont);
}
void PasswordSafeFrame::OnChangeNotesFont(wxCommandEvent& WXUNUSED(evt))
{
ChangeFontPreference(PWSprefs::NotesFont);
}
void PasswordSafeFrame::OnChangeVirtualKeyboardFont(wxCommandEvent& WXUNUSED(evt))
{
ChangeFontPreference(PWSprefs::VKeyboardFontName);
}
void PasswordSafeFrame::RunShowReport(int iAction)
{
CReport rpt;
rpt.StartReport(iAction, m_core.GetCurFile().c_str(), false);
if(rpt.ReadFromDisk()) {
ViewReportDlg dlg(this, &rpt, true);
dlg.ShowModal();
}
else {
wxString tcAction = CReport::ReportNames.find(iAction)->second;
wxMessageBox(_(tcAction) + _(L" file \'") + rpt.GetFileName() + _(L"' not readable"), _("View Report"), wxOK|wxICON_ERROR);
}
}
void PasswordSafeFrame::OnShowReportSynchronize(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTSYNCH);
}
void PasswordSafeFrame::OnShowReportCompare(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTCOMPARE);
}
void PasswordSafeFrame::OnShowReportMerge(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTMERGE);
}
void PasswordSafeFrame::OnShowReportImportText(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTIMPORTTEXT);
}
void PasswordSafeFrame::OnShowReportImportXML(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTIMPORTXML);
}
void PasswordSafeFrame::OnShowReportImportKeePassV1_TXT(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTIMPORTKPV1TXT);
}
void PasswordSafeFrame::OnShowReportImportKeePassV1_CSV(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTIMPORTKPV1CSV);
}
void PasswordSafeFrame::OnShowReportExportText(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTEXPORTTEXT);
}
void PasswordSafeFrame::OnShowReportExportXML(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTEXPORTXML);
}
void PasswordSafeFrame::OnShowReportExportDB(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTEXPORTDB);
}
void PasswordSafeFrame::OnShowReportFind(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTFIND);
}
void PasswordSafeFrame::OnShowReportValidate(wxCommandEvent& WXUNUSED(evt))
{
RunShowReport(IDSC_RPTVALIDATE);
}
void PasswordSafeFrame::OnShowHideToolBar(wxCommandEvent& evt)
{
GetToolBar()->Show(evt.IsChecked());
PWSprefs::GetInstance()->SetPref(PWSprefs::ShowToolbar, evt.IsChecked());
DoLayout();
SendSizeEvent();
}
void PasswordSafeFrame::OnShowHideDragBar(wxCommandEvent& evt)
{
DragBarCtrl* dragbar = GetDragBar();
wxCHECK_RET(dragbar, wxT("Could not find dragbar"));
dragbar->Show(evt.IsChecked());
PWSprefs::GetInstance()->SetPref(PWSprefs::ShowDragbar, evt.IsChecked());
DoLayout();
}
//-----------------------------------------------------------------
// Filters related
// (Starting with predefined filters)
//-----------------------------------------------------------------
void PasswordSafeFrame::OnShowAllExpiryClick( wxCommandEvent& event )
{
if (!(m_CurrentPredefinedFilter == NONE || m_CurrentPredefinedFilter == EXPIRY))
return; // should be disabled - we support only one predefined at a time
bool showExpiry = event.IsChecked();
m_CurrentPredefinedFilter = showExpiry ? EXPIRY : NONE;
m_bFilterActive = showExpiry;
if (showExpiry) {
CurrentFilter() = m_FilterManager.GetExpireFilter();
// Entries with Expiry date iterates on entries only
m_bShowEmptyGroupsInFilter = false;
} else {
CurrentFilter().Empty();
// Set back to default value at end of filter
m_bShowEmptyGroupsInFilter = false;
}
GetMenuBar()->Check(ID_SHOW_EMPTY_GROUP_IN_FILTER, m_bShowEmptyGroupsInFilter);
GetMenuBar()->Refresh();
ApplyFilters();
}
void PasswordSafeFrame::OnShowUnsavedEntriesClick( wxCommandEvent& event )
{
if (!(m_CurrentPredefinedFilter == NONE || m_CurrentPredefinedFilter == UNSAVED))
return; // should be disabled - we support only one predefined at a time
bool showUnsaved = event.IsChecked();
m_CurrentPredefinedFilter = showUnsaved ? UNSAVED : NONE;
m_bFilterActive = showUnsaved;
if (showUnsaved) {
CurrentFilter() = m_FilterManager.GetUnsavedFilter();
// Unsaved Entries might include groups, set show groups by default
m_bShowEmptyGroupsInFilter = false;
} else {
CurrentFilter().Empty();
// Set back to default value at end of filter
m_bShowEmptyGroupsInFilter = false;
}
GetMenuBar()->Check(ID_SHOW_EMPTY_GROUP_IN_FILTER, m_bShowEmptyGroupsInFilter);
GetMenuBar()->Refresh();
ApplyFilters();
}
void PasswordSafeFrame::OnShowLastFindClick( wxCommandEvent& event )
{
if (!(m_CurrentPredefinedFilter == NONE || m_CurrentPredefinedFilter == LASTFIND))
return; // should be disabled - we support only one predefined at a time
bool showLastFind = event.IsChecked();
m_CurrentPredefinedFilter = showLastFind ? LASTFIND : NONE;
m_FilterManager.SetFindFilter(showLastFind);
m_bFilterActive = showLastFind;
if (showLastFind) {
CurrentFilter() = m_FilterManager.GetFoundFilter();
// Last Find iterates on entries only
m_bShowEmptyGroupsInFilter = false;
} else {
CurrentFilter().Empty();
// Set back to default value at end of filter
m_bShowEmptyGroupsInFilter = false;
}
GetMenuBar()->Check(ID_SHOW_EMPTY_GROUP_IN_FILTER, m_bShowEmptyGroupsInFilter);
GetMenuBar()->Refresh();
ApplyFilters();
}
void PasswordSafeFrame::ApplyFilters()
{
m_FilterManager.CreateGroups();
// Update and setting of filter state is not needed here, as update is done at the end of RefreshView()
RefreshViews();
}
void PasswordSafeFrame::OnEditFilter(wxCommandEvent& )
{
st_filters filters(CurrentFilter());
bool bCanHaveAttachments = m_core.GetNumAtts() > 0;
const std::set<StringX> sMediaTypes = m_core.GetAllMediaTypes();
bool bAppliedCalled;
stringT oldName = CurrentFilter().fname;
st_Filterkey fk;
bool bDoEdit = true;
while(bDoEdit) {
bDoEdit = false; // In formal case we run only one time in the loop; but when removal of double entry is requested we avoid goto
SetFiltersDlg dlg(this, &filters, &CurrentFilter(), &bAppliedCalled, DFTYPE_MAIN, FPOOL_SESSION, bCanHaveAttachments, &sMediaTypes);
int rc = dlg.ShowModal();
if (rc == wxID_OK || (rc == wxID_CANCEL && bAppliedCalled)) {
// User can apply the filter in SetFiltersDlg and then press Cancel button
// and afterwards process changes, update only on OK button and continue with actualized version
if(rc == wxID_OK) {
CurrentFilter().Empty();
CurrentFilter() = filters;
}
// Update pre-defined filter, if present
wxMenuBar* menuBar = GetMenuBar();
if(CurrentFilter() == m_FilterManager.GetExpireFilter()) {
m_CurrentPredefinedFilter = EXPIRY;
menuBar->Check(ID_SHOW_ALL_EXPIRY, true);
menuBar->Check(ID_SHOWHIDE_UNSAVED, false);
menuBar->Check(ID_SHOW_LAST_FIND_RESULTS, false);
} else if(CurrentFilter() == m_FilterManager.GetUnsavedFilter()) {
m_CurrentPredefinedFilter = UNSAVED;
menuBar->Check(ID_SHOW_ALL_EXPIRY, false);
menuBar->Check(ID_SHOWHIDE_UNSAVED, true);
menuBar->Check(ID_SHOW_LAST_FIND_RESULTS, false);
} else if(CurrentFilter() == m_FilterManager.GetFoundFilter()) {
m_CurrentPredefinedFilter = LASTFIND;
menuBar->Check(ID_SHOW_ALL_EXPIRY, false);
menuBar->Check(ID_SHOWHIDE_UNSAVED, false);
menuBar->Check(ID_SHOW_LAST_FIND_RESULTS, true);
} else {
m_CurrentPredefinedFilter = NONE;
menuBar->Check(ID_SHOW_ALL_EXPIRY, false);
menuBar->Check(ID_SHOWHIDE_UNSAVED, false);
menuBar->Check(ID_SHOW_LAST_FIND_RESULTS, false);
}
// Update filter in Filters map
fk.fpool = FPOOL_SESSION;
fk.cs_filtername = CurrentFilter().fname;
PWSFilters::iterator mf_iter = m_MapAllFilters.find(fk);
// When entry already in map and had been new or name changed
if(mf_iter != m_MapAllFilters.end() && (oldName.empty() || (oldName != CurrentFilter().fname) || (m_currentfilterpool != FPOOL_SESSION))) {
wxMessageDialog dialog(this, _("This filter already exists"), _("Do you wish to replace it?"), wxYES_NO | wxICON_EXCLAMATION);
if(dialog.ShowModal() == wxID_NO) {
bDoEdit = true; // Repeat editing to allow name change
continue;
}
}
}
// Erase entry and add again with actual content
m_MapAllFilters.erase(fk);
m_MapAllFilters.insert(PWSFilters::Pair(fk, CurrentFilter()));
m_currentfilterpool = fk.fpool;
m_selectedfiltername = fk.cs_filtername.c_str();
// If filters currently active - update and re-apply
if (m_bFilterActive) {
m_bFilterActive = CurrentFilter().IsActive();
ApplyFilters();
}
}
}
void PasswordSafeFrame::OnApplyFilter(wxCommandEvent& event)
{
wxMenuBar* menuBar = GetMenuBar();
wxString par = event.GetString(); // From Edit/New filter dialog a string is set
// Toggle filter Apply / Clear, when not called from Edit/New filter -> while perform apply always
if(m_bFilterActive && par.IsEmpty()) {
m_bFilterActive = false;
if(m_CurrentPredefinedFilter == EXPIRY) {
menuBar->Check(ID_SHOW_ALL_EXPIRY, false);
CurrentFilter().Empty();
} else if (m_CurrentPredefinedFilter == UNSAVED) {
menuBar->Check(ID_SHOWHIDE_UNSAVED, false);
CurrentFilter().Empty();
} else if (m_CurrentPredefinedFilter == LASTFIND) {
menuBar->Check(ID_SHOW_LAST_FIND_RESULTS, false);
CurrentFilter().Empty();
}
m_CurrentPredefinedFilter = NONE;
m_ApplyClearFilter->SetItemLabel(_("&Apply current"));
}
else {
m_bFilterActive = CurrentFilter().IsActive();
m_ApplyClearFilter->SetItemLabel(_("&Clear current"));
if(par.CompareTo(pwManageFiltersTable::getSourcePoolLabel(FPOOL_DATABASE).c_str()) == 0) {
m_currentfilterpool = FPOOL_DATABASE;
}
else if(par.CompareTo(pwManageFiltersTable::getSourcePoolLabel(FPOOL_AUTOLOAD).c_str()) == 0) {
m_currentfilterpool = FPOOL_AUTOLOAD;
}
else if(par.CompareTo(pwManageFiltersTable::getSourcePoolLabel(FPOOL_IMPORTED).c_str()) == 0) {
m_currentfilterpool = FPOOL_IMPORTED;
}
else if(par.CompareTo(pwManageFiltersTable::getSourcePoolLabel(FPOOL_SESSION).c_str()) == 0) {
m_currentfilterpool = FPOOL_SESSION;
}
m_selectedfiltername = CurrentFilter().fname;
}
// Update menu
menuBar->Refresh();
// Update shown items
ApplyFilters();
// If Apply called from Edit/New Filter or Manage Filter expand tree view
if(! par.IsEmpty()) {
if(IsTreeView() && !m_tree->IsEmpty()) {
m_tree->ExpandAll();
}
}
}
// functor for Copy subset of map entries back to the database
struct CopyDBFilters {
CopyDBFilters(PWSFilters &core_mapFilters) :
m_CoreMapFilters(core_mapFilters)
{}
// operator
void operator()(std::pair<const st_Filterkey, st_filters> p)
{
m_CoreMapFilters.insert(PWSFilters::Pair(p.first, p.second));
}
private:
PWSFilters &m_CoreMapFilters;
};
void PasswordSafeFrame::OnManageFilters(wxCommandEvent& )
{
st_Filterkey fkl, fku;
PWSFilters::iterator mf_iter, mf_lower_iter, mf_upper_iter;
// Search range for data base filters
fkl.fpool = FPOOL_DATABASE;
fkl.cs_filtername = L"";
fku.fpool = (FilterPool)((int)FPOOL_DATABASE + 1);
fku.cs_filtername = L"";
// Find & delete DB filters only
if(!m_MapAllFilters.empty()) {
mf_lower_iter = m_MapAllFilters.lower_bound(fkl);
// Check that there are some first!
if (mf_lower_iter->first.fpool == FPOOL_DATABASE) {
// Now find upper bound of database filters
mf_upper_iter = m_MapAllFilters.upper_bound(fku);
// Delete existing database filters (if any)
m_MapAllFilters.erase(mf_lower_iter, mf_upper_iter);
}
}
// Get current core filters
PWSFilters core_filters = m_core.GetDBFilters();
const PWSFilters original_core_filters = m_core.GetDBFilters();
// Now add any existing database filters
for(mf_iter = core_filters.begin();
mf_iter != core_filters.end(); mf_iter++) {
m_MapAllFilters.insert(PWSFilters::Pair(mf_iter->first, mf_iter->second));
}
bool bCanHaveAttachments = m_core.GetNumAtts() > 0;
const std::set<StringX> sMediaTypes = m_core.GetAllMediaTypes();
ManageFiltersDlg dlg(this, &m_core, m_MapAllFilters, &CurrentFilter(), &m_currentfilterpool, &m_selectedfiltername, &m_bFilterActive, bCanHaveAttachments, &sMediaTypes, m_core.IsReadOnly());
int rc = dlg.ShowModal();
// No change in DB filter when return ID_CANCEL
if(rc == wxID_CANCEL)
return;
// Clear core filters ready to replace with new ones
core_filters.clear();
// Get DB filters populated via CManageFiltersDlg
if(!m_MapAllFilters.empty()) {
mf_lower_iter = m_MapAllFilters.lower_bound(fkl);
// Check that there are some first!
if(mf_lower_iter->first.fpool == FPOOL_DATABASE) {
// Now find upper bound of database filters
mf_upper_iter = m_MapAllFilters.upper_bound(fku);
// Copy database filters (if any) to the core
CopyDBFilters copy_db_filters(core_filters);
for_each(mf_lower_iter, mf_upper_iter, copy_db_filters);
}
}
// However, we need to check as user may have edited the filter more than once
// and reverted any changes!
if(core_filters != original_core_filters) {
// Now update DB filters in core
Command *pcmd = DBFiltersCommand::Create(&m_core, core_filters);
// Do it
Execute(pcmd);
}
}
|
#include <iostream>
#include <tins/tins.h>
using namespace Tins;
using namespace std;
bool callback(const PDU &pdu) {
// Find the IP layer
const IP &ip = pdu.rfind_pdu<IP>();
// Find the TCP layer
const TCP &tcp = pdu.rfind_pdu<TCP>();
cout << ip.src_addr() << ':' << tcp.sport() << " -> " << ip.dst_addr() << ':' << tcp.dport() << endl;
return true;
}
int main() {
cout << "Starting..."<< endl;
Sniffer("docker0").sniff_loop(callback);
}
|
; A286577: If n = 3k-1 then a(n) = a(k), otherwise a(n) = n.
; 0,1,1,3,4,1,6,7,3,9,10,4,12,13,1,15,16,6,18,19,7,21,22,3,24,25,9,27,28,10,30,31,4,33,34,12,36,37,13,39,40,1,42,43,15,45,46,16,48,49,6,51,52,18,54,55,19,57,58,7,60,61,21,63,64,22,66,67,3,69,70,24,72,73,25,75,76,9,78,79,27,81,82,28,84,85,10,87,88,30,90,91,31,93,94,4,96,97,33,99,100,34,102,103,12,105,106,36,108,109,37,111,112,13,114,115,39,117,118,40,120,121,1,123,124,42,126,127,43,129,130,15,132,133,45,135,136,46,138,139,16,141,142,48,144,145,49,147,148,6,150,151,51,153,154,52,156,157,18,159,160,54,162,163,55,165,166,19,168,169,57,171,172,58,174,175,7,177,178,60,180,181,61,183,184,21,186,187,63,189,190,64,192,193,22,195,196,66,198,199,67,201,202,3,204,205,69,207,208,70,210,211,24,213,214,72,216,217,73,219,220,25,222,223,75,225,226,76,228,229,9,231,232,78,234,235,79,237,238,27,240,241,81,243,244,82,246,247,28,249
lpb $0
add $0,1
dif $0,3
lpe
mov $1,$0
|
_test_sema: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
void test_func2(void *arg);
struct Semaphore s;
int var = 7;
int var1 = 8;
int main(){
1000: 55 push %ebp
1001: 89 e5 mov %esp,%ebp
1003: 83 e4 f0 and $0xfffffff0,%esp
1006: 83 ec 20 sub $0x20,%esp
sem_init(&s,1);
1009: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
1010: 00
1011: c7 04 24 8c 1c 00 00 movl $0x1c8c,(%esp)
1018: e8 d4 0b 00 00 call 1bf1 <sem_init>
void* tid = thread_create(test_func,(void *)&var);
101d: c7 44 24 04 60 1c 00 movl $0x1c60,0x4(%esp)
1024: 00
1025: c7 04 24 74 10 00 00 movl $0x1074,(%esp)
102c: e8 fd 08 00 00 call 192e <thread_create>
1031: 89 44 24 18 mov %eax,0x18(%esp)
if(tid == 0) exit();
1035: 83 7c 24 18 00 cmpl $0x0,0x18(%esp)
103a: 75 05 jne 1041 <main+0x41>
103c: e8 23 03 00 00 call 1364 <exit>
wait();
1041: e8 26 03 00 00 call 136c <wait>
void* yid = thread_create(test_func2,(void *)&var1);
1046: c7 44 24 04 64 1c 00 movl $0x1c64,0x4(%esp)
104d: 00
104e: c7 04 24 ba 10 00 00 movl $0x10ba,(%esp)
1055: e8 d4 08 00 00 call 192e <thread_create>
105a: 89 44 24 1c mov %eax,0x1c(%esp)
if(yid == 0) exit();
105e: 83 7c 24 1c 00 cmpl $0x0,0x1c(%esp)
1063: 75 05 jne 106a <main+0x6a>
1065: e8 fa 02 00 00 call 1364 <exit>
wait();
106a: e8 fd 02 00 00 call 136c <wait>
exit();
106f: e8 f0 02 00 00 call 1364 <exit>
00001074 <test_func>:
return 0;
}
void test_func(void *arg) {
1074: 55 push %ebp
1075: 89 e5 mov %esp,%ebp
1077: 83 ec 28 sub $0x28,%esp
int* num = (void*)arg;
107a: 8b 45 08 mov 0x8(%ebp),%eax
107d: 89 45 f4 mov %eax,-0xc(%ebp)
sem_acquire(&s);
1080: c7 04 24 8c 1c 00 00 movl $0x1c8c,(%esp)
1087: e8 b4 0a 00 00 call 1b40 <sem_acquire>
printf(1,"hi %d.\n",*num);
108c: 8b 45 f4 mov -0xc(%ebp),%eax
108f: 8b 00 mov (%eax),%eax
1091: 89 44 24 08 mov %eax,0x8(%esp)
1095: c7 44 24 04 1b 1c 00 movl $0x1c1b,0x4(%esp)
109c: 00
109d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
10a4: e8 5c 04 00 00 call 1505 <printf>
sem_signal(&s);
10a9: c7 04 24 8c 1c 00 00 movl $0x1c8c,(%esp)
10b0: e8 e9 0a 00 00 call 1b9e <sem_signal>
texit();
10b5: e8 52 03 00 00 call 140c <texit>
000010ba <test_func2>:
}
void test_func2(void *arg) {
10ba: 55 push %ebp
10bb: 89 e5 mov %esp,%ebp
10bd: 83 ec 28 sub $0x28,%esp
int* num = (void*)arg;
10c0: 8b 45 08 mov 0x8(%ebp),%eax
10c3: 89 45 f4 mov %eax,-0xc(%ebp)
sem_acquire(&s);
10c6: c7 04 24 8c 1c 00 00 movl $0x1c8c,(%esp)
10cd: e8 6e 0a 00 00 call 1b40 <sem_acquire>
printf(1,"hey %d.\n",*num);
10d2: 8b 45 f4 mov -0xc(%ebp),%eax
10d5: 8b 00 mov (%eax),%eax
10d7: 89 44 24 08 mov %eax,0x8(%esp)
10db: c7 44 24 04 23 1c 00 movl $0x1c23,0x4(%esp)
10e2: 00
10e3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
10ea: e8 16 04 00 00 call 1505 <printf>
sem_signal(&s);
10ef: c7 04 24 8c 1c 00 00 movl $0x1c8c,(%esp)
10f6: e8 a3 0a 00 00 call 1b9e <sem_signal>
texit();
10fb: e8 0c 03 00 00 call 140c <texit>
00001100 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1100: 55 push %ebp
1101: 89 e5 mov %esp,%ebp
1103: 57 push %edi
1104: 53 push %ebx
asm volatile("cld; rep stosb" :
1105: 8b 4d 08 mov 0x8(%ebp),%ecx
1108: 8b 55 10 mov 0x10(%ebp),%edx
110b: 8b 45 0c mov 0xc(%ebp),%eax
110e: 89 cb mov %ecx,%ebx
1110: 89 df mov %ebx,%edi
1112: 89 d1 mov %edx,%ecx
1114: fc cld
1115: f3 aa rep stos %al,%es:(%edi)
1117: 89 ca mov %ecx,%edx
1119: 89 fb mov %edi,%ebx
111b: 89 5d 08 mov %ebx,0x8(%ebp)
111e: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1121: 5b pop %ebx
1122: 5f pop %edi
1123: 5d pop %ebp
1124: c3 ret
00001125 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1125: 55 push %ebp
1126: 89 e5 mov %esp,%ebp
1128: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
112b: 8b 45 08 mov 0x8(%ebp),%eax
112e: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1131: 8b 45 0c mov 0xc(%ebp),%eax
1134: 0f b6 10 movzbl (%eax),%edx
1137: 8b 45 08 mov 0x8(%ebp),%eax
113a: 88 10 mov %dl,(%eax)
113c: 8b 45 08 mov 0x8(%ebp),%eax
113f: 0f b6 00 movzbl (%eax),%eax
1142: 84 c0 test %al,%al
1144: 0f 95 c0 setne %al
1147: 83 45 08 01 addl $0x1,0x8(%ebp)
114b: 83 45 0c 01 addl $0x1,0xc(%ebp)
114f: 84 c0 test %al,%al
1151: 75 de jne 1131 <strcpy+0xc>
;
return os;
1153: 8b 45 fc mov -0x4(%ebp),%eax
}
1156: c9 leave
1157: c3 ret
00001158 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1158: 55 push %ebp
1159: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
115b: eb 08 jmp 1165 <strcmp+0xd>
p++, q++;
115d: 83 45 08 01 addl $0x1,0x8(%ebp)
1161: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1165: 8b 45 08 mov 0x8(%ebp),%eax
1168: 0f b6 00 movzbl (%eax),%eax
116b: 84 c0 test %al,%al
116d: 74 10 je 117f <strcmp+0x27>
116f: 8b 45 08 mov 0x8(%ebp),%eax
1172: 0f b6 10 movzbl (%eax),%edx
1175: 8b 45 0c mov 0xc(%ebp),%eax
1178: 0f b6 00 movzbl (%eax),%eax
117b: 38 c2 cmp %al,%dl
117d: 74 de je 115d <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
117f: 8b 45 08 mov 0x8(%ebp),%eax
1182: 0f b6 00 movzbl (%eax),%eax
1185: 0f b6 d0 movzbl %al,%edx
1188: 8b 45 0c mov 0xc(%ebp),%eax
118b: 0f b6 00 movzbl (%eax),%eax
118e: 0f b6 c0 movzbl %al,%eax
1191: 89 d1 mov %edx,%ecx
1193: 29 c1 sub %eax,%ecx
1195: 89 c8 mov %ecx,%eax
}
1197: 5d pop %ebp
1198: c3 ret
00001199 <strlen>:
uint
strlen(char *s)
{
1199: 55 push %ebp
119a: 89 e5 mov %esp,%ebp
119c: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
119f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
11a6: eb 04 jmp 11ac <strlen+0x13>
11a8: 83 45 fc 01 addl $0x1,-0x4(%ebp)
11ac: 8b 45 fc mov -0x4(%ebp),%eax
11af: 03 45 08 add 0x8(%ebp),%eax
11b2: 0f b6 00 movzbl (%eax),%eax
11b5: 84 c0 test %al,%al
11b7: 75 ef jne 11a8 <strlen+0xf>
;
return n;
11b9: 8b 45 fc mov -0x4(%ebp),%eax
}
11bc: c9 leave
11bd: c3 ret
000011be <memset>:
void*
memset(void *dst, int c, uint n)
{
11be: 55 push %ebp
11bf: 89 e5 mov %esp,%ebp
11c1: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
11c4: 8b 45 10 mov 0x10(%ebp),%eax
11c7: 89 44 24 08 mov %eax,0x8(%esp)
11cb: 8b 45 0c mov 0xc(%ebp),%eax
11ce: 89 44 24 04 mov %eax,0x4(%esp)
11d2: 8b 45 08 mov 0x8(%ebp),%eax
11d5: 89 04 24 mov %eax,(%esp)
11d8: e8 23 ff ff ff call 1100 <stosb>
return dst;
11dd: 8b 45 08 mov 0x8(%ebp),%eax
}
11e0: c9 leave
11e1: c3 ret
000011e2 <strchr>:
char*
strchr(const char *s, char c)
{
11e2: 55 push %ebp
11e3: 89 e5 mov %esp,%ebp
11e5: 83 ec 04 sub $0x4,%esp
11e8: 8b 45 0c mov 0xc(%ebp),%eax
11eb: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
11ee: eb 14 jmp 1204 <strchr+0x22>
if(*s == c)
11f0: 8b 45 08 mov 0x8(%ebp),%eax
11f3: 0f b6 00 movzbl (%eax),%eax
11f6: 3a 45 fc cmp -0x4(%ebp),%al
11f9: 75 05 jne 1200 <strchr+0x1e>
return (char*)s;
11fb: 8b 45 08 mov 0x8(%ebp),%eax
11fe: eb 13 jmp 1213 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
1200: 83 45 08 01 addl $0x1,0x8(%ebp)
1204: 8b 45 08 mov 0x8(%ebp),%eax
1207: 0f b6 00 movzbl (%eax),%eax
120a: 84 c0 test %al,%al
120c: 75 e2 jne 11f0 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
120e: b8 00 00 00 00 mov $0x0,%eax
}
1213: c9 leave
1214: c3 ret
00001215 <gets>:
char*
gets(char *buf, int max)
{
1215: 55 push %ebp
1216: 89 e5 mov %esp,%ebp
1218: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
121b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
1222: eb 44 jmp 1268 <gets+0x53>
cc = read(0, &c, 1);
1224: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
122b: 00
122c: 8d 45 ef lea -0x11(%ebp),%eax
122f: 89 44 24 04 mov %eax,0x4(%esp)
1233: c7 04 24 00 00 00 00 movl $0x0,(%esp)
123a: e8 3d 01 00 00 call 137c <read>
123f: 89 45 f4 mov %eax,-0xc(%ebp)
if(cc < 1)
1242: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1246: 7e 2d jle 1275 <gets+0x60>
break;
buf[i++] = c;
1248: 8b 45 f0 mov -0x10(%ebp),%eax
124b: 03 45 08 add 0x8(%ebp),%eax
124e: 0f b6 55 ef movzbl -0x11(%ebp),%edx
1252: 88 10 mov %dl,(%eax)
1254: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(c == '\n' || c == '\r')
1258: 0f b6 45 ef movzbl -0x11(%ebp),%eax
125c: 3c 0a cmp $0xa,%al
125e: 74 16 je 1276 <gets+0x61>
1260: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1264: 3c 0d cmp $0xd,%al
1266: 74 0e je 1276 <gets+0x61>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1268: 8b 45 f0 mov -0x10(%ebp),%eax
126b: 83 c0 01 add $0x1,%eax
126e: 3b 45 0c cmp 0xc(%ebp),%eax
1271: 7c b1 jl 1224 <gets+0xf>
1273: eb 01 jmp 1276 <gets+0x61>
cc = read(0, &c, 1);
if(cc < 1)
break;
1275: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1276: 8b 45 f0 mov -0x10(%ebp),%eax
1279: 03 45 08 add 0x8(%ebp),%eax
127c: c6 00 00 movb $0x0,(%eax)
return buf;
127f: 8b 45 08 mov 0x8(%ebp),%eax
}
1282: c9 leave
1283: c3 ret
00001284 <stat>:
int
stat(char *n, struct stat *st)
{
1284: 55 push %ebp
1285: 89 e5 mov %esp,%ebp
1287: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
128a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1291: 00
1292: 8b 45 08 mov 0x8(%ebp),%eax
1295: 89 04 24 mov %eax,(%esp)
1298: e8 07 01 00 00 call 13a4 <open>
129d: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd < 0)
12a0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
12a4: 79 07 jns 12ad <stat+0x29>
return -1;
12a6: b8 ff ff ff ff mov $0xffffffff,%eax
12ab: eb 23 jmp 12d0 <stat+0x4c>
r = fstat(fd, st);
12ad: 8b 45 0c mov 0xc(%ebp),%eax
12b0: 89 44 24 04 mov %eax,0x4(%esp)
12b4: 8b 45 f0 mov -0x10(%ebp),%eax
12b7: 89 04 24 mov %eax,(%esp)
12ba: e8 fd 00 00 00 call 13bc <fstat>
12bf: 89 45 f4 mov %eax,-0xc(%ebp)
close(fd);
12c2: 8b 45 f0 mov -0x10(%ebp),%eax
12c5: 89 04 24 mov %eax,(%esp)
12c8: e8 bf 00 00 00 call 138c <close>
return r;
12cd: 8b 45 f4 mov -0xc(%ebp),%eax
}
12d0: c9 leave
12d1: c3 ret
000012d2 <atoi>:
int
atoi(const char *s)
{
12d2: 55 push %ebp
12d3: 89 e5 mov %esp,%ebp
12d5: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
12d8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
12df: eb 24 jmp 1305 <atoi+0x33>
n = n*10 + *s++ - '0';
12e1: 8b 55 fc mov -0x4(%ebp),%edx
12e4: 89 d0 mov %edx,%eax
12e6: c1 e0 02 shl $0x2,%eax
12e9: 01 d0 add %edx,%eax
12eb: 01 c0 add %eax,%eax
12ed: 89 c2 mov %eax,%edx
12ef: 8b 45 08 mov 0x8(%ebp),%eax
12f2: 0f b6 00 movzbl (%eax),%eax
12f5: 0f be c0 movsbl %al,%eax
12f8: 8d 04 02 lea (%edx,%eax,1),%eax
12fb: 83 e8 30 sub $0x30,%eax
12fe: 89 45 fc mov %eax,-0x4(%ebp)
1301: 83 45 08 01 addl $0x1,0x8(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
1305: 8b 45 08 mov 0x8(%ebp),%eax
1308: 0f b6 00 movzbl (%eax),%eax
130b: 3c 2f cmp $0x2f,%al
130d: 7e 0a jle 1319 <atoi+0x47>
130f: 8b 45 08 mov 0x8(%ebp),%eax
1312: 0f b6 00 movzbl (%eax),%eax
1315: 3c 39 cmp $0x39,%al
1317: 7e c8 jle 12e1 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
1319: 8b 45 fc mov -0x4(%ebp),%eax
}
131c: c9 leave
131d: c3 ret
0000131e <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
131e: 55 push %ebp
131f: 89 e5 mov %esp,%ebp
1321: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
1324: 8b 45 08 mov 0x8(%ebp),%eax
1327: 89 45 f8 mov %eax,-0x8(%ebp)
src = vsrc;
132a: 8b 45 0c mov 0xc(%ebp),%eax
132d: 89 45 fc mov %eax,-0x4(%ebp)
while(n-- > 0)
1330: eb 13 jmp 1345 <memmove+0x27>
*dst++ = *src++;
1332: 8b 45 fc mov -0x4(%ebp),%eax
1335: 0f b6 10 movzbl (%eax),%edx
1338: 8b 45 f8 mov -0x8(%ebp),%eax
133b: 88 10 mov %dl,(%eax)
133d: 83 45 f8 01 addl $0x1,-0x8(%ebp)
1341: 83 45 fc 01 addl $0x1,-0x4(%ebp)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
1345: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
1349: 0f 9f c0 setg %al
134c: 83 6d 10 01 subl $0x1,0x10(%ebp)
1350: 84 c0 test %al,%al
1352: 75 de jne 1332 <memmove+0x14>
*dst++ = *src++;
return vdst;
1354: 8b 45 08 mov 0x8(%ebp),%eax
}
1357: c9 leave
1358: c3 ret
1359: 90 nop
135a: 90 nop
135b: 90 nop
0000135c <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
135c: b8 01 00 00 00 mov $0x1,%eax
1361: cd 40 int $0x40
1363: c3 ret
00001364 <exit>:
SYSCALL(exit)
1364: b8 02 00 00 00 mov $0x2,%eax
1369: cd 40 int $0x40
136b: c3 ret
0000136c <wait>:
SYSCALL(wait)
136c: b8 03 00 00 00 mov $0x3,%eax
1371: cd 40 int $0x40
1373: c3 ret
00001374 <pipe>:
SYSCALL(pipe)
1374: b8 04 00 00 00 mov $0x4,%eax
1379: cd 40 int $0x40
137b: c3 ret
0000137c <read>:
SYSCALL(read)
137c: b8 05 00 00 00 mov $0x5,%eax
1381: cd 40 int $0x40
1383: c3 ret
00001384 <write>:
SYSCALL(write)
1384: b8 10 00 00 00 mov $0x10,%eax
1389: cd 40 int $0x40
138b: c3 ret
0000138c <close>:
SYSCALL(close)
138c: b8 15 00 00 00 mov $0x15,%eax
1391: cd 40 int $0x40
1393: c3 ret
00001394 <kill>:
SYSCALL(kill)
1394: b8 06 00 00 00 mov $0x6,%eax
1399: cd 40 int $0x40
139b: c3 ret
0000139c <exec>:
SYSCALL(exec)
139c: b8 07 00 00 00 mov $0x7,%eax
13a1: cd 40 int $0x40
13a3: c3 ret
000013a4 <open>:
SYSCALL(open)
13a4: b8 0f 00 00 00 mov $0xf,%eax
13a9: cd 40 int $0x40
13ab: c3 ret
000013ac <mknod>:
SYSCALL(mknod)
13ac: b8 11 00 00 00 mov $0x11,%eax
13b1: cd 40 int $0x40
13b3: c3 ret
000013b4 <unlink>:
SYSCALL(unlink)
13b4: b8 12 00 00 00 mov $0x12,%eax
13b9: cd 40 int $0x40
13bb: c3 ret
000013bc <fstat>:
SYSCALL(fstat)
13bc: b8 08 00 00 00 mov $0x8,%eax
13c1: cd 40 int $0x40
13c3: c3 ret
000013c4 <link>:
SYSCALL(link)
13c4: b8 13 00 00 00 mov $0x13,%eax
13c9: cd 40 int $0x40
13cb: c3 ret
000013cc <mkdir>:
SYSCALL(mkdir)
13cc: b8 14 00 00 00 mov $0x14,%eax
13d1: cd 40 int $0x40
13d3: c3 ret
000013d4 <chdir>:
SYSCALL(chdir)
13d4: b8 09 00 00 00 mov $0x9,%eax
13d9: cd 40 int $0x40
13db: c3 ret
000013dc <dup>:
SYSCALL(dup)
13dc: b8 0a 00 00 00 mov $0xa,%eax
13e1: cd 40 int $0x40
13e3: c3 ret
000013e4 <getpid>:
SYSCALL(getpid)
13e4: b8 0b 00 00 00 mov $0xb,%eax
13e9: cd 40 int $0x40
13eb: c3 ret
000013ec <sbrk>:
SYSCALL(sbrk)
13ec: b8 0c 00 00 00 mov $0xc,%eax
13f1: cd 40 int $0x40
13f3: c3 ret
000013f4 <sleep>:
SYSCALL(sleep)
13f4: b8 0d 00 00 00 mov $0xd,%eax
13f9: cd 40 int $0x40
13fb: c3 ret
000013fc <uptime>:
SYSCALL(uptime)
13fc: b8 0e 00 00 00 mov $0xe,%eax
1401: cd 40 int $0x40
1403: c3 ret
00001404 <clone>:
SYSCALL(clone)
1404: b8 16 00 00 00 mov $0x16,%eax
1409: cd 40 int $0x40
140b: c3 ret
0000140c <texit>:
SYSCALL(texit)
140c: b8 17 00 00 00 mov $0x17,%eax
1411: cd 40 int $0x40
1413: c3 ret
00001414 <tsleep>:
SYSCALL(tsleep)
1414: b8 18 00 00 00 mov $0x18,%eax
1419: cd 40 int $0x40
141b: c3 ret
0000141c <twakeup>:
SYSCALL(twakeup)
141c: b8 19 00 00 00 mov $0x19,%eax
1421: cd 40 int $0x40
1423: c3 ret
00001424 <thread_yield>:
SYSCALL(thread_yield)
1424: b8 1a 00 00 00 mov $0x1a,%eax
1429: cd 40 int $0x40
142b: c3 ret
0000142c <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
142c: 55 push %ebp
142d: 89 e5 mov %esp,%ebp
142f: 83 ec 28 sub $0x28,%esp
1432: 8b 45 0c mov 0xc(%ebp),%eax
1435: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
1438: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
143f: 00
1440: 8d 45 f4 lea -0xc(%ebp),%eax
1443: 89 44 24 04 mov %eax,0x4(%esp)
1447: 8b 45 08 mov 0x8(%ebp),%eax
144a: 89 04 24 mov %eax,(%esp)
144d: e8 32 ff ff ff call 1384 <write>
}
1452: c9 leave
1453: c3 ret
00001454 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
1454: 55 push %ebp
1455: 89 e5 mov %esp,%ebp
1457: 53 push %ebx
1458: 83 ec 44 sub $0x44,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
145b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
1462: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
1466: 74 17 je 147f <printint+0x2b>
1468: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
146c: 79 11 jns 147f <printint+0x2b>
neg = 1;
146e: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
1475: 8b 45 0c mov 0xc(%ebp),%eax
1478: f7 d8 neg %eax
147a: 89 45 f4 mov %eax,-0xc(%ebp)
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
147d: eb 06 jmp 1485 <printint+0x31>
neg = 1;
x = -xx;
} else {
x = xx;
147f: 8b 45 0c mov 0xc(%ebp),%eax
1482: 89 45 f4 mov %eax,-0xc(%ebp)
}
i = 0;
1485: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
do{
buf[i++] = digits[x % base];
148c: 8b 4d ec mov -0x14(%ebp),%ecx
148f: 8b 5d 10 mov 0x10(%ebp),%ebx
1492: 8b 45 f4 mov -0xc(%ebp),%eax
1495: ba 00 00 00 00 mov $0x0,%edx
149a: f7 f3 div %ebx
149c: 89 d0 mov %edx,%eax
149e: 0f b6 80 68 1c 00 00 movzbl 0x1c68(%eax),%eax
14a5: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
14a9: 83 45 ec 01 addl $0x1,-0x14(%ebp)
}while((x /= base) != 0);
14ad: 8b 45 10 mov 0x10(%ebp),%eax
14b0: 89 45 d4 mov %eax,-0x2c(%ebp)
14b3: 8b 45 f4 mov -0xc(%ebp),%eax
14b6: ba 00 00 00 00 mov $0x0,%edx
14bb: f7 75 d4 divl -0x2c(%ebp)
14be: 89 45 f4 mov %eax,-0xc(%ebp)
14c1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
14c5: 75 c5 jne 148c <printint+0x38>
if(neg)
14c7: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
14cb: 74 28 je 14f5 <printint+0xa1>
buf[i++] = '-';
14cd: 8b 45 ec mov -0x14(%ebp),%eax
14d0: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
14d5: 83 45 ec 01 addl $0x1,-0x14(%ebp)
while(--i >= 0)
14d9: eb 1a jmp 14f5 <printint+0xa1>
putc(fd, buf[i]);
14db: 8b 45 ec mov -0x14(%ebp),%eax
14de: 0f b6 44 05 dc movzbl -0x24(%ebp,%eax,1),%eax
14e3: 0f be c0 movsbl %al,%eax
14e6: 89 44 24 04 mov %eax,0x4(%esp)
14ea: 8b 45 08 mov 0x8(%ebp),%eax
14ed: 89 04 24 mov %eax,(%esp)
14f0: e8 37 ff ff ff call 142c <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
14f5: 83 6d ec 01 subl $0x1,-0x14(%ebp)
14f9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
14fd: 79 dc jns 14db <printint+0x87>
putc(fd, buf[i]);
}
14ff: 83 c4 44 add $0x44,%esp
1502: 5b pop %ebx
1503: 5d pop %ebp
1504: c3 ret
00001505 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1505: 55 push %ebp
1506: 89 e5 mov %esp,%ebp
1508: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
150b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
ap = (uint*)(void*)&fmt + 1;
1512: 8d 45 0c lea 0xc(%ebp),%eax
1515: 83 c0 04 add $0x4,%eax
1518: 89 45 f4 mov %eax,-0xc(%ebp)
for(i = 0; fmt[i]; i++){
151b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
1522: e9 7e 01 00 00 jmp 16a5 <printf+0x1a0>
c = fmt[i] & 0xff;
1527: 8b 55 0c mov 0xc(%ebp),%edx
152a: 8b 45 ec mov -0x14(%ebp),%eax
152d: 8d 04 02 lea (%edx,%eax,1),%eax
1530: 0f b6 00 movzbl (%eax),%eax
1533: 0f be c0 movsbl %al,%eax
1536: 25 ff 00 00 00 and $0xff,%eax
153b: 89 45 e8 mov %eax,-0x18(%ebp)
if(state == 0){
153e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1542: 75 2c jne 1570 <printf+0x6b>
if(c == '%'){
1544: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1548: 75 0c jne 1556 <printf+0x51>
state = '%';
154a: c7 45 f0 25 00 00 00 movl $0x25,-0x10(%ebp)
1551: e9 4b 01 00 00 jmp 16a1 <printf+0x19c>
} else {
putc(fd, c);
1556: 8b 45 e8 mov -0x18(%ebp),%eax
1559: 0f be c0 movsbl %al,%eax
155c: 89 44 24 04 mov %eax,0x4(%esp)
1560: 8b 45 08 mov 0x8(%ebp),%eax
1563: 89 04 24 mov %eax,(%esp)
1566: e8 c1 fe ff ff call 142c <putc>
156b: e9 31 01 00 00 jmp 16a1 <printf+0x19c>
}
} else if(state == '%'){
1570: 83 7d f0 25 cmpl $0x25,-0x10(%ebp)
1574: 0f 85 27 01 00 00 jne 16a1 <printf+0x19c>
if(c == 'd'){
157a: 83 7d e8 64 cmpl $0x64,-0x18(%ebp)
157e: 75 2d jne 15ad <printf+0xa8>
printint(fd, *ap, 10, 1);
1580: 8b 45 f4 mov -0xc(%ebp),%eax
1583: 8b 00 mov (%eax),%eax
1585: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
158c: 00
158d: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1594: 00
1595: 89 44 24 04 mov %eax,0x4(%esp)
1599: 8b 45 08 mov 0x8(%ebp),%eax
159c: 89 04 24 mov %eax,(%esp)
159f: e8 b0 fe ff ff call 1454 <printint>
ap++;
15a4: 83 45 f4 04 addl $0x4,-0xc(%ebp)
15a8: e9 ed 00 00 00 jmp 169a <printf+0x195>
} else if(c == 'x' || c == 'p'){
15ad: 83 7d e8 78 cmpl $0x78,-0x18(%ebp)
15b1: 74 06 je 15b9 <printf+0xb4>
15b3: 83 7d e8 70 cmpl $0x70,-0x18(%ebp)
15b7: 75 2d jne 15e6 <printf+0xe1>
printint(fd, *ap, 16, 0);
15b9: 8b 45 f4 mov -0xc(%ebp),%eax
15bc: 8b 00 mov (%eax),%eax
15be: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
15c5: 00
15c6: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
15cd: 00
15ce: 89 44 24 04 mov %eax,0x4(%esp)
15d2: 8b 45 08 mov 0x8(%ebp),%eax
15d5: 89 04 24 mov %eax,(%esp)
15d8: e8 77 fe ff ff call 1454 <printint>
ap++;
15dd: 83 45 f4 04 addl $0x4,-0xc(%ebp)
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
15e1: e9 b4 00 00 00 jmp 169a <printf+0x195>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
15e6: 83 7d e8 73 cmpl $0x73,-0x18(%ebp)
15ea: 75 46 jne 1632 <printf+0x12d>
s = (char*)*ap;
15ec: 8b 45 f4 mov -0xc(%ebp),%eax
15ef: 8b 00 mov (%eax),%eax
15f1: 89 45 e4 mov %eax,-0x1c(%ebp)
ap++;
15f4: 83 45 f4 04 addl $0x4,-0xc(%ebp)
if(s == 0)
15f8: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
15fc: 75 27 jne 1625 <printf+0x120>
s = "(null)";
15fe: c7 45 e4 2c 1c 00 00 movl $0x1c2c,-0x1c(%ebp)
while(*s != 0){
1605: eb 1f jmp 1626 <printf+0x121>
putc(fd, *s);
1607: 8b 45 e4 mov -0x1c(%ebp),%eax
160a: 0f b6 00 movzbl (%eax),%eax
160d: 0f be c0 movsbl %al,%eax
1610: 89 44 24 04 mov %eax,0x4(%esp)
1614: 8b 45 08 mov 0x8(%ebp),%eax
1617: 89 04 24 mov %eax,(%esp)
161a: e8 0d fe ff ff call 142c <putc>
s++;
161f: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
1623: eb 01 jmp 1626 <printf+0x121>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1625: 90 nop
1626: 8b 45 e4 mov -0x1c(%ebp),%eax
1629: 0f b6 00 movzbl (%eax),%eax
162c: 84 c0 test %al,%al
162e: 75 d7 jne 1607 <printf+0x102>
1630: eb 68 jmp 169a <printf+0x195>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
1632: 83 7d e8 63 cmpl $0x63,-0x18(%ebp)
1636: 75 1d jne 1655 <printf+0x150>
putc(fd, *ap);
1638: 8b 45 f4 mov -0xc(%ebp),%eax
163b: 8b 00 mov (%eax),%eax
163d: 0f be c0 movsbl %al,%eax
1640: 89 44 24 04 mov %eax,0x4(%esp)
1644: 8b 45 08 mov 0x8(%ebp),%eax
1647: 89 04 24 mov %eax,(%esp)
164a: e8 dd fd ff ff call 142c <putc>
ap++;
164f: 83 45 f4 04 addl $0x4,-0xc(%ebp)
1653: eb 45 jmp 169a <printf+0x195>
} else if(c == '%'){
1655: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1659: 75 17 jne 1672 <printf+0x16d>
putc(fd, c);
165b: 8b 45 e8 mov -0x18(%ebp),%eax
165e: 0f be c0 movsbl %al,%eax
1661: 89 44 24 04 mov %eax,0x4(%esp)
1665: 8b 45 08 mov 0x8(%ebp),%eax
1668: 89 04 24 mov %eax,(%esp)
166b: e8 bc fd ff ff call 142c <putc>
1670: eb 28 jmp 169a <printf+0x195>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
1672: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
1679: 00
167a: 8b 45 08 mov 0x8(%ebp),%eax
167d: 89 04 24 mov %eax,(%esp)
1680: e8 a7 fd ff ff call 142c <putc>
putc(fd, c);
1685: 8b 45 e8 mov -0x18(%ebp),%eax
1688: 0f be c0 movsbl %al,%eax
168b: 89 44 24 04 mov %eax,0x4(%esp)
168f: 8b 45 08 mov 0x8(%ebp),%eax
1692: 89 04 24 mov %eax,(%esp)
1695: e8 92 fd ff ff call 142c <putc>
}
state = 0;
169a: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
16a1: 83 45 ec 01 addl $0x1,-0x14(%ebp)
16a5: 8b 55 0c mov 0xc(%ebp),%edx
16a8: 8b 45 ec mov -0x14(%ebp),%eax
16ab: 8d 04 02 lea (%edx,%eax,1),%eax
16ae: 0f b6 00 movzbl (%eax),%eax
16b1: 84 c0 test %al,%al
16b3: 0f 85 6e fe ff ff jne 1527 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
16b9: c9 leave
16ba: c3 ret
16bb: 90 nop
000016bc <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
16bc: 55 push %ebp
16bd: 89 e5 mov %esp,%ebp
16bf: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
16c2: 8b 45 08 mov 0x8(%ebp),%eax
16c5: 83 e8 08 sub $0x8,%eax
16c8: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16cb: a1 88 1c 00 00 mov 0x1c88,%eax
16d0: 89 45 fc mov %eax,-0x4(%ebp)
16d3: eb 24 jmp 16f9 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
16d5: 8b 45 fc mov -0x4(%ebp),%eax
16d8: 8b 00 mov (%eax),%eax
16da: 3b 45 fc cmp -0x4(%ebp),%eax
16dd: 77 12 ja 16f1 <free+0x35>
16df: 8b 45 f8 mov -0x8(%ebp),%eax
16e2: 3b 45 fc cmp -0x4(%ebp),%eax
16e5: 77 24 ja 170b <free+0x4f>
16e7: 8b 45 fc mov -0x4(%ebp),%eax
16ea: 8b 00 mov (%eax),%eax
16ec: 3b 45 f8 cmp -0x8(%ebp),%eax
16ef: 77 1a ja 170b <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
16f1: 8b 45 fc mov -0x4(%ebp),%eax
16f4: 8b 00 mov (%eax),%eax
16f6: 89 45 fc mov %eax,-0x4(%ebp)
16f9: 8b 45 f8 mov -0x8(%ebp),%eax
16fc: 3b 45 fc cmp -0x4(%ebp),%eax
16ff: 76 d4 jbe 16d5 <free+0x19>
1701: 8b 45 fc mov -0x4(%ebp),%eax
1704: 8b 00 mov (%eax),%eax
1706: 3b 45 f8 cmp -0x8(%ebp),%eax
1709: 76 ca jbe 16d5 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
170b: 8b 45 f8 mov -0x8(%ebp),%eax
170e: 8b 40 04 mov 0x4(%eax),%eax
1711: c1 e0 03 shl $0x3,%eax
1714: 89 c2 mov %eax,%edx
1716: 03 55 f8 add -0x8(%ebp),%edx
1719: 8b 45 fc mov -0x4(%ebp),%eax
171c: 8b 00 mov (%eax),%eax
171e: 39 c2 cmp %eax,%edx
1720: 75 24 jne 1746 <free+0x8a>
bp->s.size += p->s.ptr->s.size;
1722: 8b 45 f8 mov -0x8(%ebp),%eax
1725: 8b 50 04 mov 0x4(%eax),%edx
1728: 8b 45 fc mov -0x4(%ebp),%eax
172b: 8b 00 mov (%eax),%eax
172d: 8b 40 04 mov 0x4(%eax),%eax
1730: 01 c2 add %eax,%edx
1732: 8b 45 f8 mov -0x8(%ebp),%eax
1735: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
1738: 8b 45 fc mov -0x4(%ebp),%eax
173b: 8b 00 mov (%eax),%eax
173d: 8b 10 mov (%eax),%edx
173f: 8b 45 f8 mov -0x8(%ebp),%eax
1742: 89 10 mov %edx,(%eax)
1744: eb 0a jmp 1750 <free+0x94>
} else
bp->s.ptr = p->s.ptr;
1746: 8b 45 fc mov -0x4(%ebp),%eax
1749: 8b 10 mov (%eax),%edx
174b: 8b 45 f8 mov -0x8(%ebp),%eax
174e: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
1750: 8b 45 fc mov -0x4(%ebp),%eax
1753: 8b 40 04 mov 0x4(%eax),%eax
1756: c1 e0 03 shl $0x3,%eax
1759: 03 45 fc add -0x4(%ebp),%eax
175c: 3b 45 f8 cmp -0x8(%ebp),%eax
175f: 75 20 jne 1781 <free+0xc5>
p->s.size += bp->s.size;
1761: 8b 45 fc mov -0x4(%ebp),%eax
1764: 8b 50 04 mov 0x4(%eax),%edx
1767: 8b 45 f8 mov -0x8(%ebp),%eax
176a: 8b 40 04 mov 0x4(%eax),%eax
176d: 01 c2 add %eax,%edx
176f: 8b 45 fc mov -0x4(%ebp),%eax
1772: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1775: 8b 45 f8 mov -0x8(%ebp),%eax
1778: 8b 10 mov (%eax),%edx
177a: 8b 45 fc mov -0x4(%ebp),%eax
177d: 89 10 mov %edx,(%eax)
177f: eb 08 jmp 1789 <free+0xcd>
} else
p->s.ptr = bp;
1781: 8b 45 fc mov -0x4(%ebp),%eax
1784: 8b 55 f8 mov -0x8(%ebp),%edx
1787: 89 10 mov %edx,(%eax)
freep = p;
1789: 8b 45 fc mov -0x4(%ebp),%eax
178c: a3 88 1c 00 00 mov %eax,0x1c88
}
1791: c9 leave
1792: c3 ret
00001793 <morecore>:
static Header*
morecore(uint nu)
{
1793: 55 push %ebp
1794: 89 e5 mov %esp,%ebp
1796: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
1799: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
17a0: 77 07 ja 17a9 <morecore+0x16>
nu = 4096;
17a2: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
17a9: 8b 45 08 mov 0x8(%ebp),%eax
17ac: c1 e0 03 shl $0x3,%eax
17af: 89 04 24 mov %eax,(%esp)
17b2: e8 35 fc ff ff call 13ec <sbrk>
17b7: 89 45 f0 mov %eax,-0x10(%ebp)
if(p == (char*)-1)
17ba: 83 7d f0 ff cmpl $0xffffffff,-0x10(%ebp)
17be: 75 07 jne 17c7 <morecore+0x34>
return 0;
17c0: b8 00 00 00 00 mov $0x0,%eax
17c5: eb 22 jmp 17e9 <morecore+0x56>
hp = (Header*)p;
17c7: 8b 45 f0 mov -0x10(%ebp),%eax
17ca: 89 45 f4 mov %eax,-0xc(%ebp)
hp->s.size = nu;
17cd: 8b 45 f4 mov -0xc(%ebp),%eax
17d0: 8b 55 08 mov 0x8(%ebp),%edx
17d3: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
17d6: 8b 45 f4 mov -0xc(%ebp),%eax
17d9: 83 c0 08 add $0x8,%eax
17dc: 89 04 24 mov %eax,(%esp)
17df: e8 d8 fe ff ff call 16bc <free>
return freep;
17e4: a1 88 1c 00 00 mov 0x1c88,%eax
}
17e9: c9 leave
17ea: c3 ret
000017eb <malloc>:
void*
malloc(uint nbytes)
{
17eb: 55 push %ebp
17ec: 89 e5 mov %esp,%ebp
17ee: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
17f1: 8b 45 08 mov 0x8(%ebp),%eax
17f4: 83 c0 07 add $0x7,%eax
17f7: c1 e8 03 shr $0x3,%eax
17fa: 83 c0 01 add $0x1,%eax
17fd: 89 45 f4 mov %eax,-0xc(%ebp)
if((prevp = freep) == 0){
1800: a1 88 1c 00 00 mov 0x1c88,%eax
1805: 89 45 f0 mov %eax,-0x10(%ebp)
1808: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
180c: 75 23 jne 1831 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
180e: c7 45 f0 80 1c 00 00 movl $0x1c80,-0x10(%ebp)
1815: 8b 45 f0 mov -0x10(%ebp),%eax
1818: a3 88 1c 00 00 mov %eax,0x1c88
181d: a1 88 1c 00 00 mov 0x1c88,%eax
1822: a3 80 1c 00 00 mov %eax,0x1c80
base.s.size = 0;
1827: c7 05 84 1c 00 00 00 movl $0x0,0x1c84
182e: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1831: 8b 45 f0 mov -0x10(%ebp),%eax
1834: 8b 00 mov (%eax),%eax
1836: 89 45 ec mov %eax,-0x14(%ebp)
if(p->s.size >= nunits){
1839: 8b 45 ec mov -0x14(%ebp),%eax
183c: 8b 40 04 mov 0x4(%eax),%eax
183f: 3b 45 f4 cmp -0xc(%ebp),%eax
1842: 72 4d jb 1891 <malloc+0xa6>
if(p->s.size == nunits)
1844: 8b 45 ec mov -0x14(%ebp),%eax
1847: 8b 40 04 mov 0x4(%eax),%eax
184a: 3b 45 f4 cmp -0xc(%ebp),%eax
184d: 75 0c jne 185b <malloc+0x70>
prevp->s.ptr = p->s.ptr;
184f: 8b 45 ec mov -0x14(%ebp),%eax
1852: 8b 10 mov (%eax),%edx
1854: 8b 45 f0 mov -0x10(%ebp),%eax
1857: 89 10 mov %edx,(%eax)
1859: eb 26 jmp 1881 <malloc+0x96>
else {
p->s.size -= nunits;
185b: 8b 45 ec mov -0x14(%ebp),%eax
185e: 8b 40 04 mov 0x4(%eax),%eax
1861: 89 c2 mov %eax,%edx
1863: 2b 55 f4 sub -0xc(%ebp),%edx
1866: 8b 45 ec mov -0x14(%ebp),%eax
1869: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
186c: 8b 45 ec mov -0x14(%ebp),%eax
186f: 8b 40 04 mov 0x4(%eax),%eax
1872: c1 e0 03 shl $0x3,%eax
1875: 01 45 ec add %eax,-0x14(%ebp)
p->s.size = nunits;
1878: 8b 45 ec mov -0x14(%ebp),%eax
187b: 8b 55 f4 mov -0xc(%ebp),%edx
187e: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
1881: 8b 45 f0 mov -0x10(%ebp),%eax
1884: a3 88 1c 00 00 mov %eax,0x1c88
return (void*)(p + 1);
1889: 8b 45 ec mov -0x14(%ebp),%eax
188c: 83 c0 08 add $0x8,%eax
188f: eb 38 jmp 18c9 <malloc+0xde>
}
if(p == freep)
1891: a1 88 1c 00 00 mov 0x1c88,%eax
1896: 39 45 ec cmp %eax,-0x14(%ebp)
1899: 75 1b jne 18b6 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
189b: 8b 45 f4 mov -0xc(%ebp),%eax
189e: 89 04 24 mov %eax,(%esp)
18a1: e8 ed fe ff ff call 1793 <morecore>
18a6: 89 45 ec mov %eax,-0x14(%ebp)
18a9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
18ad: 75 07 jne 18b6 <malloc+0xcb>
return 0;
18af: b8 00 00 00 00 mov $0x0,%eax
18b4: eb 13 jmp 18c9 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
18b6: 8b 45 ec mov -0x14(%ebp),%eax
18b9: 89 45 f0 mov %eax,-0x10(%ebp)
18bc: 8b 45 ec mov -0x14(%ebp),%eax
18bf: 8b 00 mov (%eax),%eax
18c1: 89 45 ec mov %eax,-0x14(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
18c4: e9 70 ff ff ff jmp 1839 <malloc+0x4e>
}
18c9: c9 leave
18ca: c3 ret
18cb: 90 nop
000018cc <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
18cc: 55 push %ebp
18cd: 89 e5 mov %esp,%ebp
18cf: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
18d2: 8b 55 08 mov 0x8(%ebp),%edx
18d5: 8b 45 0c mov 0xc(%ebp),%eax
18d8: 8b 4d 08 mov 0x8(%ebp),%ecx
18db: f0 87 02 lock xchg %eax,(%edx)
18de: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
18e1: 8b 45 fc mov -0x4(%ebp),%eax
}
18e4: c9 leave
18e5: c3 ret
000018e6 <lock_init>:
#include "x86.h"
#include "proc.h"
unsigned long rands = 1;
void lock_init(lock_t *lock){
18e6: 55 push %ebp
18e7: 89 e5 mov %esp,%ebp
lock->locked = 0;
18e9: 8b 45 08 mov 0x8(%ebp),%eax
18ec: c7 00 00 00 00 00 movl $0x0,(%eax)
}
18f2: 5d pop %ebp
18f3: c3 ret
000018f4 <lock_acquire>:
void lock_acquire(lock_t *lock){
18f4: 55 push %ebp
18f5: 89 e5 mov %esp,%ebp
18f7: 83 ec 08 sub $0x8,%esp
while(xchg(&lock->locked,1) != 0);
18fa: 8b 45 08 mov 0x8(%ebp),%eax
18fd: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
1904: 00
1905: 89 04 24 mov %eax,(%esp)
1908: e8 bf ff ff ff call 18cc <xchg>
190d: 85 c0 test %eax,%eax
190f: 75 e9 jne 18fa <lock_acquire+0x6>
}
1911: c9 leave
1912: c3 ret
00001913 <lock_release>:
void lock_release(lock_t *lock){
1913: 55 push %ebp
1914: 89 e5 mov %esp,%ebp
1916: 83 ec 08 sub $0x8,%esp
xchg(&lock->locked,0);
1919: 8b 45 08 mov 0x8(%ebp),%eax
191c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1923: 00
1924: 89 04 24 mov %eax,(%esp)
1927: e8 a0 ff ff ff call 18cc <xchg>
}
192c: c9 leave
192d: c3 ret
0000192e <thread_create>:
void *thread_create(void(*start_routine)(void*), void *arg){
192e: 55 push %ebp
192f: 89 e5 mov %esp,%ebp
1931: 83 ec 28 sub $0x28,%esp
int tid;
void * stack = malloc(2 * 4096);
1934: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
193b: e8 ab fe ff ff call 17eb <malloc>
1940: 89 45 f0 mov %eax,-0x10(%ebp)
void *garbage_stack = stack;
1943: 8b 45 f0 mov -0x10(%ebp),%eax
1946: 89 45 f4 mov %eax,-0xc(%ebp)
// printf(1,"start routine addr : %d\n",(uint)start_routine);
if((uint)stack % 4096){
1949: 8b 45 f0 mov -0x10(%ebp),%eax
194c: 25 ff 0f 00 00 and $0xfff,%eax
1951: 85 c0 test %eax,%eax
1953: 74 15 je 196a <thread_create+0x3c>
stack = stack + (4096 - (uint)stack % 4096);
1955: 8b 45 f0 mov -0x10(%ebp),%eax
1958: 89 c2 mov %eax,%edx
195a: 81 e2 ff 0f 00 00 and $0xfff,%edx
1960: b8 00 10 00 00 mov $0x1000,%eax
1965: 29 d0 sub %edx,%eax
1967: 01 45 f0 add %eax,-0x10(%ebp)
}
if (stack == 0){
196a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
196e: 75 1b jne 198b <thread_create+0x5d>
printf(1,"malloc fail \n");
1970: c7 44 24 04 33 1c 00 movl $0x1c33,0x4(%esp)
1977: 00
1978: c7 04 24 01 00 00 00 movl $0x1,(%esp)
197f: e8 81 fb ff ff call 1505 <printf>
return 0;
1984: b8 00 00 00 00 mov $0x0,%eax
1989: eb 6f jmp 19fa <thread_create+0xcc>
}
tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg);
198b: 8b 4d 0c mov 0xc(%ebp),%ecx
198e: 8b 55 08 mov 0x8(%ebp),%edx
1991: 8b 45 f0 mov -0x10(%ebp),%eax
1994: 89 4c 24 0c mov %ecx,0xc(%esp)
1998: 89 54 24 08 mov %edx,0x8(%esp)
199c: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp)
19a3: 00
19a4: 89 04 24 mov %eax,(%esp)
19a7: e8 58 fa ff ff call 1404 <clone>
19ac: 89 45 ec mov %eax,-0x14(%ebp)
if(tid < 0){
19af: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
19b3: 79 1b jns 19d0 <thread_create+0xa2>
printf(1,"clone fails\n");
19b5: c7 44 24 04 41 1c 00 movl $0x1c41,0x4(%esp)
19bc: 00
19bd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
19c4: e8 3c fb ff ff call 1505 <printf>
return 0;
19c9: b8 00 00 00 00 mov $0x0,%eax
19ce: eb 2a jmp 19fa <thread_create+0xcc>
}
if(tid > 0){
19d0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
19d4: 7e 05 jle 19db <thread_create+0xad>
//store threads on thread table
return garbage_stack;
19d6: 8b 45 f4 mov -0xc(%ebp),%eax
19d9: eb 1f jmp 19fa <thread_create+0xcc>
}
if(tid == 0){
19db: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
19df: 75 14 jne 19f5 <thread_create+0xc7>
printf(1,"tid = 0 return \n");
19e1: c7 44 24 04 4e 1c 00 movl $0x1c4e,0x4(%esp)
19e8: 00
19e9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
19f0: e8 10 fb ff ff call 1505 <printf>
}
// wait();
// free(garbage_stack);
return 0;
19f5: b8 00 00 00 00 mov $0x0,%eax
}
19fa: c9 leave
19fb: c3 ret
000019fc <random>:
// generate 0 -> max random number exclude max.
int random(int max){
19fc: 55 push %ebp
19fd: 89 e5 mov %esp,%ebp
rands = rands * 1664525 + 1013904233;
19ff: a1 7c 1c 00 00 mov 0x1c7c,%eax
1a04: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax
1a0a: 05 69 f3 6e 3c add $0x3c6ef369,%eax
1a0f: a3 7c 1c 00 00 mov %eax,0x1c7c
return (int)(rands % max);
1a14: a1 7c 1c 00 00 mov 0x1c7c,%eax
1a19: 8b 4d 08 mov 0x8(%ebp),%ecx
1a1c: ba 00 00 00 00 mov $0x0,%edx
1a21: f7 f1 div %ecx
1a23: 89 d0 mov %edx,%eax
}
1a25: 5d pop %ebp
1a26: c3 ret
1a27: 90 nop
00001a28 <init_q>:
#include "queue.h"
#include "types.h"
#include "user.h"
void init_q(struct queue *q){
1a28: 55 push %ebp
1a29: 89 e5 mov %esp,%ebp
q->size = 0;
1a2b: 8b 45 08 mov 0x8(%ebp),%eax
1a2e: c7 00 00 00 00 00 movl $0x0,(%eax)
q->head = 0;
1a34: 8b 45 08 mov 0x8(%ebp),%eax
1a37: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1a3e: 8b 45 08 mov 0x8(%ebp),%eax
1a41: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
1a48: 5d pop %ebp
1a49: c3 ret
00001a4a <add_q>:
void add_q(struct queue *q, int v){
1a4a: 55 push %ebp
1a4b: 89 e5 mov %esp,%ebp
1a4d: 83 ec 28 sub $0x28,%esp
struct node * n = malloc(sizeof(struct node));
1a50: c7 04 24 08 00 00 00 movl $0x8,(%esp)
1a57: e8 8f fd ff ff call 17eb <malloc>
1a5c: 89 45 f4 mov %eax,-0xc(%ebp)
n->next = 0;
1a5f: 8b 45 f4 mov -0xc(%ebp),%eax
1a62: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->value = v;
1a69: 8b 45 f4 mov -0xc(%ebp),%eax
1a6c: 8b 55 0c mov 0xc(%ebp),%edx
1a6f: 89 10 mov %edx,(%eax)
if(q->head == 0){
1a71: 8b 45 08 mov 0x8(%ebp),%eax
1a74: 8b 40 04 mov 0x4(%eax),%eax
1a77: 85 c0 test %eax,%eax
1a79: 75 0b jne 1a86 <add_q+0x3c>
q->head = n;
1a7b: 8b 45 08 mov 0x8(%ebp),%eax
1a7e: 8b 55 f4 mov -0xc(%ebp),%edx
1a81: 89 50 04 mov %edx,0x4(%eax)
1a84: eb 0c jmp 1a92 <add_q+0x48>
}else{
q->tail->next = n;
1a86: 8b 45 08 mov 0x8(%ebp),%eax
1a89: 8b 40 08 mov 0x8(%eax),%eax
1a8c: 8b 55 f4 mov -0xc(%ebp),%edx
1a8f: 89 50 04 mov %edx,0x4(%eax)
}
q->tail = n;
1a92: 8b 45 08 mov 0x8(%ebp),%eax
1a95: 8b 55 f4 mov -0xc(%ebp),%edx
1a98: 89 50 08 mov %edx,0x8(%eax)
q->size++;
1a9b: 8b 45 08 mov 0x8(%ebp),%eax
1a9e: 8b 00 mov (%eax),%eax
1aa0: 8d 50 01 lea 0x1(%eax),%edx
1aa3: 8b 45 08 mov 0x8(%ebp),%eax
1aa6: 89 10 mov %edx,(%eax)
}
1aa8: c9 leave
1aa9: c3 ret
00001aaa <empty_q>:
int empty_q(struct queue *q){
1aaa: 55 push %ebp
1aab: 89 e5 mov %esp,%ebp
if(q->size == 0)
1aad: 8b 45 08 mov 0x8(%ebp),%eax
1ab0: 8b 00 mov (%eax),%eax
1ab2: 85 c0 test %eax,%eax
1ab4: 75 07 jne 1abd <empty_q+0x13>
return 1;
1ab6: b8 01 00 00 00 mov $0x1,%eax
1abb: eb 05 jmp 1ac2 <empty_q+0x18>
else
return 0;
1abd: b8 00 00 00 00 mov $0x0,%eax
}
1ac2: 5d pop %ebp
1ac3: c3 ret
00001ac4 <pop_q>:
int pop_q(struct queue *q){
1ac4: 55 push %ebp
1ac5: 89 e5 mov %esp,%ebp
1ac7: 83 ec 28 sub $0x28,%esp
int val;
struct node *destroy;
if(!empty_q(q)){
1aca: 8b 45 08 mov 0x8(%ebp),%eax
1acd: 89 04 24 mov %eax,(%esp)
1ad0: e8 d5 ff ff ff call 1aaa <empty_q>
1ad5: 85 c0 test %eax,%eax
1ad7: 75 5d jne 1b36 <pop_q+0x72>
val = q->head->value;
1ad9: 8b 45 08 mov 0x8(%ebp),%eax
1adc: 8b 40 04 mov 0x4(%eax),%eax
1adf: 8b 00 mov (%eax),%eax
1ae1: 89 45 f0 mov %eax,-0x10(%ebp)
destroy = q->head;
1ae4: 8b 45 08 mov 0x8(%ebp),%eax
1ae7: 8b 40 04 mov 0x4(%eax),%eax
1aea: 89 45 f4 mov %eax,-0xc(%ebp)
q->head = q->head->next;
1aed: 8b 45 08 mov 0x8(%ebp),%eax
1af0: 8b 40 04 mov 0x4(%eax),%eax
1af3: 8b 50 04 mov 0x4(%eax),%edx
1af6: 8b 45 08 mov 0x8(%ebp),%eax
1af9: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
1afc: 8b 45 f4 mov -0xc(%ebp),%eax
1aff: 89 04 24 mov %eax,(%esp)
1b02: e8 b5 fb ff ff call 16bc <free>
q->size--;
1b07: 8b 45 08 mov 0x8(%ebp),%eax
1b0a: 8b 00 mov (%eax),%eax
1b0c: 8d 50 ff lea -0x1(%eax),%edx
1b0f: 8b 45 08 mov 0x8(%ebp),%eax
1b12: 89 10 mov %edx,(%eax)
if(q->size == 0){
1b14: 8b 45 08 mov 0x8(%ebp),%eax
1b17: 8b 00 mov (%eax),%eax
1b19: 85 c0 test %eax,%eax
1b1b: 75 14 jne 1b31 <pop_q+0x6d>
q->head = 0;
1b1d: 8b 45 08 mov 0x8(%ebp),%eax
1b20: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1b27: 8b 45 08 mov 0x8(%ebp),%eax
1b2a: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
1b31: 8b 45 f0 mov -0x10(%ebp),%eax
1b34: eb 05 jmp 1b3b <pop_q+0x77>
}
return -1;
1b36: b8 ff ff ff ff mov $0xffffffff,%eax
}
1b3b: c9 leave
1b3c: c3 ret
1b3d: 90 nop
1b3e: 90 nop
1b3f: 90 nop
00001b40 <sem_acquire>:
#include "semaphore.h"
void sem_acquire(struct Semaphore *s)
{
1b40: 55 push %ebp
1b41: 89 e5 mov %esp,%ebp
1b43: 83 ec 18 sub $0x18,%esp
lock_acquire(&s->lock);
1b46: 8b 45 08 mov 0x8(%ebp),%eax
1b49: 89 04 24 mov %eax,(%esp)
1b4c: e8 a3 fd ff ff call 18f4 <lock_acquire>
s->count--;
1b51: 8b 45 08 mov 0x8(%ebp),%eax
1b54: 8b 40 04 mov 0x4(%eax),%eax
1b57: 8d 50 ff lea -0x1(%eax),%edx
1b5a: 8b 45 08 mov 0x8(%ebp),%eax
1b5d: 89 50 04 mov %edx,0x4(%eax)
if( s->count < 0)
1b60: 8b 45 08 mov 0x8(%ebp),%eax
1b63: 8b 40 04 mov 0x4(%eax),%eax
1b66: 85 c0 test %eax,%eax
1b68: 79 27 jns 1b91 <sem_acquire+0x51>
{
add_q(&s->q, getpid());
1b6a: e8 75 f8 ff ff call 13e4 <getpid>
1b6f: 8b 55 08 mov 0x8(%ebp),%edx
1b72: 83 c2 08 add $0x8,%edx
1b75: 89 44 24 04 mov %eax,0x4(%esp)
1b79: 89 14 24 mov %edx,(%esp)
1b7c: e8 c9 fe ff ff call 1a4a <add_q>
lock_release(&s->lock);
1b81: 8b 45 08 mov 0x8(%ebp),%eax
1b84: 89 04 24 mov %eax,(%esp)
1b87: e8 87 fd ff ff call 1913 <lock_release>
tsleep();
1b8c: e8 83 f8 ff ff call 1414 <tsleep>
}
lock_release(&s->lock);
1b91: 8b 45 08 mov 0x8(%ebp),%eax
1b94: 89 04 24 mov %eax,(%esp)
1b97: e8 77 fd ff ff call 1913 <lock_release>
}
1b9c: c9 leave
1b9d: c3 ret
00001b9e <sem_signal>:
void sem_signal(struct Semaphore *s)
{
1b9e: 55 push %ebp
1b9f: 89 e5 mov %esp,%ebp
1ba1: 83 ec 28 sub $0x28,%esp
lock_acquire(&s->lock);
1ba4: 8b 45 08 mov 0x8(%ebp),%eax
1ba7: 89 04 24 mov %eax,(%esp)
1baa: e8 45 fd ff ff call 18f4 <lock_acquire>
s->count++;
1baf: 8b 45 08 mov 0x8(%ebp),%eax
1bb2: 8b 40 04 mov 0x4(%eax),%eax
1bb5: 8d 50 01 lea 0x1(%eax),%edx
1bb8: 8b 45 08 mov 0x8(%ebp),%eax
1bbb: 89 50 04 mov %edx,0x4(%eax)
if( s->count <= 0)
1bbe: 8b 45 08 mov 0x8(%ebp),%eax
1bc1: 8b 40 04 mov 0x4(%eax),%eax
1bc4: 85 c0 test %eax,%eax
1bc6: 7f 1c jg 1be4 <sem_signal+0x46>
{
int tid = pop_q(&s->q);
1bc8: 8b 45 08 mov 0x8(%ebp),%eax
1bcb: 83 c0 08 add $0x8,%eax
1bce: 89 04 24 mov %eax,(%esp)
1bd1: e8 ee fe ff ff call 1ac4 <pop_q>
1bd6: 89 45 f4 mov %eax,-0xc(%ebp)
twakeup(tid);
1bd9: 8b 45 f4 mov -0xc(%ebp),%eax
1bdc: 89 04 24 mov %eax,(%esp)
1bdf: e8 38 f8 ff ff call 141c <twakeup>
}
lock_release(&s->lock);
1be4: 8b 45 08 mov 0x8(%ebp),%eax
1be7: 89 04 24 mov %eax,(%esp)
1bea: e8 24 fd ff ff call 1913 <lock_release>
}
1bef: c9 leave
1bf0: c3 ret
00001bf1 <sem_init>:
void sem_init(struct Semaphore *s, int size){
1bf1: 55 push %ebp
1bf2: 89 e5 mov %esp,%ebp
1bf4: 83 ec 18 sub $0x18,%esp
lock_init(&s->lock);
1bf7: 8b 45 08 mov 0x8(%ebp),%eax
1bfa: 89 04 24 mov %eax,(%esp)
1bfd: e8 e4 fc ff ff call 18e6 <lock_init>
s->count = size;
1c02: 8b 45 08 mov 0x8(%ebp),%eax
1c05: 8b 55 0c mov 0xc(%ebp),%edx
1c08: 89 50 04 mov %edx,0x4(%eax)
init_q(&s->q);
1c0b: 8b 45 08 mov 0x8(%ebp),%eax
1c0e: 83 c0 08 add $0x8,%eax
1c11: 89 04 24 mov %eax,(%esp)
1c14: e8 0f fe ff ff call 1a28 <init_q>
}
1c19: c9 leave
1c1a: c3 ret
|
org 100h ; #include <stdio.h> starting add - 0000, ending - FFFF; prog start, assembler, return
;02 -- 02H(){
;int main(){
MOV AX, 02
MOV BX, 03
MOV CX, 04
;AX=BX+CX+DX ;int a=2, b= 3, c=4;
;d=a+b+c;
;printf(d);
;return 0;
ret
|
//=======================================================================
// Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/range/irange.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <iostream>
using namespace boost;
template < typename TimeMap >
class dfs_time_visitor : public default_dfs_visitor
{
typedef typename property_traits< TimeMap >::value_type T;
public:
dfs_time_visitor(TimeMap dmap, TimeMap fmap, T& t)
: m_dtimemap(dmap), m_ftimemap(fmap), m_time(t)
{
}
template < typename Vertex, typename Graph >
void discover_vertex(Vertex u, const Graph& g) const
{
put(m_dtimemap, u, m_time++);
}
template < typename Vertex, typename Graph >
void finish_vertex(Vertex u, const Graph& g) const
{
put(m_ftimemap, u, m_time++);
}
TimeMap m_dtimemap;
TimeMap m_ftimemap;
T& m_time;
};
int main()
{
// Select the graph type we wish to use
typedef adjacency_list< vecS, vecS, directedS > graph_t;
typedef graph_traits< graph_t >::vertices_size_type size_type;
// Set up the vertex names
enum
{
u,
v,
w,
x,
y,
z,
N
};
char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' };
// Specify the edges in the graph
typedef std::pair< int, int > E;
E edge_array[] = { E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y),
E(w, z), E(z, z) };
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
graph_t g(N);
for (std::size_t j = 0; j < sizeof(edge_array) / sizeof(E); ++j)
add_edge(edge_array[j].first, edge_array[j].second, g);
#else
graph_t g(edge_array, edge_array + sizeof(edge_array) / sizeof(E), N);
#endif
// discover time and finish time properties
std::vector< size_type > dtime(num_vertices(g));
std::vector< size_type > ftime(num_vertices(g));
typedef iterator_property_map< std::vector< size_type >::iterator,
property_map< graph_t, vertex_index_t >::const_type >
time_pm_type;
time_pm_type dtime_pm(dtime.begin(), get(vertex_index, g));
time_pm_type ftime_pm(ftime.begin(), get(vertex_index, g));
size_type t = 0;
dfs_time_visitor< time_pm_type > vis(dtime_pm, ftime_pm, t);
depth_first_search(g, visitor(vis));
// use std::sort to order the vertices by their discover time
std::vector< size_type > discover_order(N);
integer_range< size_type > r(0, N);
std::copy(r.begin(), r.end(), discover_order.begin());
std::sort(discover_order.begin(), discover_order.end(),
indirect_cmp< time_pm_type, std::less< size_type > >(dtime_pm));
std::cout << "order of discovery: ";
int i;
for (i = 0; i < N; ++i)
std::cout << name[discover_order[i]] << " ";
std::vector< size_type > finish_order(N);
std::copy(r.begin(), r.end(), finish_order.begin());
std::sort(finish_order.begin(), finish_order.end(),
indirect_cmp< time_pm_type, std::less< size_type > >(ftime_pm));
std::cout << std::endl << "order of finish: ";
for (i = 0; i < N; ++i)
std::cout << name[finish_order[i]] << " ";
std::cout << std::endl;
return EXIT_SUCCESS;
}
|
; A178681: a(n) = 6^n + 6.
; 7,12,42,222,1302,7782,46662,279942,1679622,10077702,60466182,362797062,2176782342,13060694022,78364164102,470184984582,2821109907462,16926659444742,101559956668422,609359740010502,3656158440062982,21936950640377862,131621703842267142,789730223053602822,4738381338321616902,28430288029929701382,170581728179578208262,1023490369077469249542,6140942214464815497222,36845653286788892983302,221073919720733357899782,1326443518324400147398662,7958661109946400884391942,47751966659678405306351622
mov $1,6
pow $1,$0
add $1,6
mov $0,$1
|
; A085297: Nonzero residues of Catalan sequence modulo 3; related to the Thue-Morse sequence (A001285).
; 1,1,2,2,2,2,2,2,1,1,1,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,1,1,1,2,2,2,2,2,2,1,1,1,2,2,2,1,1,1,1,1,1,2,2,2,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,1,1,2
mul $0,2
add $0,3
div $0,3
mov $3,1
lpb $0
div $0,2
mov $2,1
add $3,$0
lpe
add $3,$2
add $1,$3
mod $1,2
add $1,1
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// Usage: replay_computation some_binary_snapshot_proto*
//
// Replays computations and shows the results on the command line.
//
// some_binary_snapshot_proto is obtained by serializing the SessionModule from
// ServiceInterface::SnapshotComputation to disk.
//
// Computations that require arguments can be replayed using fake data by
// passing --use_fake_data on the command line. If the real data is available
// in the proto and --use_fake_data is false, the real data is used.
//
// The output format is:
//
// file_path: computation_name :: type:literal_str
#include <stdio.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "tensorflow/compiler/xla/client/client.h"
#include "tensorflow/compiler/xla/client/client_library.h"
#include "tensorflow/compiler/xla/client/computation.h"
#include "tensorflow/compiler/xla/client/global_data.h"
#include "tensorflow/compiler/xla/client/lib/testing.h"
#include "tensorflow/compiler/xla/client/local_client.h"
#include "tensorflow/compiler/xla/literal_util.h"
#include "tensorflow/compiler/xla/service/session.pb.h"
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/statusor.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/util/command_line_flags.h"
namespace xla {
namespace tools {
// Invokes the given computation passing arbitrary data for every (unbound)
// parameter if use_fake_data, Otherwise use recorded data if available.
StatusOr<std::unique_ptr<Literal>> ReplayComputation(
const SessionModule& module, bool use_fake_data, Client* client) {
TF_ASSIGN_OR_RETURN(Computation computation, client->LoadSnapshot(module));
std::vector<std::unique_ptr<GlobalData>> arguments;
if (use_fake_data) {
arguments = MakeFakeArgumentsOrDie(computation, client);
} else { // use recorded data if available
for (const Literal& literal : module.arguments()) {
TF_ASSIGN_OR_RETURN(std::unique_ptr<GlobalData> data,
client->TransferToServer(literal));
arguments.push_back(std::move(data));
}
}
std::vector<GlobalData*> execute_arguments;
for (auto& argument : arguments) {
execute_arguments.push_back(argument.get());
}
return client->ExecuteAndTransfer(computation, execute_arguments);
}
void RealMain(tensorflow::gtl::ArraySlice<char*> args, bool use_fake_data) {
Client* client = ClientLibrary::LocalClientOrDie();
tensorflow::Env* env = tensorflow::Env::Default();
for (char* arg : args) {
SessionModule module;
TF_CHECK_OK(tensorflow::ReadBinaryProto(env, arg, &module));
StatusOr<std::unique_ptr<Literal>> result_status =
ReplayComputation(module, use_fake_data, client);
if (!result_status.ok()) {
fprintf(stderr, "%s: error: %s\n", arg,
result_status.status().ToString().c_str());
continue;
}
std::unique_ptr<Literal> result = result_status.ConsumeValueOrDie();
fprintf(stdout, "%s: %s :: %s:%s\n", arg, module.entry().name().c_str(),
ShapeUtil::HumanString(result->shape()).c_str(),
LiteralUtil::ToString(*result).c_str());
if (module.has_result()) {
fprintf(stdout, "was %s:%s\n",
ShapeUtil::HumanString(module.result().shape()).c_str(),
LiteralUtil::ToString(module.result()).c_str());
}
}
}
} // namespace tools
} // namespace xla
int main(int argc, char** argv) {
// Flags
bool use_fake_data = false;
const std::vector<tensorflow::Flag> flag_list = {
tensorflow::Flag("use_fake_data", &use_fake_data,
"Replay computation using fake data"),
};
xla::string usage = tensorflow::Flags::Usage(argv[0], flag_list);
bool parse_ok = tensorflow::Flags::Parse(&argc, argv, flag_list);
tensorflow::port::InitMain(argv[0], &argc, &argv);
if (argc < 2 || !parse_ok) {
LOG(QFATAL) << usage;
}
tensorflow::gtl::ArraySlice<char*> args(argv, argc);
args.pop_front(); // Pop off the binary name, argv[0]
xla::tools::RealMain(args, use_fake_data);
return 0;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r9
push %rax
push %rbx
push %rdx
lea addresses_D_ht+0x3773, %rdx
nop
nop
cmp $24813, %rax
movw $0x6162, (%rdx)
nop
nop
nop
add $26073, %rdx
lea addresses_UC_ht+0x3eb5, %rbx
nop
nop
dec %r9
movl $0x61626364, (%rbx)
nop
nop
nop
nop
nop
cmp %rdx, %rdx
lea addresses_WC_ht+0xbc37, %rbx
nop
nop
nop
add $3350, %r12
vmovups (%rbx), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %r11
nop
nop
nop
nop
add %r12, %r12
lea addresses_UC_ht+0x1637, %r13
nop
nop
nop
dec %rbx
movl $0x61626364, (%r13)
nop
nop
nop
nop
nop
inc %r12
pop %rdx
pop %rbx
pop %rax
pop %r9
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r8
push %rax
push %rbp
push %rbx
push %rdx
// Store
lea addresses_D+0xbe37, %rdx
clflush (%rdx)
nop
nop
nop
nop
nop
xor $38608, %rax
mov $0x5152535455565758, %r8
movq %r8, %xmm1
vmovups %ymm1, (%rdx)
nop
nop
nop
nop
add %r10, %r10
// Store
lea addresses_PSE+0x3657, %rbp
nop
nop
xor $63493, %r13
movb $0x51, (%rbp)
nop
nop
nop
nop
nop
dec %r10
// Store
lea addresses_UC+0xdbb9, %rbp
nop
nop
cmp %r10, %r10
mov $0x5152535455565758, %rax
movq %rax, %xmm3
vmovups %ymm3, (%rbp)
nop
nop
xor %r8, %r8
// Faulty Load
lea addresses_PSE+0x1437, %rdx
nop
nop
nop
nop
xor %rbx, %rbx
movb (%rdx), %al
lea oracles, %r10
and $0xff, %rax
shlq $12, %rax
mov (%r10,%rax,1), %rax
pop %rdx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 1}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
;******************************************************************************
;* SIMD-optimized quarterpel functions
;* Copyright (c) 2008 Loren Merritt
;* Copyright (c) 2003-2013 Michael Niedermayer
;* Copyright (c) 2013 Daniel Kang
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* FFmpeg 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
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with FFmpeg; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION .text
%macro op_avgh 3
movh %3, %2
pavgb %1, %3
movh %2, %1
%endmacro
%macro op_avg 2
pavgb %1, %2
mova %2, %1
%endmacro
%macro op_puth 2-3
movh %2, %1
%endmacro
%macro op_put 2
mova %2, %1
%endmacro
; void ff_put/avg_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
; int dstStride, int src1Stride, int h)
%macro PIXELS4_L2 1
%define OP op_%1h
cglobal %1_pixels4_l2, 6,6
movsxdifnidn r3, r3d
movsxdifnidn r4, r4d
test r5d, 1
je .loop
movd m0, [r1]
movd m1, [r2]
add r1, r4
add r2, 4
pavgb m0, m1
OP m0, [r0], m3
add r0, r3
dec r5d
.loop:
mova m0, [r1]
mova m1, [r1+r4]
lea r1, [r1+2*r4]
pavgb m0, [r2]
pavgb m1, [r2+4]
OP m0, [r0], m3
OP m1, [r0+r3], m3
lea r0, [r0+2*r3]
mova m0, [r1]
mova m1, [r1+r4]
lea r1, [r1+2*r4]
pavgb m0, [r2+8]
pavgb m1, [r2+12]
OP m0, [r0], m3
OP m1, [r0+r3], m3
lea r0, [r0+2*r3]
add r2, 16
sub r5d, 4
jne .loop
REP_RET
%endmacro
INIT_MMX mmxext
PIXELS4_L2 put
PIXELS4_L2 avg
; void ff_put/avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
; int dstStride, int src1Stride, int h)
%macro PIXELS8_L2 1
%define OP op_%1
cglobal %1_pixels8_l2, 6,6
movsxdifnidn r3, r3d
movsxdifnidn r4, r4d
test r5d, 1
je .loop
mova m0, [r1]
mova m1, [r2]
add r1, r4
add r2, 8
pavgb m0, m1
OP m0, [r0]
add r0, r3
dec r5d
.loop:
mova m0, [r1]
mova m1, [r1+r4]
lea r1, [r1+2*r4]
pavgb m0, [r2]
pavgb m1, [r2+8]
OP m0, [r0]
OP m1, [r0+r3]
lea r0, [r0+2*r3]
mova m0, [r1]
mova m1, [r1+r4]
lea r1, [r1+2*r4]
pavgb m0, [r2+16]
pavgb m1, [r2+24]
OP m0, [r0]
OP m1, [r0+r3]
lea r0, [r0+2*r3]
add r2, 32
sub r5d, 4
jne .loop
REP_RET
%endmacro
INIT_MMX mmxext
PIXELS8_L2 put
PIXELS8_L2 avg
; void ff_put/avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
; int dstStride, int src1Stride, int h)
%macro PIXELS16_L2 1
%define OP op_%1
cglobal %1_pixels16_l2, 6,6
movsxdifnidn r3, r3d
movsxdifnidn r4, r4d
test r5d, 1
je .loop
mova m0, [r1]
mova m1, [r1+8]
pavgb m0, [r2]
pavgb m1, [r2+8]
add r1, r4
add r2, 16
OP m0, [r0]
OP m1, [r0+8]
add r0, r3
dec r5d
.loop:
mova m0, [r1]
mova m1, [r1+8]
add r1, r4
pavgb m0, [r2]
pavgb m1, [r2+8]
OP m0, [r0]
OP m1, [r0+8]
add r0, r3
mova m0, [r1]
mova m1, [r1+8]
add r1, r4
pavgb m0, [r2+16]
pavgb m1, [r2+24]
OP m0, [r0]
OP m1, [r0+8]
add r0, r3
add r2, 32
sub r5d, 2
jne .loop
REP_RET
%endmacro
INIT_MMX mmxext
PIXELS16_L2 put
PIXELS16_L2 avg
|
// Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <optional>
#include <pup.h>
#include <string>
#include <utility>
#include <type_traits>
#include "Options/Options.hpp"
#include "Parallel/CharmPupable.hpp"
#include "Parallel/GlobalCache.hpp"
#include "Parallel/Main.hpp"
#include "Parallel/PhaseControl/PhaseChange.hpp"
#include "Utilities/ErrorHandling/Error.hpp"
#include "Utilities/Functional.hpp"
#include "Utilities/TMPL.hpp"
#include "Utilities/TaggedTuple.hpp"
/// \cond
namespace PhaseControl {
template <typename Metavariables, typename Metavariables::Phase TargetPhase,
typename PhaseChangeRegistrars>
class VisitAndReturn;
namespace Registrars {
template <typename Metavariables, typename Metavariables::Phase TargetPhase>
struct VisitAndReturn {
template <typename PhaseChangeRegistrars>
using f = ::PhaseControl::VisitAndReturn<Metavariables, TargetPhase,
PhaseChangeRegistrars>;
};
} // namespace Registrars
/// \endcond
namespace Tags {
/// Storage in the phase change decision tuple so that the Main chare can record
/// the phase to return to after a temporary phase.
///
/// \note This tag is not intended to participate in any of the reduction
/// procedures, so will error if the combine method is called.
template <auto Phase>
struct ReturnPhase {
using type = std::optional<decltype(Phase)>;
struct combine_method {
std::optional<decltype(Phase)> operator()(
const std::optional<decltype(Phase)> /*first_phase*/,
const std::optional<decltype(Phase)>& /*second_phase*/) noexcept {
ERROR(
"The return phase should only be altered by the phase change "
"arbitration in the Main chare, so no reduction data should be "
"provided.");
}
};
using main_combine_method = combine_method;
};
/// Stores whether the phase in question has been requested.
///
/// Combinations are performed via `funcl::Or`, as the phase in question should
/// be chosen if any component requests the jump.
template <auto Phase>
struct TemporaryPhaseRequested {
using type = bool;
using combine_method = funcl::Or<>;
using main_combine_method = funcl::Or<>;
};
} // namespace Tags
/*!
* \brief Phase control object for temporarily visiting `TargetPhase`, until the
* algorithm halts again, then returning to the original phase.
*
* The motivation for this type of procedure is e.g. load balancing,
* checkpointing, and other maintenance tasks that should be performed
* periodically during a lengthy evolution.
* Once triggered, this will cause a change to `TargetPhase`, but store the
* current phase to resume execution when the tasks in `TargetPhase` are
* completed.
*
* Any parallel component can participate in the associated phase change
* reduction data contribution, and if any component requests the temporary
* phase, it will execute.
*
* To determine which specialization of this template is requested from the
* input file, the `Metavariables` must define a `phase_name(Phase)` static
* member function that returns a string for each phase that will be used in
* `VisitAndReturn`s.
*
* \note If multiple such methods are specified (with different
* `TargetPhase`s), then the order of phase jumps depends on their order in the
* list.
* - If multiple `VisitAndReturn`s trigger simultaneously, then they will visit
* in sequence specified by the input file: first going to the first
* `TargetPhase` until that phase resolves, then immediately entering the
* second `TargetPhase` (without yet returning to the original phase), then
* finally returning to the original phase.
* - If a `VisitAndReturn` is triggered in a phase that is already a
* `TargetPhase` of another `VisitAndReturn`, it will be executed, and
* following completion, control will return to the original phase from before
* the first `VisitAndReturn`.
*/
template <typename Metavariables, typename Metavariables::Phase TargetPhase,
typename PhaseChangeRegistrars = tmpl::list<
Registrars::VisitAndReturn<Metavariables, TargetPhase>>>
struct VisitAndReturn : public PhaseChange<PhaseChangeRegistrars> {
/// \cond
VisitAndReturn() = default;
explicit VisitAndReturn(CkMigrateMessage* /*unused*/) noexcept {}
using PUP::able::register_constructor;
WRAPPED_PUPable_decl_template(VisitAndReturn); // NOLINT
/// \endcond
static std::string name() noexcept {
return "VisitAndReturn(" + Metavariables::phase_name(TargetPhase) +
")";
}
using options = tmpl::list<>;
static constexpr Options::String help{
"Temporarily jump to the phase given by `TargetPhase`, returning to the "
"previously executing phase when complete."};
using argument_tags = tmpl::list<>;
using return_tags = tmpl::list<>;
using phase_change_tags_and_combines =
tmpl::list<Tags::ReturnPhase<TargetPhase>,
Tags::TemporaryPhaseRequested<TargetPhase>>;
template <typename LocalMetavariables>
using participating_components = typename LocalMetavariables::component_list;
template <typename... DecisionTags>
void initialize_phase_data_impl(
const gsl::not_null<tuples::TaggedTuple<DecisionTags...>*>
phase_change_decision_data) const noexcept {
tuples::get<Tags::ReturnPhase<TargetPhase>>(*phase_change_decision_data) =
std::nullopt;
tuples::get<Tags::TemporaryPhaseRequested<TargetPhase>>(
*phase_change_decision_data) = false;
}
template <typename ParallelComponent, typename ArrayIndex,
typename LocalMetavariables>
void contribute_phase_data_impl(
Parallel::GlobalCache<LocalMetavariables>& cache,
const ArrayIndex& array_index) const noexcept {
if constexpr (std::is_same_v<typename ParallelComponent::chare_type,
Parallel::Algorithms::Array>) {
Parallel::contribute_to_phase_change_reduction<ParallelComponent>(
tuples::TaggedTuple<Tags::TemporaryPhaseRequested<TargetPhase>>{true},
cache, array_index);
} else {
Parallel::contribute_to_phase_change_reduction<ParallelComponent>(
tuples::TaggedTuple<Tags::TemporaryPhaseRequested<TargetPhase>>{true},
cache);
}
}
template <typename... DecisionTags, typename LocalMetavariables>
typename std::optional<
std::pair<typename Metavariables::Phase, ArbitrationStrategy>>
arbitrate_phase_change_impl(
const gsl::not_null<tuples::TaggedTuple<DecisionTags...>*>
phase_change_decision_data,
const typename LocalMetavariables::Phase current_phase,
const Parallel::GlobalCache<LocalMetavariables>& /*cache*/)
const noexcept {
auto& return_phase = tuples::get<Tags::ReturnPhase<TargetPhase>>(
*phase_change_decision_data);
if (return_phase.has_value()) {
const auto result = return_phase;
return_phase.reset();
return std::make_pair(result.value(),
ArbitrationStrategy::PermitAdditionalJumps);
}
auto& temporary_phase_requested =
tuples::get<Tags::TemporaryPhaseRequested<TargetPhase>>(
*phase_change_decision_data);
if (temporary_phase_requested) {
return_phase = current_phase;
temporary_phase_requested = false;
return std::make_pair(TargetPhase,
ArbitrationStrategy::RunPhaseImmediately);
}
return std::nullopt;
}
void pup(PUP::er& /*p*/) noexcept override {}
};
} // namespace PhaseControl
/// \cond
template <typename Metavariables, typename Metavariables::Phase TargetPhase,
typename PhaseChangeRegistrars>
PUP::able::PUP_ID PhaseControl::VisitAndReturn<
Metavariables, TargetPhase, PhaseChangeRegistrars>::my_PUP_ID = 0;
/// \endcond
|
; A242510: Number of n-length words on {1,2,3} such that the maximal blocks (runs) of 1's have odd length, the maximal blocks of 2's have even length and the maximal blocks of 3's have odd length.
; Submitted by Christian Krause
; 1,2,3,8,15,32,67,138,289,600,1249,2600,5409,11258,23427,48752,101455,211128,439363,914322,1902721,3959600,8240001,17147600,35684481,74260082,154536643,321593688,669242575,1392706512,2898248707
mov $2,1
lpb $0
sub $0,1
sub $3,$4
add $1,$3
add $1,$3
add $4,1
mov $5,$4
mov $4,$2
mov $2,$3
add $4,$1
add $5,$4
mov $3,$5
lpe
mov $0,$4
add $0,1
|
; int getchar_unlocked(void)
SECTION code_stdio
PUBLIC _getchar_unlocked
EXTERN asm_getchar_unlocked
_getchar_unlocked:
push ix
call asm_getchar_unlocked
pop ix
ret
|
; A114051: x such that x^2 - 23*y^2 = 1.
; Submitted by Jamie Morken(s2)
; 1,24,1151,55224,2649601,127125624,6099380351,292643131224,14040770918401,673664360952024,32321848554778751,1550775066268428024,74404881332329766401,3569883528885560359224,171280004505174567476351,8217870332719493678505624,394286495966030522000793601,18917533936036745562359587224,907647342433797756471259393151,43548154902886255565058091284024,2089403787996106469366317122240001,100247833668910224274018163776236024,4809806612319694658683505544137089151,230770469557676433392534247954804043224
mov $3,1
lpb $0
sub $0,$3
add $4,$2
mov $1,$4
mul $1,23
add $2,1
add $2,$1
add $4,$2
lpe
mov $0,$4
mul $0,23
add $0,1
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT:
MODULE:
FILE: dustpref.asm
AUTHOR: Adam de Boor, Dec 3, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 12/ 3/92 Initial revision
DESCRIPTION:
Saver-specific preferences for driver.
$Id: dustpref.asm,v 1.1 97/04/04 16:48:18 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
; include the standard suspects
include geos.def
include heap.def
include geode.def
include resource.def
include ec.def
include library.def
include object.def
include graphics.def
include gstring.def
UseLib ui.def
UseLib config.def ; Most objects we use come from here
UseLib saver.def
;
; Include constants from , the saver, for use in our objects.
;
include ../dust.def
;
; Now the object tree.
;
include dustpref.rdef
idata segment
idata ends
DustPrefCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DustPrefGetPrefUITree
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Return the root of the UI tree for "Preferences"
CALLED BY: PrefMgr
PASS: none
RETURN: dx:ax - OD of root of tree
DESTROYED: none
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 8/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DustPrefGetPrefUITree proc far
mov dx, handle RootObject
mov ax, offset RootObject
ret
DustPrefGetPrefUITree endp
global DustPrefGetPrefUITree:far
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DustPrefGetModuleInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fill in the PrefModuleInfo buffer so that PrefMgr
can decide whether to show this button
CALLED BY: PrefMgr
PASS: ds:si - PrefModuleInfo structure to be filled in
RETURN: ds:si - buffer filled in
DESTROYED: ax,bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECSnd/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 10/26/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DustPrefGetModuleInfo proc far
.enter
clr ax
mov ds:[si].PMI_requiredFeatures, mask PMF_USER
mov ds:[si].PMI_prohibitedFeatures, ax
mov ds:[si].PMI_minLevel, ax
mov ds:[si].PMI_maxLevel, UIInterfaceLevel-1
movdw ds:[si].PMI_monikerList, axax
mov {word} ds:[si].PMI_monikerToken, ax
mov {word} ds:[si].PMI_monikerToken+2, ax
mov {word} ds:[si].PMI_monikerToken+4, ax
.leave
ret
DustPrefGetModuleInfo endp
global DustPrefGetModuleInfo:far
DustPrefCode ends
|
/**
* @file Test.cpp
* @author Hugo Marquez
* @brief The tests executable
* @version 0.0.1
* @date 2022-03-24
*
* @copyright Copyright (c) 2022
*/
// This tells Catch to provide a main() - only do this in one cpp file
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
// pn-system library
#include "./pn/system/LoggerTest.h"
|
;------------------------------------------------------------------------------
; @file
; This file includes all other code files to assemble the reset vector code
;
; Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
;------------------------------------------------------------------------------
%ifdef ARCH_IA32
%ifdef ARCH_X64
%error "Only one of ARCH_IA32 or ARCH_X64 can be defined."
%endif
%elifdef ARCH_X64
%else
%error "Either ARCH_IA32 or ARCH_X64 must be defined."
%endif
%include "CommonMacros.inc"
%include "PostCodes.inc"
%ifdef DEBUG_NONE
%include "DebugDisabled.asm"
%elifdef DEBUG_PORT80
%include "Port80Debug.asm"
%elifdef DEBUG_SERIAL
%include "SerialDebug.asm"
%else
%error "No debug type was specified."
%endif
%include "Ia32/SearchForBfvBase.asm"
%include "Ia32/SearchForSecEntry.asm"
%ifdef ARCH_X64
%include "Ia32/Flat32ToFlat64.asm"
%include "Ia32/PageTables64.asm"
%endif
%include "Ia16/Real16ToFlat32.asm"
%include "Ia16/Init16.asm"
%include "Main.asm"
%include "Ia16/ResetVectorVtf0.asm"
|
; Lab8 Part I - Program to prompt the user to enter a string
; Gets characters from the keyboard one at a time
; Checks if the user presses 'ENTER'
; Once 'ENTER' is pressed, echos the string back from the stack in REVERSE order
; Constant definitions
DISPLAY .EQU 04E9h ; address of Libra display
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Insert Sub-routines getChar, printStr, and newLine from Lab 7 here
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printStr:
; Save registers modified by this subroutine
push AX ; FIXED
push SI ; FIXED
push DX ; FIXED
mov DX, DISPLAY
LoopPS:
mov AL, [SI] ; Load the next char to be printed - USING INPUT PARAMETER SI
cmp AL, '$' ; Compare the char to '$'
je quitPS ; If it is equal, then quit subroutine and return to calling code
out DX,AL ; If it is not equal to '$', then print it
inc SI ; Point to the next char to be printed
jmp LoopPS ; Jump back to the top of the loop
quitPS:
; Restore registers
pop DX ; FIXED
pop SI ; FIXED
pop AX ; FIXED
RET
s_CR .EQU 0Dh ; ASCII value for Carriage return
s_LF .EQU 0Ah ; ASCII value for NewLine
newLine:
; Save registers modified by this subroutine
push AX ; FIXED
push DX ; FIXED
mov DX, DISPLAY ; Initialize the output port number in DX
mov AL, s_LF ; Load line feed (LF) into AL
out DX,AL ; print the char
mov AL, s_CR ; Load carriage return (CR) into AL
out DX,AL ; print the char
; Restore registers
pop DX ; FIXED
pop AX ; FIXED
RET
; ---------------------------------------------------------------
; getChar: waits for a keypress and returns pressed key in AL
; Input parameters:
; none.
; Output parameters:
; AL: ASCII Value of key pressed by user
; ---------------------------------------------------------------
; Constants used by this subroutine
KBSTATUS .EQU 0064h ; FIXED port number of keyboard STATUS reg
KBBUFFER .EQU 0060h ; FIXED port number of keyboard BUFFER reg
getChar:
push DX ; save reg used
GCWait:
mov DX, KBSTATUS ; load addr of keybrd STATUS
in AL,DX ; Read contents of keyboard STATUS register
cmp AL,0 ; key pressed?
je GCWait ; no, go back and check again for keypress
mov DX, KBBUFFER ; load port number of kbrd BUFFER register
in AL,DX ; get key into AL from BUFFER
GCDone:
pop DX ; restore regs
ret
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; END OF SUBROUTINES FROM lab7.asm
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ---------------------------------------------------------------
; print2Str: Subroutine to print a '$'-terminated string
; Each character in the string is stored
; as a 2-byte value. Only the lower byte is meaningful
; Input parameters:
; SI: Address of start of string to be printed
; Output parameters:
; None.
; ---------------------------------------------------------------
print2Str:
; FIXED -- Complete this subroutine. Use printStr, and just change one line...
call printStr
inc SI
inc SI
RET
Message1: .DB 'Enter a string$' ; Prompt to be printed on screen
; ---------------------------------------------------------------
; Main function: Asks the user to enter a string
; Echos the string to screen in reverse order.
; Uses printStr, newline, and getChar subroutines.
; ---------------------------------------------------------------
main:
mov SI, Message1 ; FIXED -- prompt the user
call printStr ; FIXED
call newLine ; FIXED
mov AH, 00h ; FIXED -- These three lines should push a '$' (zero-padded to 16 bits). WHY??
mov AL, '$'
push AX
gsAgain:
call getChar ; FIXED -- Get a character
cmp AL, 0Ah ; FIXED -- Next two lines should check if the user pressed ENTER, then stop accepting characters
je gsPrint
push AX ; FIXED -- Push the character as a 16-bit value
jmp gsAgain ; FIXED -- Get the next char
gsPrint:
; I don't know what's the starting address...
mov SI, SP ; FIXED -- Load the starting address of the string
call print2Str ; FIXED -- Print the string in reverse
call newLine ; FIXED
gsDone:
; Quit
HLT
.END main ; Entry point of program is main()
|
Name: en-drive.asm
Type: file
Size: 43178
Last-Modified: '2000-11-08T02:03:12Z'
SHA-1: F0901CDA8893F2AA6EBD0694CE9637028532E505
Description: null
|
//===- SIMemoryLegalizer.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
/// \file
/// Memory legalizer - implements memory model. More information can be
/// found here:
/// http://llvm.org/docs/AMDGPUUsage.html#memory-model
//
//===----------------------------------------------------------------------===//
#include "AMDGPU.h"
#include "AMDGPUMachineModuleInfo.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/TargetParser.h"
using namespace llvm;
using namespace llvm::AMDGPU;
#define DEBUG_TYPE "si-memory-legalizer"
#define PASS_NAME "SI Memory Legalizer"
static cl::opt<bool> AmdgcnSkipCacheInvalidations(
"amdgcn-skip-cache-invalidations", cl::init(false), cl::Hidden,
cl::desc("Use this to skip inserting cache invalidating instructions."));
namespace {
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
/// Memory operation flags. Can be ORed together.
enum class SIMemOp {
NONE = 0u,
LOAD = 1u << 0,
STORE = 1u << 1,
LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */ STORE)
};
/// Position to insert a new instruction relative to an existing
/// instruction.
enum class Position {
BEFORE,
AFTER
};
/// The atomic synchronization scopes supported by the AMDGPU target.
enum class SIAtomicScope {
NONE,
SINGLETHREAD,
WAVEFRONT,
WORKGROUP,
AGENT,
SYSTEM
};
/// The distinct address spaces supported by the AMDGPU target for
/// atomic memory operation. Can be ORed toether.
enum class SIAtomicAddrSpace {
NONE = 0u,
GLOBAL = 1u << 0,
LDS = 1u << 1,
SCRATCH = 1u << 2,
GDS = 1u << 3,
OTHER = 1u << 4,
/// The address spaces that can be accessed by a FLAT instruction.
FLAT = GLOBAL | LDS | SCRATCH,
/// The address spaces that support atomic instructions.
ATOMIC = GLOBAL | LDS | SCRATCH | GDS,
/// All address spaces.
ALL = GLOBAL | LDS | SCRATCH | GDS | OTHER,
LLVM_MARK_AS_BITMASK_ENUM(/* LargestFlag = */ ALL)
};
class SIMemOpInfo final {
private:
friend class SIMemOpAccess;
AtomicOrdering Ordering = AtomicOrdering::NotAtomic;
AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic;
SIAtomicScope Scope = SIAtomicScope::SYSTEM;
SIAtomicAddrSpace OrderingAddrSpace = SIAtomicAddrSpace::NONE;
SIAtomicAddrSpace InstrAddrSpace = SIAtomicAddrSpace::NONE;
bool IsCrossAddressSpaceOrdering = false;
bool IsVolatile = false;
bool IsNonTemporal = false;
SIMemOpInfo(AtomicOrdering Ordering = AtomicOrdering::SequentiallyConsistent,
SIAtomicScope Scope = SIAtomicScope::SYSTEM,
SIAtomicAddrSpace OrderingAddrSpace = SIAtomicAddrSpace::ATOMIC,
SIAtomicAddrSpace InstrAddrSpace = SIAtomicAddrSpace::ALL,
bool IsCrossAddressSpaceOrdering = true,
AtomicOrdering FailureOrdering =
AtomicOrdering::SequentiallyConsistent,
bool IsVolatile = false,
bool IsNonTemporal = false)
: Ordering(Ordering), FailureOrdering(FailureOrdering),
Scope(Scope), OrderingAddrSpace(OrderingAddrSpace),
InstrAddrSpace(InstrAddrSpace),
IsCrossAddressSpaceOrdering(IsCrossAddressSpaceOrdering),
IsVolatile(IsVolatile),
IsNonTemporal(IsNonTemporal) {
if (Ordering == AtomicOrdering::NotAtomic) {
assert(Scope == SIAtomicScope::NONE &&
OrderingAddrSpace == SIAtomicAddrSpace::NONE &&
!IsCrossAddressSpaceOrdering &&
FailureOrdering == AtomicOrdering::NotAtomic);
return;
}
assert(Scope != SIAtomicScope::NONE &&
(OrderingAddrSpace & SIAtomicAddrSpace::ATOMIC) !=
SIAtomicAddrSpace::NONE &&
(InstrAddrSpace & SIAtomicAddrSpace::ATOMIC) !=
SIAtomicAddrSpace::NONE);
// There is also no cross address space ordering if the ordering
// address space is the same as the instruction address space and
// only contains a single address space.
if ((OrderingAddrSpace == InstrAddrSpace) &&
isPowerOf2_32(uint32_t(InstrAddrSpace)))
this->IsCrossAddressSpaceOrdering = false;
// Limit the scope to the maximum supported by the instruction's address
// spaces.
if ((InstrAddrSpace & ~SIAtomicAddrSpace::SCRATCH) ==
SIAtomicAddrSpace::NONE) {
this->Scope = std::min(Scope, SIAtomicScope::SINGLETHREAD);
} else if ((InstrAddrSpace &
~(SIAtomicAddrSpace::SCRATCH | SIAtomicAddrSpace::LDS)) ==
SIAtomicAddrSpace::NONE) {
this->Scope = std::min(Scope, SIAtomicScope::WORKGROUP);
} else if ((InstrAddrSpace &
~(SIAtomicAddrSpace::SCRATCH | SIAtomicAddrSpace::LDS |
SIAtomicAddrSpace::GDS)) == SIAtomicAddrSpace::NONE) {
this->Scope = std::min(Scope, SIAtomicScope::AGENT);
}
}
public:
/// \returns Atomic synchronization scope of the machine instruction used to
/// create this SIMemOpInfo.
SIAtomicScope getScope() const {
return Scope;
}
/// \returns Ordering constraint of the machine instruction used to
/// create this SIMemOpInfo.
AtomicOrdering getOrdering() const {
return Ordering;
}
/// \returns Failure ordering constraint of the machine instruction used to
/// create this SIMemOpInfo.
AtomicOrdering getFailureOrdering() const {
return FailureOrdering;
}
/// \returns The address spaces be accessed by the machine
/// instruction used to create this SiMemOpInfo.
SIAtomicAddrSpace getInstrAddrSpace() const {
return InstrAddrSpace;
}
/// \returns The address spaces that must be ordered by the machine
/// instruction used to create this SiMemOpInfo.
SIAtomicAddrSpace getOrderingAddrSpace() const {
return OrderingAddrSpace;
}
/// \returns Return true iff memory ordering of operations on
/// different address spaces is required.
bool getIsCrossAddressSpaceOrdering() const {
return IsCrossAddressSpaceOrdering;
}
/// \returns True if memory access of the machine instruction used to
/// create this SIMemOpInfo is volatile, false otherwise.
bool isVolatile() const {
return IsVolatile;
}
/// \returns True if memory access of the machine instruction used to
/// create this SIMemOpInfo is nontemporal, false otherwise.
bool isNonTemporal() const {
return IsNonTemporal;
}
/// \returns True if ordering constraint of the machine instruction used to
/// create this SIMemOpInfo is unordered or higher, false otherwise.
bool isAtomic() const {
return Ordering != AtomicOrdering::NotAtomic;
}
};
class SIMemOpAccess final {
private:
AMDGPUMachineModuleInfo *MMI = nullptr;
/// Reports unsupported message \p Msg for \p MI to LLVM context.
void reportUnsupported(const MachineBasicBlock::iterator &MI,
const char *Msg) const;
/// Inspects the target synchronization scope \p SSID and determines
/// the SI atomic scope it corresponds to, the address spaces it
/// covers, and whether the memory ordering applies between address
/// spaces.
Optional<std::tuple<SIAtomicScope, SIAtomicAddrSpace, bool>>
toSIAtomicScope(SyncScope::ID SSID, SIAtomicAddrSpace InstrAddrSpace) const;
/// \return Return a bit set of the address spaces accessed by \p AS.
SIAtomicAddrSpace toSIAtomicAddrSpace(unsigned AS) const;
/// \returns Info constructed from \p MI, which has at least machine memory
/// operand.
Optional<SIMemOpInfo> constructFromMIWithMMO(
const MachineBasicBlock::iterator &MI) const;
public:
/// Construct class to support accessing the machine memory operands
/// of instructions in the machine function \p MF.
SIMemOpAccess(MachineFunction &MF);
/// \returns Load info if \p MI is a load operation, "None" otherwise.
Optional<SIMemOpInfo> getLoadInfo(
const MachineBasicBlock::iterator &MI) const;
/// \returns Store info if \p MI is a store operation, "None" otherwise.
Optional<SIMemOpInfo> getStoreInfo(
const MachineBasicBlock::iterator &MI) const;
/// \returns Atomic fence info if \p MI is an atomic fence operation,
/// "None" otherwise.
Optional<SIMemOpInfo> getAtomicFenceInfo(
const MachineBasicBlock::iterator &MI) const;
/// \returns Atomic cmpxchg/rmw info if \p MI is an atomic cmpxchg or
/// rmw operation, "None" otherwise.
Optional<SIMemOpInfo> getAtomicCmpxchgOrRmwInfo(
const MachineBasicBlock::iterator &MI) const;
};
class SICacheControl {
protected:
/// AMDGPU subtarget info.
const GCNSubtarget &ST;
/// Instruction info.
const SIInstrInfo *TII = nullptr;
IsaVersion IV;
/// Whether to insert cache invalidating instructions.
bool InsertCacheInv;
SICacheControl(const GCNSubtarget &ST);
/// Sets named bit \p BitName to "true" if present in instruction \p MI.
/// \returns Returns true if \p MI is modified, false otherwise.
bool enableNamedBit(const MachineBasicBlock::iterator MI,
AMDGPU::CPol::CPol Bit) const;
public:
/// Create a cache control for the subtarget \p ST.
static std::unique_ptr<SICacheControl> create(const GCNSubtarget &ST);
/// Update \p MI memory load instruction to bypass any caches up to
/// the \p Scope memory scope for address spaces \p
/// AddrSpace. Return true iff the instruction was modified.
virtual bool enableLoadCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const = 0;
/// Update \p MI memory store instruction to bypass any caches up to
/// the \p Scope memory scope for address spaces \p
/// AddrSpace. Return true iff the instruction was modified.
virtual bool enableStoreCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const = 0;
/// Update \p MI memory read-modify-write instruction to bypass any caches up
/// to the \p Scope memory scope for address spaces \p AddrSpace. Return true
/// iff the instruction was modified.
virtual bool enableRMWCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const = 0;
/// Update \p MI memory instruction of kind \p Op associated with address
/// spaces \p AddrSpace to indicate it is volatile and/or nontemporal. Return
/// true iff the instruction was modified.
virtual bool enableVolatileAndOrNonTemporal(MachineBasicBlock::iterator &MI,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op, bool IsVolatile,
bool IsNonTemporal) const = 0;
/// Inserts any necessary instructions at position \p Pos relative
/// to instruction \p MI to ensure memory instructions before \p Pos of kind
/// \p Op associated with address spaces \p AddrSpace have completed. Used
/// between memory instructions to enforce the order they become visible as
/// observed by other memory instructions executing in memory scope \p Scope.
/// \p IsCrossAddrSpaceOrdering indicates if the memory ordering is between
/// address spaces. Returns true iff any instructions inserted.
virtual bool insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const = 0;
/// Inserts any necessary instructions at position \p Pos relative to
/// instruction \p MI to ensure any subsequent memory instructions of this
/// thread with address spaces \p AddrSpace will observe the previous memory
/// operations by any thread for memory scopes up to memory scope \p Scope .
/// Returns true iff any instructions inserted.
virtual bool insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const = 0;
/// Inserts any necessary instructions at position \p Pos relative to
/// instruction \p MI to ensure previous memory instructions by this thread
/// with address spaces \p AddrSpace have completed and can be observed by
/// subsequent memory instructions by any thread executing in memory scope \p
/// Scope. \p IsCrossAddrSpaceOrdering indicates if the memory ordering is
/// between address spaces. Returns true iff any instructions inserted.
virtual bool insertRelease(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
bool IsCrossAddrSpaceOrdering,
Position Pos) const = 0;
/// Virtual destructor to allow derivations to be deleted.
virtual ~SICacheControl() = default;
};
class SIGfx6CacheControl : public SICacheControl {
protected:
/// Sets GLC bit to "true" if present in \p MI. Returns true if \p MI
/// is modified, false otherwise.
bool enableGLCBit(const MachineBasicBlock::iterator &MI) const {
return enableNamedBit(MI, AMDGPU::CPol::GLC);
}
/// Sets SLC bit to "true" if present in \p MI. Returns true if \p MI
/// is modified, false otherwise.
bool enableSLCBit(const MachineBasicBlock::iterator &MI) const {
return enableNamedBit(MI, AMDGPU::CPol::SLC);
}
public:
SIGfx6CacheControl(const GCNSubtarget &ST) : SICacheControl(ST) {}
bool enableLoadCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableStoreCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableRMWCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableVolatileAndOrNonTemporal(MachineBasicBlock::iterator &MI,
SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile,
bool IsNonTemporal) const override;
bool insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const override;
bool insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const override;
bool insertRelease(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
bool IsCrossAddrSpaceOrdering,
Position Pos) const override;
};
class SIGfx7CacheControl : public SIGfx6CacheControl {
public:
SIGfx7CacheControl(const GCNSubtarget &ST) : SIGfx6CacheControl(ST) {}
bool insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const override;
};
class SIGfx90ACacheControl : public SIGfx7CacheControl {
public:
SIGfx90ACacheControl(const GCNSubtarget &ST) : SIGfx7CacheControl(ST) {}
bool enableLoadCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableStoreCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableRMWCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableVolatileAndOrNonTemporal(MachineBasicBlock::iterator &MI,
SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile,
bool IsNonTemporal) const override;
bool insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const override;
bool insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const override;
bool insertRelease(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
bool IsCrossAddrSpaceOrdering,
Position Pos) const override;
};
class SIGfx10CacheControl : public SIGfx7CacheControl {
protected:
/// Sets DLC bit to "true" if present in \p MI. Returns true if \p MI
/// is modified, false otherwise.
bool enableDLCBit(const MachineBasicBlock::iterator &MI) const {
return enableNamedBit(MI, AMDGPU::CPol::DLC);
}
public:
SIGfx10CacheControl(const GCNSubtarget &ST) : SIGfx7CacheControl(ST) {}
bool enableLoadCacheBypass(const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const override;
bool enableVolatileAndOrNonTemporal(MachineBasicBlock::iterator &MI,
SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile,
bool IsNonTemporal) const override;
bool insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const override;
bool insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const override;
};
class SIMemoryLegalizer final : public MachineFunctionPass {
private:
/// Cache Control.
std::unique_ptr<SICacheControl> CC = nullptr;
/// List of atomic pseudo instructions.
std::list<MachineBasicBlock::iterator> AtomicPseudoMIs;
/// Return true iff instruction \p MI is a atomic instruction that
/// returns a result.
bool isAtomicRet(const MachineInstr &MI) const {
return SIInstrInfo::isAtomicRet(MI);
}
/// Removes all processed atomic pseudo instructions from the current
/// function. Returns true if current function is modified, false otherwise.
bool removeAtomicPseudoMIs();
/// Expands load operation \p MI. Returns true if instructions are
/// added/deleted or \p MI is modified, false otherwise.
bool expandLoad(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI);
/// Expands store operation \p MI. Returns true if instructions are
/// added/deleted or \p MI is modified, false otherwise.
bool expandStore(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI);
/// Expands atomic fence operation \p MI. Returns true if
/// instructions are added/deleted or \p MI is modified, false otherwise.
bool expandAtomicFence(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI);
/// Expands atomic cmpxchg or rmw operation \p MI. Returns true if
/// instructions are added/deleted or \p MI is modified, false otherwise.
bool expandAtomicCmpxchgOrRmw(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI);
public:
static char ID;
SIMemoryLegalizer() : MachineFunctionPass(ID) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
MachineFunctionPass::getAnalysisUsage(AU);
}
StringRef getPassName() const override {
return PASS_NAME;
}
bool runOnMachineFunction(MachineFunction &MF) override;
};
} // end namespace anonymous
void SIMemOpAccess::reportUnsupported(const MachineBasicBlock::iterator &MI,
const char *Msg) const {
const Function &Func = MI->getParent()->getParent()->getFunction();
DiagnosticInfoUnsupported Diag(Func, Msg, MI->getDebugLoc());
Func.getContext().diagnose(Diag);
}
Optional<std::tuple<SIAtomicScope, SIAtomicAddrSpace, bool>>
SIMemOpAccess::toSIAtomicScope(SyncScope::ID SSID,
SIAtomicAddrSpace InstrAddrSpace) const {
if (SSID == SyncScope::System)
return std::make_tuple(SIAtomicScope::SYSTEM,
SIAtomicAddrSpace::ATOMIC,
true);
if (SSID == MMI->getAgentSSID())
return std::make_tuple(SIAtomicScope::AGENT,
SIAtomicAddrSpace::ATOMIC,
true);
if (SSID == MMI->getWorkgroupSSID())
return std::make_tuple(SIAtomicScope::WORKGROUP,
SIAtomicAddrSpace::ATOMIC,
true);
if (SSID == MMI->getWavefrontSSID())
return std::make_tuple(SIAtomicScope::WAVEFRONT,
SIAtomicAddrSpace::ATOMIC,
true);
if (SSID == SyncScope::SingleThread)
return std::make_tuple(SIAtomicScope::SINGLETHREAD,
SIAtomicAddrSpace::ATOMIC,
true);
if (SSID == MMI->getSystemOneAddressSpaceSSID())
return std::make_tuple(SIAtomicScope::SYSTEM,
SIAtomicAddrSpace::ATOMIC & InstrAddrSpace,
false);
if (SSID == MMI->getAgentOneAddressSpaceSSID())
return std::make_tuple(SIAtomicScope::AGENT,
SIAtomicAddrSpace::ATOMIC & InstrAddrSpace,
false);
if (SSID == MMI->getWorkgroupOneAddressSpaceSSID())
return std::make_tuple(SIAtomicScope::WORKGROUP,
SIAtomicAddrSpace::ATOMIC & InstrAddrSpace,
false);
if (SSID == MMI->getWavefrontOneAddressSpaceSSID())
return std::make_tuple(SIAtomicScope::WAVEFRONT,
SIAtomicAddrSpace::ATOMIC & InstrAddrSpace,
false);
if (SSID == MMI->getSingleThreadOneAddressSpaceSSID())
return std::make_tuple(SIAtomicScope::SINGLETHREAD,
SIAtomicAddrSpace::ATOMIC & InstrAddrSpace,
false);
return None;
}
SIAtomicAddrSpace SIMemOpAccess::toSIAtomicAddrSpace(unsigned AS) const {
if (AS == AMDGPUAS::FLAT_ADDRESS)
return SIAtomicAddrSpace::FLAT;
if (AS == AMDGPUAS::GLOBAL_ADDRESS)
return SIAtomicAddrSpace::GLOBAL;
if (AS == AMDGPUAS::LOCAL_ADDRESS)
return SIAtomicAddrSpace::LDS;
if (AS == AMDGPUAS::PRIVATE_ADDRESS)
return SIAtomicAddrSpace::SCRATCH;
if (AS == AMDGPUAS::REGION_ADDRESS)
return SIAtomicAddrSpace::GDS;
return SIAtomicAddrSpace::OTHER;
}
SIMemOpAccess::SIMemOpAccess(MachineFunction &MF) {
MMI = &MF.getMMI().getObjFileInfo<AMDGPUMachineModuleInfo>();
}
Optional<SIMemOpInfo> SIMemOpAccess::constructFromMIWithMMO(
const MachineBasicBlock::iterator &MI) const {
assert(MI->getNumMemOperands() > 0);
SyncScope::ID SSID = SyncScope::SingleThread;
AtomicOrdering Ordering = AtomicOrdering::NotAtomic;
AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic;
SIAtomicAddrSpace InstrAddrSpace = SIAtomicAddrSpace::NONE;
bool IsNonTemporal = true;
bool IsVolatile = false;
// Validator should check whether or not MMOs cover the entire set of
// locations accessed by the memory instruction.
for (const auto &MMO : MI->memoperands()) {
IsNonTemporal &= MMO->isNonTemporal();
IsVolatile |= MMO->isVolatile();
InstrAddrSpace |=
toSIAtomicAddrSpace(MMO->getPointerInfo().getAddrSpace());
AtomicOrdering OpOrdering = MMO->getSuccessOrdering();
if (OpOrdering != AtomicOrdering::NotAtomic) {
const auto &IsSyncScopeInclusion =
MMI->isSyncScopeInclusion(SSID, MMO->getSyncScopeID());
if (!IsSyncScopeInclusion) {
reportUnsupported(MI,
"Unsupported non-inclusive atomic synchronization scope");
return None;
}
SSID = IsSyncScopeInclusion.getValue() ? SSID : MMO->getSyncScopeID();
Ordering = getMergedAtomicOrdering(Ordering, OpOrdering);
assert(MMO->getFailureOrdering() != AtomicOrdering::Release &&
MMO->getFailureOrdering() != AtomicOrdering::AcquireRelease);
FailureOrdering =
getMergedAtomicOrdering(FailureOrdering, MMO->getFailureOrdering());
}
}
SIAtomicScope Scope = SIAtomicScope::NONE;
SIAtomicAddrSpace OrderingAddrSpace = SIAtomicAddrSpace::NONE;
bool IsCrossAddressSpaceOrdering = false;
if (Ordering != AtomicOrdering::NotAtomic) {
auto ScopeOrNone = toSIAtomicScope(SSID, InstrAddrSpace);
if (!ScopeOrNone) {
reportUnsupported(MI, "Unsupported atomic synchronization scope");
return None;
}
std::tie(Scope, OrderingAddrSpace, IsCrossAddressSpaceOrdering) =
ScopeOrNone.getValue();
if ((OrderingAddrSpace == SIAtomicAddrSpace::NONE) ||
((OrderingAddrSpace & SIAtomicAddrSpace::ATOMIC) != OrderingAddrSpace) ||
((InstrAddrSpace & SIAtomicAddrSpace::ATOMIC) == SIAtomicAddrSpace::NONE)) {
reportUnsupported(MI, "Unsupported atomic address space");
return None;
}
}
return SIMemOpInfo(Ordering, Scope, OrderingAddrSpace, InstrAddrSpace,
IsCrossAddressSpaceOrdering, FailureOrdering, IsVolatile,
IsNonTemporal);
}
Optional<SIMemOpInfo> SIMemOpAccess::getLoadInfo(
const MachineBasicBlock::iterator &MI) const {
assert(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic);
if (!(MI->mayLoad() && !MI->mayStore()))
return None;
// Be conservative if there are no memory operands.
if (MI->getNumMemOperands() == 0)
return SIMemOpInfo();
return constructFromMIWithMMO(MI);
}
Optional<SIMemOpInfo> SIMemOpAccess::getStoreInfo(
const MachineBasicBlock::iterator &MI) const {
assert(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic);
if (!(!MI->mayLoad() && MI->mayStore()))
return None;
// Be conservative if there are no memory operands.
if (MI->getNumMemOperands() == 0)
return SIMemOpInfo();
return constructFromMIWithMMO(MI);
}
Optional<SIMemOpInfo> SIMemOpAccess::getAtomicFenceInfo(
const MachineBasicBlock::iterator &MI) const {
assert(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic);
if (MI->getOpcode() != AMDGPU::ATOMIC_FENCE)
return None;
AtomicOrdering Ordering =
static_cast<AtomicOrdering>(MI->getOperand(0).getImm());
SyncScope::ID SSID = static_cast<SyncScope::ID>(MI->getOperand(1).getImm());
auto ScopeOrNone = toSIAtomicScope(SSID, SIAtomicAddrSpace::ATOMIC);
if (!ScopeOrNone) {
reportUnsupported(MI, "Unsupported atomic synchronization scope");
return None;
}
SIAtomicScope Scope = SIAtomicScope::NONE;
SIAtomicAddrSpace OrderingAddrSpace = SIAtomicAddrSpace::NONE;
bool IsCrossAddressSpaceOrdering = false;
std::tie(Scope, OrderingAddrSpace, IsCrossAddressSpaceOrdering) =
ScopeOrNone.getValue();
if ((OrderingAddrSpace == SIAtomicAddrSpace::NONE) ||
((OrderingAddrSpace & SIAtomicAddrSpace::ATOMIC) != OrderingAddrSpace)) {
reportUnsupported(MI, "Unsupported atomic address space");
return None;
}
return SIMemOpInfo(Ordering, Scope, OrderingAddrSpace, SIAtomicAddrSpace::ATOMIC,
IsCrossAddressSpaceOrdering, AtomicOrdering::NotAtomic);
}
Optional<SIMemOpInfo> SIMemOpAccess::getAtomicCmpxchgOrRmwInfo(
const MachineBasicBlock::iterator &MI) const {
assert(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic);
if (!(MI->mayLoad() && MI->mayStore()))
return None;
// Be conservative if there are no memory operands.
if (MI->getNumMemOperands() == 0)
return SIMemOpInfo();
return constructFromMIWithMMO(MI);
}
SICacheControl::SICacheControl(const GCNSubtarget &ST) : ST(ST) {
TII = ST.getInstrInfo();
IV = getIsaVersion(ST.getCPU());
InsertCacheInv = !AmdgcnSkipCacheInvalidations;
}
bool SICacheControl::enableNamedBit(const MachineBasicBlock::iterator MI,
AMDGPU::CPol::CPol Bit) const {
MachineOperand *CPol = TII->getNamedOperand(*MI, AMDGPU::OpName::cpol);
if (!CPol)
return false;
CPol->setImm(CPol->getImm() | Bit);
return true;
}
/* static */
std::unique_ptr<SICacheControl> SICacheControl::create(const GCNSubtarget &ST) {
GCNSubtarget::Generation Generation = ST.getGeneration();
if (ST.hasGFX90AInsts())
return std::make_unique<SIGfx90ACacheControl>(ST);
if (Generation <= AMDGPUSubtarget::SOUTHERN_ISLANDS)
return std::make_unique<SIGfx6CacheControl>(ST);
if (Generation < AMDGPUSubtarget::GFX10)
return std::make_unique<SIGfx7CacheControl>(ST);
return std::make_unique<SIGfx10CacheControl>(ST);
}
bool SIGfx6CacheControl::enableLoadCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
// Set L1 cache policy to MISS_EVICT.
// Note: there is no L2 cache bypass policy at the ISA level.
Changed |= enableGLCBit(MI);
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to bypass.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory caches
/// to be bypassed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
return Changed;
}
bool SIGfx6CacheControl::enableStoreCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(!MI->mayLoad() && MI->mayStore());
bool Changed = false;
/// The L1 cache is write through so does not need to be bypassed. There is no
/// bypass control for the L2 cache at the isa level.
return Changed;
}
bool SIGfx6CacheControl::enableRMWCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(MI->mayLoad() && MI->mayStore());
bool Changed = false;
/// Do not set GLC for RMW atomic operations as L0/L1 cache is automatically
/// bypassed, and the GLC bit is instead used to indicate if they are
/// return or no-return.
/// Note: there is no L2 cache coherent bypass control at the ISA level.
return Changed;
}
bool SIGfx6CacheControl::enableVolatileAndOrNonTemporal(
MachineBasicBlock::iterator &MI, SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile, bool IsNonTemporal) const {
// Only handle load and store, not atomic read-modify-write insructions. The
// latter use glc to indicate if the atomic returns a result and so must not
// be used for cache control.
assert(MI->mayLoad() ^ MI->mayStore());
// Only update load and store, not LLVM IR atomic read-modify-write
// instructions. The latter are always marked as volatile so cannot sensibly
// handle it as do not want to pessimize all atomics. Also they do not support
// the nontemporal attribute.
assert(Op == SIMemOp::LOAD || Op == SIMemOp::STORE);
bool Changed = false;
if (IsVolatile) {
// Set L1 cache policy to be MISS_EVICT for load instructions
// and MISS_LRU for store instructions.
// Note: there is no L2 cache bypass policy at the ISA level.
if (Op == SIMemOp::LOAD)
Changed |= enableGLCBit(MI);
// Ensure operation has completed at system scope to cause all volatile
// operations to be visible outside the program in a global order. Do not
// request cross address space as only the global address space can be
// observable outside the program, so no need to cause a waitcnt for LDS
// address space operations.
Changed |= insertWait(MI, SIAtomicScope::SYSTEM, AddrSpace, Op, false,
Position::AFTER);
return Changed;
}
if (IsNonTemporal) {
// Setting both GLC and SLC configures L1 cache policy to MISS_EVICT
// for both loads and stores, and the L2 cache policy to STREAM.
Changed |= enableGLCBit(MI);
Changed |= enableSLCBit(MI);
return Changed;
}
return Changed;
}
bool SIGfx6CacheControl::insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const {
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
bool VMCnt = false;
bool LGKMCnt = false;
if ((AddrSpace & (SIAtomicAddrSpace::GLOBAL | SIAtomicAddrSpace::SCRATCH)) !=
SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
VMCnt |= true;
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The L1 cache keeps all memory operations in order for
// wavefronts in the same work-group.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if ((AddrSpace & SIAtomicAddrSpace::LDS) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
case SIAtomicScope::WORKGROUP:
// If no cross address space ordering then an "S_WAITCNT lgkmcnt(0)" is
// not needed as LDS operations for all waves are executed in a total
// global ordering as observed by all waves. Required if also
// synchronizing with global/GDS memory as LDS operations could be
// reordered with respect to later global/GDS memory operations of the
// same wave.
LGKMCnt |= IsCrossAddrSpaceOrdering;
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The LDS keeps all memory operations in order for
// the same wavesfront.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if ((AddrSpace & SIAtomicAddrSpace::GDS) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
// If no cross address space ordering then an GDS "S_WAITCNT lgkmcnt(0)"
// is not needed as GDS operations for all waves are executed in a total
// global ordering as observed by all waves. Required if also
// synchronizing with global/LDS memory as GDS operations could be
// reordered with respect to later global/LDS memory operations of the
// same wave.
LGKMCnt |= IsCrossAddrSpaceOrdering;
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The GDS keeps all memory operations in order for
// the same work-group.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if (VMCnt || LGKMCnt) {
unsigned WaitCntImmediate =
AMDGPU::encodeWaitcnt(IV,
VMCnt ? 0 : getVmcntBitMask(IV),
getExpcntBitMask(IV),
LGKMCnt ? 0 : getLgkmcntBitMask(IV));
BuildMI(MBB, MI, DL, TII->get(AMDGPU::S_WAITCNT)).addImm(WaitCntImmediate);
Changed = true;
}
if (Pos == Position::AFTER)
--MI;
return Changed;
}
bool SIGfx6CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const {
if (!InsertCacheInv)
return false;
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_WBINVL1));
Changed = true;
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to invalidate.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory cache
/// to be flushed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
if (Pos == Position::AFTER)
--MI;
return Changed;
}
bool SIGfx6CacheControl::insertRelease(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
bool IsCrossAddrSpaceOrdering,
Position Pos) const {
return insertWait(MI, Scope, AddrSpace, SIMemOp::LOAD | SIMemOp::STORE,
IsCrossAddrSpaceOrdering, Pos);
}
bool SIGfx7CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const {
if (!InsertCacheInv)
return false;
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
const GCNSubtarget &STM = MBB.getParent()->getSubtarget<GCNSubtarget>();
const unsigned InvalidateL1 = STM.isAmdPalOS() || STM.isMesa3DOS()
? AMDGPU::BUFFER_WBINVL1
: AMDGPU::BUFFER_WBINVL1_VOL;
if (Pos == Position::AFTER)
++MI;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
BuildMI(MBB, MI, DL, TII->get(InvalidateL1));
Changed = true;
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to invalidate.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory cache
/// to be flushed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
if (Pos == Position::AFTER)
--MI;
return Changed;
}
bool SIGfx90ACacheControl::enableLoadCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
// Set the L1 cache policy to MISS_LRU.
// Note: there is no L2 cache bypass policy at the ISA level.
Changed |= enableGLCBit(MI);
break;
case SIAtomicScope::WORKGROUP:
// In threadgroup split mode the waves of a work-group can be executing on
// different CUs. Therefore need to bypass the L1 which is per CU.
// Otherwise in non-threadgroup split mode all waves of a work-group are
// on the same CU, and so the L1 does not need to be bypassed.
if (ST.isTgSplitEnabled())
Changed |= enableGLCBit(MI);
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to bypass.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory caches
/// to be bypassed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
return Changed;
}
bool SIGfx90ACacheControl::enableStoreCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(!MI->mayLoad() && MI->mayStore());
bool Changed = false;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
/// Do not set glc for store atomic operations as they implicitly write
/// through the L1 cache.
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to bypass. Store atomics implicitly write through the L1
// cache.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory caches
/// to be bypassed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
return Changed;
}
bool SIGfx90ACacheControl::enableRMWCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(MI->mayLoad() && MI->mayStore());
bool Changed = false;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
/// Do not set glc for RMW atomic operations as they implicitly bypass
/// the L1 cache, and the glc bit is instead used to indicate if they are
/// return or no-return.
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to bypass. RMW atomics implicitly bypass the L1 cache.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
return Changed;
}
bool SIGfx90ACacheControl::enableVolatileAndOrNonTemporal(
MachineBasicBlock::iterator &MI, SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile, bool IsNonTemporal) const {
// Only handle load and store, not atomic read-modify-write insructions. The
// latter use glc to indicate if the atomic returns a result and so must not
// be used for cache control.
assert(MI->mayLoad() ^ MI->mayStore());
// Only update load and store, not LLVM IR atomic read-modify-write
// instructions. The latter are always marked as volatile so cannot sensibly
// handle it as do not want to pessimize all atomics. Also they do not support
// the nontemporal attribute.
assert(Op == SIMemOp::LOAD || Op == SIMemOp::STORE);
bool Changed = false;
if (IsVolatile) {
// Set L1 cache policy to be MISS_EVICT for load instructions
// and MISS_LRU for store instructions.
// Note: there is no L2 cache bypass policy at the ISA level.
if (Op == SIMemOp::LOAD)
Changed |= enableGLCBit(MI);
// Ensure operation has completed at system scope to cause all volatile
// operations to be visible outside the program in a global order. Do not
// request cross address space as only the global address space can be
// observable outside the program, so no need to cause a waitcnt for LDS
// address space operations.
Changed |= insertWait(MI, SIAtomicScope::SYSTEM, AddrSpace, Op, false,
Position::AFTER);
return Changed;
}
if (IsNonTemporal) {
// Setting both GLC and SLC configures L1 cache policy to MISS_EVICT
// for both loads and stores, and the L2 cache policy to STREAM.
Changed |= enableGLCBit(MI);
Changed |= enableSLCBit(MI);
return Changed;
}
return Changed;
}
bool SIGfx90ACacheControl::insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const {
if (ST.isTgSplitEnabled()) {
// In threadgroup split mode the waves of a work-group can be executing on
// different CUs. Therefore need to wait for global or GDS memory operations
// to complete to ensure they are visible to waves in the other CUs.
// Otherwise in non-threadgroup split mode all waves of a work-group are on
// the same CU, so no need to wait for global memory as all waves in the
// work-group access the same the L1, nor wait for GDS as access are ordered
// on a CU.
if (((AddrSpace & (SIAtomicAddrSpace::GLOBAL | SIAtomicAddrSpace::SCRATCH |
SIAtomicAddrSpace::GDS)) != SIAtomicAddrSpace::NONE) &&
(Scope == SIAtomicScope::WORKGROUP)) {
// Same as GFX7 using agent scope.
Scope = SIAtomicScope::AGENT;
}
// In threadgroup split mode LDS cannot be allocated so no need to wait for
// LDS memory operations.
AddrSpace &= ~SIAtomicAddrSpace::LDS;
}
return SIGfx7CacheControl::insertWait(MI, Scope, AddrSpace, Op,
IsCrossAddrSpaceOrdering, Pos);
}
bool SIGfx90ACacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const {
if (!InsertCacheInv)
return false;
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
// Ensures that following loads will not see stale remote VMEM data or
// stale local VMEM data with MTYPE NC. Local VMEM data with MTYPE RW and
// CC will never be stale due to the local memory probes.
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_INVL2));
// Inserting a "S_WAITCNT vmcnt(0)" after is not required because the
// hardware does not reorder memory operations by the same wave with
// respect to a preceding "BUFFER_INVL2". The invalidate is guaranteed to
// remove any cache lines of earlier writes by the same wave and ensures
// later reads by the same wave will refetch the cache lines.
Changed = true;
break;
case SIAtomicScope::AGENT:
// Same as GFX7.
break;
case SIAtomicScope::WORKGROUP:
// In threadgroup split mode the waves of a work-group can be executing on
// different CUs. Therefore need to invalidate the L1 which is per CU.
// Otherwise in non-threadgroup split mode all waves of a work-group are
// on the same CU, and so the L1 does not need to be invalidated.
if (ST.isTgSplitEnabled()) {
// Same as GFX7 using agent scope.
Scope = SIAtomicScope::AGENT;
}
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// Same as GFX7.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory cache
/// to be flushed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
if (Pos == Position::AFTER)
--MI;
Changed |= SIGfx7CacheControl::insertAcquire(MI, Scope, AddrSpace, Pos);
return Changed;
}
bool SIGfx90ACacheControl::insertRelease(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
bool IsCrossAddrSpaceOrdering,
Position Pos) const {
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
// Inserting a "S_WAITCNT vmcnt(0)" before is not required because the
// hardware does not reorder memory operations by the same wave with
// respect to a following "BUFFER_WBL2". The "BUFFER_WBL2" is guaranteed
// to initiate writeback of any dirty cache lines of earlier writes by the
// same wave. A "S_WAITCNT vmcnt(0)" is needed after to ensure the
// writeback has completed.
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_WBL2));
// Followed by same as GFX7, which will ensure the necessary "S_WAITCNT
// vmcnt(0)" needed by the "BUFFER_WBL2".
Changed = true;
break;
case SIAtomicScope::AGENT:
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// Same as GFX7.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if (Pos == Position::AFTER)
--MI;
Changed |=
SIGfx7CacheControl::insertRelease(MI, Scope, AddrSpace,
IsCrossAddrSpaceOrdering, Pos);
return Changed;
}
bool SIGfx10CacheControl::enableLoadCacheBypass(
const MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace) const {
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
// Set the L0 and L1 cache policies to MISS_EVICT.
// Note: there is no L2 cache coherent bypass control at the ISA level.
Changed |= enableGLCBit(MI);
Changed |= enableDLCBit(MI);
break;
case SIAtomicScope::WORKGROUP:
// In WGP mode the waves of a work-group can be executing on either CU of
// the WGP. Therefore need to bypass the L0 which is per CU. Otherwise in
// CU mode all waves of a work-group are on the same CU, and so the L0
// does not need to be bypassed.
if (!ST.isCuModeEnabled())
Changed |= enableGLCBit(MI);
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to bypass.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory caches
/// to be bypassed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
return Changed;
}
bool SIGfx10CacheControl::enableVolatileAndOrNonTemporal(
MachineBasicBlock::iterator &MI, SIAtomicAddrSpace AddrSpace, SIMemOp Op,
bool IsVolatile, bool IsNonTemporal) const {
// Only handle load and store, not atomic read-modify-write insructions. The
// latter use glc to indicate if the atomic returns a result and so must not
// be used for cache control.
assert(MI->mayLoad() ^ MI->mayStore());
// Only update load and store, not LLVM IR atomic read-modify-write
// instructions. The latter are always marked as volatile so cannot sensibly
// handle it as do not want to pessimize all atomics. Also they do not support
// the nontemporal attribute.
assert(Op == SIMemOp::LOAD || Op == SIMemOp::STORE);
bool Changed = false;
if (IsVolatile) {
// Set L0 and L1 cache policy to be MISS_EVICT for load instructions
// and MISS_LRU for store instructions.
// Note: there is no L2 cache coherent bypass control at the ISA level.
if (Op == SIMemOp::LOAD) {
Changed |= enableGLCBit(MI);
Changed |= enableDLCBit(MI);
}
// Ensure operation has completed at system scope to cause all volatile
// operations to be visible outside the program in a global order. Do not
// request cross address space as only the global address space can be
// observable outside the program, so no need to cause a waitcnt for LDS
// address space operations.
Changed |= insertWait(MI, SIAtomicScope::SYSTEM, AddrSpace, Op, false,
Position::AFTER);
return Changed;
}
if (IsNonTemporal) {
// For loads setting SLC configures L0 and L1 cache policy to HIT_EVICT
// and L2 cache policy to STREAM.
// For stores setting both GLC and SLC configures L0 and L1 cache policy
// to MISS_EVICT and the L2 cache policy to STREAM.
if (Op == SIMemOp::STORE)
Changed |= enableGLCBit(MI);
Changed |= enableSLCBit(MI);
return Changed;
}
return Changed;
}
bool SIGfx10CacheControl::insertWait(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
SIMemOp Op,
bool IsCrossAddrSpaceOrdering,
Position Pos) const {
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
bool VMCnt = false;
bool VSCnt = false;
bool LGKMCnt = false;
if ((AddrSpace & (SIAtomicAddrSpace::GLOBAL | SIAtomicAddrSpace::SCRATCH)) !=
SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
if ((Op & SIMemOp::LOAD) != SIMemOp::NONE)
VMCnt |= true;
if ((Op & SIMemOp::STORE) != SIMemOp::NONE)
VSCnt |= true;
break;
case SIAtomicScope::WORKGROUP:
// In WGP mode the waves of a work-group can be executing on either CU of
// the WGP. Therefore need to wait for operations to complete to ensure
// they are visible to waves in the other CU as the L0 is per CU.
// Otherwise in CU mode and all waves of a work-group are on the same CU
// which shares the same L0.
if (!ST.isCuModeEnabled()) {
if ((Op & SIMemOp::LOAD) != SIMemOp::NONE)
VMCnt |= true;
if ((Op & SIMemOp::STORE) != SIMemOp::NONE)
VSCnt |= true;
}
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The L0 cache keeps all memory operations in order for
// work-items in the same wavefront.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if ((AddrSpace & SIAtomicAddrSpace::LDS) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
case SIAtomicScope::WORKGROUP:
// If no cross address space ordering then an "S_WAITCNT lgkmcnt(0)" is
// not needed as LDS operations for all waves are executed in a total
// global ordering as observed by all waves. Required if also
// synchronizing with global/GDS memory as LDS operations could be
// reordered with respect to later global/GDS memory operations of the
// same wave.
LGKMCnt |= IsCrossAddrSpaceOrdering;
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The LDS keeps all memory operations in order for
// the same wavesfront.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if ((AddrSpace & SIAtomicAddrSpace::GDS) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
// If no cross address space ordering then an GDS "S_WAITCNT lgkmcnt(0)"
// is not needed as GDS operations for all waves are executed in a total
// global ordering as observed by all waves. Required if also
// synchronizing with global/LDS memory as GDS operations could be
// reordered with respect to later global/LDS memory operations of the
// same wave.
LGKMCnt |= IsCrossAddrSpaceOrdering;
break;
case SIAtomicScope::WORKGROUP:
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// The GDS keeps all memory operations in order for
// the same work-group.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
if (VMCnt || LGKMCnt) {
unsigned WaitCntImmediate =
AMDGPU::encodeWaitcnt(IV,
VMCnt ? 0 : getVmcntBitMask(IV),
getExpcntBitMask(IV),
LGKMCnt ? 0 : getLgkmcntBitMask(IV));
BuildMI(MBB, MI, DL, TII->get(AMDGPU::S_WAITCNT)).addImm(WaitCntImmediate);
Changed = true;
}
if (VSCnt) {
BuildMI(MBB, MI, DL, TII->get(AMDGPU::S_WAITCNT_VSCNT))
.addReg(AMDGPU::SGPR_NULL, RegState::Undef)
.addImm(0);
Changed = true;
}
if (Pos == Position::AFTER)
--MI;
return Changed;
}
bool SIGfx10CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
SIAtomicScope Scope,
SIAtomicAddrSpace AddrSpace,
Position Pos) const {
if (!InsertCacheInv)
return false;
bool Changed = false;
MachineBasicBlock &MBB = *MI->getParent();
DebugLoc DL = MI->getDebugLoc();
if (Pos == Position::AFTER)
++MI;
if ((AddrSpace & SIAtomicAddrSpace::GLOBAL) != SIAtomicAddrSpace::NONE) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
case SIAtomicScope::AGENT:
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_GL0_INV));
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_GL1_INV));
Changed = true;
break;
case SIAtomicScope::WORKGROUP:
// In WGP mode the waves of a work-group can be executing on either CU of
// the WGP. Therefore need to invalidate the L0 which is per CU. Otherwise
// in CU mode and all waves of a work-group are on the same CU, and so the
// L0 does not need to be invalidated.
if (!ST.isCuModeEnabled()) {
BuildMI(MBB, MI, DL, TII->get(AMDGPU::BUFFER_GL0_INV));
Changed = true;
}
break;
case SIAtomicScope::WAVEFRONT:
case SIAtomicScope::SINGLETHREAD:
// No cache to invalidate.
break;
default:
llvm_unreachable("Unsupported synchronization scope");
}
}
/// The scratch address space does not need the global memory cache
/// to be flushed as all memory operations by the same thread are
/// sequentially consistent, and no other thread can access scratch
/// memory.
/// Other address spaces do not have a cache.
if (Pos == Position::AFTER)
--MI;
return Changed;
}
bool SIMemoryLegalizer::removeAtomicPseudoMIs() {
if (AtomicPseudoMIs.empty())
return false;
for (auto &MI : AtomicPseudoMIs)
MI->eraseFromParent();
AtomicPseudoMIs.clear();
return true;
}
bool SIMemoryLegalizer::expandLoad(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI) {
assert(MI->mayLoad() && !MI->mayStore());
bool Changed = false;
if (MOI.isAtomic()) {
if (MOI.getOrdering() == AtomicOrdering::Monotonic ||
MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) {
Changed |= CC->enableLoadCacheBypass(MI, MOI.getScope(),
MOI.getOrderingAddrSpace());
}
if (MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent)
Changed |= CC->insertWait(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
SIMemOp::LOAD | SIMemOp::STORE,
MOI.getIsCrossAddressSpaceOrdering(),
Position::BEFORE);
if (MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) {
Changed |= CC->insertWait(MI, MOI.getScope(),
MOI.getInstrAddrSpace(),
SIMemOp::LOAD,
MOI.getIsCrossAddressSpaceOrdering(),
Position::AFTER);
Changed |= CC->insertAcquire(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
Position::AFTER);
}
return Changed;
}
// Atomic instructions already bypass caches to the scope specified by the
// SyncScope operand. Only non-atomic volatile and nontemporal instructions
// need additional treatment.
Changed |= CC->enableVolatileAndOrNonTemporal(MI, MOI.getInstrAddrSpace(),
SIMemOp::LOAD, MOI.isVolatile(),
MOI.isNonTemporal());
return Changed;
}
bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI) {
assert(!MI->mayLoad() && MI->mayStore());
bool Changed = false;
if (MOI.isAtomic()) {
if (MOI.getOrdering() == AtomicOrdering::Monotonic ||
MOI.getOrdering() == AtomicOrdering::Release ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) {
Changed |= CC->enableStoreCacheBypass(MI, MOI.getScope(),
MOI.getOrderingAddrSpace());
}
if (MOI.getOrdering() == AtomicOrdering::Release ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent)
Changed |= CC->insertRelease(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
MOI.getIsCrossAddressSpaceOrdering(),
Position::BEFORE);
return Changed;
}
// Atomic instructions already bypass caches to the scope specified by the
// SyncScope operand. Only non-atomic volatile and nontemporal instructions
// need additional treatment.
Changed |= CC->enableVolatileAndOrNonTemporal(
MI, MOI.getInstrAddrSpace(), SIMemOp::STORE, MOI.isVolatile(),
MOI.isNonTemporal());
return Changed;
}
bool SIMemoryLegalizer::expandAtomicFence(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI) {
assert(MI->getOpcode() == AMDGPU::ATOMIC_FENCE);
AtomicPseudoMIs.push_back(MI);
bool Changed = false;
if (MOI.isAtomic()) {
if (MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::Release ||
MOI.getOrdering() == AtomicOrdering::AcquireRelease ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent)
/// TODO: This relies on a barrier always generating a waitcnt
/// for LDS to ensure it is not reordered with the completion of
/// the proceeding LDS operations. If barrier had a memory
/// ordering and memory scope, then library does not need to
/// generate a fence. Could add support in this file for
/// barrier. SIInsertWaitcnt.cpp could then stop unconditionally
/// adding S_WAITCNT before a S_BARRIER.
Changed |= CC->insertRelease(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
MOI.getIsCrossAddressSpaceOrdering(),
Position::BEFORE);
// TODO: If both release and invalidate are happening they could be combined
// to use the single "BUFFER_WBINV*" instruction. This could be done by
// reorganizing this code or as part of optimizing SIInsertWaitcnt pass to
// track cache invalidate and write back instructions.
if (MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::AcquireRelease ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent)
Changed |= CC->insertAcquire(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
Position::BEFORE);
return Changed;
}
return Changed;
}
bool SIMemoryLegalizer::expandAtomicCmpxchgOrRmw(const SIMemOpInfo &MOI,
MachineBasicBlock::iterator &MI) {
assert(MI->mayLoad() && MI->mayStore());
bool Changed = false;
if (MOI.isAtomic()) {
if (MOI.getOrdering() == AtomicOrdering::Monotonic ||
MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::Release ||
MOI.getOrdering() == AtomicOrdering::AcquireRelease ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) {
Changed |= CC->enableRMWCacheBypass(MI, MOI.getScope(),
MOI.getInstrAddrSpace());
}
if (MOI.getOrdering() == AtomicOrdering::Release ||
MOI.getOrdering() == AtomicOrdering::AcquireRelease ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent ||
MOI.getFailureOrdering() == AtomicOrdering::SequentiallyConsistent)
Changed |= CC->insertRelease(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
MOI.getIsCrossAddressSpaceOrdering(),
Position::BEFORE);
if (MOI.getOrdering() == AtomicOrdering::Acquire ||
MOI.getOrdering() == AtomicOrdering::AcquireRelease ||
MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent ||
MOI.getFailureOrdering() == AtomicOrdering::Acquire ||
MOI.getFailureOrdering() == AtomicOrdering::SequentiallyConsistent) {
Changed |= CC->insertWait(MI, MOI.getScope(),
MOI.getInstrAddrSpace(),
isAtomicRet(*MI) ? SIMemOp::LOAD :
SIMemOp::STORE,
MOI.getIsCrossAddressSpaceOrdering(),
Position::AFTER);
Changed |= CC->insertAcquire(MI, MOI.getScope(),
MOI.getOrderingAddrSpace(),
Position::AFTER);
}
return Changed;
}
return Changed;
}
bool SIMemoryLegalizer::runOnMachineFunction(MachineFunction &MF) {
bool Changed = false;
SIMemOpAccess MOA(MF);
CC = SICacheControl::create(MF.getSubtarget<GCNSubtarget>());
for (auto &MBB : MF) {
for (auto MI = MBB.begin(); MI != MBB.end(); ++MI) {
// Unbundle instructions after the post-RA scheduler.
if (MI->isBundle() && MI->mayLoadOrStore()) {
MachineBasicBlock::instr_iterator II(MI->getIterator());
for (MachineBasicBlock::instr_iterator I = ++II, E = MBB.instr_end();
I != E && I->isBundledWithPred(); ++I) {
I->unbundleFromPred();
for (MachineOperand &MO : I->operands())
if (MO.isReg())
MO.setIsInternalRead(false);
}
MI->eraseFromParent();
MI = II->getIterator();
}
if (!(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic))
continue;
if (const auto &MOI = MOA.getLoadInfo(MI))
Changed |= expandLoad(MOI.getValue(), MI);
else if (const auto &MOI = MOA.getStoreInfo(MI))
Changed |= expandStore(MOI.getValue(), MI);
else if (const auto &MOI = MOA.getAtomicFenceInfo(MI))
Changed |= expandAtomicFence(MOI.getValue(), MI);
else if (const auto &MOI = MOA.getAtomicCmpxchgOrRmwInfo(MI))
Changed |= expandAtomicCmpxchgOrRmw(MOI.getValue(), MI);
}
}
Changed |= removeAtomicPseudoMIs();
return Changed;
}
INITIALIZE_PASS(SIMemoryLegalizer, DEBUG_TYPE, PASS_NAME, false, false)
char SIMemoryLegalizer::ID = 0;
char &llvm::SIMemoryLegalizerID = SIMemoryLegalizer::ID;
FunctionPass *llvm::createSIMemoryLegalizerPass() {
return new SIMemoryLegalizer();
}
|
; A016958: a(n) = (6n + 4)^2.
; 16,100,256,484,784,1156,1600,2116,2704,3364,4096,4900,5776,6724,7744,8836,10000,11236,12544,13924,15376,16900,18496,20164,21904,23716,25600,27556,29584,31684,33856,36100,38416,40804,43264,45796,48400,51076,53824,56644,59536,62500,65536,68644,71824,75076,78400,81796,85264,88804,92416,96100,99856,103684,107584,111556,115600,119716,123904,128164,132496,136900,141376,145924,150544,155236,160000,164836,169744,174724,179776,184900,190096,195364,200704,206116,211600,217156,222784,228484,234256,240100,246016,252004,258064,264196,270400,276676,283024,289444,295936,302500,309136,315844,322624,329476,336400,343396,350464,357604
mul $0,6
add $0,4
pow $0,2
|
.
. An example of an SIC assembly file
.
COPY START 1000 COPY FILE FROM INPUT TO OUTPUT
FIRST STL RETADR SAVE RETURN ADDRESS
CLOOP JSUB RDREC READ INPUT RECORD
LDA LENGTH TEST FOR EOF (LENGTH = 0)
COMP ZERO
JEQ ENDFIL EXIT IF EOF FOUND
JSUB WRREC WRITE OUTPUT RECORD
J CLOOP LOOP
ENDFIL LDA EOF INSERT END OF FILE MARKER
STA BUFFER
LDA THREE SET LENGTH = 3
STA LENGTH
JSUB WRREC WRITE EOF
LDL RETADR GET RETURN ADDRESS
RSUB RETURN TO CALLER
EOF BYTE C'EOF'
THREE WORD 3
ZERO WORD 0
RETADR RESW 1
LENGTH RESW 1 LENGTH OF RECORD
BUFFER RESB 4096 4096-BYTE BUFFER AREA
.
. SUBROUTINE TO READ RECORD INTO BUFFER
.
RDREC LDX ZERO CLEAR LOOP COUNTER
LDA ZERO CLEAR A TO ZERO
RLOOP TD INPUT TEST INPUT DEVICE
JEQ RLOOP LOOP UNTIL READY
RD INPUT READ CHARACTER INTO REGISTAR A
COMP ZERO TEST FOR END OF RECORD (X'00')
JEQ EXIT EXIT LOOP IF EOF
STCH BUFFER,X STORE CHARCTER IN BUFFER
TIX MAXLEN LOOP UNLESS MAX LENGTH
JLT RLOOP HAS BEEN REACHED
EXIT STX LENGTH SAVE RECORD LENGTH
RSUB RETURN TO CALLER
INPUT BYTE X'F1' CODE FOR INPUT DEVICE
MAXLEN WORD 4096
.
. SUBROUTINE TO WRITE RECORD FROM BUFFER
.
WRREC LDX ZERO CLEAR LOOP COUNTER
WLOOP TD OUTPUT TEST OUTPUT DEVICE
JEQ WLOOP LOOP UNTIL READY
LDCH BUFFER,X GET CHARCTER FROM BUFFER
WD OUTPUT WRITE CHARACTER
TIX LENGTH LOOP UNTIL ALL CHARACTERS
JLT WLOOP HAVE BEEN WRITTEN
RSUB RETURN TO CALLER
OUTPUT BYTE X'05' CODE FOR OUTPUT DEVICE
END FIRST
|
; Original address was $BCEE
; 6-9
.word W609_UnderL ; Alternate level layout
.word W609_UnderO ; Alternate object layout
.byte LEVEL1_SIZE_06 | LEVEL1_YSTART_180
.byte LEVEL2_BGPAL_00 | LEVEL2_OBJPAL_08 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_03 | LEVEL3_VSCROLL_LOCKLOW | LEVEL3_PIPENOTEXIT
.byte LEVEL4_BGBANK_INDEX(12) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_OVERWORLD | LEVEL5_TIME_300
.byte $1A, $00, $10, $5F, $74, $0C, $80, $76, $0A, $83, $78, $08, $85, $36, $0E, $94
.byte $E0, $02, $40, $6E, $18, $8C, $70, $18, $8C, $72, $18, $8C, $74, $18, $8C, $76
.byte $18, $8C, $78, $18, $8F, $2B, $25, $0B, $4D, $23, $E0, $4D, $27, $E0, $78, $3E
.byte $80, $37, $34, $A3, $40, $48, $09, $FF
|
#pragma once
#include "Camera.hpp"
#include "Texture.hpp"
namespace Skye {
class Renderer2D
{
public:
static void Init();
static void Shutdown();
static void Flush();
static void BeginScene(const OrthographicCamera& camera);
static void EndScene();
// Primitives - rotation in radians!
static void DrawQuad(const glm::vec2& position, const float rotation_angle, const glm::vec2& size, const glm::vec4& color);
static void DrawQuad(const glm::vec3& position, const float rotation_angle, const glm::vec2& size, const glm::vec4& color);
static void DrawQuad(const glm::vec2& position, const glm::vec2& size, const float rotation_angle, const Ref<Texture2D>& texture, float tileMultiplier = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f));
static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const float rotation_angle, const Ref<Texture2D>& texture, float tileMultiplier = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f));
// Statistics for drawing
struct Statistics
{
uint32_t DrawCalls{ 0 };
uint32_t QuadCount{ 0 };
uint32_t GetTotalVertexCount() { return QuadCount * 4; }
uint32_t GetTotalIndexCount() { return QuadCount * 6; }
};
static Statistics GetStats();
static void ResetStats();
private:
static void FlushAndReset();
};
} |
; A016919: a(n) = (6*n)^11.
; 0,362797056,743008370688,64268410079232,1521681143169024,17714700000000000,131621703842267136,717368321110468608,3116402981210161152,11384956040305711104,36279705600000000000,103510234140112521216,269561249468963094528,650190514836423555072,1469170321634239709184,3138105960900000000000,6382393305518410039296,12433743083946522728448,23316389970546096340992,42262322980951656843264,74300837068800000000000,127079645979756182501376,211988959518950443450368,345676575099245416998912,552061438912436417593344,864975585937500000000000,1331590174384995440787456,2016810807672035804940288,3008860818706922924408832,4426309024697324523239424,6426841007923200000000000,9218120615459689670977536,13071141489701703760478208,18336527447218512795850752,25464305835922478547861504,35027750054222100000000000,47751966659678405306351616,64547989392109719104944128,86553237464988993215004672,115179299131727923510339584,152168114316902400000000000,199657752537985561759389696,260259114966540661762818048,337145032839390594819950592,434153389094810508186353664,555906056655552300000000000,707945625803254614013771776,896892085195750456196179968,1130621826892669783231168512,1418471565912741035860383744,1771470000000000000000000000,2202600286091874661776377856,2727096677140470662732709888,3362778947134455039659538432,4130428534112329328517709824,5054210651372681700000000000,6162146956711778149189287936,7486643729106643154813687808,9065080882580120623594340352,10940467548815308008476411904,13162170384226713600000000000,15786721204455474199101782016,18878711020461444446161993728,22511778046375868461571254272,26769697770909089301459369984,31747583732247243900000000000,37553208211903514205902340096,44308452666811124371870107648,52150898351969236066020360192,61235568249106027885106264064,71736832111046860800000000000,83850487157725321590910642176,97796027719021374067408109568,113819117912838588948194138112,132194282275040704726925574144,153227830122070312500000000000,177261030328297458104329568256,204673554139436097229551679488,235887204621778787349175468032,271369952365606399975686580224,311640298121016115200000000000,357271984146678126737757198336,408899077197794430483230097408,467221447269921365272965629952,533010667451475275290251362304,607116361520826305100000000000,690473027255071938191258812416,784107364798056947318294243328,889146140866171920765652303872,1006824621053134925509846800384,1138495604030571110400000000000,1285639093030998565918998890496,1449872641645065449500204597248,1632962412666837646144657569792,1836834990480896934289776574464,2063589989304280119300000000000,2315513501476187716057433112576,2595092431930248824098639239168,2905029766989293641442065907712,3248260827692417886246573164544
pow $0,11
mul $0,362797056
|
; A000749: a(n) = 4a(n-1) - 6a(n-2) + 4a(n-3), n > 3, with a(0)=a(1)=a(2)=0, a(3)=1.
; 0,0,0,1,4,10,20,36,64,120,240,496,1024,2080,4160,8256,16384,32640,65280,130816,262144,524800,1049600,2098176,4194304,8386560,16773120,33550336,67108864,134225920,268451840,536887296,1073741824,2147450880,4294901760,8589869056,17179869184,34359869440,68719738880,137439215616,274877906944,549755289600,1099510579200,2199022206976,4398046511104,8796095119360,17592190238720,35184376283136,70368744177664,140737479966720,281474959933440,562949936644096,1125899906842624,2251799847239680,4503599694479360,9007199321849856
mov $3,$0
mov $4,79
lpb $4
mov $2,$3
bin $2,$4
add $1,$2
sub $4,4
lpe
|
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Stephane Tayeb
//
//******************************************************************************
// File Description : Test C3T3 class.
//******************************************************************************
#include <CGAL/Bbox_3.h>
#include "test_utilities.h"
#include <CGAL/Polyhedral_mesh_domain_3.h>
// IO
#include <fstream>
#include <iostream>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/File_medit.h>
#include <CGAL/IO/File_tetgen.h>
template <typename K>
struct Tester
{
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, K> Mesh_domain;
typedef typename CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
typedef CGAL::Mesh_3::Mesh_complex_3_in_triangulation_3_base<Tr,
CGAL::Sequential_tag> C3t3_base_sequential;
typedef CGAL::Mesh_3::Mesh_complex_3_in_triangulation_3_base<Tr,
CGAL::Parallel_tag> C3t3_base_parallel;
typedef typename Tr::Bare_point Bare_point;
typedef typename Tr::Weighted_point Weighted_point;
typedef typename Tr::Geom_traits Gt;
typedef typename Gt::FT FT;
typedef typename C3t3::Cell_handle Cell_handle;
typedef typename C3t3::Facet Facet;
typedef typename C3t3::Facets_in_complex_iterator Facet_iterator;
typedef typename C3t3::Vertex_handle Vertex_handle;
typedef typename C3t3::Subdomain_index Subdomain_index;
typedef typename C3t3::Surface_patch_index Surface_patch_index;
typedef typename C3t3::Index Index;
typedef typename C3t3::size_type size_type;
void operator()() const
{
//-------------------------------------------------------
// Test default constructed c3t3
//-------------------------------------------------------
C3t3 c3t3;
Tr& tr = c3t3.triangulation();
assert(c3t3.cells_in_complex_begin() == c3t3.cells_in_complex_end());
assert(c3t3.facets_in_complex_begin() == c3t3.facets_in_complex_end());
assert(c3t3.number_of_cells_in_complex() == 0);
assert(c3t3.number_of_facets_in_complex() == 0);
//-------------------------------------------------------
// Data generation : fill a triangulation with 4 vertices
//-------------------------------------------------------
Weighted_point p1(0,0,0);
Weighted_point p2(1,0,0);
Weighted_point p3(0,1,0);
Weighted_point p4(0,0,1);
tr.insert(p1);
tr.insert(p2);
tr.insert(p3);
tr.insert(p4);
Subdomain_index subdomain_index (1);
Subdomain_index subdomain_index_bis (2);
Surface_patch_index surface_patch_index (0,1);
Surface_patch_index surface_patch_index_bis (2,3);
Index vertex_index (2);
//-------------------------------------------------------
// Test empty c3t3
//-------------------------------------------------------
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(c3t3.cells_in_complex_begin() == c3t3.cells_in_complex_end());
assert(c3t3.facets_in_complex_begin() == c3t3.facets_in_complex_end());
assert(c3t3.number_of_cells_in_complex() == 0);
assert(c3t3.number_of_facets_in_complex() == 0);
//-------------------------------------------------------
// Add cell to c3t3 and verify
//-------------------------------------------------------
std::cerr << "Insert one cell in c3t3" << std::endl;
Cell_handle ch = tr.finite_cells_begin();
c3t3.add_to_complex(ch,subdomain_index);
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(ch == (Cell_handle)c3t3.cells_in_complex_begin());
assert(c3t3.number_of_cells_in_complex() == 1);
assert(c3t3.number_of_cells_in_complex() == (size_type)std::distance(c3t3.cells_in_complex_begin(),
c3t3.cells_in_complex_end()));
assert(c3t3.is_in_complex(ch));
assert(c3t3.subdomain_index(ch) == subdomain_index);
//-------------------------------------------------------
// Test move construction
//-------------------------------------------------------
C3t3 c3t3_moved{std::move(c3t3)};
assert(c3t3_moved.is_valid());
assert(c3t3.is_valid());
assert(ch == (Cell_handle)c3t3_moved.cells_in_complex_begin());
assert(c3t3_moved.number_of_cells_in_complex() == 1);
assert(c3t3_moved.number_of_cells_in_complex() ==
(size_type)std::distance(c3t3_moved.cells_in_complex_begin(),
c3t3_moved.cells_in_complex_end()));
assert(c3t3_moved.is_in_complex(ch));
assert(c3t3_moved.subdomain_index(ch) == subdomain_index);
assert(c3t3.number_of_cells_in_complex() == 0);
assert(c3t3.number_of_cells_in_complex() == (size_type)std::distance(c3t3.cells_in_complex_begin(),
c3t3.cells_in_complex_end()));
c3t3 = std::move(c3t3_moved);
assert(ch == (Cell_handle)c3t3.cells_in_complex_begin());
assert(c3t3.number_of_cells_in_complex() == 1);
assert(c3t3.number_of_cells_in_complex() == (size_type)std::distance(c3t3.cells_in_complex_begin(),
c3t3.cells_in_complex_end()));
assert(c3t3.is_in_complex(ch));
assert(c3t3.subdomain_index(ch) == subdomain_index);
assert(c3t3_moved.number_of_cells_in_complex() == 0);
assert(c3t3_moved.number_of_cells_in_complex() ==
(size_type)std::distance(c3t3_moved.cells_in_complex_begin(),
c3t3_moved.cells_in_complex_end()));
// -----------------------------------
// Test Cell_in_complex_iterator
// The goal here is to test operators and conversion on iterator type
// -----------------------------------
typename C3t3::Cells_in_complex_iterator cit = c3t3.cells_in_complex_begin();
ch = cit;
typename C3t3::Triangulation::Cell& c1 = *ch;
typename C3t3::Triangulation::Cell& c2 = *cit;
assert( c1.subdomain_index() == c2.subdomain_index() );
assert ( cit->vertex(0) == ch->vertex(0) );
//-------------------------------------------------------
// Remove cell from c3t3 and verify
//-------------------------------------------------------
std::cerr << "Remove cell from c3t3" << std::endl;
c3t3.remove_from_complex(ch);
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(c3t3.number_of_cells_in_complex() == 0);
assert(! c3t3.is_in_complex(ch));
assert(c3t3.subdomain_index(ch) == Subdomain_index());
//-------------------------------------------------------
// Add facet to c3t3 and verify
//-------------------------------------------------------
std::cerr << "Insert one facet in c3t3" << std::endl;
Facet f = *( ++tr.finite_facets_begin() );
c3t3.add_to_complex(f,surface_patch_index);
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(*(c3t3.facets_in_complex_begin()) == f);
assert(c3t3.number_of_facets_in_complex() == 1);
assert(c3t3.number_of_facets_in_complex() == (size_type)std::distance(c3t3.facets_in_complex_begin(),
c3t3.facets_in_complex_end()));
assert(c3t3.is_in_complex(f));
assert(c3t3.surface_patch_index(f) == surface_patch_index);
//-------------------------------------------------------
// Remove facet from c3t3 and verify
//-------------------------------------------------------
std::cerr << "Remove facet from c3t3" << std::endl;
c3t3.remove_from_complex(f);
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(c3t3.facets_in_complex_begin() == c3t3.facets_in_complex_end());
assert(c3t3.number_of_facets_in_complex() == 0);
assert(!c3t3.is_in_complex(f));
assert(c3t3.surface_patch_index(f) == Surface_patch_index());
//-------------------------------------------------------
// Add facet to c3t3 and verify (with f=(c,i))
//-------------------------------------------------------
c3t3.add_to_complex(f.first,f.second,surface_patch_index);
assert(*(c3t3.facets_in_complex_begin()) == f);
assert(c3t3.number_of_facets_in_complex() == 1);
assert(c3t3.number_of_facets_in_complex() == (size_type)std::distance(c3t3.facets_in_complex_begin(),
c3t3.facets_in_complex_end()));
assert(c3t3.is_in_complex(f));
assert(c3t3.surface_patch_index(f) == surface_patch_index);
c3t3.remove_from_complex(f);
//-------------------------------------------------------
// Add 4 facets to c3t3 and verify
//-------------------------------------------------------
std::cerr << "Insert 4 facets in c3t3" << std::endl;
typename Tr::Finite_facets_iterator fit = tr.finite_facets_begin();
while ( fit != tr.finite_facets_end() )
c3t3.add_to_complex(*(fit++), surface_patch_index);
std::cerr << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cerr << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
assert(c3t3.number_of_facets_in_complex() == 4);
assert(c3t3.number_of_facets_in_complex() == (size_type)std::distance(c3t3.facets_in_complex_begin(),
c3t3.facets_in_complex_end()));
//-------------------------------------------------------
// Create c3t3_bis
//-------------------------------------------------------
std::cout << "Insert 6 points from domain in c3t3_bis, add 1 cell to c3t3_bis\n";
Polyhedron polyhedron;
std::ifstream input("data/sphere.off");
input >> polyhedron;
input.close();
Mesh_domain domain(polyhedron);
typedef std::vector<std::pair<Bare_point, Index> > Initial_points_vector;
Initial_points_vector initial_points;
domain.construct_initial_points_object()(std::back_inserter(initial_points), 6);
C3t3 c3t3_bis;
c3t3_bis.insert_surface_points(initial_points.begin(), initial_points.end());
Cell_handle ch_bis = c3t3_bis.triangulation().finite_cells_begin();
c3t3_bis.add_to_complex(ch_bis,subdomain_index);
std::cout << "\tNumber of cells in c3t3_bis: "
<< c3t3_bis.number_of_cells_in_complex() << std::endl;
std::cout << "\tNumber of facets in c3t3_bis: "
<< c3t3_bis.number_of_facets_in_complex() << std::endl;
std::cout << "\tNumber of vertices in c3t3_bis triangulation: "
<< c3t3_bis.triangulation().number_of_vertices() << std::endl;
//-------------------------------------------------------
// Swap c3t3 and c3t3_bis
//-------------------------------------------------------
std::cout << "Swap c3t3 and c3t3_bis\n";
typedef typename C3t3::size_type size_type;
size_type c3t3_cell_nb = c3t3.number_of_cells_in_complex();
size_type c3t3_facet_nb = c3t3.number_of_facets_in_complex();
size_type c3t3_vertex_nb = c3t3.triangulation().number_of_vertices();
size_type c3t3_bis_cell_nb = c3t3_bis.number_of_cells_in_complex();
size_type c3t3_bis_facet_nb = c3t3_bis.number_of_facets_in_complex();
size_type c3t3_bis_vertex_nb = c3t3_bis.triangulation().number_of_vertices();
c3t3.swap(c3t3_bis);
std::cout << "\tNumber of cells in c3t3: "
<< c3t3.number_of_cells_in_complex() << std::endl;
std::cout << "\tNumber of facets in c3t3: "
<< c3t3.number_of_facets_in_complex() << std::endl;
std::cout << "\tNumber of vertices in c3t3 triangulation: "
<< c3t3.triangulation().number_of_vertices() << std::endl;
std::cout << "\tNumber of cells in c3t3_bis: "
<< c3t3_bis.number_of_cells_in_complex() << std::endl;
std::cout << "\tNumber of facets in c3t3_bis: "
<< c3t3_bis.number_of_facets_in_complex() << std::endl;
std::cout << "\tNumber of vertices in c3t3_bis triangulation: "
<< c3t3_bis.triangulation().number_of_vertices() << std::endl;
assert(c3t3_cell_nb == c3t3_bis.number_of_cells_in_complex());
assert(c3t3_facet_nb == c3t3_bis.number_of_facets_in_complex());
assert(c3t3_vertex_nb == c3t3_bis.triangulation().number_of_vertices());
assert(c3t3_bis_cell_nb == c3t3.number_of_cells_in_complex());
assert(c3t3_bis_facet_nb == c3t3.number_of_facets_in_complex());
assert(c3t3_bis_vertex_nb == c3t3.triangulation().number_of_vertices());
// reset
c3t3.swap(c3t3_bis);
//-------------------------------------------------------
// Modify indices and dimension and verify
//-------------------------------------------------------
std::cerr << "Play with indices\n";
c3t3.add_to_complex(ch_bis, subdomain_index);
Facet f2 = *c3t3.facets_in_complex_begin();
Vertex_handle vh = c3t3.triangulation().vertices_begin();
c3t3.set_subdomain_index(ch, subdomain_index_bis);
c3t3.set_surface_patch_index(f2, surface_patch_index_bis);
#ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX
c3t3.set_surface_index(f2, surface_patch_index_bis);
c3t3.set_surface_index(f2.first, f2.second, surface_patch_index_bis);
#endif
c3t3.set_dimension(vh, 1);
c3t3.set_index(vh, vertex_index);
assert(c3t3.subdomain_index(ch) == subdomain_index_bis);
assert(c3t3.surface_patch_index(f2) == surface_patch_index_bis);
#ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX
assert(c3t3.surface_index(f2) == surface_patch_index_bis);
assert(c3t3.surface_index(f2.first, f2.second) == surface_patch_index_bis);
#endif
assert(c3t3.in_dimension(vh) == 1);
assert(c3t3.index(vh) == vertex_index);
c3t3.set_surface_patch_index(f2.first, f2.second, surface_patch_index);
assert(c3t3.surface_patch_index(f2) == surface_patch_index);
// -----------------------------------
// Test subdomain iterators
// -----------------------------------
std::cerr << "Test subdomain iterators\n";
typename C3t3::Cells_in_complex_iterator subdomain_cit =
c3t3.cells_in_complex_begin(subdomain_index);
typename C3t3::Cells_in_complex_iterator subdomain_cit_bis =
c3t3.cells_in_complex_begin(subdomain_index_bis);
typename C3t3::Cells_in_complex_iterator cend =
c3t3.cells_in_complex_end();
std::cout << "\tNumber of cells of index '" << subdomain_index << "': "
<< std::distance(subdomain_cit,cend) << std::endl;
std::cout << "\tNumber of cells of index '" << subdomain_index_bis << "': "
<< std::distance(subdomain_cit_bis,cend) << std::endl;
assert ( std::distance(subdomain_cit,cend) == 0 );
assert ( std::distance(subdomain_cit_bis,cend) == 1 );
assert ( c3t3.subdomain_index(subdomain_cit_bis) == subdomain_index_bis );
// -----------------------------------
// Test surface patch iterators
// -----------------------------------
std::cerr << "Test surface patch iterators\n";
c3t3.set_surface_patch_index(f2.first, f2.second, surface_patch_index_bis);
typename C3t3::Facets_in_complex_iterator patch_fit =
c3t3.facets_in_complex_begin(surface_patch_index);
typename C3t3::Facets_in_complex_iterator patch_fit_bis =
c3t3.facets_in_complex_begin(surface_patch_index_bis);
typename C3t3::Facets_in_complex_iterator fend =
c3t3.facets_in_complex_end();
std::cout << "\tNumber of facets of index '<" << surface_patch_index.first
<< "," << surface_patch_index.second << ">': "
<< std::distance(patch_fit,fend) << std::endl;
std::cout << "\tNumber of facets of index '<" << surface_patch_index_bis.first
<< "," << surface_patch_index.second << ">': "
<< std::distance(patch_fit_bis,fend) << std::endl;
assert ( std::distance(patch_fit,fend) == 3 );
assert ( std::distance(patch_fit_bis,fend) == 1 );
assert ( c3t3.surface_patch_index(*patch_fit) == surface_patch_index );
assert ( c3t3.surface_patch_index(*patch_fit_bis) == surface_patch_index_bis );
std::ofstream out_medit("test-medit.mesh");
CGAL::IO::output_to_medit(out_medit, c3t3);
CGAL::IO::output_to_tetgen("test-tetgen", c3t3);
}
};
int main()
{
std::cerr << "TESTING WITH Exact_predicates_inexact_constructions_kernel...\n";
Tester<K_e_i> test_epic;
test_epic();
std::cerr << "\nTESTING WITH Exact_predicates_exact_constructions_kernel...\n";
Tester<K_e_e> test_epec;
test_epec();
return EXIT_SUCCESS;
}
|
; Fill save area v2.11 1999 Tony Tebby
; 2002 Marcel Kilgus
;
; 2002-02-13 2.11 Changes for on-thy-fly wallpaper colour (MK)
;
; Fill the save area with the image (a1) or the colour in the linkage
; the lines in the image must be rounded up to the nearest long word
; If no save area is given the screen will be used as destination.
;
; D2 image type 0 = native, -1 = none
; A0 ^ cdb preserved
; A1 ^ image
; A3 ^ dddb preserved
;
section driver
;
include 'dev8_keys_con'
include 'dev8_keys_iod'
include 'dev8_keys_chn'
;
xdef pt_fillsv
xref pt_mblock
xref cn_fblock
xref.s pt.spxlw
xref.s pt.rpxlw
xref.l pt.samsk
;
pt_fillsv
ptf.reg reg d1-d7/a1-a5
stk_d2 equ $04
movem.l ptf.reg,-(sp)
move.w pt_bgstp(a3),d6 ; stipple
move.l pt_bgclm(a3),d7 ; colour
moveq #pt.rpxlw,d3 ;
add.w sd_xhits(a0),d3 ; save area size, rounded up
move.w #pt.spxlw,d0 ; to number of bytes
lsr.l d0,d3 ; to nearest long word
lsl.w #2,d3 ; in bytes
move.l d3,a2 ; source increment
move.l sd_wsave(a0),d0 ; get save area
beq.s ptf_screen ; none, use screen directly
move.l d0,a5 ; destination is save area
lea 4(a2),a3 ; destination increment
move.l #pt.samsk,d3
and.l sd_xhito(a0),d3 ; x-origin is offset this much in save
move.w sd_yhito(a0),d3
andi.w #1,d3 ; origin at odd line?
beq.s ptf_do
sub.l a3,a5 ; yes, adjust base. This is to correct
bra.s ptf_do ; the stipple line order
ptf_screen
move.l pt_scren(a3),a5 ; screen is destination
move.w pt_scinc(a3),a3 ; destination increment
move.l sd_xhito(a0),d3 ; absolute origin on screen
ptf_do
move.l sd_xhits(a0),d1 ; size
tst.l stk_d2(sp) ; image?
bne.s ptf_block
move.l a1,a4 ; source address
moveq #0,d2 ; source origin
jsr pt_mblock ; move an area
bra.s ptf_ok
ptf_block
move.l a3,a2 ; line increment
move.l a5,a1 ; base of area
move.l d3,d2 ; origin
jsr cn_fblock
ptf_ok
movem.l (sp)+,ptf.reg
moveq #0,d0
rts
;
end
|
; A126121: Numerators of sequence of fractions with e.g.f. sqrt(1+x)/(1-x)^2.
; Submitted by Jon Maiga
; 1,5,31,255,2577,31245,439695,7072695,127699425,2562270165,56484554175,1358576240175,35374065613425,992016072172125,29792674421484975,954480422711190375,32479589325536978625,1170329273010701929125,44502357662442514209375,1781390379962467540641375,74859445955552143761500625,3295777452916207485459358125,151675046660308209060566919375,7284014590075631866512363684375,364341523829964507321507498110625,18953709935007708686644616876203125,1023839435441448037103067204563109375
mov $3,1
lpb $0
mov $2,$3
mul $3,5
add $3,$1
mov $1,$0
sub $0,1
add $1,$0
bin $1,2
mul $2,2
mul $1,$2
lpe
mov $0,$3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r9
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x88a6, %r11
and %rbp, %rbp
movb $0x61, (%r11)
nop
dec %rbx
lea addresses_UC_ht+0x1b1f6, %rax
nop
sub $62896, %r13
vmovups (%rax), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %r9
nop
add %r9, %r9
lea addresses_normal_ht+0x1da4e, %r12
nop
nop
nop
nop
nop
add $528, %r13
vmovups (%r12), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %rbp
and %r11, %r11
lea addresses_WC_ht+0xb37a, %r11
nop
nop
nop
nop
add %rax, %rax
movb $0x61, (%r11)
nop
nop
sub $3901, %rbp
lea addresses_normal_ht+0x7866, %rsi
lea addresses_normal_ht+0x10076, %rdi
nop
add $1200, %r11
mov $107, %rcx
rep movsq
cmp %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r8
push %r9
push %rax
push %rdi
// Load
lea addresses_WT+0xccd6, %r8
cmp %r13, %r13
movb (%r8), %r11b
nop
nop
nop
nop
nop
sub $23674, %rax
// Store
lea addresses_WC+0xa7f6, %rdi
nop
nop
sub $58959, %r10
mov $0x5152535455565758, %r9
movq %r9, %xmm0
vmovups %ymm0, (%rdi)
cmp $37312, %r11
// Store
lea addresses_PSE+0x1d596, %r10
nop
nop
nop
nop
nop
and %r8, %r8
mov $0x5152535455565758, %rdi
movq %rdi, (%r10)
nop
nop
nop
nop
add %r9, %r9
// Store
lea addresses_normal+0x15f6, %r11
nop
nop
xor $29820, %r8
movl $0x51525354, (%r11)
cmp %rax, %rax
// Faulty Load
lea addresses_normal+0x141f6, %r10
nop
nop
nop
nop
and %r9, %r9
mov (%r10), %r8w
lea oracles, %r9
and $0xff, %r8
shlq $12, %r8
mov (%r9,%r8,1), %r8
pop %rdi
pop %rax
pop %r9
pop %r8
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 2}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.