text stringlengths 1 1.05M |
|---|
; A314753: Coordination sequence Gal.4.52.2 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,19,23,27,32,37,41,45,51,55,59,64,69,73,77,83,87,91,96,101,105,109,115,119,123,128,133,137,141,147,151,155,160,165,169,173,179,183,187,192,197,201,205,211,215,219,224
mov $5,$0
mul $0,2
mov $1,2
mov $2,2
lpb $0,1
sub $0,4
sub $0,$4
trn $0,2
add $1,$4
add $1,4
mov $3,$4
trn $3,$0
add $0,1
sub $1,4
mov $4,2
sub $4,$3
lpe
add $1,$2
lpb $5,1
add $1,4
sub $5,1
lpe
sub $1,3
|
// Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef ARGS_FWD_DWA2002927_HPP
# define ARGS_FWD_DWA2002927_HPP
# include <boost/python/detail/prefix.hpp>
# include <boost/python/handle.hpp>
# include <boost/config.hpp>
# include <cstddef>
# include <utility>
namespace boost { namespace python {
namespace detail
{
struct keyword
{
keyword(char const* name_=0)
: name(name_)
{}
char const* name;
handle<> default_value;
};
template <std::size_t nkeywords = 0> struct keywords;
typedef std::pair<keyword const*, keyword const*> keyword_range;
template <>
struct keywords<0>
{
BOOST_STATIC_CONSTANT(std::size_t, size = 0);
static keyword_range range() { return keyword_range(); }
};
namespace error
{
template <int keywords, int function_args>
struct more_keywords_than_function_arguments
{
typedef char too_many_keywords[keywords > function_args ? -1 : 1];
};
}
}
}} // namespace boost::python
#endif // ARGS_FWD_DWA2002927_HPP
|
%include "struct.inc"
;In this file,we don't need interrupt_table_addr in struct.inc
ORG 0x100
CLI
MOV AX,0
MOV ES,AX
MOV AX,CS
MOV word [ES:(0x08*4)],timer_intrrrupt;Offset
MOV word [ES:(0x08*4+2)],AX;Segment
MOV word [ES:(0x09*4)],keyboard_interrupt;Offset
MOV word [ES:(0x09*4+2)],AX;Segment
MOV word [ES:(0x21*4)],dos_interrupt;Offset
MOV word [ES:(0x21*4+2)],AX;Segment
mov al,0b00000001;Enable all of the interrupt of the master 8259A
out 0x21,al;Master 8259A,OCW1
mov al,0b00000000;Enable all of the interrupt of the slave 8259A
out 0x0A1,al;Slave 8259A,OCW1
STI
MOV BX,in_dos_text
call reset_disk
;Address:0x3CA00
;H 0
;S 5
;C 6
MOV AX,0x00F0
MOV ES,AX
MOV AH,0x02
MOV AL,0x01
;Sector number
MOV CH,13
MOV CL,18
MOV DX,0
MOV BX,0x00
int 0x13
JC run_program_failed
MOV BX,0
PUSH BX
next_file:
MOV CX,command_name
CMP BX,512
JE command_not_found;There is no command.com
compare_next_char:
CMP CX,command_name+11
JE compare2
MOV AL,[ES:BX];AL name in root directory
PUSH BX
MOV BX,CX
MOV AH,[BX];AH name in command_name
POP BX
CMP AL,AH
JNE not_this_file
ADD BX,1
ADD CX,1
JMP compare_next_char
find_file:
POP BX
call cluster_translate
call reset_disk
CLI
MOV AH,0x02
;Read
MOV AL,2
;Sector number of each program
MOV DL,0x00
MOV BX,0x00
int 0x13
JC run_program_failed
MOV AX,0x0E0
MOV DS,AX
MOV ES,AX
JMP 0x0E0:0x100;0x0F00
loop:
JMP loop
reset_disk:
PUSHA
MOV AX,0x00
MOV DX,0x00
int 0x13
JC run_program_failed
POPA
ret
not_this_file:
POP BX
ADD BX,0x20
PUSH BX;Turn to start address
JMP next_file
compare2:
POP BX
PUSH BX;Turn to start
CMP byte [ES:BX],0xE5
JE not_this_file
ADD BX,0xB
CMP byte [ES:BX],0x0F
JE not_this_file
ADD BX,-0xB+0x1A
MOV AX,[ES:BX];Save cluster id
CMP AX,0x0002
JL not_this_file
ADD BX,-0x1A+0x1C
CMP dword [ES:BX],2048
JG not_this_file
JMP find_file
cluster_translate:
;0x40A00+cluster*8192
;cluster is in AX
;It will set CH CL and DH.
MOV CH,14
MOV CL,14
MOV DH,0x00
cluster_translate_start:
CMP AX,2
JLE cluster_translate_finished
ADD CL,16
ADD AX,-1
CMP CL,18
JLE cluster_translate_start
CMP DH,0x1
JE next_cylinder
cluster_translate_next:
NOT DH
AND DH,0x1
ADD CL,-18
JMP cluster_translate_start
cluster_translate_finished:
ret
next_cylinder:
ADD CH,1
JMP cluster_translate_next
in_dos_text:
db "DOS",0x00
%include "print.inc"
show_cursor:
PUSH AX
PUSH CX
MOV AH,0x01
MOV AL,0x00
MOV CX,0x0607
;INT 0x10
POP CX
POP AX
ret
hide_cursor:
PUSH AX
PUSH CX
MOV AH,0x01
MOV AL,0x00
MOV CX,0x0706
;OR MOV CX,0x2706
;http://en.wikipedia.org/wiki/INT_10H
;INT 0x10
POP CX
POP AX
ret
command_not_found:
MOV BX,command_not_found_text
call print_text
JMP loop
run_program_failed:
MOV BX,run_program_failed_text
call print_text
JMP loop
command_not_found_text:
db "There is no command.com.",0x00
run_program_failed_text:
db "Run command.com failed.",0x00
command_name:
db "COMMAND COM"
;times 512-($-$$) db 0
;You can save things in both sector
;Interrupt Sector
;timer interrupt
timer_intrrrupt:
;MOV BX,interrupt_text
;call print_text
PUSHA
PUSH DS
MOV AX,CS
MOV DS,AX
MOV BX,interrupt_table+interrupt_space0
MOV AL,[DS:BX]
CMP AL,9
;Cursor flash
JE deal_interrupt
ADD AL,1
MOV [DS:BX],AL;Add interrupt_space0
stop_interrupt:
mov al,20h;EOI
out 20h,al;Send EOI to master 8259A
out 0A0h,al;Send EOI to slave 8259A
PUSH DS
POPA
iret
deal_interrupt:
MOV BX,interrupt_table+interrupt_space0
MOV byte [DS:BX],0;Set interrupt_space0 to zero
MOV BX,interrupt_table+interrupt_space1
MOV AL,[DS:BX]
CMP AL,0
JE hide_cursor_interrupt
call show_cursor
MOV byte [DS:BX],0
JMP stop_interrupt
hide_cursor_interrupt:
call hide_cursor
MOV byte [DS:BX],1
JMP stop_interrupt
keyboard_interrupt:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
MOV AX,CS
MOV DS,AX
in al,60h;Keyboard port
;Find ASCII
MOV BX,keyboard_table+1
MOV CX,special_keyboard_table
re_match:
PUSH BX
MOV BX,CX
MOV AH,[DS:BX]
POP BX
cmp al,ah
JE deal_with_special_key
CMP AH,0
JNE add_cx
;If special keys' table is end,ignore.
add_cx_next:
MOV AH,[DS:BX]
CMP AH,0
JE stop_keyboard_interrupt
;If normal keys' table is end,exit.
cmp al,ah
je print_keyboard
CMP AH,0
JNE add_bx
add_bx_next:
JMP re_match
stop_keyboard_interrupt:
mov al,20h;EOI
out 20h,al;Send EOI to master 8259A
out 0A0h,al;Send EOI to slave 8259A
POP DS
POP DX
POP CX
POP BX
POP AX
iret
add_cx:
ADD CX,3
JMP add_cx_next
add_bx:
ADD BX,2
JMP add_bx_next
print_keyboard:
PUSH BX
;Read caps lock
MOV BX,interrupt_table+interrupt_space2
MOV AH,[DS:BX];Caps lock
MOV BX,interrupt_table+interrupt_space3
MOV AL,[DS:BX];Shift
XOR AH,AL;Shift and Caps lock
;S C CAPITAL
;1 1 0
;0 1 1
;1 0 1
;0 0 0
POP BX
;Read ASCII code
ADD BX,-1
;DW is opposite
MOV AL,[DS:BX]
;Compare
CMP AH,1
JE capital_case1
keyboard_print_char:
MOV BX,interrupt_table+keyboard_buffer_pointer
MOV AH,[DS:BX]
CMP BX,interrupt_table+keyboard_buffer_length
;You can save default 32 chars.
JE stop_keyboard_interrupt;It's full
MOV BX,interrupt_table+keyboard_buffer
PUSH AX
MOV AL,AH
MOV AH,0
ADD AX,BX
MOV BX,AX
POP AX
MOV [DS:BX],AL
;Save char to buffer
MOV BX,interrupt_table+keyboard_buffer_pointer
MOV AH,[DS:BX]
ADD AH,1
MOV [DS:BX],AH
;Buffer's pointer
MOV BX,interrupt_table+interrupt_space5
MOV AH,[DS:BX]
CMP AH,0
JE stop_keyboard_interrupt
;Stop if program does not allow this program to print text
call print_char
JMP stop_keyboard_interrupt
capital_case1:
CMP AL,'a'
JL keyboard_print_char
;Jump If Less
CMP AL,'z'
JG keyboard_print_char
;Jump If Bigger(greater)
ADD AL,-('a'-'A')
JMP keyboard_print_char
press_enter_key:
;Enter
PUSH AX
MOV BX,interrupt_table+interrupt_space5
MOV AL,[DS:BX]
CMP AL,0
JE press_enter_key_next
call return
press_enter_key_next:
MOV BX,interrupt_table+interrupt_space4
MOV AL,[DS:BX]
CMP AL,1
JE press_enter_key_program_is_running
MOV BX,interrupt_table+interrupt_space4
MOV byte [DS:BX],1
;Run program.
press_enter_key_program_is_running:
POP AX
ret
press_caps_lock_key:
MOV BX,interrupt_table+interrupt_space2
;MOV AL,[DS:BX]
;ADD AL,'0'
;call print_char
NOT byte [DS:BX]
AND byte [DS:BX],1
ret
press_backspace_key:
MOV BX,interrupt_table+keyboard_buffer_pointer
MOV AL,[DS:BX]
CMP AL,0
JE press_backspace_key_end;It's empty
ADD AL,-1
MOV [DS:BX],AL
MOV AL,0x08
call print_char
MOV AL,0x20
call print_char
MOV AL,0x08
call print_char
press_backspace_key_end:
ret
press_shift_key:
MOV BX,interrupt_table+interrupt_space3
MOV byte [DS:BX],1
ret
release_shift_key:
MOV BX,interrupt_table+interrupt_space3
MOV byte [DS:BX],0
ret
deal_with_special_key:
ADD CX,1
MOV BX,CX
MOV AX,[DS:BX]
call [DS:BX]
JMP stop_keyboard_interrupt
dos_interrupt:
PUSH AX
PUSH BX
PUSH DS
PUSH AX
MOV AX,CS
MOV DS,AX
POP AX
CMP AH,0x4C
JE exit_dos_program
stop_dos_interrupt:
mov al,20h;EOI
out 20h,al;Send EOI to master 8259A
out 0A0h,al;Send EOI to slave 8259A
POP DS
POP BX
POP AX
iret
exit_dos_program:
POP DS
POP BX
POP AX
mov al,20h;EOI
out 20h,al;Send EOI to master 8259A
out 0A0h,al;Send EOI to slave 8259A
MOV AX,0xD0
MOV DS,AX
MOV ES,AX
MOV BX,interrupt_table+return_code
MOV [DS:BX],AL
MOV BX,interrupt_table+interrupt_space4
MOV byte [DS:BX],0
POP AX
POP AX
MOV AX,0
;Fake POP
PUSH 0x50;CS
PUSH 0x100;IP
;Replace the data in memory and execute iret to jump to run_cmd
iret
;JMP 0xD0:0x100
%include "keymap.asm"
times 1536-($-$$) db 0
interrupt_table:
istruc interrupt_table_type
at interrupt_space5, db 1
at keyboard_buffer_pointer, db 0
at keyboard_buffer,times keyboard_buffer_length db 0
at program_name_buffer, db " COM"
iend
times 2048-($-$$) db 0
times 8192-($-$$) db 0 |
; A032918: Numbers whose set of base-11 digits is {1,3}.
; Submitted by Simon Strandgaard
; 1,3,12,14,34,36,133,135,155,157,375,377,397,399,1464,1466,1486,1488,1706,1708,1728,1730,4126,4128,4148,4150,4368,4370,4390,4392,16105,16107,16127,16129,16347,16349,16369,16371,18767,18769,18789,18791,19009,19011,19031,19033,45387,45389,45409,45411,45629,45631,45651,45653,48049,48051,48071,48073,48291,48293,48313,48315,177156,177158,177178,177180,177398,177400,177420,177422,179818,179820,179840,179842,180060,180062,180082,180084,206438,206440,206460,206462,206680,206682,206702,206704,209100
add $0,1
mov $2,1
lpb $0
mul $0,2
sub $0,1
mov $3,$0
div $0,4
mod $3,4
mul $3,$2
add $1,$3
mul $2,11
lpe
mov $0,$1
|
; A001654: Golden rectangle numbers: F(n)*F(n+1), where F(n) = A000045(n) (Fibonacci numbers).
; 0,1,2,6,15,40,104,273,714,1870,4895,12816,33552,87841,229970,602070,1576239,4126648,10803704,28284465,74049690,193864606,507544127,1328767776,3478759200,9107509825,23843770274,62423800998,163427632719,427859097160,1120149658760,2932589879121,7677619978602,20100270056686,52623190191455,137769300517680,360684711361584,944284833567073,2472169789339634,6472224534451830
mov $18,$0
mov $20,$0
lpb $20
clr $0,18
mov $0,$18
sub $20,1
sub $0,$20
mov $15,$0
mov $17,$0
lpb $17
mov $0,$15
sub $17,1
sub $0,$17
mov $11,$0
mov $13,2
lpb $13
mov $0,$11
sub $13,1
add $0,$13
mov $1,3
mov $5,-2
mov $8,3
lpb $0
sub $0,1
sub $3,$8
add $5,$1
mov $1,$3
mov $3,$5
add $3,6
mov $8,1
lpe
pow $1,2
div $1,36
mul $1,3
mov $3,3
mov $14,$13
lpb $14
mov $12,$1
sub $14,1
lpe
lpe
lpb $11
mov $11,0
sub $12,$1
lpe
mov $1,$12
div $1,3
add $16,$1
lpe
add $19,$16
lpe
mov $1,$19
|
INCLUDE "config_zxn_private.inc"
SECTION code_user
PUBLIC _load_snap
PUBLIC _load_nex
defc MAX_NAME_LEN = 48
;;;;;;;;;;;;;;;;;;;;;;
; void load_snap(void)
;;;;;;;;;;;;;;;;;;;;;;
_load_snap:
ld sp,(__SYSVAR_ERRSP)
call close_dot_handle
; place reclaim_stub on stack
; addr of reclaim_stub left on stack
call stack_reclaim_stub
; make room for snap_stub underneath PROG
ld hl,(__SYSVAR_PROG)
ld bc,snap_stub_end - snap_stub + MAX_NAME_LEN + 1
push bc
rst __ESX_RST_ROM
defw __ROM3_MAKE_ROOM ; insert space before hl
inc hl ; point at space
pop bc
pop de
push bc ; save space size for reclaim_stub
push hl ; save space addr for reclaim_stub
push hl ; save exec address
push de ; save addr of reclaim_stub
; copy snap_stub except two bytes for jp destination
ex de,hl
ld hl,snap_stub
ld bc,snap_stub_end - snap_stub - 2
ldir
; write address of reclaim_stub into jp
pop hl ; hl = addr of reclaim_stub
ex de,hl
ld (hl),e
inc hl
ld (hl),d
inc hl
ex de,hl
; copy filename
push de
pop ix ; ix = filename
call stack_copy_name
ld a,0xff
ld (de),a ; terminate with 0xff
pop hl ; hl = exec address
rst __ESX_RST_EXITDOT
; must be below PROG not in stack
snap_stub:
push ix
pop hl
exx
ld de,__NEXTOS_IDE_SNAPLOAD
ld c,7
rst __ESX_RST_SYS
defb __ESX_M_P3DOS
jp 0 ; jump to reclaim_stub
snap_stub_end:
;;;;;;;;;;;;;;;;;;;;;
; void load_nex(void)
;;;;;;;;;;;;;;;;;;;;;
_load_nex:
ld sp,(__SYSVAR_ERRSP)
call close_dot_handle
; place reclaim_stub on stack
; addr of reclaim_stub left on stack
call stack_reclaim_stub
; make room for nex_stub underneath PROG
ld hl,(__SYSVAR_PROG)
ld bc,nex_stub_end - nex_stub + MAX_NAME_LEN + 1
push bc
rst __ESX_RST_ROM
defw __ROM3_MAKE_ROOM ; insert space before hl
inc hl ; point at space
pop bc
pop de
push bc ; save space size for reclaim_stub
push hl ; save space addr for reclaim_stub
push hl ; save exec address
push de ; save addr of reclaim_stub
; copy nex_stub except two bytes for jp destination
ex de,hl
ld hl,nex_stub
ld bc,nex_stub_cmd - nex_stub - 2
ldir
; write address of reclaim_stub into jp
pop hl ; hl = addr of reclaim_stub
ex de,hl
ld (hl),e
inc hl
ld (hl),d
inc hl
ex de,hl
; copy dot command
push de
pop ix ; ix = dot command
ld hl,nex_stub_cmd
ld bc,nex_stub_end - nex_stub_cmd
ldir
; copy filename
call stack_copy_name
xor a
ld (de),a ; zero terminate
pop hl ; hl = exec address
rst __ESX_RST_EXITDOT
; must be below PROG not in stack
nex_stub:
push ix
pop hl
rst __ESX_RST_SYS
defb __ESX_M_EXECCMD
jp 0 ; jump to reclaim_stub
nex_stub_cmd:
defm "nexload "
nex_stub_end:
;;;;;;;;;;;;;;;;;;
; close dot handle
;;;;;;;;;;;;;;;;;;
; exit via rst$20 does not close the dot handle
close_dot_handle:
rst __ESX_RST_SYS
defb __ESX_M_GETHANDLE
rst __ESX_RST_SYS
defb __ESX_F_CLOSE
ret
;;;;;;;;;;;;;;;;;;;;;;;
; stack execution tools
;;;;;;;;;;;;;;;;;;;;;;;
EXTERN _program_name
EXTERN asm_basename
; copy program name to max length without terminating zero
stack_copy_name:
push de ; save destination
ld hl,_program_name
call asm_basename
pop de
ld bc,MAX_NAME_LEN
xor a
loop_name:
cp (hl)
ret z ; if terminator met
ldi
jp pe, loop_name ; if max len not exceeded
ret
; copy reclaim_stub code to stack
; leave address of reclaim_stub on stack
stack_reclaim_stub:
pop ix
ld hl,reclaim_stub - reclaim_stub_end
add hl,sp
ld sp,hl
push hl ; save address of reclaim_stub
ex de,hl
ld hl,reclaim_stub
ld bc,reclaim_stub_end - reclaim_stub
ldir
jp (ix)
reclaim_stub:
pop hl ; space addr
pop bc ; space size
call __ROM3_RECLAIM_2 ; release reserved memory
rst 8
defb __ERRB_Q_PARAMETER_ERROR - 1
reclaim_stub_end:
|
SECTION code_clib
PUBLIC res_MODE0
.res_MODE0
ld a,l
cp 48
ret nc
ld a,h
cp 64
ret nc
defc NEEDunplot = 1
INCLUDE "graphics/generic_console/pixel6.asm"
|
###############################################################################
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# 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.
###############################################################################
.text
.p2align 5, 0x90
.globl _e9_EncryptStreamCTR32_AES_NI
_e9_EncryptStreamCTR32_AES_NI:
push %rbx
sub $(128), %rsp
movdqu (%r9), %xmm0
movslq %r8d, %r8
lea (15)(%r8), %r11
shr $(4), %r11
movq (8)(%r9), %rax
movq (%r9), %rbx
bswap %rax
bswap %rbx
mov %eax, %r10d
add %r11, %rax
adc $(0), %rbx
bswap %rax
bswap %rbx
movq %rax, (8)(%r9)
movq %rbx, (%r9)
movl (12)(%rcx), %r11d
pxor (%rcx), %xmm0
add $(16), %rcx
movdqa %xmm0, (%rsp)
movdqa %xmm0, (16)(%rsp)
movdqa %xmm0, (32)(%rsp)
movdqa %xmm0, (48)(%rsp)
movdqa %xmm0, (64)(%rsp)
movdqa %xmm0, (80)(%rsp)
movdqa %xmm0, (96)(%rsp)
movdqa %xmm0, (112)(%rsp)
mov %rsp, %r9
cmp $(16), %r8
jle .Lshort123_inputgas_1
movdqa %xmm0, %xmm1
movdqa %xmm0, %xmm2
movdqa %xmm0, %xmm3
lea (1)(%r10d), %ebx
lea (2)(%r10d), %eax
lea (3)(%r10d), %r9d
bswap %ebx
bswap %eax
bswap %r9d
xor %r11d, %ebx
pinsrd $(3), %ebx, %xmm1
xor %r11d, %eax
pinsrd $(3), %eax, %xmm2
xor %r11d, %r9d
pinsrd $(3), %r9d, %xmm3
movdqa %xmm1, (16)(%rsp)
movdqa %xmm2, (32)(%rsp)
movdqa %xmm3, (48)(%rsp)
mov %rsp, %r9
movdqa (%rcx), %xmm4
movdqa (16)(%rcx), %xmm5
cmp $(64), %r8
jl .Lshort123_inputgas_1
jz .Lshort_inputgas_1
lea (4)(%r10d), %eax
lea (5)(%r10d), %ebx
bswap %eax
bswap %ebx
xor %r11d, %ebx
xor %r11d, %eax
movl %eax, (76)(%rsp)
movl %ebx, (92)(%rsp)
lea (6)(%r10d), %eax
lea (7)(%r10d), %ebx
bswap %eax
bswap %ebx
xor %r11d, %eax
xor %r11d, %ebx
movl %eax, (108)(%rsp)
movl %ebx, (124)(%rsp)
cmp $(128), %r8
jl .Lshort_inputgas_1
sub $(64), %rsp
movdqa %xmm10, (%rsp)
movdqa %xmm11, (16)(%rsp)
movdqa %xmm12, (32)(%rsp)
movdqa %xmm13, (48)(%rsp)
push %rcx
push %rdx
sub $(128), %r8
.p2align 5, 0x90
.Lblk8_loopgas_1:
add $(32), %rcx
add $(8), %r10d
sub $(4), %rdx
movdqa (64)(%r9), %xmm6
movdqa (80)(%r9), %xmm7
movdqa (96)(%r9), %xmm8
movdqa (112)(%r9), %xmm9
mov %r10d, %eax
aesenc %xmm4, %xmm0
lea (1)(%r10d), %ebx
aesenc %xmm4, %xmm1
bswap %eax
aesenc %xmm4, %xmm2
bswap %ebx
aesenc %xmm4, %xmm3
xor %r11d, %eax
aesenc %xmm4, %xmm6
xor %r11d, %ebx
aesenc %xmm4, %xmm7
movl %eax, (12)(%r9)
aesenc %xmm4, %xmm8
movl %ebx, (28)(%r9)
aesenc %xmm4, %xmm9
movdqa (%rcx), %xmm4
lea (2)(%r10d), %eax
aesenc %xmm5, %xmm0
lea (3)(%r10d), %ebx
aesenc %xmm5, %xmm1
bswap %eax
aesenc %xmm5, %xmm2
bswap %ebx
aesenc %xmm5, %xmm3
xor %r11d, %eax
aesenc %xmm5, %xmm6
xor %r11d, %ebx
aesenc %xmm5, %xmm7
movl %eax, (44)(%r9)
aesenc %xmm5, %xmm8
movl %ebx, (60)(%r9)
aesenc %xmm5, %xmm9
movdqa (16)(%rcx), %xmm5
.p2align 5, 0x90
.Lcipher_loopgas_1:
add $(32), %rcx
sub $(2), %rdx
aesenc %xmm4, %xmm0
aesenc %xmm4, %xmm1
aesenc %xmm4, %xmm2
aesenc %xmm4, %xmm3
aesenc %xmm4, %xmm6
aesenc %xmm4, %xmm7
aesenc %xmm4, %xmm8
aesenc %xmm4, %xmm9
movdqa (%rcx), %xmm4
aesenc %xmm5, %xmm0
aesenc %xmm5, %xmm1
aesenc %xmm5, %xmm2
aesenc %xmm5, %xmm3
aesenc %xmm5, %xmm6
aesenc %xmm5, %xmm7
aesenc %xmm5, %xmm8
aesenc %xmm5, %xmm9
movdqa (16)(%rcx), %xmm5
jnz .Lcipher_loopgas_1
lea (4)(%r10d), %eax
aesenc %xmm4, %xmm0
lea (5)(%r10d), %ebx
aesenc %xmm4, %xmm1
bswap %eax
aesenc %xmm4, %xmm2
bswap %ebx
aesenc %xmm4, %xmm3
xor %r11d, %eax
aesenc %xmm4, %xmm6
xor %r11d, %ebx
aesenc %xmm4, %xmm7
movl %eax, (76)(%r9)
aesenc %xmm4, %xmm8
movl %ebx, (92)(%r9)
aesenc %xmm4, %xmm9
lea (6)(%r10d), %eax
aesenclast %xmm5, %xmm0
lea (7)(%r10d), %ebx
aesenclast %xmm5, %xmm1
bswap %eax
aesenclast %xmm5, %xmm2
bswap %ebx
aesenclast %xmm5, %xmm3
xor %r11d, %eax
aesenclast %xmm5, %xmm6
xor %r11d, %ebx
aesenclast %xmm5, %xmm7
movl %eax, (108)(%r9)
aesenclast %xmm5, %xmm8
movl %ebx, (124)(%r9)
aesenclast %xmm5, %xmm9
movdqu (%rdi), %xmm10
movdqu (16)(%rdi), %xmm11
movdqu (32)(%rdi), %xmm12
movdqu (48)(%rdi), %xmm13
pxor %xmm10, %xmm0
pxor %xmm11, %xmm1
pxor %xmm12, %xmm2
pxor %xmm13, %xmm3
movdqu %xmm0, (%rsi)
movdqu %xmm1, (16)(%rsi)
movdqu %xmm2, (32)(%rsi)
movdqu %xmm3, (48)(%rsi)
movdqu (64)(%rdi), %xmm10
movdqu (80)(%rdi), %xmm11
movdqu (96)(%rdi), %xmm12
movdqu (112)(%rdi), %xmm13
pxor %xmm10, %xmm6
pxor %xmm11, %xmm7
pxor %xmm12, %xmm8
pxor %xmm13, %xmm9
movdqu %xmm6, (64)(%rsi)
movdqu %xmm7, (80)(%rsi)
movdqu %xmm8, (96)(%rsi)
movdqu %xmm9, (112)(%rsi)
movq (8)(%rsp), %rcx
movq (%rsp), %rdx
movdqa (%r9), %xmm0
movdqa (16)(%r9), %xmm1
movdqa (32)(%r9), %xmm2
movdqa (48)(%r9), %xmm3
movdqa (%rcx), %xmm4
movdqa (16)(%rcx), %xmm5
add $(128), %rdi
add $(128), %rsi
sub $(128), %r8
jge .Lblk8_loopgas_1
pop %rdx
pop %rcx
movdqa (%rsp), %xmm10
movdqa (16)(%rsp), %xmm11
movdqa (32)(%rsp), %xmm12
movdqa (48)(%rsp), %xmm13
add $(64), %rsp
add $(128), %r8
jz .Lquitgas_1
.p2align 5, 0x90
.Lshort_inputgas_1:
cmp $(64), %r8
jl .Lshort123_inputgas_1
mov %rcx, %rbx
lea (-2)(%rdx), %r10
.p2align 5, 0x90
.Lcipher_loop4gas_1:
add $(32), %rbx
sub $(2), %r10
aesenc %xmm4, %xmm0
aesenc %xmm4, %xmm1
aesenc %xmm4, %xmm2
aesenc %xmm4, %xmm3
movdqa (%rbx), %xmm4
aesenc %xmm5, %xmm0
aesenc %xmm5, %xmm1
aesenc %xmm5, %xmm2
aesenc %xmm5, %xmm3
movdqa (16)(%rbx), %xmm5
jnz .Lcipher_loop4gas_1
movdqu (%rdi), %xmm6
movdqu (16)(%rdi), %xmm7
movdqu (32)(%rdi), %xmm8
movdqu (48)(%rdi), %xmm9
add $(64), %rdi
aesenc %xmm4, %xmm0
aesenc %xmm4, %xmm1
aesenc %xmm4, %xmm2
aesenc %xmm4, %xmm3
aesenclast %xmm5, %xmm0
aesenclast %xmm5, %xmm1
aesenclast %xmm5, %xmm2
aesenclast %xmm5, %xmm3
pxor %xmm6, %xmm0
movdqu %xmm0, (%rsi)
pxor %xmm7, %xmm1
movdqu %xmm1, (16)(%rsi)
pxor %xmm8, %xmm2
movdqu %xmm2, (32)(%rsi)
pxor %xmm9, %xmm3
movdqu %xmm3, (48)(%rsi)
add $(64), %rsi
add $(64), %r9
sub $(64), %r8
jz .Lquitgas_1
.Lshort123_inputgas_1:
lea (,%rdx,4), %rbx
lea (-160)(%rcx,%rbx,4), %rbx
.Lsingle_blkgas_1:
movdqa (%r9), %xmm0
add $(16), %r9
cmp $(12), %rdx
jl .Lkey_128_sgas_1
jz .Lkey_192_sgas_1
.Lkey_256_sgas_1:
aesenc (-64)(%rbx), %xmm0
aesenc (-48)(%rbx), %xmm0
.Lkey_192_sgas_1:
aesenc (-32)(%rbx), %xmm0
aesenc (-16)(%rbx), %xmm0
.Lkey_128_sgas_1:
aesenc (%rbx), %xmm0
aesenc (16)(%rbx), %xmm0
aesenc (32)(%rbx), %xmm0
aesenc (48)(%rbx), %xmm0
aesenc (64)(%rbx), %xmm0
aesenc (80)(%rbx), %xmm0
aesenc (96)(%rbx), %xmm0
aesenc (112)(%rbx), %xmm0
aesenc (128)(%rbx), %xmm0
aesenclast (144)(%rbx), %xmm0
cmp $(16), %r8
jl .Lpartial_blockgas_1
movdqu (%rdi), %xmm1
add $(16), %rdi
pxor %xmm1, %xmm0
movdqu %xmm0, (%rsi)
add $(16), %rsi
sub $(16), %r8
jz .Lquitgas_1
jmp .Lsingle_blkgas_1
.Lpartial_blockgas_1:
pextrb $(0), %xmm0, %eax
psrldq $(1), %xmm0
movzbl (%rdi), %edx
inc %rdi
xor %rdx, %rax
movb %al, (%rsi)
inc %rsi
dec %r8
jnz .Lpartial_blockgas_1
.Lquitgas_1:
pxor %xmm4, %xmm4
pxor %xmm5, %xmm5
add $(128), %rsp
vzeroupper
pop %rbx
ret
|
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/gl/gl.h>
#include <pangolin/gl/glpixformat.h>
#include <pangolin/display/display.h>
#include <pangolin/image/image_io.h>
#include <algorithm>
#include <stdexcept>
namespace pangolin
{
////////////////////////////////////////////////
// Implementation of gl.h
////////////////////////////////////////////////
#ifndef HAVE_GLES
const int MAX_ATTACHMENTS = 8;
const static GLuint attachment_buffers[] = {
GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT,
GL_COLOR_ATTACHMENT2_EXT,
GL_COLOR_ATTACHMENT3_EXT,
GL_COLOR_ATTACHMENT4_EXT,
GL_COLOR_ATTACHMENT5_EXT,
GL_COLOR_ATTACHMENT6_EXT,
GL_COLOR_ATTACHMENT7_EXT
};
#else // HAVE_GLES
const int MAX_ATTACHMENTS = 1;
const static GLuint attachment_buffers[] = {
GL_COLOR_ATTACHMENT0_EXT
};
#endif // HAVE_GLES
const static size_t datatype_bytes[] = {
1, // #define GL_BYTE 0x1400
1, // #define GL_UNSIGNED_BYTE 0x1401
2, // #define GL_SHORT 0x1402
2, // #define GL_UNSIGNED_SHORT 0x1403
4, // #define GL_INT 0x1404
4, // #define GL_UNSIGNED_INT 0x1405
4, // #define GL_FLOAT 0x1406
2, // #define GL_2_BYTES 0x1407
3, // #define GL_3_BYTES 0x1408
4, // #define GL_4_BYTES 0x1409
8 // #define GL_DOUBLE 0x140A
};
const static size_t format_channels[] = {
1, // #define GL_RED 0x1903
1, // #define GL_GREEN 0x1904
1, // #define GL_BLUE 0x1905
1, // #define GL_ALPHA 0x1906
3, // #define GL_RGB 0x1907
4, // #define GL_RGBA 0x1908
1, // #define GL_LUMINANCE 0x1909
2 // #define GL_LUMINANCE_ALPHA 0x190A
};
inline size_t GlDataTypeBytes(GLenum type)
{
return datatype_bytes[type - GL_BYTE];
}
inline size_t GlFormatChannels(GLenum data_layout)
{
return format_channels[data_layout - GL_RED];
}
//template<typename T>
//struct GlDataTypeTrait {};
//template<> struct GlDataTypeTrait<float>{ static const GLenum type = GL_FLOAT; };
//template<> struct GlDataTypeTrait<int>{ static const GLenum type = GL_INT; };
//template<> struct GlDataTypeTrait<unsigned char>{ static const GLenum type = GL_UNSIGNED_BYTE; };
inline GlTexture::GlTexture()
: internal_format(0), tid(0), width(0), height(0)
{
// Not a texture constructor
}
inline GlTexture::GlTexture(GLint width, GLint height, GLint internal_format, bool sampling_linear, int border, GLenum glformat, GLenum gltype, GLvoid* data )
: internal_format(0), tid(0)
{
Reinitialise(width,height,internal_format,sampling_linear,border,glformat,gltype,data);
}
inline GlTexture::GlTexture(GlTexture&& tex)
{
*this = std::move(tex);
}
inline void GlTexture::operator=(GlTexture&& tex)
{
internal_format = tex.internal_format;
tid = tex.tid;
tex.internal_format = 0;
tex.tid = 0;
}
inline bool GlTexture::IsValid() const
{
return tid != 0;
}
inline void GlTexture::Delete()
{
// We have no GL context whilst exiting.
if(internal_format!=0 && !pangolin::ShouldQuit() ) {
glDeleteTextures(1,&tid);
internal_format = 0;
tid = 0;
width = 0;
height = 0;
}
}
inline GlTexture::~GlTexture()
{
// We have no GL context whilst exiting.
if(internal_format!=0 && !pangolin::ShouldQuit() ) {
glDeleteTextures(1,&tid);
}
}
inline void GlTexture::Bind() const
{
glBindTexture(GL_TEXTURE_2D, tid);
}
inline void GlTexture::Unbind() const
{
glBindTexture(GL_TEXTURE_2D, 0);
}
inline void GlTexture::Reinitialise(GLsizei w, GLsizei h, GLint int_format, bool sampling_linear, int border, GLenum glformat, GLenum gltype, GLvoid* data )
{
if(tid!=0) {
glDeleteTextures(1,&tid);
}
internal_format = int_format;
width = w;
height = h;
glGenTextures(1,&tid);
Bind();
// GL_LUMINANCE and GL_FLOAT don't seem to actually affect buffer, but some values are required
// for call to succeed.
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, border, glformat, gltype, data);
if(sampling_linear) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}else{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
CheckGlDieOnError();
}
inline void GlTexture::Upload(
const void* data,
GLenum data_format, GLenum data_type
) {
Bind();
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,data_format,data_type,data);
CheckGlDieOnError();
}
inline void GlTexture::Upload(
const void* data,
GLsizei tex_x_offset, GLsizei tex_y_offset,
GLsizei data_w, GLsizei data_h,
GLenum data_format, GLenum data_type )
{
Bind();
glTexSubImage2D(GL_TEXTURE_2D,0,tex_x_offset,tex_y_offset,data_w,data_h,data_format,data_type,data);
CheckGlDieOnError();
}
inline void GlTexture::Load(const TypedImage& image, bool sampling_linear)
{
GlPixFormat fmt(image.fmt);
Reinitialise((GLint)image.w, (GLint)image.h, GL_RGBA32F, sampling_linear, 0, fmt.glformat, fmt.gltype, image.ptr );
}
inline void GlTexture::LoadFromFile(const std::string& filename, bool sampling_linear)
{
TypedImage image = LoadImage(filename);
Load(image, sampling_linear);
}
#ifndef HAVE_GLES
inline void GlTexture::Download(void* image, GLenum data_layout, GLenum data_type) const
{
Bind();
glGetTexImage(GL_TEXTURE_2D, 0, data_layout, data_type, image);
Unbind();
}
inline void GlTexture::Download(TypedImage& image) const
{
switch (internal_format)
{
case GL_LUMINANCE8:
image.Reinitialise(width, height, PixelFormatFromString("GRAY8") );
Download(image.ptr, GL_LUMINANCE, GL_UNSIGNED_BYTE);
break;
case GL_LUMINANCE16:
image.Reinitialise(width, height, PixelFormatFromString("GRAY16LE") );
Download(image.ptr, GL_LUMINANCE, GL_UNSIGNED_SHORT);
break;
case GL_RGB8:
image.Reinitialise(width, height, PixelFormatFromString("RGB24"));
Download(image.ptr, GL_RGB, GL_UNSIGNED_BYTE);
break;
case GL_RGBA8:
image.Reinitialise(width, height, PixelFormatFromString("RGBA32"));
Download(image.ptr, GL_RGBA, GL_UNSIGNED_BYTE);
break;
case GL_RGB16:
image.Reinitialise(width, height, PixelFormatFromString("RGB48"));
Download(image.ptr, GL_RGB, GL_UNSIGNED_SHORT);
break;
case GL_RGBA16:
image.Reinitialise(width, height, PixelFormatFromString("RGBA64"));
Download(image.ptr, GL_RGBA, GL_UNSIGNED_SHORT);
break;
case GL_LUMINANCE:
case GL_LUMINANCE32F_ARB:
image.Reinitialise(width, height, PixelFormatFromString("GRAY32F"));
Download(image.ptr, GL_LUMINANCE, GL_FLOAT);
break;
case GL_RGB:
case GL_RGB32F:
image.Reinitialise(width, height, PixelFormatFromString("RGB96F"));
Download(image.ptr, GL_RGB, GL_FLOAT);
break;
case GL_RGBA:
case GL_RGBA32F:
image.Reinitialise(width, height, PixelFormatFromString("RGBA128F"));
Download(image.ptr, GL_RGBA, GL_FLOAT);
break;
default:
throw std::runtime_error(
"GlTexture::Download - Unknown internal format (" +
pangolin::Convert<std::string,GLint>::Do(internal_format) +
")"
);
}
}
inline void GlTexture::Save(const std::string& filename, bool top_line_first)
{
TypedImage image;
Download(image);
pangolin::SaveImage(image, filename, top_line_first);
}
#endif // HAVE_GLES
inline void GlTexture::SetLinear()
{
Bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Unbind();
}
inline void GlTexture::SetNearestNeighbour()
{
Bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
Unbind();
}
inline void GlTexture::RenderToViewport(const bool flip) const
{
if(flip) {
RenderToViewportFlipY();
}else{
RenderToViewport();
}
}
inline void GlTexture::RenderToViewport() const
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat sq_vert[] = { -1,-1, 1,-1, 1, 1, -1, 1 };
glVertexPointer(2, GL_FLOAT, 0, sq_vert);
glEnableClientState(GL_VERTEX_ARRAY);
GLfloat sq_tex[] = { 0,0, 1,0, 1,1, 0,1 };
glTexCoordPointer(2, GL_FLOAT, 0, sq_tex);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
Bind();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
inline void GlTexture::RenderToViewport(Viewport tex_vp, bool flipx, bool flipy) const
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat sq_vert[] = { -1,-1, 1,-1, 1, 1, -1, 1 };
glVertexPointer(2, GL_FLOAT, 0, sq_vert);
glEnableClientState(GL_VERTEX_ARRAY);
GLfloat l = tex_vp.l / (float)(width);
GLfloat b = tex_vp.b / (float)(height);
GLfloat r = (tex_vp.l+tex_vp.w) / (float)(width);
GLfloat t = (tex_vp.b+tex_vp.h) / (float)(height);
if(flipx) std::swap(l,r);
if(flipy) std::swap(b,t);
GLfloat sq_tex[] = { l,b, r,b, r,t, l,t };
glTexCoordPointer(2, GL_FLOAT, 0, sq_tex);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
Bind();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
inline void GlTexture::RenderToViewportFlipY() const
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat sq_vert[] = { -1,-1, 1,-1, 1, 1, -1, 1 };
glVertexPointer(2, GL_FLOAT, 0, sq_vert);
glEnableClientState(GL_VERTEX_ARRAY);
GLfloat sq_tex[] = { 0,1, 1,1, 1,0, 0,0 };
glTexCoordPointer(2, GL_FLOAT, 0, sq_tex);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
Bind();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
inline void GlTexture::RenderToViewportFlipXFlipY() const
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLfloat sq_vert[] = { 1,1, -1,1, -1,-1, 1,-1 };
glVertexPointer(2, GL_FLOAT, 0, sq_vert);
glEnableClientState(GL_VERTEX_ARRAY);
GLfloat sq_tex[] = { 0,0, 1,0, 1,1, 0,1 };
glTexCoordPointer(2, GL_FLOAT, 0, sq_tex);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
Bind();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
////////////////////////////////////////////////////////////////////////////
inline GlRenderBuffer::GlRenderBuffer()
: width(0), height(0), rbid(0)
{
}
inline GlRenderBuffer::GlRenderBuffer(GLint width, GLint height, GLint internal_format )
: width(0), height(0), rbid(0)
{
Reinitialise(width,height,internal_format);
}
#ifndef HAVE_GLES
inline void GlRenderBuffer::Reinitialise(GLint width, GLint height, GLint internal_format)
{
if( this->width != 0 ) {
glDeleteRenderbuffersEXT(1, &rbid);
}
this->width = width;
this->height = height;
glGenRenderbuffersEXT(1, &rbid);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rbid);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internal_format, width, height);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
inline GlRenderBuffer::~GlRenderBuffer()
{
// We have no GL context whilst exiting.
if( width!=0 && !pangolin::ShouldQuit() ) {
glDeleteRenderbuffersEXT(1, &rbid);
}
}
#else
inline void GlRenderBuffer::Reinitialise(GLint width, GLint height, GLint internal_format)
{
if( width!=0 ) {
glDeleteTextures(1, &rbid);
}
// Use a texture instead...
glGenTextures(1, &rbid);
glBindTexture(GL_TEXTURE_2D, rbid);
glTexImage2D(GL_TEXTURE_2D, 0, internal_format,
width, height,
0, internal_format, GL_UNSIGNED_SHORT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
inline GlRenderBuffer::~GlRenderBuffer()
{
// We have no GL context whilst exiting.
if( width!=0 && !pangolin::ShouldQuit() ) {
glDeleteTextures(1, &rbid);
}
}
#endif // HAVE_GLES
inline GlRenderBuffer::GlRenderBuffer(GlRenderBuffer&& tex)
: width(tex.width), height(tex.height), rbid(tex.rbid)
{
tex.rbid = tex.width = tex.height = 0;
}
////////////////////////////////////////////////////////////////////////////
inline GlFramebuffer::GlFramebuffer()
: fbid(0), attachments(0)
{
}
inline GlFramebuffer::~GlFramebuffer()
{
if(fbid) {
glDeleteFramebuffersEXT(1, &fbid);
}
}
inline GlFramebuffer::GlFramebuffer(GlTexture& colour, GlRenderBuffer& depth)
: attachments(0)
{
glGenFramebuffersEXT(1, &fbid);
AttachColour(colour);
AttachDepth(depth);
CheckGlDieOnError();
}
inline GlFramebuffer::GlFramebuffer(GlTexture& colour0, GlTexture& colour1, GlRenderBuffer& depth)
: attachments(0)
{
glGenFramebuffersEXT(1, &fbid);
AttachColour(colour0);
AttachColour(colour1);
AttachDepth(depth);
CheckGlDieOnError();
}
inline void GlFramebuffer::Bind() const
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbid);
#ifndef HAVE_GLES
glDrawBuffers( attachments, attachment_buffers );
#endif
}
inline void GlFramebuffer::Reinitialise()
{
if(fbid) {
glDeleteFramebuffersEXT(1, &fbid);
}
glGenFramebuffersEXT(1, &fbid);
}
inline void GlFramebuffer::Unbind() const
{
#ifndef HAVE_GLES
glDrawBuffers( 1, attachment_buffers );
#endif
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
inline GLenum GlFramebuffer::AttachColour(GlTexture& tex )
{
if(!fbid) Reinitialise();
const GLenum color_attachment = GL_COLOR_ATTACHMENT0_EXT + attachments;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbid);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, color_attachment, GL_TEXTURE_2D, tex.tid, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
attachments++;
CheckGlDieOnError();
return color_attachment;
}
inline void GlFramebuffer::AttachDepth(GlRenderBuffer& rb )
{
if(!fbid) Reinitialise();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbid);
#if !defined(HAVE_GLES)
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rb.rbid);
#elif defined(HAVE_GLES_2)
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, rb.rbid, 0);
#else
throw std::exception();
#endif
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
CheckGlDieOnError();
}
////////////////////////////////////////////////////////////////////////////
inline GlBuffer::GlBuffer()
: bo(0), num_elements(0)
{
}
inline GlBuffer::GlBuffer(GlBufferType buffer_type, GLuint num_elements, GLenum datatype, GLuint count_per_element, GLenum gluse )
: bo(0), num_elements(0)
{
Reinitialise(buffer_type, num_elements, datatype, count_per_element, gluse );
}
inline GlBuffer::GlBuffer(GlBuffer&& buffer)
{
*this = std::move(buffer);
}
inline void GlBuffer::operator=(GlBuffer&& buffer)
{
bo = buffer.bo;
buffer_type = buffer.buffer_type;
gluse = buffer.gluse;
datatype = buffer.datatype;
num_elements = buffer.num_elements;
count_per_element = buffer.count_per_element;
buffer.bo = 0;
}
inline bool GlBuffer::IsValid() const
{
return bo != 0;
}
inline size_t GlBuffer::SizeBytes() const
{
return num_elements * GlDataTypeBytes(datatype) * count_per_element;
}
inline void GlBuffer::Reinitialise(GlBufferType buffer_type, GLuint num_elements, GLenum datatype, GLuint count_per_element, GLenum gluse )
{
this->buffer_type = buffer_type;
this->gluse = gluse;
this->datatype = datatype;
this->num_elements = num_elements;
this->count_per_element = count_per_element;
if(!bo) {
glGenBuffers(1, &bo);
}
Bind();
glBufferData(buffer_type, num_elements*GlDataTypeBytes(datatype)*count_per_element, 0, gluse);
Unbind();
}
inline void GlBuffer::Reinitialise(GlBuffer const& other )
{
Reinitialise(other.buffer_type, other.num_elements, other.datatype, other.count_per_element, other.gluse);
}
inline void GlBuffer::Resize(GLuint new_num_elements)
{
if(bo!=0) {
#ifndef HAVE_GLES
// Backup current data, reinit memory, restore old data
const size_t backup_elements = std::min(new_num_elements,num_elements);
const size_t backup_size_bytes = backup_elements*GlDataTypeBytes(datatype)*count_per_element;
unsigned char* backup = new unsigned char[backup_size_bytes];
Bind();
glGetBufferSubData(buffer_type, 0, backup_size_bytes, backup);
glBufferData(buffer_type, new_num_elements*GlDataTypeBytes(datatype)*count_per_element, 0, gluse);
glBufferSubData(buffer_type, 0, backup_size_bytes, backup);
Unbind();
delete[] backup;
#else
throw std::exception();
#endif
}else{
Reinitialise(buffer_type, new_num_elements, datatype, count_per_element, gluse);
}
num_elements = new_num_elements;
}
inline GlBuffer::~GlBuffer()
{
if(bo!=0) {
glDeleteBuffers(1, &bo);
}
}
inline void GlBuffer::Bind() const
{
glBindBuffer(buffer_type, bo);
}
inline void GlBuffer::Unbind() const
{
glBindBuffer(buffer_type, 0);
}
inline void GlBuffer::Upload(const GLvoid* data, GLsizeiptr size_bytes, GLintptr offset)
{
Bind();
glBufferSubData(buffer_type,offset,size_bytes, data);
Unbind();
}
inline void GlBuffer::Download(GLvoid* data, GLsizeiptr size_bytes, GLintptr offset) const
{
Bind();
glGetBufferSubData(buffer_type, offset, size_bytes, data);
Unbind();
}
////////////////////////////////////////////////////////////////////////////
inline GlSizeableBuffer::GlSizeableBuffer(GlBufferType buffer_type, GLuint initial_num_elements, GLenum datatype, GLuint count_per_element, GLenum gluse )
: GlBuffer(buffer_type, initial_num_elements, datatype, count_per_element, gluse), m_num_verts(0)
{
}
inline void GlSizeableBuffer::Clear()
{
m_num_verts = 0;
}
#ifdef USE_EIGEN
template<typename Derived> inline
void GlSizeableBuffer::Add(const Eigen::DenseBase<Derived>& vec)
{
typedef typename Eigen::DenseBase<Derived>::Scalar Scalar;
assert(vec.rows()==GlBuffer::count_per_element);
CheckResize(m_num_verts + 1);
// TODO: taking address of first element is really dodgey. Need to work out
// when this is okay!
Upload(&vec(0,0), sizeof(Scalar)*vec.rows()*vec.cols(), sizeof(Scalar)*vec.rows()*m_num_verts);
m_num_verts += vec.cols();
}
template<typename Derived> inline
void GlSizeableBuffer::Update(const Eigen::DenseBase<Derived>& vec, size_t position )
{
typedef typename Eigen::DenseBase<Derived>::Scalar Scalar;
assert(vec.rows()==GlBuffer::count_per_element);
CheckResize(position + vec.cols() );
// TODO: taking address of first element is really dodgey. Need to work out
// when this is okay!
Upload(&vec(0,0), sizeof(Scalar)*vec.rows()*vec.cols(), sizeof(Scalar)*vec.rows()*position );
m_num_verts = std::max(position+vec.cols(), m_num_verts);
}
#endif
inline size_t GlSizeableBuffer::start() const {
return 0;
}
inline size_t GlSizeableBuffer::size() const {
return m_num_verts;
}
inline void GlSizeableBuffer::CheckResize(size_t num_verts)
{
if( num_verts > GlBuffer::num_elements) {
const size_t new_size = NextSize(num_verts);
GlBuffer::Resize((GLuint)new_size);
}
}
inline size_t GlSizeableBuffer::NextSize(size_t min_size) const
{
size_t new_size = std::max(GlBuffer::num_elements, 1u);
while(new_size < min_size) {
new_size *= 2;
}
return new_size;
}
}
|
public print_number, calc_all, calc_rank, print_all, calc_suggestion_level
print_newline macro
push ax
push dx
mov ah, 02h
mov dl, 13
int 21h
mov ah, 02h
mov dl, 10
int 21h
pop dx
pop ax
endm
print macro string
push ax
push dx
mov dx, offset string
mov ah, 09h
int 21h
pop dx
pop ax
endm
print_address macro address
push ax
push dx
mov dx, address
mov ah, 09h
int 21h
pop dx
pop ax
endm
print_char macro char
push ax
push dx
mov ah, 02h
mov dl, char
int 21h
pop dx
pop ax
endm
input macro string
push ax
push dx
mov dx, offset string
mov ah, 0Ah
int 21h
print_newline
pop dx
pop ax
endm
.386
stack segment use16 stack
db 500 dup(0)
stack ends
data segment use16 para public 'data'
item_number equ 30
calc_fail_hint db 'Error: Divide by zero!', 13, 10, '$'
info_header_2 db 'name', 9, 'discnt', 9, 'inPrice', 9, 'price', 9, 'inNum', 9, 'outNum', 9, 'suggestion', 9, 'rank', 13, 10, '$'
data ends
code segment use16 para public 'code'
assume cs:code, ds:data, ss:stack
print_number proc far
pusha
mov bx, 10
mov cx, 0
loop_divide_number:
mov dx, 0
div bx
add dl, '0'
push dx
inc cx
cmp ax, 0
jne loop_divide_number
loop_print_number:
pop dx
print_char dl
loop loop_print_number
print_char 9
popa
ret
print_number endp
calc_all proc far
pusha
mov cx, item_number
loop_calc_all:
call calc_suggestion_level
add dx, 21
loop loop_calc_all
popa
ret
calc_all endp
calc_rank proc far
pusha
call calc_all
push di
push dx
push cx
mov bx, 0
mov si, dx
loop_set_array:
mov [di + bx], si
add si, 21
add bx, 2
cmp bx, item_number * 2
je loop_sort
jmp loop_set_array
loop_sort:
mov dx, 0
mov bx, 0
compare:
mov si, [di + bx]
add si, 19
mov ax, [si]
mov si, [di + bx + 2]
add si, 19
mov cx, [si]
add bx, 2
cmp bx, item_number * 2
je judge_loop_sort
cmp ax, cx
jge compare
mov dx, 1
mov ax, [di + bx]
push ax
mov ax, [di + bx - 2]
mov [di + bx], ax
pop ax
mov [di + bx - 2], ax
jmp compare
judge_loop_sort:
cmp dx, 1
je loop_sort
pop di ; rank
pop si ; items
pop bx ; to_sort
mov dx, 0
loop_call_set_rank:
call set_rank_func
inc dx
cmp dx, item_number
jne loop_call_set_rank
popa
ret
calc_rank endp
set_rank_func proc
pusha
push dx
mov cx, 1
imul dx, 21
add si, dx
loop_set_rank:
mov ax, [si + 19]
mov dx, [bx]
push bx
mov bx, dx
mov dx, [bx + 19]
pop bx
cmp ax, dx
je set_rank
inc cx
add bx, 2
jmp loop_set_rank
set_rank:
pop bx
mov [di + bx], cl
popa
ret
set_rank_func endp
print_all proc far
pusha
call calc_rank
print info_header_2
mov bx, 0
mov si, dx
mov di, cx
loop_print_all:
print_address si
print_char 9
movzx ax, byte ptr[si + 10]
call print_number
mov ax, [si + 11]
call print_number
mov ax, [si + 13]
call print_number
mov ax, [si + 15]
call print_number
mov ax, [si + 17]
call print_number
mov ax, [si + 19]
call print_number
movzx ax, byte ptr[di + bx]
call print_number
print_newline
inc bx
add si, 21
cmp bx, item_number
jne loop_print_all
popa
ret
print_all endp
calc_suggestion_level proc far
pusha
mov si, dx
add si, 10
movzx ax, byte ptr[si]
inc si
imul ax, word ptr[si+2]
cwd
mov dx, 0
mov bx, 10
idiv bx
mov bx, ax
mov ax, word ptr[si]
imul ax, 1280
cwd
mov dx, 0
cmp bx, 0
je calc_failed
idiv bx
mov cx, ax
mov bx, word ptr[si+4]
mov ax, word ptr[si+6]
imul ax, 1280
cwd
mov dx, 0
cmp bx, 0
je calc_failed
idiv bx
add cx, ax
mov ax, cx
cwd
mov dx, 0
mov bx, 10
idiv bx
mov cx, ax
mov word ptr[si+8], cx
popa
ret
calc_failed:
print calc_fail_hint
popa
ret
calc_suggestion_level endp
code ends
end
|
page ,132
TITLE UIFILEIO - low level file io routines.
;***
;UIFILEIO - low level file io routines.
;
; Copyright <C> 1988, Microsoft Corporation
;
;Purpose:
;
;
;*******************************************************************************
.xlist
include version.inc
UIFILEIO_ASM = ON
.list
include cw/version.inc
include cw/windows.inc
include cw/edityp.inc
includeonce architec
includeonce rtps
includeonce uiint
includeonce heap
assumes DS,DATA
assumes ES,DATA
assumes SS,DATA
; Following declarations/definitions added while converting c - Asm.
externFP BdAlloc
externFP SetTabs
externFP SetIsaColor
externFP GetIsaColor
externFP GetTabs
externNP ColorResolution
externFP FindAndOpenFile
subttl DATA segment definitions.
sBegin DATA
;NOTE: ORDERING OF bdLibPath, bdExePath, bdInclPath, bdHelpPath
; IN UIPATHS.ASM MUST REMAIN CONSTANT.
externW bdLibPath
externW fOptionsChanged
externW fScrollBars
externB fSyntaxCheck
externB fDebugScr
externB fRightMouseHelp
externB b$Buf1
externW __aenvseg
; some constants for ReadQbIni and WriteQbIni
QBSIGNATURE equ 4251h ; Signature for 2.0, 3.0, 4.5
QB45VERSION equ 0450h
QB40SIGNATURE equ 4215h
QB40VERSION equ 0390h
QB20VERSION equ 0200h
QHELP11VERSION equ 0460h ; [QH1]
AtrData struc
bkClr dw ?
fgClr dw ?
fHLgt dw ?
fBlnk dw ?
AtrData ends
;*************************************************************
; WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING !
; B$ULLoad in RTMLOAD.ASM also reads qb.ini but doesn't have
; access to this structure definition. If this structure changes
; B$ULLoad must also be changed.
; WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING !
;*************************************************************
;; [QH1]
;; a-emoryh:
;; Well, i looked, but i didn't find any code to change over in rtmload.asm.
;; My guess is that user-library stuff was removed from Dos5 QBasic, to keep
;; it lower-end than the stand-alone Basic products. Hope that's true!
;;
OPTIONS struc
signature dw ?
version dw ?
normT db SIZE ATRDATA DUP(?)
curLn db SIZE ATRDATA DUP(?)
bpLn db SIZE ATRDATA DUP(?)
tabStopsOpt dw ?
fScroBars dw ?
fSyntCheck dw ?
fEZM db ?
RightM db ?
iPrint dw ? ; [QH1]
fFile dw ? ; [QH1]
szPrint db MAX_PATH DUP(?) ; [QH1]
OPTIONS ends
staticW fh,0
globalB qbIniFName,<"qbasic.ini",0>
cbqbIniFName = $ - qbIniFName
sEnd DATA
page
sBegin UI
assumes CS,UI
externNP CheckSwitchDiskettes
subttl Low level MSDOS File I/O calls.
page
; NOTE: can't assert that b$fInt24Err is NZ in all these routines, since
; a few are called from TXTLOAD/TXTSAVE, and int24 errors are supposed
; to be hooked there.
; Exit:
; If error, ax = UNDEFINED
; otherwise, ax = return code
;
cProc DoInt21,<NEAR>
cBegin
int 21h
jnc IntOk ;brif no error
mov ax,-1 ;Return error condition.
IntOk:
cEnd
;***
; OpenFile(szFile), CreateFile(szFile)
; Purpose:
; Open specified file using supplied string.
; Opens file for Read-Only access.
; Use CreateFile to open for write-access.
; Entry:
; pointer to Zero terminated string.
; Exit:
; AX == file fhandle.
; AX == -1 for error condition, carry set
;
;****
labelNP <PUBLIC,OpenFile>
mov ax,3d00h ; open for read access
SKIP2_PSW ; eat the next MOV
labelNP <PUBLIC,CreateFile>
mov ah,3ch ; create
cProc OpenCreateFile,<NEAR>
ParmW szFile
cBegin
mov bx,[szFile] ; bx = *file name
cCall <FAR ptr OpenCheckDrive>,<ds:[bx]> ; make sure we don't
; have to switch diskettes
; PRESERVES ALL REGISTERS
mov dx,bx ; dx = * to fn
xor cx,cx ; for CreateFile
call DoInt21
cEnd
;***
;OpenCheckDrive(drive)
;
;Purpose:
; Called before opening a file or getting the current directory,
; to check if the logical drive might have to be switched.
;
; Re-written with revision [6].
;
;Entry:
; drive = possible "drive_letter" + ":"
;
;Exit:
; None
;
;Uses:
; None. Callers depend on ALL REGISTERS being preserved
;****
cProc OpenCheckDrive,<FAR,PUBLIC>,<ax,bx,cx,dx,es>
parmW drive
cBegin
cmp fDebugScr,0 ; capable of displaying a msg?
jz NoNewDrive ; brif not -- let DOS do it
mov ax,[drive] ; bx = possible "drive_letter" + ":"
cmp ah,':' ; drive specified?
jne NoNewDrive ; brif not
DbAssertRelB al,ne,0,UI,<OpenCheckDrive: Null filename>
cCall CheckSwitchDiskettes,<ax> ; if we are switching logical disk
; drives, do it, and display a msgbox
NoNewDrive:
cEnd
page
;***
; CloseFileNear(fhandle) [3]
;
; Near routine to close file specified by "fhandle"
;
; Inputs: integer specifying fhandle to be closed.
;
; Outputs: AX == -1 for error conditio, carry set
;
;****
cProc CloseFileNear,<PUBLIC,NEAR>
ParmW fhandle
cBegin
mov bx, [fhandle]
mov ah, 3eh
call DoInt21
cEnd
page
;***
; WriteFile(fhandle, offBuf, cb)
;
; Write cb bytes to file fhandle.
;
; Inputs:
; fhandle - file handle to write to.
; offBuf - address of buffer.
; cb - length of buffer.
;
; Outputs: AX == -1 for error conditions, carry set
;
;****
cProc WriteFile,<PUBLIC,NEAR>,<SI,DI,DS>
ParmW fhandle
ParmW offBuf
ParmW cb
cBegin
mov bx, [fhandle]
mov cx, [cb]
mov dx, [offBuf]
mov ah, 40H
call DoInt21
cEnd
page
;***
; ReadFile(fhandle, offBuf, cb)
;
; Read file fhandle of cb bytes into the segment:offset buffer area.
;
; Inputs: unsigned integer file fhandle.
; unsigned integer offset address.
; unsigned integer count of bytes to read.
;
; Outputs: AX == -1 for error conditions, carry set
;
;****
cProc ReadFile,<PUBLIC,NEAR>
ParmW fhandle
ParmW offBuf
ParmW cb
cBegin
mov bx, [fhandle]
mov cx, [cb]
mov dx, [offBuf]
mov ah, 3fh
call DoInt21
cEnd
page
;***
; FileExists(szFile)
; Purpose:
; Determine whether or not a given filename exists.
; Entry:
; szFile = pointer to Zero terminated string.
; Exit:
; AX == TRUE if file found, false if not.
;
;****
cProc FileExists,<PUBLIC,FAR>
ParmW szFile
cBegin
push [szFile]
call OpenFile ;ax = file handle
inc ax
je NotOpened ;return FALSE if file not opened
dec ax ;restore ax = file handle
cCall CloseFileNear,<ax>
mov ax,sp ;return TRUE
NotOpened:
cEnd
;***
; DelFile(szFile)
; Purpose:
; Delete a file
; Entry:
; szFile = pointer to Zero terminated string.
; Exit:
; ax = -1 if error
;
;****
cProc DelFile,<PUBLIC,FAR>
ParmW szFile
cBegin
mov dx, [szFile]
mov ah, 41h
call DoInt21
cEnd
;***
; ReadQbIni () - Read QB.INI file into the system
;
; Purpose:
; Called at startup to read in the qb.ini file off the path and
; set up defaults as appropriate.
;
; Entry:
; None.
;
; Exit:
; Sets up fOptionsChanged, fEZMenus, fRightMouseHelp, fSyntaxCheck
; variables to default setup. Also sets colors using SetIsaColor.
;
; Uses:
; Per Convention
;
;************************************************************************
cProc ReadQbIni,<PUBLIC,NEAR>,<SI,DI>
cBegin
DbAssertRel b$fInt24Err,ne,0,UI,<ReadQbIni: Int 24 errors not ignored>
mov iPrintPort, DEV_LPT1 ; Set up print-dest defaults ; [QH1]
mov fPrintToFile, 0 ; [QH1]
mov szPrintDest, 0 ; [QH1]
mov ax,SIZE OPTIONS ; Allocate space on the frame
sub sp,ax ; for local structure.
mov fOptionsChanged,FALSE
push ax ; AX = SIZE OPTIONS
mov di,DATAOFFSET bdLibPath ; Allocate runtime heap entries
mov si,UIOFFSET DoAllocs ; for all 4 Paths in environment
Call FourTimes ; Lib, Exe, Incl, Help
mov di,DATAOFFSET bdLibPath ;[9] Set cbLogical to 1 for all 4
mov si,UIOFFSET DoTrims ; path bd's (Lib, Exe, Incl, Help)
Call FourTimes
cmp uierr,FALSE ; if heap allocation failed then exit
jne jmp_OpenFailed ; from ReadQbIni. This is Out_of_Memory
; error. User interface will check
; for this and exit gracefully.
; initialise for unchanged Ini file
xor bx,bx ; BX = FALSE for Read Only Mode.
call OpenQBIni ; Open the QB.INI file for reading
jnz OpenOK ; AX = File Handle for QB.INI
jmp_OpenFailed:
jmp short OpenFailed
OpenOK:
DbHeapMoveOff ; can't have heap movement below, since BD's
; could be trimed back to their cbLogical's,
; causing us to read QB.INI paths over the
; top of memory we don't own.
pop bx ; BX = Size of Options, Bytes to be read
mov si,sp ; set up si to Frame for Ini Options
push bx ; Save Size of Options for later usage
cCall ReadFile,<ax,si,bx>
cmp ax,UNDEFINED ; AX = -1 if error in reading.
jz ReadDone ; brif error -- close file & return
mov ax,[si].signature
cmp ax,QB40SIGNATURE ; if it is qb40 change its signature
jnz notqb40 ; to qbsignature
mov ax,QBSIGNATURE
dec fOptionsChanged ; fOptionsChanged set to TRUE
notqb40:
cmp ax,QBSIGNATURE ; check for qb signature
jnz ReadDone ; if not qb4 then look for qb2
mov ax,[si].version ; AX=VERSION
; [QH1]
cmp ax, QHELP11VERSION ; If QHELP version, start reading
je qb4version
mov fOptionsChanged, TRUE ; Else upgrade it to QHELP11VERSION
cmp ax,QB40VERSION ; check for qb 40 or 45 versions
je qb4version
cmp ax,QB45VERSION
je qb4version
cmp ax,QB20VERSION ; Check for qb20 version. If
jnz ReadDone ; yes then OptionsChanged True.
jmp SHORT ReadDone
qb4version:
push si ; Save SI = pointer to Option
; Frame on stack, because it is
; modified by Chk3Windows/SetSColor
mov di,UIOFFSET SetSColor ; Set up default colors for
call Chk3Windows ; Normal Text, Break Points,
; and Current Statement by calling
; SetSColor in Chk3Windows.
call ColorResolution ; Resolve color dependencies.
pop si ; Restore SI=ptr to Option Frame
mov di,si ; di = *options(for later)
lea si,[si.tabStopsOpt] ; SI = *tabstopsOpt
lodsw ; Get default TabStops
cCall SetTabs,<ax> ; Set Tabs
lodsw ; Get default ScrollBars
mov fScrollBars,ax ; Set ScrollBars
lodsw ; Get default SyntaxCheck Status
mov fSyntaxCheck,al ; Set SyntaxCheck Status
cmp [di].version,QB45VERSION ; DI = Options
jl ReadDone
lodsb ; Get fEZM
lodsb ; Get RightMouseHelp Status
;; [QH1] - Read print-dest info, if ini-file was QHELP version
cmp [di].version, QHELP11VERSION
je ReadPrintInfo
ReadPaths:
mov ax,UIOFFSET readfileabc ; Read four Paths
call rd_wrt_path
ReadDone:
cCall CloseFileNear,<fh> ; Close the opened file
DbHeapMoveOn ; heap movement OK now
OpenFailed:
pop ax ; AX = SIZE OPTIONS
add sp,ax ; Release allocated frame space
cEnd
;;
;; [QH1] Start
;;
;; Read print-dest info
;; SI now points to Options.iPrint
;; DI points to beginning of Options
;;
ReadPrintInfo:
lodsw ; Load printer port
cmp ax, cDEVICES ; Make sure field is valid
jge SkipDevField ; Bogus value!!, so keep default
mov iPrintPort, ax
lodsw ; Read PrinterOrFile flag
mov fPrintToFile, ax
SkipDevField:
; Load szPrintDest
push di
mov ax, ds ; Give ES the DATA seg (I hope!)
mov es, ax
lea di, szPrintDest
mov cx, MAX_PATH
rep movsb
dec di
mov BYTE PTR [di], 0 ; Make it asciiz, if not already
pop di
; Now SI should point to first field following Option.szPrint[]
jmp short ReadPaths
;;
;; [QH1] End
;;
;***
; rd_wrt_path() - performs read/write of all 4 path names
;
; Purpose:
; This is written to save code. ReadQbIni reads and WriteQbIni
; writes the information.
;
; Entry:
; AX should have address of read/write-fileabc to be invoked by
; by rd_wrt_cb2.
;
; Exit:
; None.
;
; Uses:
; Both SI,DI are destroyed.
;***********************************************************************
cProc rd_wrt_path,<NEAR>
cBegin
mov di,DATAOFFSET bdLibPath ; Write BD structure for all the
mov si,UIOFFSET rd_wrt_cb2 ; four paths
jmp SHORT Fourtimes ; Call rd_wrt_cb2 4 times and return
cEnd <nogen>
;***
; rd_wrt_cb2() - reads/writes size of paths, then reads/writes the path into
; heap entry for it.
; Purpose:
; It has been written to save on code. This reading/writing
; is done for all the four paths. It is used in conjunction
; with procedure FourTimes.
;
; Entry:
; DI should point to bd structure for current path.
; fh has file handle for qb.ini
; AX has offset of readfileabc/writefileabc - routine to be called
; bdLibPath, bdExePath, bdInclPath, bdHelpPath must be contiguous
; and in correct order.
;
; Exit:
; DI is updated to next bd structure
;
; Uses:
; DI is destroyed.
;
;***************************************************************************
cProc rd_wrt_cb2,<NEAR>
cBegin
lea bx,[di].bd_cbLogical ; reads a word having size of
mov cx,02 ; bd structure into bd_cbLogical
push ax ; save address read/write-fileabc
call ax ; call read/write-fileabc
pop ax ; restore address read/write-fileabc
mov bx,[di].bd_pb ; reads the bd structure from
mov cx,[di].bd_cbLogical ; file.
push ax ; save address read/write-fileabc
call ax ; Call read/write-fileabc
pop ax ; restore address read/write-fileabc
add di,SIZE bd ; Updates DI to point to next bd.
cEnd
;***
; readfileabc() - makes the call to read file.
;
; Purpose:
; Written to save code by pushing 3 parms, and calling ReadFile.
;
; Entry:
; fh has the file handle to read from.
; cx has the number of bytes to read
; bx has the address of buffer to read into.
;
; Exit:
; None.
;
; Uses:
; Per Convention
;
;**************************************************************************
cProc readfileabc,<NEAR>
cBegin
cCall ReadFile,<fh,bx,cx>
cEnd
;***
; writefileabc() - Makes the WriteFile call.
;
; Purpose:
; Written to save code by pushing 3 params, and calling WriteFile
;
; Entry:
; fh has the file handle.
; bx has the address of buffer
; cx has the count of bytes to be written into file.
;
; Exit:
; None.
;
; Uses:
; Per Convention
;
;**************************************************************************
cProc writefileabc,<NEAR>
cBegin
cCall WriteFile,<fh,bx,cx>
cEnd
;***
; FourTimes() - Makes call to the given procedure four times.
;
; Purpose:
; Read and Write QBINI procedures make all file operations
; for four paths Exe, Lib, Help and Inc.
;
; Entry:
; SI has the OFFSET of procedure to be called four times.
;
; Exit:
; None.
;
; Uses:
; Per Convention
;
;*********************************************************************
cProc FourTimes,<NEAR>
cBegin
mov cx,4 ; Sets up a count of 4
FT_next:
push cx ; loop until zero to make four call on given
call si ; procedure. Since the given procedure could
pop cx ; destroy count (CX) save it.
loop FT_next
cEnd
;***
; DoAllocs - allocates runtime heap entry
;
; Purpose:
; Allocate an interpreter specific heap entry from runtime
; and set respective flags. If Out_of_Memory then SetUiErrOm.
;
; DoAllocs works in conjunction with Fourtimes. It is done to
; save on code for param initialization and passing. It assumes
; ORDER of bdLibPath,bdExePath,bdInclPath,bdHelpPath and adds
; size of Bd structure to get to next. Saves code!
;
; Entry:
; DI has address of a bd structure of a env path
;
; Exit:
; bd_pb of bd structure points to heap entry.
; bd_cbPhysical of bd structure is set to cbSize.
; DI is incremented to next bd structure.
; AX is set TRUE is heap entry was allocated else FALSE.
;
;****************************************************************
cProc DoAllocs,<NEAR>
cBegin
mov ax,MAX_SEARCH_PATH ; Number of bytes wanted on heap
mov bx,IT_NO_OWNERS ; Type of interp table
cCall BdAlloc,<di,ax,bx> ; Allocate the heap entry
or ax,ax ; NZ if allocation successful
jnz DoAllocsOK ; if heap alloc failed
cCall SetUiErrOm ; out of memory error. (sets uierr)
; OK to fall into DoTrims, since it
; will be done anyway later.
labelNP <DoTrims> ; ROUTINE to trim size of BD's
mov [di].bd_cbLogical,1 ; set initial size = 1 so we have
; a null path string.
DoAllocsOK:
add di,SIZE bd ; increment DI to point to next
; bd structur i.e. next path.
cEnd
;***
; OpenQBIni() - Opens the QB.INI file
;
; Purpose:
; Opens the QB.INI file for reading/writing the system
; default parameters.
; Entry:
; BX = TRUE for WriteOnly mode
; FALSE for ReadOnly mode
; Exit:
; fh has the file handle
; NZ if open successful
; ZF if open unsuccessful
; Uses:
; Per Convention
;
;*********************************************************************
cProc OpenQBIni,<NEAR>,<DI,SI>
cBegin
push bx ; save file open mode
mov ah,30h ; get version number
int 21h ; AX = dos version number
pop bx ; restore file open mode
cmp al,3 ; are we DOS 3.x or above?
jb UsePATH ; brif not, no path present
mov es,__aenvseg ; ES:0 is location of env.
xor di,di ; ES:DI is location of env
mov cx,8000h ; scan to end of env table
xor ax,ax ; for a 0
LocateFname:
repne scasb ;
scasb ; skip null, see if double 0
jne LocateFname ; brif not double 0, keep looking
scasw ; skip following 1
ASSUMES DS,NOTHING
mov si, di ; ES:SI = ptr to QBASIC path & name
mov di, DATAOFFSET b$buf1 ; DS:DI = ptr to INI path & name
push es ;
pop ds ; DS:SI = ptr to QBASIC path & name
push ss ;
pop es ; ES:DI = ptr to INI path & name
mov cx,di ; DS:CX = ptr to last seen path char
; in name as it is copied over
CopyName:
lodsb ; grab a byte
stosb ; and store it
cmp al,'\' ; is it a slash
je PathChar ; go remember it
cmp al,'/' ; or this slash
jne TestTerminator ; go remember it
PathChar:
mov cx,di ; set last path character found
TestTerminator:
or al,al ; 0 terminator?
jnz CopyName ; brif not, more characters to do
HavePath:
push ss ;
pop ds ; restore DS = DGROUP = ES
ASSUMES DS,DGROUP
cmp cx, DATAOFFSET b$buf1 ; did we have any path?
je UsePATH ; brif not, use $PATH:
mov di, cx ; ES:DI = ptr to end of INI path
mov si, DATAOFFSET qbIniFName; DS:SI = ptr to new file name
mov cx, cbqbIniFName ; CX = # characters
rep movsb ; and copy it over
; all set up, lets go open the INI file
mov ax,3d00h ; Open existing file, read only
or bx,bx ; BX = 0 (FALSE = Read Only)
jz ReadOnly ; brif assumption true
mov ah,3ch ; Create file, write access
ReadOnly:
push bx ; save open flag (open could fail)
PUSHI cx,<DATAOFFSET b$buf1> ;
call OpenCreateFile ; open file for mode AX
pop bx ; restore open flag
mov cl,1 ;
inc cl ; Clear ZF, don't touch Carry
jnc FileOpened ; brif success
UsePATH:
mov ax,DATAOFFSET qbIniFName ; AX = "QB.INI"
mov cx,EXEFILE ; return value for success/failure
cCall FindAndOpenFile,<ax,bx,cx>
or ax,ax ; NZ ==> success
FileOpened:
mov fh,ax ; save the file handle value.
cEnd
;***
;Chk3Windows() - It makes GetSColor/SetSColor to 3 Isa's.
;
;Purpose:
; To set up / save color defaults for various things on QB
; Get / Set is performed during write/read. This helps save
; code by setting up parameter and calling Get/Set as set
; in DI.
;Entry:
; SI points to the OPTIONS frame on stack
; DI points to procedure for GetSColor/SetSColor
;Exit:
; SI points to ATTRDATA of BreakPoint.
;Uses:
; Per Convention
;
;*********************************************************************
cProc Chk3Windows,<NEAR> ; Added with revision
cBegin
lea si,[si].normT ; SI to point to ATTRDATA for Normal Text
mov ax,isaEditWindow ; Isa - Edit Window
call di ; Call GetSColor/SetSColor
lea si,[si].(curLn-normT); SI to point to ATTRDATA for Cur Stmt
mov ax,isaCurStmt ; Isa - Cur Stmt
call di ; Call GetSColor/SetSColor
lea si,[si].(bpLn-curLn); SI to point to ATTRDATA for Brk Point
mov ax,isaBreakpoint ; Isa - Break Point
jmp di ; Call GetSColor/SetSColor and return
cEnd <nogen>
;***
; SetSColor() - Set System Color Defaults
;
; Purpose:
; Default colors for Hight Light, Back Ground, Fore Ground etc
; set for Edit Window, Break Point etc.
;
; Based on SetSysColor Macro
;
; Entry:
; ax has the Isa identifier like Edit Window, etc.
; SI points to ATTRDATA of window in Options Frame on stack.
; Exit:
; None.
; Uses:
; Per Convention
;
;************************************************************************
cProc SetSColor,<NEAR>
cBegin
push ax ; SetIsaColor Parm #1
mov ax,[si].fHlgt ; Set up the High Light + Foreground
or ax,ax ; Parameter
jz NoBrForeground
mov ax,8
NoBrForeground:
add ax,[si].fgClr
push ax ; SetIsaColor Parm #2
mov ax,[si].fBlnk ; Set up the Blink + Background parameter
or ax,ax
jz NoBrBackground
mov ax,8
NoBrBackground:
add ax,[si].bkClr
push ax ; SetIsaColor Parm #3
cCall SetIsaColor ; Set up the colors.
cEnd
;***
; GetSColor() - Gets current system colors
; Purpose:
; Current colors for EditWindow, BreakPoint, Current Statement
; etc are obtained and later written into QB.INI file. This
; ensures that next time the user would get same set up as at
; the end of last session with QB.
; Based on GETSYSCOLOR in file "uioptns.c".
; Entry:
; ax has the Isa identifier like Edit Window, Break Point.
; SI points to ATTRDATA structure correspoinding Isa in Options
; frame on stack.
; Exit:
; None.
; Uses:
; Per Convention
;
;**********************************************************************
cProc GetSColor,<NEAR>
cBegin
push ax ; GetIsaColor parm #1
lea ax,[si].fgClr ; Set up the address of Foreground Color
push ax ; GetIsaColor parm #2
lea ax,[si].bkClr ; Set up the address of Background Color
push ax ; GetIsaColor parm #3
cCall GetIsaColor ; Read the current colors into frame.
xor ax,ax ; Decode Background and Blink based on
test [si].bkClr,8 ; formula in SetSColor and setup.
jz dontsetbit
inc ax
dontsetbit:
mov [si].fBlnk,ax ; store blink bit (0, 1)
xor ax,ax
test [si].fgClr,8 ; Decode Foreground and High Light based
jz donotsetbit ; on formula in SetSColor and setup.
inc ax
donotsetbit:
mov [si].fHlgt,ax ; store highlight bit (0, 1)
and [si].bkClr,0fff7h ; Strip off Blink bit
and [si].fgClr,0fff7h ; Strip off Hightlight bit
cEnd
;***
; WriteQbIni() - Writes QB.INI File.
;
; Purpose:
; Called at exit to write the qb.ini file if current default
; options of QB are changed.
;
; Entry:
; Uses a lot of system's common status variables.
;
; Exit:
; None.
;
; Uses:
; Per Convention (After explicitly saving SI,DI)
;
;**********************************************************************
cProc WriteQBIni,<PUBLIC,NEAR>,<SI,DI>
cBegin
cCall HookInt24 ; ignore int 24 errors for the
; duration of this routine
cmp fOptionsChanged,FALSE ; were options changed?
je OptNotChanged ; brif not -- just exit
mov bx,TRUE ; Open QB.INI file for write only mode
call OpenQBIni
jnz FileFound ; brif file found -- don't create one.
mov ax,DATAOFFSET qbIniFName; AX = "QB.INI"
cCall CreateFile,<AX> ; create file, AX = file handle
mov fh,ax ; fh = file handle
FileFound:
cmp ax,UNDEFINED ; If file creation successful proceed
jz NoHandle ; else set fOptionsChanged to FALSE
; and exit gracefully.
mov ax,SIZE OPTIONS
sub sp,ax ;Set up frame for OPTION structure
mov di,sp ; DI points to OPTIONS frame.
push ax ;save SIZE OPTIONS
mov [di].signature,QBSIGNATURE ; Set up QBSIGNATURE and
; VERSION on frame.
mov [di].version, QHELP11VERSION ; [QH1]
push ds ; Set ES = DS for following STOS instructions.
pop es
push di ; save *options
lea di,[di.tabStopsOpt]
cCall GetTabs ; AX = current tab setting
stosw ; and set in Option Frame
mov ax,fScrollBars ; AX = ScrollBars
stosw ; and set in Option Frame
mov al,fSyntaxCheck ; AX = SyntaxCheck
cbw ; convert to word
stosw ; and set in Option Frame
mov al,1 ; store TRUE
stosb
mov al,fRightMouseHelp ; store RightMouseHelp
stosb
pop si ; si = *options
mov di,UIOFFSET GetSColor ; Get color settings.
push si
call Chk3Windows ; for each isa, perform GetSColor
pop si
call SavePrintInfo ; [QH1]
pop ax ;AX = SIZE OPTIONS
push ax ;FH = File Handle
; Write OPTION structure with current
cCall WriteFile,<fh,si,ax> ; settings into QB.INI file.
mov ax,UIOFFSET writefileabc ; for each bd, call writefileabc
call rd_wrt_path
cCall CloseFileNear,<fh> ; Close the file.
pop ax ; AX = SIZE OPTIONS
add sp,ax ; Release frame from stack.
NoHandle:
mov fOptionsChanged,FALSE ; Now current settings conform to
; the ones in QB.INI
OptNotChanged:
cCall UnHookInt24 ; have runtime handle int 24 errors
cEnd
;;
;; [QH1] Start
;;
;; Save print-dest info
;; SI points to beginning of Options
;;
SavePrintInfo:
cld
mov ax, iPrintPort ; Save printer port
mov [si].iPrint, ax
mov ax, fPrintToFile ; Save PrinterOrFile flag
mov [si].fFile, ax
mov cx, MAX_PATH ; Save print-filename, if any
lea di, [si].szPrint
mov ax, ds
mov es, ax
push si
lea si, szPrintDest
rep movsb
pop si
ret
;;
;; [QH1] End
;;
sEnd UI
end
|
; End-of-text marker for print_string_*
eot = 128
; Select mode A and turn the cursor off.
; TODO: It's annoying that the cursor is briefly visible when doing this.
; Waiting for VSYNC doesn't seem to help. It might be possible to work around
; this by programming the CRTC directly instead of going via the OS.
.set_mode
pha
lda #vdu_set_mode:jsr oswrch
pla:jsr oswrch
jsr print_string_inline:equb 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, eot
rts
; Set logical colour X to physical colour Y.
.set_palette_x_to_y
lda #vdu_set_palette:jsr oswrch
txa:jsr oswrch
tya:jsr oswrch
jsr print_string_inline:equb 0, 0, 0, eot
rts
; Print the string following "jsr print_string_inline" (terminated by eot) using
; OSWRCH.
.print_string_inline
{
ptr = zp_tmp
pla:sta ptr
pla:sta ptr+1
ldy #0
.loop
inc_word ptr
lda (ptr),y
cmp #eot:beq done
jsr oswrch
jmp loop
.done
lda ptr+1:pha
lda ptr:pha
rts
}
|
/********************************************************************
Copyright 2016-2018 Tang, Wenyi. All Rights Reserved.
Description
Using MediaSDK in Android as the codec
Author : Wenyi Tang
Email : wenyi.tang@intel.com
Created : Mar. 16th, 2017
********************************************************************/
#if !WIN32
#include "ll_codec/impl/msdk/utility/mfx_alloc_va.h"
#include <mfxstructures.h>
#include <map>
using MFXFMT = std::pair<mfxU32, uint>;
const std::map<mfxU32, uint> MFXFormat = {
MFXFMT(MFX_FOURCC_NV12, VA_FOURCC_NV12),
MFXFMT(MFX_FOURCC_RGB4, VA_FOURCC_RGBA),
};
CMFXAllocator::CMFXAllocator() {
pthis = this;
Alloc = Alloc_;
Lock = Lock_;
Free = Free_;
Unlock = Unlock_;
GetHDL = GetHDL_;
}
CMFXAllocator::~CMFXAllocator() {}
mfxStatus CMFXAllocator::Alloc_(mfxHDL pthis, mfxFrameAllocRequest *request,
mfxFrameAllocResponse *response) {
if (!pthis) return MFX_ERR_MEMORY_ALLOC;
auto self = (CMFXAllocator *)pthis;
return self->AllocFrames(request, response);
}
mfxStatus CMFXAllocator::Lock_(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) {
if (!pthis) return MFX_ERR_MEMORY_ALLOC;
auto self = (CMFXAllocator *)pthis;
return self->LockFrame(mid, ptr);
}
mfxStatus CMFXAllocator::Unlock_(mfxHDL pthis, mfxMemId mid,
mfxFrameData *ptr) {
if (!pthis) return MFX_ERR_MEMORY_ALLOC;
auto self = (CMFXAllocator *)pthis;
return self->UnlockFrame(mid, ptr);
}
mfxStatus CMFXAllocator::GetHDL_(mfxHDL pthis, mfxMemId mid, mfxHDL *handle) {
if (!pthis) return MFX_ERR_MEMORY_ALLOC;
auto self = (CMFXAllocator *)pthis;
return self->GetFrameHDL(mid, handle);
}
mfxStatus CMFXAllocator::Free_(mfxHDL pthis, mfxFrameAllocResponse *response) {
if (!pthis) return MFX_ERR_MEMORY_ALLOC;
auto self = (CMFXAllocator *)pthis;
return self->FreeFrames(response);
}
CVRVAAllocator::CVRVAAllocator(VADisplay dpy) {
m_va = dpy;
m_resources.clear();
}
CVRVAAllocator::~CVRVAAllocator() {
for (auto &&res : m_resources) {
vaDestroySurfaces(m_va, &res.m_sid, 1);
}
}
mfxStatus CVRVAAllocator::AllocFrames(mfxFrameAllocRequest *request,
mfxFrameAllocResponse *response) {
if (!request || !response) return MFX_ERR_NULL_PTR;
if (!(request->Type & MFX_MEMTYPE_RESERVED1)) {
// todo be cautious
*response = m_resp.front();
return MFX_ERR_NONE;
}
VAStatus va_res;
uint va_surface_format;
uint va_rt_format;
VASurfaceAttrib attrib;
VASurfaceID *surf;
mfxU16 surfaces_num = request->NumFrameSuggested;
if (!surfaces_num) {
return MFX_ERR_MEMORY_ALLOC;
}
// specify surface color format
std::memset(response, 0, sizeof(mfxFrameAllocResponse));
va_surface_format = MFXFormat.at(request->Info.FourCC);
switch (request->Info.FourCC) {
case MFX_FOURCC_NV12:
va_rt_format = VA_RT_FORMAT_YUV420;
break;
case MFX_FOURCC_RGB4:
va_rt_format = VA_RT_FORMAT_RGB32;
break;
default:
return MFX_ERR_UNSUPPORTED;
}
// create va surfaces
attrib.type = VASurfaceAttribPixelFormat;
attrib.flags = VA_SURFACE_ATTRIB_SETTABLE;
attrib.value.type = VAGenericValueTypeInteger;
attrib.value.value.i = va_surface_format;
surf = new VASurfaceID[surfaces_num];
va_res =
vaCreateSurfaces(m_va, va_rt_format, request->Info.Width,
request->Info.Height, surf, surfaces_num, &attrib, 1);
if (va_res != VA_STATUS_SUCCESS) {
delete surf;
return MFX_ERR_MEMORY_ALLOC;
}
auto beg = m_mid.size();
for (mfxU16 i = 0; i < surfaces_num; ++i) {
m_resources.emplace_back(Resource{surf[i], request->Info.FourCC});
}
std::generate_n(std::back_inserter(m_mid), surfaces_num, [&]() {
auto ret = m_mid.empty() ? 1 : (size_t)m_mid.back() + 1;
return (mfxMemId)ret;
});
response->AllocId = request->AllocId;
response->mids = &m_mid[beg];
response->NumFrameActual = surfaces_num;
// record the response
m_resp.push_back(*response);
delete surf;
return MFX_ERR_NONE;
}
mfxStatus CVRVAAllocator::GetFrameHDL(mfxMemId mid, mfxHDL *handle) {
if (mid == 0 || !handle) return MFX_ERR_INVALID_HANDLE;
auto index = (size_t)mid - 1;
if (index > m_resources.size()) return MFX_ERR_NOT_ENOUGH_BUFFER;
*handle = &m_resources[index].m_sid;
return MFX_ERR_NONE;
}
mfxStatus CVRVAAllocator::FreeFrames(mfxFrameAllocResponse *response) {
return MFX_ERR_NONE;
}
mfxStatus CVRVAAllocator::LockFrame(mfxMemId mid, mfxFrameData *ptr) {
return MFX_ERR_UNSUPPORTED;
}
mfxStatus CVRVAAllocator::UnlockFrame(mfxMemId mid, mfxFrameData *ptr) {
return MFX_ERR_UNSUPPORTED;
}
#endif
|
; void balloc_free(void *m)
SECTION code_clib
SECTION code_alloc_balloc
PUBLIC balloc_free
EXTERN asm_balloc_free
defc balloc_free = asm_balloc_free
|
; A067187: Numbers that can be expressed as the sum of two primes in exactly one way.
; 4,5,6,7,8,9,12,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
mov $1,$0
sub $0,6
max $0,1
add $0,$1
seq $0,173919 ; Numbers that are prime or one less than a prime.
add $0,2
|
; A083043: Integers y such that 11*x^2 - 9*y^2 = 2 for some integer x.
; Submitted by Jon Maiga
; 1,21,419,8359,166761,3326861,66370459,1324082319,26415275921,526981436101,10513213446099,209737287485879,4184232536271481,83474913437943741,1665314036222603339,33222805811014123039,662790802184059857441,13222593237870183025781,263789073955219600658179,5262558885866521830137799,104987388643375217002097801,2094485213981637818211818221,41784716890989381147234266619,833599852605805985126473514159,16630212335225130321382236016561,331770646851896800442518246817061,6618782724702710878528982700324659
mov $2,2
mov $3,1
lpb $0
sub $0,1
mov $1,$3
mul $1,18
add $2,$1
add $3,$2
lpe
mov $0,$3
|
; A309355: Even numbers k such that k! is divisible by k*(k+1)/2.
; Submitted by Jamie Morken
; 8,14,20,24,26,32,34,38,44,48,50,54,56,62,64,68,74,76,80,84,86,90,92,94,98,104,110,114,116,118,120,122,124,128,132,134,140,142,144,146,152,154,158,160,164,168,170,174,176,182,184,186,188,194,200,202,204,206
add $0,2
mov $1,3
mov $2,1
lpb $0
mov $3,$2
lpb $3
add $2,2
mov $4,$1
gcd $4,$2
cmp $4,1
sub $3,$4
lpe
sub $0,1
add $2,2
mul $1,$2
lpe
mov $0,$2
sub $0,1
|
;***************************************************************************
; DEFINE SECTION
;***************************************************************************
; load vectrex bios routine definitions
INCLUDE "VECTREX.I" ; vectrex function includes
;***************************************************************************
; Variable / RAM SECTION
;***************************************************************************
; insert your variables (RAM usage) in the BSS section
; user RAM starts at $c880
BSS
ORG $c880 ; start of our ram space
; Vars
;
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Sound vars
;;;;;;;;;;;;;;;;;;;;;;;;;
currentMusic ds 2 ; ym player used
currentYLenCount ds 2 ; ym player used
nextMusic ds 2 ; ym player used
currentSFX_1 ds 2 ; sfx player used
sfx_pointer_1 ds 2 ; sfx player used
sfx_status_1 ds 1 ; sfx player used
currentSFX_2 ds 2 ; sfx player used
sfx_pointer_2 ds 2 ; sfx player used
sfx_status_2 ds 1 ; sfx player used
currentSFX_3 ds 2 ; sfx player used
sfx_pointer_3 ds 2 ; sfx player used
sfx_status_3 ds 1 ; sfx player used
current_button_state ds 1 ; only bit 0
last_button_state ds 1 ; only bit 0
tmp_count ds 1 ; poly
tmp_count2 ds 1 ;
tmp_add ds 2 ; poly
tmp_angle ds 2 ; poly
tmp_offset ds 2 ; poly
tmp_lastpos ds 2 ; poly
tmp_first_vector ds 2
;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Game vars
;;;;;;;;;;;;;;;;;;;;;;;;;
X_addi ds 1 ; change pos by this each "change"
X_add_delay ds 1 ; change pos each this "ticks"
base_angle ds 2 ; current start angle of base (*2)
sided ds 1 ; current count of sides for base
shieldWidthGrowth ds 1 ; shield width, grows each "x" cycles by "y" (this is y)
shieldWidthCounter ds 1 ; shield width, grows each "x" cycles by "y" (this is x)
shieldWidth ds 1 ; shield width now
shieldStart ds 1 ; outer shield position (in scale)
innerShield ds 1 ; inner shield position (in scale)
shieldSpeed ds 1 ; speed of the shield MOVEMENT - not the speed of growth
noShieldGrowthVar ds 1 ; if shield has max size do not grow anymore!
current_forth_dif ds 1 ; var for oscillating "inner" shield
current_back_dif ds 1 ; var for oscillating "inner" shield
osc_forth ds 1 ; var for oscillating "inner" shield
osc_back ds 1 ; var for oscillating "inner" shield
rotList ds 8*2+3 ; some ... space for a max 8 sided base (shield/explosion)
spawn_reset ds 1 ; after x ticks a new spawn happens
spawn_timer ds 1 ; current counter for those ticks
currentMaxOffset ds 1 ; dunno if that is correct anymore with new collision detection (TODO check - as of now this is FIXED, should be scale dependend)
list_empty_head ds 2 ; if empty these contain a positive value that points to a RTS
list_objects_head ds 2 ; if negative, than this is a pointer to a RAM location
list_objects_tail ds 2
MAX_OBJECTS = 35 ; todo determine max possible spawns!
; all objects are held in a linked list
; the linked list is made up by object defined in below structs
; the BASIC Object list consists of empty fileds - plus the last entry "NEXT_OBJECT"
; if NEXT_OBJECT is positive (not RAM pointer), than the list is finished
org $c900
; 20 bytes per object
struct ObjectStruct
ds Y_POS,1 ; D (1) current position
ds X_POS,1 ; D (2)
ds CURRENT_LIST,2 ; X current list vectorlist
ds DDRA,1 ; Y (1)
ds SCALE,1 ; Y (2) scale to position the object
ds BEHAVIOUR,2 ; PC
ds TYPE,1 ; enemy type
ds ANGLE,2 ; if angle base, angle in degree *2
ds PREVIOUS_OBJECT,2 ; positive = start of list
ds NEXT_OBJECT,2 ; positive = end of list
ds filler, 5
end struct
; all following object "inherit" from above defined Object struct
; all vars after "NEXT_OBJECT" can be different for each of the objects
;
; all definitions with the same name must be at the same structure position
struct XObjectStruct
ds Y_POS,1 ; current position
ds X_POS,1
ds CURRENT_LIST,2 ; current list vectorlist
ds DDRA,1
ds SCALE,1 ; scale to position the object
ds BEHAVIOUR,2
ds TYPE,1 ; enemy type
ds ANGLE,2 ; if angle base, angle in degree *2
ds PREVIOUS_OBJECT,2 ; positive = start of list
ds NEXT_OBJECT,2 ; positive = end of list
ds TICK_COUNTER,1 ; after how many rounds the movement updates (0 = each, 1 = every second etc)
ds SPEED_COUNTER,1 ; with what value does the movement get updated (1-4)?
ds ANIM_COUNTER,1 ; jmp to current draw routine
ds ORIGIN,2 ; pointer to original object definition
ds filler, 0
end struct
;
struct ExplosionObjectStruct
ds Y_POS,1 ; current position
ds X_POS,1
ds CURRENT_LIST,2 ; current list vectorlist
ds DDRA,1
ds SCALE,1 ; scale to position the object
ds BEHAVIOUR,2
ds TYPE,1 ; enemy type
ds ANGLE,2 ; if angle base, angle in degree *2
ds PREVIOUS_OBJECT,2 ; positive = start of list
ds NEXT_OBJECT,2 ; positive = end of list
ds EXPLOSION_SCALE,1
ds filler, 4
end struct
;
struct ScoreObjectStruct
ds Y_POS,1 ; current position
ds X_POS,1
ds CURRENT_LIST,2 ; current list vectorlist
ds DDRA,1
ds SCALE,1 ; scale to position the object
ds BEHAVIOUR,2
ds TYPE,1 ; enemy type
ds ANGLE,2 ; if angle base, angle in degree *2
ds PREVIOUS_OBJECT,2 ; positive = start of list
ds NEXT_OBJECT,2 ; positive = end of list
ds SCORE_COUNTDOWN,1
ds filler, 4
end struct
object_list ds ObjectStruct*MAX_OBJECTS
; for debugging some possible watches
o_behaviour = object_list +BEHAVIOUR
o_type = object_list+TYPE
o_scale = object_list+SCALE
o_angle = object_list+ANGLE
o_pos = object_list+Y_POS
o_list = object_list+CURRENT_LIST
o_previous = object_list+PREVIOUS_OBJECT
o_next = object_list+NEXT_OBJECT
;
; Defines
;
BASE_SCALE = 5 ; base scale is "5"
;BASE_SHIELD_WIDTH = 5 ; first shield width is 5 (shield starts at 15) scale
SHIELD_WIDTH_GROWTH_DEFAULT = 4 ; grow shield width every 4 round with 1
SHIELD_DEFAULT_SPEED = 2 ; increase position of shield with 2 every each increase step
BASE_SHIELD_WIDTH set 20
EXPLOSION_MAX = 40 ; max scale of explosion
TYPE_X = 1
TYPE_EX = -1 ; negative types are not destroyed by shield
TYPE_SCORE = -2 ;
SCORE_DISPLAY_TIME = 50
;
;
;***************************************************************************
; HEADER SECTION
;***************************************************************************
; The cartridge ROM starts at address 0
CODE
ORG 0
; the first few bytes are mandatory, otherwise the BIOS will not load
; the ROM file, and will start MineStorm instead
DB "g GCE 1998", $80 ; 'g' is copyright sign
DW music1 ; music from the rom
DB $F8, $50, $20, -$80 ; hight, width, rel y, rel x (from 0,0)
DB "RELEASE", $80 ; some game information, ending with $80
DB 0 ; end of game header
;***************************************************************************
; CODE SECTION
;***************************************************************************
; here the cartridge program starts off
bra start
INCLUDE "macro.i" ; vectrex function includes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
jsr initGame
_DP_TO_D0 ; round_startup_main expects dp set to d0
; reset music to 0
CLR Vec_Music_Flag ; no music is playing ->0
JSR Init_Music_Buf ; shadow regs
JSR Do_Sound ; ROM function that does the sound playing
; INIT_MUSICl gameStartMusic
main: ;#isfunction
jsr Wait_Recal
JSR do_ym_sound2
; increase base angle by 1 degree
; and modulo it at 360 degrees
ldx base_angle
leax 2,x
cmpx #(360*2)
blo angleOk
leax -(360*2),x
angleOk:
stx base_angle
; query joystick buttons
; four states:
; a) was not pressed and is not pressed -> do nothing
; b) was not pressed and is NOW pressed -> init new shield
; c) was pressed and is pressed -> continue shield (grow)
; d) was pressed and is NOT pressed -> shield finished
jsr getButtonState ; is a button pressed?
CMPB #$01 ; yes, but last time is was not pressed
lbeq newShield
CMPB #$03 ; yes, and last time was pressed
lbeq continueShield
CMPB #$02 ; no, but last time was pressed
lbeq finishShield
; beq no_playerAction ; zero means no, and last was also not pressed
no_playerAction:
jsr Reset0Ref
jsr drawPlayerHome
jsr Reset0Ref
bsr check_spawn
ldu list_objects_head
pulu d,x,y,pc ; (D = y,x, X = vectorlist, Y = DDRA+Scale)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; new list object to U
; leaves with flags set to i contents
; (positive = not successfull) ROM
; negative = successfull RAM
; destroys d, u , x
newObject ;#isfunction
ldu list_empty_head
bpl cs_done_no ; we don't have any spare objects -> go out
; set the new empty head
ldd NEXT_OBJECT,u
std list_empty_head
; load last of current object list
ldx list_objects_tail
; of our new object, that last object is the previous
stx PREVIOUS_OBJECT,u
bpl no_next_no ; the last object was 0, so we do net set a next there
; of the last object, the new object is the next object
stu NEXT_OBJECT,x
bra was_not_only_no
no_next_no:
stu list_objects_head ; if there was no last, than also no first -> therefor set new object as head
was_not_only_no:
; the next object of our current object is null, since we are last
ldd #PC_MAIN
std NEXT_OBJECT,u
; our new object is the new tail
stu list_objects_tail
cs_done_no
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; counts down spawn timer
; if 0 than spawn new
check_spawn: ;#isfunction
dec spawn_timer
lbne cs_done
; reset the timer for next spawn
lda spawn_reset
deca
cmpa #15
bgt nomin_cs
lda #15
nomin_cs
sta spawn_reset
sta spawn_timer
; calculate object position of next spawned object
jsr newObject
lbpl cs_done_no
PC_MAIN:
leax ,u ; pointer to new object
; determine (random) type
; random coordinates
; scale
; todo ... somehow determine random type of object
; for starters we determined an "X" object
jsr spawnX
cs_done:
rts
; this is actually an Object structure with a behaviour RTS
;ONE_RTS:
; dw 0 ; d
; dw 0 ; x
; dw 0 ; y
dw #main ; pc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE "objects.asm"
INCLUDE "drawSubRoutines.i" ; vectrex function includes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; construct new shield from current player base
newShield:
lda #BASE_SCALE+BASE_SHIELD_WIDTH ; the relevant "measure" shield is the outer shield wall
sta shieldStart ; this is our reference "start" value
sta osc_forth ; both oscillator drawing start from the outer rim
sta osc_back
lda shieldSpeed ; the speed of oscillators differs while still growing
lsla
sta current_forth_dif ; going forth is double the shield speed
lsra
lsra
sta current_back_dif ; going back is half the shield speed
; init a new shield with default values
lda #BASE_SHIELD_WIDTH ; for a new shield initialize the width to
sta shieldWidth ; the default width
lda shieldWidthGrowth
sta shieldWidthCounter
clr noShieldGrowthVar ; once the shield reaches maximum ($ff) stop growing - here, allow it
; each single button press (== new shield)
; the side of the base (and shield) is
; increased up 8 sides
lda sided
inca
cmpa #8
ble sideok
lda #5
sideok
sta sided
; set the current maximum of possible offset values
; for the n sided polygon
; used in first stage shield bound-check
suba #5
ldx #maxOffsetValues
lda a,x
sta currentMaxOffset
; shield scale starts of with base scale + shield width
; each round the size of the
; shield increases
continueShield:
tst noShieldGrowthVar ; do not grow if max size is acchieved
bne noShieldGrowth
dec shieldWidthCounter ; growth only happens each "x" rounds (kept in shieldWidthCounter)
bpl noShieldGrowth ; jump if that counter is not belwo zero
lda shieldWidthGrowth ; restore current growth rate to counter
sta shieldWidthCounter
; shield growth influences the width of the shield,
; NOT the position!
inc shieldWidth ; increase the width of the shield
noShieldGrowth:
; no the position of the shield is updated
lda shieldStart
adda shieldSpeed
bcc noMax ; $ff is max, if carry is set, than we have an overflow to our max,
; if outer shield stops growing we have to fix the oscilator speed
; oscillator speed is now dependend on
; a) width of shield
; b) speed of growth
lda shieldSpeed
sta current_forth_dif
sta current_back_dif
lda shieldWidth
cmpa #$80
ble nowidthuse
lsra
lsra
lsra
sta current_forth_dif
sta current_back_dif
nowidthuse
; also reduce the max to (unsigned) 255
lda #$ff ; max the shields outer rim
noMax:
sta shieldStart
; and draw the complete shield
jsr drawShield
; jsr testShield
jmp no_playerAction
finishShield: ;#isfunction
; check all objects if they are destroyed by shield vanishing
;..............
SET_CORRECTION_POINTER ; load x with correct correction pointer
ldu list_objects_head
beq shield_check_done
do_next_shield_check:
jsr onShield
tsta
beq shield_not_touched ; branch if a (shield inner wall) is higher or same than pos (scale) of object
jsr exchangeToExplosion
shield_not_touched:
ldu NEXT_OBJECT,u
bmi do_next_shield_check
shield_check_done:
;..............
jmp no_playerAction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; u pointer to object being tested
; relevant data in u, SCALE
; routine tests if object hits the shield
; return a = 0 -> no
; return a = 1 -> yes
; u is preserved
; expects polygon correction table of the current shield polygon set to X
;
; trying to figure out whether the current object
; mathematically lies on the area of the shield is
; quite bothersome - so I take a shortcut here
; since I know the current angle of the base and the "angle" of the object
; I can calculate the difference in angle
; both objects are drawn with the same scale
; knowing that the scale is actual the radius of a circle they are drawn
; around the middle point, I only have to check whether
; the object lies within the inner radius (scale) and the outer radius
; (scale) of the shield
; using a perfect circle while drawing a 5 sided polygon is
; error prone, but since I know the angle between the objects
; I can do some error correction to "circle" coordinates
; to simulate a n sided polygon
; for each sided x sided polygon slightly different error corrections
; are used
; using the radius and a polygon correction I ONLY
; have to check the scale value not even a single coordinate!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; n correction values
correctionList:
maxOffsetValues:
db 21,16,11,10 ; this should be scale related, e.g. instead of 21 it should be ~ 1/5 of scale
SHIELD_VARIANCE equ 5
polygon_5_div_correction ; 72 values
db NO_DIV,NO_DIV, DIV_BY32, DIV_BY12, DIV_BY12,DIV_BY11, DIV_BY10, DIV_BY8, DIV_BY8, DIV_BY7
db DIV_BY7, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY52, DIV_BY52, DIV_BY52, DIV_BY53
db DIV_BY53, DIV_BY53, DIV_BY53, DIV_BY53, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55
db DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY5, DIV_BY5, DIV_BY5, DIV_BY5, DIV_BY5, DIV_BY55, DIV_BY55
db DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY55, DIV_BY53, DIV_BY53, DIV_BY53
db DIV_BY53, DIV_BY53, DIV_BY52, DIV_BY52, DIV_BY52, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6
db DIV_BY6, DIV_BY7, DIV_BY7, DIV_BY8, DIV_BY8, DIV_BY10, DIV_BY11,DIV_BY12, DIV_BY12, DIV_BY32
db NO_DIV, NO_DIV
polygon_6_div_correction: ; 60 values
db NO_DIV, DIV_BY32, DIV_BY32, DIV_BY32, DIV_BY16, DIV_BY16, DIV_BY16, DIV_BY12, DIV_BY12, DIV_BY12
db DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY8, DIV_BY8, DIV_BY7, DIV_BY7, DIV_BY6, DIV_BY6
db DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6
db DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6, DIV_BY6
db DIV_BY6, DIV_BY6, DIV_BY7, DIV_BY7, DIV_BY8, DIV_BY8, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10
db DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY16, DIV_BY16, DIV_BY16, DIV_BY32, DIV_BY32, DIV_BY32, NO_DIV
polygon_7_div_correction: ; 52 values
db NO_DIV, NO_DIV, DIV_BY32, DIV_BY32, DIV_BY32, DIV_BY16, DIV_BY16, DIV_BY12, DIV_BY12, DIV_BY12
db DIV_BY12, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10
db DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10
db DIV_BY11, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY11, DIV_BY11
db DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY16, DIV_BY16, DIV_BY32, DIV_BY32, DIV_BY32
db NO_DIV, NO_DIV
polygon_8_div_correction: ; 45 values
db NO_DIV, DIV_BY32, DIV_BY32, DIV_BY32, DIV_BY16, DIV_BY16, DIV_BY16, DIV_BY12, DIV_BY12, DIV_BY12
db DIV_BY12, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11
db DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY10, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY11
db DIV_BY11, DIV_BY11, DIV_BY11, DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY12, DIV_BY16, DIV_BY16
db DIV_BY16, DIV_BY32, DIV_BY32, DIV_BY32, NO_DIV
testShield
;#isfunction
jsr Reset0Ref
SET_CORRECTION_POINTER ; load x with correct correction pointer
testCount2 = tmp_first_vector
ldd #720
std testCount2
nextAngle_ts
; now a more thorough check is needed
; if the shield were a perfect circle the above should be enough
ldd testCount2
; angle of object
subd base_angle ; angle diff = object angle - base angle
bpl isPositive_ts
addd #720
isPositive_ts:
MY_LSR_D ; half it (value now 0 - 360 )
tfr d,y
GET_POLY_DIV ; load polygone "divider" to d (72, 60, 52 or 45)
lsrb
negb
; the following does a
; angle % poly divider
; (gets the angle modulo the polygon angle)
getMod_ts:
leay b,y
cmpy #0 ; lea does not influence carry :-(
bpl getMod_ts
negb
leay b,y
; mod done
tfr y,d
leay d,x
; now in y
; is the pointer to the correction table, for circle position correction of
; our object in relation to the shield polygon
; do the above check AGAIN now with correction values present
ldb shieldStart ; outer shield border
cmpb #$ff
bhs noadd_ts2
addb #SHIELD_VARIANCE ; a little bit wider
noadd_ts2:
jsr getDivi_b
stb VIA_t1_cnt_lo ; to timer t1 (lo)
ldd testCount2
pshs y
ldy #circle
ldd d,y
jsr Moveto_d
jsr Dot_here
jsr Reset0Ref
puls y
; outer done here
ldb shieldStart ; outer shield border
subb shieldWidth
subb #(SHIELD_VARIANCE) ; wider
bcc no_underflow_ts
addb #(SHIELD_VARIANCE) ; wider
no_underflow_ts:
jsr getDivi_b
stb VIA_t1_cnt_lo ; to timer t1 (lo)
ldd testCount2
ldy #circle
ldd d,y
jsr Moveto_d
jsr Dot_here
jsr Reset0Ref
ldd testCount2
subd #2
std testCount2
bpl nextAngle_ts
rts
out_notTouched
clra
rts
onShield: ;#isfunction
; first look if current object and shield are completely out of bounds
lda TYPE,u ; negative objects do not get hit by the shield
bmi out_notTouched
lda shieldStart ; outer shield border
cmpa #$ff
bhs noadd_os1
adda #SHIELD_VARIANCE ; a little bit wider
noadd_os1:
cmpa SCALE,u ; compare outer border with object position
bls out_notTouched ; branch if a (shield outer wall) is lower or same than pos (scale) of object
suba shieldWidth
suba #(2*SHIELD_VARIANCE) ; wider (to compensate size of object and irregulatity to circle coords)
suba currentMaxOffset
clra
bpl no_minus_os
no_minus_os:
; todo - check if below zero
cmpa SCALE,u ; compare outer border with object position
bhs out_notTouched ; branch if a (shield inner wall) is higher or same than pos (scale) of object
; real checking!
; now a more thorough check is needed
; if the shield were a perfect circle the above should be enough
ldd ANGLE,u ; angle of object
subd base_angle ; angle diff = object angle - base angle
bpl isPositive_os
addd #720
isPositive_os:
MY_LSR_D ; half it (value now 0 - 360 )
tfr d,y
GET_POLY_DIV ; load polygone "divider" to d (72, 60, 52 or 45)
lsrb
negb
; the following does a
; angle % poly divider
; (gets the angle modulo the polygon angle)
getMod_os:
leay b,y
cmpy #0 ; lea does not influence carry :-(
bpl getMod_os
negb
leay b,y
; mod done
tfr y,d
leay d,x
; now in y
; is the pointer to the correction table, for circle position correction of
; our object in relation to the shield polygon
; do the above check AGAIN now with correction values present
ldb shieldStart ; outer shield border
cmpb #$ff
bhs noadd_os2
addb #SHIELD_VARIANCE ; a little bit wider
noadd_os2:
jsr getDivi_b
cmpb SCALE,u ; compare outer border with object position
bls out_notTouched ; branch if a (shield outer wall) is lower or same than pos (scale) of object
ldb shieldStart ; outer shield border
subb shieldWidth
subb #(SHIELD_VARIANCE) ; wider
bcc no_underflow_os
addb #(SHIELD_VARIANCE) ; wider
no_underflow_os:
jsr getDivi_b
cmpb SCALE,u ; compare outer border with object position
bhs out_notTouched ; branch if a (shield inner wall) is higher or same than pos (scale) of object
lda #1
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawPlayerHome: ;#isfunction
; draw player "home"
JSR Intensity_5F ; Sets the intensity of the
; vector beam to $5f
lda #BASE_SCALE
sta VIA_t1_cnt_lo ; to timer t1 (lo=
bsr buildRotatedNSidedFigure
ldx #rotList
jsr drawRotated
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawShield: ;#isfunction
; outer shield wall
JSR Intensity_5F ; Sets the intensity of the
lda shieldStart
sta VIA_t1_cnt_lo ; to timer t1
ldx #rotList
jsr drawRotated
; inner shield wall (calc by width)
jsr Reset0Ref
lda shieldStart
suba shieldWidth
cmpa #BASE_SCALE
bhs shieldWidthOk
lda #BASE_SCALE
inc noShieldGrowthVar
shieldWidthOk:
sta innerShield
sta VIA_t1_cnt_lo ; to timer t1
ldx #rotList
jsr drawRotated
; draw oscillators
jsr Reset0Ref
; forth
ldb osc_forth
addb current_forth_dif
stb osc_forth
; does not effect carry
bcs new_osc_forth
subb shieldStart
bcs draw_next_osc_forth
new_osc_forth:
ldb shieldStart
subb shieldWidth
stb osc_forth
; does not effect carry
draw_next_osc_forth:
ldb osc_forth
; load current scale (of index)
stb VIA_t1_cnt_lo ; to timer t1
ldx #rotList
jsr drawRotated
jsr Reset0Ref
; back
ldb osc_back
subb current_back_dif
stb osc_back
subb innerShield
bcc draw_next_osc_back
new_osc_back
ldb shieldStart
stb osc_back
draw_next_osc_back:
ldb osc_back
; load current scale (of index)
stb VIA_t1_cnt_lo ; to timer t1
ldx #rotList
jsr drawRotated
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; builds to rotList
; in "base_angle" the angle to "rotate" (from 0 to 720 = 2 *360) since it is a 16 bit pointer angle!
; in "sided" the number of sides of the figure (regular figure, can be build by regular offsets in circle list)
; move coordinate is angle in circle list
; second and each following coordinate (n sided "add" in circle list)
; Ydrawvector = y2-y1
; Xdrawvector = x2-x1
; list generated will be format:
; db count
; db move y,x
; db draw y,x
; ...
; db draw y,x
;
; times two, since angle is a "list" of 16 bit values
FIVE_ADD = (360/5)*2
SIX_ADD = (360/6)*2
SEVEN_ADD = (360/7)*2
EIGHT_ADD = (360/8)*2
buildRotatedNSidedFigure ;#isfunction
ldu #rotList
lda sided
deca
sta tmp_count
dec tmp_count ; one less, since I plan to use the last vector pos = first vector pos
sta ,u+ ; count
; seek sidedness
cmpa #4
bne test_n6
ldd #FIVE_ADD
bra brnsf1
test_n6
cmpa #5
bne test_n7
ldd #SIX_ADD
bra brnsf1
test_n7
cmpa #6
bne test_n8
ldd #SEVEN_ADD
bra brnsf1
test_n8
ldd #EIGHT_ADD
brnsf1:
std tmp_add ; add to angle for n sided polygon
ldd base_angle
std tmp_angle
ldx #circle
ldd d,x
std ,u++ ; move
std tmp_first_vector
std tmp_lastpos
; now the sided
next_brnsf:
ldd tmp_angle
addd tmp_add
cmpd #(360*2)
blo brnsf2
subd #(360*2)
brnsf2
std tmp_angle
ldd d,x ; a = y2, b = x2
tfr d,y
; now we must build the y2-y1 etc part
suba tmp_lastpos ; y2-y1
sta ,u+ ; store y move
subb tmp_lastpos+1 ; x2-x1
stb ,u+ ; store x move
sty tmp_lastpos
dec tmp_count
bpl next_brnsf
;; ensure last vector = first vector
ldd tmp_first_vector ; a = y2, b = x2
tfr d,y
; now we must build the y2-y1 etc part
suba tmp_lastpos ; y2-y1
sta ,u+ ; store y move
subb tmp_lastpos+1 ; x2-x1
stb ,u+ ; store x move
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; exchange the object structure pointed to by U register
; with a new "explosion" type object
exchangeToExplosion: ;#isfunction
pshs u,x
bsr buildscore10
PLAY_SFX Explosion_Sound
puls x,u
lda #TYPE_EX
sta TYPE, u
ldd #explosionBehaviour
std BEHAVIOUR,u
clr EXPLOSION_SCALE,u
rts
buildscore10:
tfr u,y
; build new object
; #score10
jsr newObject
; copy interesting things from y to u
lda #TYPE_SCORE
sta TYPE, u
ldd Y_POS,y
std Y_POS,u
ldd ANGLE,y
std ANGLE,u
lda SCALE,y
sta SCALE,u
ldd #scoreBehaviour
std BEHAVIOUR,u
ldd #score10
std CURRENT_LIST,u
lda #SCORE_DISPLAY_TIME
sta SCORE_COUNTDOWN,u
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; initialize all game vars with sensible dfault values
initGame ;#isfunction
clra
inca
inca
sta X_add_delay ; update x every cycle
inca
sta X_addi ; with one scale dec
ldd #8 ; start with a 5 sided polygon
stb sided
clrb ; start at angle 0
std base_angle
std currentSFX_3
std currentSFX_2
std currentSFX_1
std sfx_pointer_3
std sfx_pointer_2
std sfx_pointer_1
sta sfx_status_3
sta sfx_status_2
sta sfx_status_1
sta current_button_state ; store a known current button state
sta last_button_state
lda #SHIELD_WIDTH_GROWTH_DEFAULT ; shield per default grows one scale per round
sta shieldWidthGrowth
lda #SHIELD_DEFAULT_SPEED
sta shieldSpeed
lda #50 ; spawn timer
sta spawn_reset
sta spawn_timer
; initialize the empty object list
lda #MAX_OBJECTS
ldu #object_list
stu list_empty_head
ldy #PC_MAIN
next_list_entry_ig
leax ObjectStruct,u
stx NEXT_OBJECT,u
sty PREVIOUS_OBJECT,u
leay ,u
leau ,x
deca
bne next_list_entry_ig
ldd #PC_MAIN
std NEXT_OBJECT,y
std list_objects_head
std list_objects_tail
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Button 1-4
; returns in B the current button state in relation to last button state
; bit 0 represents current button state
; bit 1 last button state
; 1 = pressed
; 0 = not pressed
getButtonState: ;#isfunction
; save last states, and shift the old current one bit
; query buttons from psg
LDA #$0E ;Sound chip register 0E to port A
STA <VIA_port_a
LDD #$9981 ;sound BDIR on, BC1 on, mux off
sta <VIA_port_b ; VIA Port B = 99, mux disabled, RAMP disabled, BC1/BDIR = 11 (Latch address)
NOP ;pause
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
CLR <VIA_DDR_a ;DDR A to input
LDD #$8981 ;sound BDIR off, BC1 on, mux off
STA <VIA_port_b ; VIA Port B = 89, mux disabled, RAMP disabled, BC1/BDIR = 01 (PSG Read)
NOP ;pause
LDA <VIA_port_a ;Read buttons
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
LDB #$FF
STB <VIA_DDR_a ;DDR A to output
; query done, in A current button state directly from psg
ldb current_button_state
stb last_button_state
lslb
anda #$f ; only jostick 1
cmpa #$0f
beq noButtonPressed
incb
noButtonPressed:
stb current_button_state
andb #3
rts
; for now this is only reached when an object "hits" the base
; as // TODO
; only remove the villain
gameOver:
PLAY_SFX Gotcha_Sound
bra removeObject ; remove the object from game - for now, this be be a "GAME OVER"
;***************************************************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE "Data.i" ; vectrex function includes
INCLUDE "sound.i" ; vectrex function includes
INCLUDE "ayfxPlayer_channel3.i"
INCLUDE "ayfxPlayer_channel2.i"
INCLUDE "ayfxPlayer_channel1.i"
INCLUDE "collisionRoutines.i"
|
; A040139: Continued fraction for sqrt(152).
; 12,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3,24,3
pow $0,4
mov $1,$0
trn $0,4
sub $0,4
gcd $1,$0
mul $1,3
|
; 8080 assembler code
.hexfile PrintNumbers.hex
.binfile PrintNumbers.com
; try "hex" for downloading in hex format
.download bin
.objcopy gobjcopy
.postbuild echo "OK!"
;.nodump
; OS call list
PRINT_B equ 1
PRINT_MEM equ 2
READ_B equ 3
READ_MEM equ 4
PRINT_STR equ 5
READ_STR equ 6
; Position for stack pointer
stack equ 04000h
org 000H
jmp begin
; Start of our Operating System
GTU_OS: PUSH D
push D
push H
push psw
nop ; This is where we run our OS in C++, see the CPU8080::isSystemCall()
; function for the detail.
pop psw
pop h
pop d
pop D
ret
; ---------------------------------------------------------------
; YOU SHOULD NOT CHANGE ANYTHING ABOVE THIS LINE
;This program adds numbers from 0 to 10. The result is stored at variable
; sum. The results is also printed on the screen.
sum ds 2 ; will keep the sum
begin:
LXI SP,stack ; always initialize the stack pointer
mvi c, 0 ; init C with 0
mvi d, 50 ; D = 50
loop:
MOV B, C ; B = A
MVI A, PRINT_B ; store the OS call code to A
call GTU_OS ; call the OS
INR c ; ++C
DCR D ; -- D
JNZ loop ; goto loop if D!=0
hlt ; end program
|
/**
* Copyright (c) 2020 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "spdk/env.h"
#include "SpdkIoBuf.h"
namespace BdevCpp {
SpdkIoBufMgr::~SpdkIoBufMgr() {}
SpdkIoBuf *SpdkIoBufMgr::getIoWriteBuf(uint32_t ioSize, uint32_t align) {
SpdkIoBuf *buf = 0;
uint32_t bufIdx = !(ioSize%4096) ? (ioSize/4096 - 1) : ioSize/4096;
if (bufIdx < 8) {
buf = block[bufIdx]->getWriteBuf();
if (!buf->getSpdkDmaBuf())
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(block[bufIdx]->getBufSize()), align, NULL));
} else {
buf = new SpdkIoSizedBuf<1 << 16, 0>(1 << 16, -1);
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
}
return buf;
}
void SpdkIoBufMgr::putIoWriteBuf(SpdkIoBuf *ioBuf) {
if (ioBuf->getIdx() != -1)
ioBuf->putWriteBuf(ioBuf);
else {
delete ioBuf;
}
}
SpdkIoBuf *SpdkIoBufMgr::getIoReadBuf(uint32_t ioSize, uint32_t align) {
SpdkIoBuf *buf = 0;
uint32_t bufIdx = !(ioSize%4096) ? (ioSize/4096 - 1) : ioSize/4096;
if (bufIdx < 8) {
buf = block[bufIdx]->getReadBuf();
if (!buf->getSpdkDmaBuf())
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(block[bufIdx]->getBufSize()), align, NULL));
} else {
buf = new SpdkIoSizedBuf<1 << 16, 0>(1 << 16, -1);
buf->setSpdkDmaBuf(
spdk_dma_zmalloc(static_cast<size_t>(ioSize), align, NULL));
}
return buf;
}
void SpdkIoBufMgr::putIoReadBuf(SpdkIoBuf *ioBuf) {
if (ioBuf->getIdx() != -1)
ioBuf->putReadBuf(ioBuf);
else
delete ioBuf;
}
Lock SpdkIoBufMgr::instanceMutex;
SpdkIoBufMgr *SpdkIoBufMgr::instance = 0;
SpdkIoBufMgr *SpdkIoBufMgr::getSpdkIoBufMgr() {
if (!SpdkIoBufMgr::instance) {
WriteLock r_lock(instanceMutex);
SpdkIoBufMgr::instance = new SpdkIoBufMgr();
}
return SpdkIoBufMgr::instance;
}
void SpdkIoBufMgr::putSpdkIoBufMgr() {
if (SpdkIoBufMgr::instance) {
WriteLock r_lock(instanceMutex);
delete SpdkIoBufMgr::instance;
SpdkIoBufMgr::instance = 0;
}
}
SpdkIoBufMgr::SpdkIoBufMgr(int inst) {
switch (inst) {
case 0:
block[0] = new SpdkIoSizedBuf<4096, 0>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 0>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 0>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 0>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 0>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 0>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 0>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 0>(8 * 4096, 7);
break;
case 1:
block[0] = new SpdkIoSizedBuf<4096, 1>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 1>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 1>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 1>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 1>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 1>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 1>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 1>(8 * 4096, 7);
break;
case 2:
block[0] = new SpdkIoSizedBuf<4096, 2>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 2>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 2>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 2>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 2>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 2>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 2>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 2>(8 * 4096, 7);
break;
case 3:
block[0] = new SpdkIoSizedBuf<4096, 3>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 3>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 3>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 3>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 3>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 3>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 3>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 3>(8 * 4096, 7);
break;
case 4:
block[0] = new SpdkIoSizedBuf<4096, 4>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 4>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 4>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 4>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 4>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 4>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 4>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 4>(8 * 4096, 7);
break;
case 5:
block[0] = new SpdkIoSizedBuf<4096, 5>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 5>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 5>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 5>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 5>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 5>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 5>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 5>(8 * 4096, 7);
break;
case 6:
block[0] = new SpdkIoSizedBuf<4096, 6>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 6>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 6>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 6>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 6>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 6>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 6>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 6>(8 * 4096, 7);
break;
case 7:
block[0] = new SpdkIoSizedBuf<4096, 7>(4096, 0);
block[1] = new SpdkIoSizedBuf<2 * 4096, 7>(2 * 4096, 1);
block[2] = new SpdkIoSizedBuf<3 * 4096, 7>(3 * 4096, 2);
block[3] = new SpdkIoSizedBuf<4 * 4096, 7>(4 * 4096, 3);
block[4] = new SpdkIoSizedBuf<5 * 4096, 7>(5 * 4096, 4);
block[5] = new SpdkIoSizedBuf<6 * 4096, 7>(6 * 4096, 5);
block[6] = new SpdkIoSizedBuf<7 * 4096, 7>(7 * 4096, 6);
block[7] = new SpdkIoSizedBuf<8 * 4096, 7>(8 * 4096, 7);
break;
}
}
} // namespace BdevCpp
|
6E_Header:
sHeaderInit ; Z80 offset is $CA00
sHeaderPatch 6E_Patches
sHeaderTick $01
sHeaderCh $01
sHeaderSFX $80, $05, 6E_FM5, $00, $00
6E_FM5:
sPatFM $00
dc.b nD0, $0D
6E_Loop1:
dc.b nD0, $0D
saVolFM $15
sLoop $00, $04, 6E_Loop1
sStop
6E_Patches:
; Patch $00
; $54
; $48, $02, $03, $01, $1F, $1F, $1F, $1F
; $11, $00, $0A, $00, $00, $05, $00, $05
; $FF, $0F, $FF, $0F, $02, $80, $10, $80
spAlgorithm $04
spFeedback $02
spDetune $04, $00, $00, $00
spMultiple $08, $03, $02, $01
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $11, $0A, $00, $00
spSustainLv $0F, $0F, $00, $00
spDecayRt $00, $00, $05, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $02, $10, $00, $00
|
; A102711: Numbers k such that 11*k + 7 is prime.
; Submitted by Christian Krause
; 0,2,6,12,20,24,26,30,32,44,50,54,66,74,80,86,90,92,96,102,104,110,116,120,132,134,146,150,156,162,164,170,180,186,194,200,204,206,212,216,240,246,254,272,282,300,302,306,314,320,324,326,330,332,342,356,360,362,372,384,386,390,396,404,410,414,416,422,432,450,456,482,492,494,500,506,512,516,522,534,536,552,554,564,570,572,576,596,600,606,614,620,624,632,642,666,680,710,716,720
mov $1,6
mov $2,$0
pow $2,2
lpb $2
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,22
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,1
lpe
mov $0,$1
div $0,11
|
; A105531: Decimal expansion of arctan 1/3.
; Submitted by Jon Maiga
; 3,2,1,7,5,0,5,5,4,3,9,6,6,4,2,1,9,3,4,0,1,4,0,4,6,1,4,3,5,8,6,6,1,3,1,9,0,2,0,7,5,5,2,9,5,5,5,7,6,5,6,1,9,1,4,3,2,8,0,3,0,5,9,3,5,6,7,5,6,2,3,7,4,0,5,8,1,0,5,4,4,3,5,6,4,0,8,4,2,2,3,5,0,6,4,1,3,7,4,4
mov $1,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $1,$3
mov $5,$3
mul $5,2
add $5,1
mul $2,$5
mul $2,5
add $1,$2
div $1,$5
div $2,$5
sub $3,1
lpe
mul $1,3
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r15
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xfb5e, %rsi
lea addresses_UC_ht+0xd5c4, %rdi
nop
sub $26490, %r10
mov $116, %rcx
rep movsw
cmp $15276, %r15
lea addresses_D_ht+0x94f6, %rbx
nop
cmp %r9, %r9
and $0xffffffffffffffc0, %rbx
vmovntdqa (%rbx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %rsi
cmp $8753, %rcx
lea addresses_WT_ht+0x19b1e, %rsi
nop
cmp %r15, %r15
mov (%rsi), %rbx
nop
nop
inc %r9
lea addresses_D_ht+0x17546, %rsi
lea addresses_WT_ht+0xff5e, %rdi
clflush (%rdi)
nop
nop
nop
nop
add %rax, %rax
mov $102, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %rax
lea addresses_normal_ht+0xa8de, %rcx
clflush (%rcx)
nop
and $37973, %rax
vmovups (%rcx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r15
nop
nop
nop
dec %r9
lea addresses_UC_ht+0x9f70, %rsi
lea addresses_D_ht+0x12b5e, %rdi
nop
nop
nop
nop
nop
xor %r9, %r9
mov $46, %rcx
rep movsb
lfence
lea addresses_normal_ht+0x120e, %rbx
nop
nop
nop
nop
nop
sub %r10, %r10
mov $0x6162636465666768, %r9
movq %r9, %xmm0
vmovups %ymm0, (%rbx)
cmp $14644, %r10
lea addresses_D_ht+0x1096a, %rcx
nop
nop
nop
nop
cmp $30798, %rbx
movb (%rcx), %r10b
nop
nop
nop
nop
xor $40317, %rax
lea addresses_normal_ht+0x875e, %rsi
lea addresses_UC_ht+0x14f5e, %rdi
nop
dec %r15
mov $78, %rcx
rep movsl
inc %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r15
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %rax
push %rdi
push %rdx
push %rsi
// Store
lea addresses_normal+0xb75e, %r12
nop
nop
nop
nop
dec %rax
movb $0x51, (%r12)
// Exception!!!
nop
nop
nop
nop
mov (0), %r12
nop
cmp $31359, %rax
// Store
lea addresses_normal+0x147aa, %r13
clflush (%r13)
xor $11786, %r14
movb $0x51, (%r13)
nop
nop
nop
cmp %r12, %r12
// Store
lea addresses_A+0x41fe, %rsi
nop
nop
nop
nop
xor %rdi, %rdi
movb $0x51, (%rsi)
nop
add %rsi, %rsi
// Store
lea addresses_D+0xf5e, %r14
nop
and %r12, %r12
movw $0x5152, (%r14)
nop
nop
nop
nop
nop
add $12163, %r13
// Store
lea addresses_UC+0x1695e, %r14
nop
nop
inc %r13
movl $0x51525354, (%r14)
nop
nop
nop
add $55265, %r12
// Load
lea addresses_WC+0xcdec, %r12
nop
nop
cmp %rsi, %rsi
mov (%r12), %r13
nop
nop
nop
nop
nop
add $51591, %r13
// Store
lea addresses_US+0x15b5e, %rdx
sub $60822, %r13
mov $0x5152535455565758, %r12
movq %r12, (%rdx)
nop
nop
nop
dec %rdi
// Store
lea addresses_D+0x1ec1e, %r14
clflush (%r14)
nop
and %rsi, %rsi
movb $0x51, (%r14)
nop
nop
nop
and $55969, %r13
// Store
mov $0x124a490000000502, %r14
clflush (%r14)
nop
nop
nop
nop
sub $20277, %r12
mov $0x5152535455565758, %rax
movq %rax, %xmm4
movups %xmm4, (%r14)
nop
nop
cmp %r12, %r12
// Faulty Load
lea addresses_normal+0xb75e, %rdx
clflush (%rdx)
nop
nop
nop
nop
add $57487, %r13
vmovaps (%rdx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rdi
lea oracles, %r14
and $0xff, %rdi
shlq $12, %rdi
mov (%r14,%rdi,1), %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rax
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC', 'same': False, 'size': 8, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_US', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'same': True, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_normal_ht', 'same': True, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'00': 6942, '51': 1448}
00 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 51 51 00 00 00 00 00 00 00 00 51 51 51 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 00 00 00 51 00 51 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 51 00 51 00 00 00 00 51 00 00 00 51 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 51 00 00 00 51 00 00 00 51 00 51 00 00 00 00 51 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 51 00 51 00 00 00 00 00 51 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 51 00 00 51 00 00 51 00 00 00 00 51 00 00 00 51 00 00 51 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 51 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 51 00 00 51 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 51 51 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 00 51 00 00 00 00 00 51 00 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 00 00 00 51 51 51 00 00 51 00 00 00 51 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 51 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 51 00 00 00 00 00 00 51 00 00 00 51 51 00 00 00 00 00 00 00 51 00 51 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 51 00 51 00 00 00 00 00 00 00 00 51 00 51 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 51 00 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 51 51 00 00 51 00 00 00 00 51 00 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 51 51 00 00 00 00 00 00 00 00 00 51 51 00 00 51 00 00 51 00 00 00 51 00 00 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 51 51 00 00 51 00 00 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 51 00 00 00 51 00 00 00 00 00 00 00 00 51 51 00 51 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00
*/
|
; A138420: a(n) = ((prime(n))^4-(prime(n))^2)/4.
; 3,18,150,588,3630,7098,20808,32490,69828,176610,230640,468198,706020,854238,1219368,1971918,3028470,3460530,5036658,6351660,7098228,9735960,11862858,15683580,22129968,26012550,28135068,32767038,35286570
cal $0,60429 ; a(n) = 4*prime(n)^2+1.
sub $1,$0
sub $0,3
add $1,1
mov $2,$0
mov $3,2
sub $3,$0
add $3,1
mul $3,$1
add $2,$3
mov $0,$2
add $0,3
mov $1,$0
sub $1,193
div $1,192
mul $1,3
add $1,3
|
; A246104: Least m > 0 for which (s(m), ..., s(n+m-1) = (s(0), ..., s(n)), the first n+1 terms of the infinite Fibonacci word A003849.
; 2,3,5,5,8,8,8,13,13,13,13,13,21,21,21,21,21,21,21,21,34,34,34,34,34,34,34,34,34,34,34,34,34,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,89,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377
mov $1,2
mov $3,3
lpb $0,1
add $0,$1
trn $0,$3
sub $2,$2
add $2,$1
mov $1,$3
add $3,$2
lpe
|
// Copyright (c) 2014-2020 The D@sh Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "governance-object.h"
#include "core_io.h"
#include "governance-classes.h"
#include "governance-validators.h"
#include "governance-vote.h"
#include "governance.h"
#include "masternode/masternode-meta.h"
#include "masternode/masternode-sync.h"
#include "messagesigner.h"
#include "spork.h"
#include "util.h"
#include "validation.h"
#include <string>
#include <univalue.h>
CGovernanceObject::CGovernanceObject() :
cs(),
nObjectType(GOVERNANCE_OBJECT_UNKNOWN),
nHashParent(),
nRevision(0),
nTime(0),
nDeletionTime(0),
nCollateralHash(),
vchData(),
masternodeOutpoint(),
vchSig(),
fCachedLocalValidity(false),
strLocalValidityError(),
fCachedFunding(false),
fCachedValid(true),
fCachedDelete(false),
fCachedEndorsed(false),
fDirtyCache(true),
fExpired(false),
fUnparsable(false),
mapCurrentMNVotes(),
fileVotes()
{
// PARSE JSON DATA STORAGE (VCHDATA)
LoadData();
}
CGovernanceObject::CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTimeIn, const uint256& nCollateralHashIn, const std::string& strDataHexIn) :
cs(),
nObjectType(GOVERNANCE_OBJECT_UNKNOWN),
nHashParent(nHashParentIn),
nRevision(nRevisionIn),
nTime(nTimeIn),
nDeletionTime(0),
nCollateralHash(nCollateralHashIn),
vchData(ParseHex(strDataHexIn)),
masternodeOutpoint(),
vchSig(),
fCachedLocalValidity(false),
strLocalValidityError(),
fCachedFunding(false),
fCachedValid(true),
fCachedDelete(false),
fCachedEndorsed(false),
fDirtyCache(true),
fExpired(false),
fUnparsable(false),
mapCurrentMNVotes(),
fileVotes()
{
// PARSE JSON DATA STORAGE (VCHDATA)
LoadData();
}
CGovernanceObject::CGovernanceObject(const CGovernanceObject& other) :
cs(),
nObjectType(other.nObjectType),
nHashParent(other.nHashParent),
nRevision(other.nRevision),
nTime(other.nTime),
nDeletionTime(other.nDeletionTime),
nCollateralHash(other.nCollateralHash),
vchData(other.vchData),
masternodeOutpoint(other.masternodeOutpoint),
vchSig(other.vchSig),
fCachedLocalValidity(other.fCachedLocalValidity),
strLocalValidityError(other.strLocalValidityError),
fCachedFunding(other.fCachedFunding),
fCachedValid(other.fCachedValid),
fCachedDelete(other.fCachedDelete),
fCachedEndorsed(other.fCachedEndorsed),
fDirtyCache(other.fDirtyCache),
fExpired(other.fExpired),
fUnparsable(other.fUnparsable),
mapCurrentMNVotes(other.mapCurrentMNVotes),
fileVotes(other.fileVotes)
{
}
bool CGovernanceObject::ProcessVote(CNode* pfrom,
const CGovernanceVote& vote,
CGovernanceException& exception,
CConnman& connman)
{
LOCK(cs);
// do not process already known valid votes twice
if (fileVotes.HasVote(vote.GetHash())) {
// nothing to do here, not an error
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Already known valid vote";
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_NONE);
return false;
}
auto mnList = deterministicMNManager->GetListAtChainTip();
auto dmn = mnList.GetMNByCollateral(vote.GetMasternodeOutpoint());
if (!dmn) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " not found";
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_PERMANENT_ERROR, 20);
return false;
}
vote_m_it it = mapCurrentMNVotes.emplace(vote_m_t::value_type(vote.GetMasternodeOutpoint(), vote_rec_t())).first;
vote_rec_t& voteRecordRef = it->second;
vote_signal_enum_t eSignal = vote.GetSignal();
if (eSignal == VOTE_SIGNAL_NONE) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Vote signal: none";
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING);
return false;
}
if (eSignal > MAX_SUPPORTED_VOTE_SIGNAL) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Unsupported vote signal: " << CGovernanceVoting::ConvertSignalToString(vote.GetSignal());
LogPrintf("%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_PERMANENT_ERROR, 20);
return false;
}
vote_instance_m_it it2 = voteRecordRef.mapInstances.emplace(vote_instance_m_t::value_type(int(eSignal), vote_instance_t())).first;
vote_instance_t& voteInstanceRef = it2->second;
// Reject obsolete votes
if (vote.GetTimestamp() < voteInstanceRef.nCreationTime) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Obsolete vote";
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_NONE);
return false;
} else if (vote.GetTimestamp() == voteInstanceRef.nCreationTime) {
// Someone is doing smth fishy, there can be no two votes from the same masternode
// with the same timestamp for the same object and signal and yet different hash/outcome.
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Invalid vote, same timestamp for the different outcome";
if (vote.GetOutcome() < voteInstanceRef.eOutcome) {
// This is an arbitrary comparison, we have to agree on some way
// to pick the "winning" vote.
ostr << ", rejected";
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_NONE);
return false;
}
ostr << ", accepted";
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
}
int64_t nNow = GetAdjustedTime();
int64_t nVoteTimeUpdate = voteInstanceRef.nTime;
if (governance.AreRateChecksEnabled()) {
int64_t nTimeDelta = nNow - voteInstanceRef.nTime;
if (nTimeDelta < GOVERNANCE_UPDATE_MIN) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Masternode voting too often"
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
<< ", governance object hash = " << GetHash().ToString()
<< ", time delta = " << nTimeDelta;
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_TEMPORARY_ERROR);
return false;
}
nVoteTimeUpdate = nNow;
}
bool onlyVotingKeyAllowed = nObjectType == GOVERNANCE_OBJECT_PROPOSAL && vote.GetSignal() == VOTE_SIGNAL_FUNDING;
// Finally check that the vote is actually valid (done last because of cost of signature verification)
if (!vote.IsValid(onlyVotingKeyAllowed)) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Invalid vote"
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
<< ", governance object hash = " << GetHash().ToString()
<< ", vote hash = " << vote.GetHash().ToString();
LogPrintf("%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_PERMANENT_ERROR, 20);
governance.AddInvalidVote(vote);
return false;
}
if (!mmetaman.AddGovernanceVote(dmn->proTxHash, vote.GetParentHash())) {
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Unable to add governance vote"
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
<< ", governance object hash = " << GetHash().ToString();
LogPrint(BCLog::GOBJECT, "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_PERMANENT_ERROR);
return false;
}
voteInstanceRef = vote_instance_t(vote.GetOutcome(), nVoteTimeUpdate, vote.GetTimestamp());
fileVotes.AddVote(vote);
fDirtyCache = true;
return true;
}
void CGovernanceObject::ClearMasternodeVotes()
{
LOCK(cs);
auto mnList = deterministicMNManager->GetListAtChainTip();
vote_m_it it = mapCurrentMNVotes.begin();
while (it != mapCurrentMNVotes.end()) {
if (!mnList.HasMNByCollateral(it->first)) {
fileVotes.RemoveVotesFromMasternode(it->first);
mapCurrentMNVotes.erase(it++);
fDirtyCache = true;
} else {
++it;
}
}
}
std::set<uint256> CGovernanceObject::RemoveInvalidVotes(const COutPoint& mnOutpoint)
{
LOCK(cs);
auto it = mapCurrentMNVotes.find(mnOutpoint);
if (it == mapCurrentMNVotes.end()) {
// don't even try as we don't have any votes from this MN
return {};
}
auto removedVotes = fileVotes.RemoveInvalidVotes(mnOutpoint, nObjectType == GOVERNANCE_OBJECT_PROPOSAL);
if (removedVotes.empty()) {
return {};
}
auto nParentHash = GetHash();
for (auto jt = it->second.mapInstances.begin(); jt != it->second.mapInstances.end(); ) {
CGovernanceVote tmpVote(mnOutpoint, nParentHash, (vote_signal_enum_t)jt->first, jt->second.eOutcome);
tmpVote.SetTime(jt->second.nCreationTime);
if (removedVotes.count(tmpVote.GetHash())) {
jt = it->second.mapInstances.erase(jt);
} else {
++jt;
}
}
if (it->second.mapInstances.empty()) {
mapCurrentMNVotes.erase(it);
}
if (!removedVotes.empty()) {
std::string removedStr;
for (auto& h : removedVotes) {
removedStr += strprintf(" %s\n", h.ToString());
}
LogPrintf("CGovernanceObject::%s -- Removed %d invalid votes for %s from MN %s:\n%s", __func__, removedVotes.size(), nParentHash.ToString(), mnOutpoint.ToString(), removedStr);
fDirtyCache = true;
}
return removedVotes;
}
uint256 CGovernanceObject::GetHash() const
{
// Note: doesn't match serialization
// CREATE HASH OF ALL IMPORTANT PIECES OF DATA
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
ss << nHashParent;
ss << nRevision;
ss << nTime;
ss << GetDataAsHexString();
ss << masternodeOutpoint << uint8_t{} << 0xffffffff; // adding dummy values here to match old hashing
ss << vchSig;
// fee_tx is left out on purpose
return ss.GetHash();
}
uint256 CGovernanceObject::GetSignatureHash() const
{
return SerializeHash(*this);
}
void CGovernanceObject::SetMasternodeOutpoint(const COutPoint& outpoint)
{
masternodeOutpoint = outpoint;
}
bool CGovernanceObject::Sign(const CBLSSecretKey& key)
{
CBLSSignature sig = key.Sign(GetSignatureHash());
if (!key.IsValid()) {
return false;
}
sig.GetBuf(vchSig);
return true;
}
bool CGovernanceObject::CheckSignature(const CBLSPublicKey& pubKey) const
{
CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.VerifyInsecure(pubKey, GetSignatureHash())) {
LogPrintf("CGovernanceObject::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
return true;
}
/**
Return the actual object from the vchData JSON structure.
Returns an empty object on error.
*/
UniValue CGovernanceObject::GetJSONObject()
{
UniValue obj(UniValue::VOBJ);
if (vchData.empty()) {
return obj;
}
UniValue objResult(UniValue::VOBJ);
GetData(objResult);
if (objResult.isObject()) {
obj = objResult;
} else {
std::vector<UniValue> arr1 = objResult.getValues();
std::vector<UniValue> arr2 = arr1.at(0).getValues();
obj = arr2.at(1);
}
return obj;
}
/**
* LoadData
* --------------------------------------------------------
*
* Attempt to load data from vchData
*
*/
void CGovernanceObject::LoadData()
{
if (vchData.empty()) {
return;
}
try {
// ATTEMPT TO LOAD JSON STRING FROM VCHDATA
UniValue objResult(UniValue::VOBJ);
GetData(objResult);
LogPrint(BCLog::GOBJECT, "CGovernanceObject::LoadData -- GetDataAsPlainString = %s\n", GetDataAsPlainString());
UniValue obj = GetJSONObject();
nObjectType = obj["type"].get_int();
} catch (std::exception& e) {
fUnparsable = true;
std::ostringstream ostr;
ostr << "CGovernanceObject::LoadData Error parsing JSON"
<< ", e.what() = " << e.what();
LogPrintf("%s\n", ostr.str());
return;
} catch (...) {
fUnparsable = true;
std::ostringstream ostr;
ostr << "CGovernanceObject::LoadData Unknown Error parsing JSON";
LogPrintf("%s\n", ostr.str());
return;
}
}
/**
* GetData - Example usage:
* --------------------------------------------------------
*
* Decode governance object data into UniValue(VOBJ)
*
*/
void CGovernanceObject::GetData(UniValue& objResult)
{
UniValue o(UniValue::VOBJ);
std::string s = GetDataAsPlainString();
o.read(s);
objResult = o;
}
/**
* GetData - As
* --------------------------------------------------------
*
*/
std::string CGovernanceObject::GetDataAsHexString() const
{
return HexStr(vchData);
}
std::string CGovernanceObject::GetDataAsPlainString() const
{
return std::string(vchData.begin(), vchData.end());
}
void CGovernanceObject::UpdateLocalValidity()
{
LOCK(cs_main);
// THIS DOES NOT CHECK COLLATERAL, THIS IS CHECKED UPON ORIGINAL ARRIVAL
fCachedLocalValidity = IsValidLocally(strLocalValidityError, false);
};
bool CGovernanceObject::IsValidLocally(std::string& strError, bool fCheckCollateral) const
{
bool fMissingConfirmations = false;
return IsValidLocally(strError, fMissingConfirmations, fCheckCollateral);
}
bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const
{
fMissingConfirmations = false;
if (fUnparsable) {
strError = "Object data unparseable";
return false;
}
switch (nObjectType) {
case GOVERNANCE_OBJECT_PROPOSAL: {
CProposalValidator validator(GetDataAsHexString(), true);
// Note: It's ok to have expired proposals
// they are going to be cleared by CGovernanceManager::UpdateCachesAndClean()
// TODO: should they be tagged as "expired" to skip vote downloading?
if (!validator.Validate(false)) {
strError = strprintf("Invalid proposal data, error messages: %s", validator.GetErrorMessages());
return false;
}
if (fCheckCollateral && !IsCollateralValid(strError, fMissingConfirmations)) {
strError = "Invalid proposal collateral";
return false;
}
return true;
}
case GOVERNANCE_OBJECT_TRIGGER: {
if (!fCheckCollateral) {
// nothing else we can check here (yet?)
return true;
}
auto mnList = deterministicMNManager->GetListAtChainTip();
std::string strOutpoint = masternodeOutpoint.ToStringShort();
auto dmn = mnList.GetMNByCollateral(masternodeOutpoint);
if (!dmn) {
strError = "Failed to find Masternode by UTXO, missing masternode=" + strOutpoint;
return false;
}
// Check that we have a valid MN signature
if (!CheckSignature(dmn->pdmnState->pubKeyOperator.Get())) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey = " + dmn->pdmnState->pubKeyOperator.Get().ToString();
return false;
}
return true;
}
default: {
strError = strprintf("Invalid object type %d", nObjectType);
return false;
}
}
}
CAmount CGovernanceObject::GetMinCollateralFee() const
{
// Only 1 type has a fee for the moment but switch statement allows for future object types
switch (nObjectType) {
case GOVERNANCE_OBJECT_PROPOSAL:
return GOVERNANCE_PROPOSAL_FEE_TX;
case GOVERNANCE_OBJECT_TRIGGER:
return 0;
default:
return MAX_MONEY;
}
}
bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
{
strError = "";
fMissingConfirmations = false;
CAmount nMinFee = GetMinCollateralFee();
uint256 nExpectedHash = GetHash();
CTransactionRef txCollateral;
uint256 nBlockHash;
// RETRIEVE TRANSACTION IN QUESTION
if (!GetTransaction(nCollateralHash, txCollateral, Params().GetConsensus(), nBlockHash, true)) {
strError = strprintf("Can't find collateral tx %s", nCollateralHash.ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (nBlockHash == uint256()) {
strError = strprintf("Collateral tx %s is not mined yet", txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (txCollateral->vout.size() < 1) {
strError = strprintf("tx vout size less than 1 | %d", txCollateral->vout.size());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
// LOOK FOR SPECIALIZED GOVERNANCE SCRIPT (PROOF OF BURN)
CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash);
LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
txCollateral->vout.size(), ScriptToAsmStr(findScript, false), nMinFee);
bool foundOpReturn = false;
for (const auto& output : txCollateral->vout) {
LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txout = %s, output.nValue = %lld, output.scriptPubKey = %s\n",
output.ToString(), output.nValue, ScriptToAsmStr(output.scriptPubKey, false));
if (!output.scriptPubKey.IsPayToPublicKeyHash() && !output.scriptPubKey.IsUnspendable()) {
strError = strprintf("Invalid Script %s", txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if (output.scriptPubKey == findScript && output.nValue >= nMinFee) {
foundOpReturn = true;
}
}
if (!foundOpReturn) {
strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral->ToString());
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
// GET CONFIRMATIONS FOR TRANSACTION
AssertLockHeld(cs_main);
int nConfirmationsIn = 0;
if (nBlockHash != uint256()) {
BlockMap::iterator mi = mapBlockIndex.find(nBlockHash);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex)) {
nConfirmationsIn += chainActive.Height() - pindex->nHeight + 1;
}
}
}
if ((nConfirmationsIn < GOVERNANCE_FEE_CONFIRMATIONS)) {
strError = strprintf("Collateral requires at least %d confirmations to be relayed throughout the network (it has only %d)", GOVERNANCE_FEE_CONFIRMATIONS, nConfirmationsIn);
if (nConfirmationsIn >= GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS) {
fMissingConfirmations = true;
strError += ", pre-accepted -- waiting for required confirmations";
} else {
strError += ", rejected -- try again later";
}
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
strError = "valid";
return true;
}
int CGovernanceObject::CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const
{
LOCK(cs);
int nCount = 0;
for (const auto& votepair : mapCurrentMNVotes) {
const vote_rec_t& recVote = votepair.second;
vote_instance_m_cit it2 = recVote.mapInstances.find(eVoteSignalIn);
if (it2 != recVote.mapInstances.end() && it2->second.eOutcome == eVoteOutcomeIn) {
++nCount;
}
}
return nCount;
}
/**
* Get specific vote counts for each outcome (funding, validity, etc)
*/
int CGovernanceObject::GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const
{
return GetYesCount(eVoteSignalIn) - GetNoCount(eVoteSignalIn);
}
int CGovernanceObject::GetAbsoluteNoCount(vote_signal_enum_t eVoteSignalIn) const
{
return GetNoCount(eVoteSignalIn) - GetYesCount(eVoteSignalIn);
}
int CGovernanceObject::GetYesCount(vote_signal_enum_t eVoteSignalIn) const
{
return CountMatchingVotes(eVoteSignalIn, VOTE_OUTCOME_YES);
}
int CGovernanceObject::GetNoCount(vote_signal_enum_t eVoteSignalIn) const
{
return CountMatchingVotes(eVoteSignalIn, VOTE_OUTCOME_NO);
}
int CGovernanceObject::GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const
{
return CountMatchingVotes(eVoteSignalIn, VOTE_OUTCOME_ABSTAIN);
}
bool CGovernanceObject::GetCurrentMNVotes(const COutPoint& mnCollateralOutpoint, vote_rec_t& voteRecord) const
{
LOCK(cs);
vote_m_cit it = mapCurrentMNVotes.find(mnCollateralOutpoint);
if (it == mapCurrentMNVotes.end()) {
return false;
}
voteRecord = it->second;
return true;
}
void CGovernanceObject::Relay(CConnman& connman)
{
// Do not relay until fully synced
if (!masternodeSync.IsSynced()) {
LogPrint(BCLog::GOBJECT, "CGovernanceObject::Relay -- won't relay until fully synced\n");
return;
}
CInv inv(MSG_GOVERNANCE_OBJECT, GetHash());
connman.RelayInv(inv, MIN_GOVERNANCE_PEER_PROTO_VERSION);
}
void CGovernanceObject::UpdateSentinelVariables()
{
// CALCULATE MINIMUM SUPPORT LEVELS REQUIRED
int nMnCount = (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount();
if (nMnCount == 0) return;
// CALCULATE THE MINUMUM VOTE COUNT REQUIRED FOR FULL SIGNAL
int nAbsVoteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, nMnCount / 10);
int nAbsDeleteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, (2 * nMnCount) / 3);
// SET SENTINEL FLAGS TO FALSE
fCachedFunding = false;
fCachedValid = true; //default to valid
fCachedEndorsed = false;
fDirtyCache = false;
// SET SENTINEL FLAGS TO TRUE IF MIMIMUM SUPPORT LEVELS ARE REACHED
// ARE ANY OF THESE FLAGS CURRENTLY ACTIVATED?
if (GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING) >= nAbsVoteReq) fCachedFunding = true;
if ((GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsDeleteReq) && !fCachedDelete) {
fCachedDelete = true;
if (nDeletionTime == 0) {
nDeletionTime = GetAdjustedTime();
}
}
if (GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED) >= nAbsVoteReq) fCachedEndorsed = true;
if (GetAbsoluteNoCount(VOTE_SIGNAL_VALID) >= nAbsVoteReq) fCachedValid = false;
}
|
; float cbrt(float x)
SECTION code_fp_math48
PUBLIC cm48_sdcciy_cbrt
EXTERN cm48_sdcciy_cbrt_fastcall
cm48_sdcciy_cbrt:
pop af
pop hl
pop de
push de
push hl
push af
jp cm48_sdcciy_cbrt_fastcall
|
// This file is part of RAVL, Recognition And Vision Library.
// Copyright (C) 2009, OmniPerception Ltd
// This code may be redistributed under the terms of the GNU Lesser
// General Public License (LGPL). See the lgpl.licence file for details or
// see http://www.gnu.org/copyleft/lesser.html
// file-header-ends-here
#ifndef RAVL_DATASERVERCONTROLINTERFACE_H
#define RAVL_DATASERVERCONTROLINTERFACE_H
#include "Ravl/RCBodyV.hh"
#include "Ravl/String.hh"
#include "Ravl/Hash.hh"
#include "Ravl/Threads/Signal1.hh"
namespace RavlN
{
//! userlevel = Develop
//: Data server control interface.
class DataServerControlInterfaceBodyC
: public RCBodyVC
{
public:
DataServerControlInterfaceBodyC();
//: Ctor.
virtual bool AddNode(const StringC& path, const StringC& nodeType, const HashC<StringC, StringC>& options);
//: Add a node to the live data server.
//!param: path - The virtual path to add to the tree.
//!param: nodeType - The node type name (matching the 'NodeType' config entry).
//!param: options - Addition options (matching the format used for node config entries).
//!return: True on success.
virtual bool RemoveNode(const StringC& path, bool removeFromDisk = false);
//: Remove a node from the live data server.
//!param: path - The virtual path to remove from the tree.
//!param: removeFromDisk - If a corresponding real file exists, remove it from the disk once all ports have closed.
//!return: True on success.
virtual Signal1C<StringC>& SignalNodeClosed()
{ return m_signalNodeClosed; }
//: Connect to this signal to be informed when all ports to a target path have closed.
//!return: Signal to a string containing the target path.
virtual Signal1C<StringC>& SignalNodeRemoved()
{ return m_signalNodeRemoved; }
//: Connect to this signal to be informed when all ports to a removed target path have closed and it has been removed.
//!return: Signal to a string containing the target path.
virtual bool QueryNodeSpace(const StringC& path, Int64T& total, Int64T& used, Int64T& available);
//: Query the space info for a node, if applicable.
//!param: total - Returns the space allocated for footage in bytes (both free and used). -1 if not applicable.
//!param: used - Returns the space used for stored footage in bytes. -1 if not applicable.
//!param: available - Returns the space available for uploading footage in bytes. -1 if not applicable.
//!return: True if the query executed successfully.
protected:
Signal1C<StringC> m_signalNodeClosed;
Signal1C<StringC> m_signalNodeRemoved;
};
//! userlevel = Normal
//: Data server control interface.
class DataServerControlInterfaceC
: public RCHandleVC<DataServerControlInterfaceBodyC>
{
public:
DataServerControlInterfaceC() {}
//: Default ctor.
DataServerControlInterfaceC(bool)
: RCHandleVC<DataServerControlInterfaceBodyC>(*new DataServerControlInterfaceBodyC())
{}
//: Ctor.
DataServerControlInterfaceC(DataServerControlInterfaceBodyC& body)
: RCHandleVC<DataServerControlInterfaceBodyC>(body)
{}
//: Body ctor.
bool AddNode(const StringC& path, const StringC& nodeType, const HashC<StringC, StringC>& options)
{ return Body().AddNode(path, nodeType, options); }
//: Add a node to the live data server.
//!param: path - The virtual path to add to the tree.
//!param: nodeType - The node type name (matching the 'NodeType' config entry).
//!param: options - Addition options (matching the format used for node config entries).
//!return: True on success.
bool RemoveNode(const StringC& path, bool removeFromDisk = false)
{ return Body().RemoveNode(path, removeFromDisk); }
//: Remove a node from the live data server.
//!param: path - The virtual path to remove from the tree.
//!param: removeFromDisk - If a corresponding real file exists, remove it from the disk once all ports have closed.
//!return: True on success.
Signal1C<StringC>& SignalNodeClosed()
{ return Body().SignalNodeClosed(); }
//: Connect to this signal to be informed when all ports to a target path have closed.
//!return: Signal to a string containing the target path.
Signal1C<StringC>& SignalNodeRemoved()
{ return Body().SignalNodeRemoved(); }
//: Connect to this signal to be informed when all ports to a removed target path have closed and it has been removed.
//!return: Signal to a string containing the target path.
bool QueryNodeSpace(const StringC& path, Int64T& total, Int64T& used, Int64T& available)
{ return Body().QueryNodeSpace(path, total, used, available); }
//: Query the space info for a node, if applicable.
//!param: total - Returns the space allocated for footage in bytes (both free and used). -1 if not applicable.
//!param: used - Returns the space used for stored footage in bytes. -1 if not applicable.
//!param: available - Returns the space available for uploading footage in bytes. -1 if not applicable.
//!return: True if the query executed successfully.
};
}
#endif
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x19fd1, %rsi
lea addresses_normal_ht+0x2c51, %rdi
nop
nop
nop
sub %r10, %r10
mov $118, %rcx
rep movsq
nop
nop
inc %r15
lea addresses_WC_ht+0x1a791, %rsi
lea addresses_A_ht+0x7d9b, %rdi
nop
add $21, %r8
mov $21, %rcx
rep movsw
nop
nop
nop
nop
sub $36220, %rcx
lea addresses_normal_ht+0x1c8d1, %rsi
nop
nop
nop
nop
and %r11, %r11
mov (%rsi), %edi
nop
nop
and %r15, %r15
lea addresses_normal_ht+0x18a11, %rsi
lea addresses_normal_ht+0xfc51, %rdi
nop
nop
nop
nop
nop
add %rdx, %rdx
mov $21, %rcx
rep movsb
nop
nop
nop
nop
nop
sub %r8, %r8
lea addresses_normal_ht+0x60d1, %r8
nop
nop
nop
nop
nop
cmp %r10, %r10
movups (%r8), %xmm5
vpextrq $1, %xmm5, %rdx
nop
nop
nop
inc %r11
lea addresses_normal_ht+0x1e85d, %rsi
lea addresses_WC_ht+0xda51, %rdi
nop
nop
and $15667, %r15
mov $68, %rcx
rep movsb
nop
nop
nop
cmp %rdx, %rdx
lea addresses_normal_ht+0x1cb51, %rsi
lea addresses_UC_ht+0x1d51, %rdi
add %r15, %r15
mov $88, %rcx
rep movsw
sub %rcx, %rcx
lea addresses_A_ht+0x3951, %rdi
nop
nop
nop
nop
nop
xor %r10, %r10
mov (%rdi), %r11w
nop
nop
nop
nop
nop
add $5987, %r8
lea addresses_WT_ht+0x197dd, %rsi
clflush (%rsi)
nop
nop
nop
nop
and $19088, %r11
movw $0x6162, (%rsi)
nop
nop
and %rcx, %rcx
lea addresses_D_ht+0x8ae5, %r15
nop
nop
nop
nop
xor $27487, %rdi
mov $0x6162636465666768, %rdx
movq %rdx, (%r15)
nop
nop
nop
nop
nop
sub $11964, %rdx
lea addresses_D_ht+0x10e51, %rcx
nop
nop
add $9494, %r15
mov $0x6162636465666768, %r11
movq %r11, %xmm6
and $0xffffffffffffffc0, %rcx
vmovntdq %ymm6, (%rcx)
nop
nop
sub %rdx, %rdx
lea addresses_A_ht+0x1c071, %r11
nop
nop
nop
nop
nop
inc %r15
mov $0x6162636465666768, %rdi
movq %rdi, (%r11)
dec %rdi
lea addresses_WT_ht+0x3451, %rdi
nop
nop
nop
nop
sub $64388, %rcx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
movups %xmm4, (%rdi)
nop
nop
inc %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %rax
push %rbp
push %rcx
push %rsi
// Store
mov $0x951, %r10
nop
cmp %rax, %rax
movw $0x5152, (%r10)
nop
nop
nop
nop
and $62207, %rsi
// Store
lea addresses_RW+0xed51, %rcx
nop
nop
nop
nop
xor $656, %rbp
mov $0x5152535455565758, %rax
movq %rax, %xmm7
vmovaps %ymm7, (%rcx)
and $58580, %rcx
// Faulty Load
lea addresses_US+0x1651, %r11
nop
nop
nop
nop
inc %rcx
mov (%r11), %si
lea oracles, %rax
and $0xff, %rsi
shlq $12, %rsi
mov (%rax,%rsi,1), %rsi
pop %rsi
pop %rcx
pop %rbp
pop %rax
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_US', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_P', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_RW', 'congruent': 8}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_US', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}}
{'dst': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 7}}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 5}}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_A_ht', 'congruent': 8}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT_ht', 'congruent': 1}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 11}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 9}, 'OP': 'STOR'}
{'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
*/
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: bsProcess.asm
AUTHOR: Chris Boyke
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 8/26/93 Initial version.
DESCRIPTION:
$Id: bsProcess.asm,v 1.1 97/04/04 16:53:04 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSProcessOpenApplication
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Load the mouse driver, if it's not already loaded.
PASS: ds, es - dgroup
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 8/26/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
mouseCatString char MOUSE_CATEGORY,0
BSProcessOpenApplication method dynamic BSProcessClass,
MSG_GEN_PROCESS_OPEN_APPLICATION
uses ax,cx,dx,bp,ds,es
.enter
mov ax, GDDT_MOUSE
call GeodeGetDefaultDriver
tst ax
jnz done
segmov ds, cs
mov si, offset mouseCatString
mov ax, SP_MOUSE_DRIVERS
clr cx, dx ; Expected
; protocol number?
call UserLoadExtendedDriver
EC < ERROR_C -1 >
mov ax, GDDT_MOUSE
call GeodeSetDefaultDriver
mov ax, GDDT_VIDEO
call GeodeGetDefaultDriver
mov_tr bx, ax
call GeodeInfoDriver
mov di, DR_VID_SHOWPTR
call ds:[si].DIS_strategy
done:
;
; Tell the mouse driver to ignore the hard icons for now
;
mov di, DR_MOUSE_START_CALIBRATION
call BSSetHardIconsOnOff
;
; Call superclass LAST, so the calibration stuff isn't on
; screen before we've loaded the mouse driver. Pretty weak
; syncronization, but
;
.leave
mov di, offset BSProcessClass
GOTO ObjCallSuperNoLock
BSProcessOpenApplication endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSProcessCreateNewStateFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make sure no state file is generated.
PASS: ds, es - dgroup
RETURN: ax = 0
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
SIDE EFFECTS: nukes any state file that the superclass creates
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 8/ 6/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
BSProcessCreateNewStateFile method dynamic BSProcessClass,
MSG_GEN_PROCESS_CREATE_NEW_STATE_FILE
clr ax
ret
BSProcessCreateNewStateFile endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSProcessCloseApplication
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Tell the UI to continue startup.
PASS: *ds:si - BSProcessClass object
ds:di - BSProcessClass instance data
es - dgroup
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
chrisb 8/30/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
BSProcessCloseApplication method dynamic BSProcessClass,
MSG_GEN_PROCESS_CLOSE_APPLICATION
;
; Turn the hard icons back on
;
mov di, DR_MOUSE_STOP_CALIBRATION
call BSSetHardIconsOnOff
;
; Continue the rest of setup
;
mov ax, MSG_USER_CONTINUE_STARTUP
mov bx, handle ui
clr di
call ObjMessage
;
; Return no state block, not that it matters...
;
clr cx
ret
BSProcessCloseApplication endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSSetHardIconsOnOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Disable or enable the use of the hard icons
CALLED BY: INTERNAL
PASS: DI = DR_MOUSE_START_CALIBRATION (ignore hard icons) or
DR_MOUSE_STOP_CALIBRATION (stop ignoring hard icons)
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 11/30/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
; this goes under the [system] category
systemCatString1 char "system", C_NULL
emulationKey1 char "bstartupPCEmulation", C_NULL
BSSetHardIconsOnOff proc near
uses ax, bx, cx, dx, di, si, bp, ds
.enter
;
; Don't call mouse driver if we are running PC emulation of bullet,
; because for genmouse driver there are no MouseStartCalibration
; and MouseStopCalibration routines defined, hence no such entries
; in mouseHandlers table. --- AY 11/15/93
;
mov cx, cs
mov dx, offset emulationKey1 ; cx:dx = emulationKey
mov ds, cx
mov si, offset systemCatString1 ; ds:si = category
clr ax ; default to FALSE
call InitFileReadBoolean ; rtn ax=TRUE/FALSE, CF
tst ax
jnz done ; jump if running PC emulation
;
; Tell the pen driver we're done calibrating.
;
mov ax, GDDT_MOUSE
call GeodeGetDefaultDriver
mov_tr bx, ax
call GeodeInfoDriver
call ds:[si].DIS_strategy
done:
.leave
ret
BSSetHardIconsOnOff endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSAppStartEndSelect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Catch all messages listed below, and forward them to the
approrpriate object, to ensure all points are the screen
are recognized.
CALLED BY: GLOBAL (MSG_META_[START, END]_SELECT)
PASS: ES = DGroup
AX = Message
CX,DX,BP= Data
RETURN: Nothing
DESTROYED: AX, CX, DX, BP
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 11/30/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
BSAppStartEndSelect method dynamic BSApplicationClass,
MSG_META_START_SELECT,
MSG_META_END_SELECT
;
; If on the Date & Time screen, let the system handle it
;
cmp es:[doingSomething], DS_DATE_TIME
jne doForward
mov di, offset BSApplicationClass
GOTO ObjCallSuperNoLock
;
; Forward the message to the correct object
;
doForward:
mov bx, handle BSWelcomeContent
mov si, offset BSWelcomeContent
cmp es:[doingSomething], DS_WELCOME
je forwardMessage
mov bx, handle ScreenVisScreen
mov si, offset ScreenVisScreen
forwardMessage:
mov di, mask MF_CALL
GOTO ObjMessage
BSAppStartEndSelect endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSCheckCalibration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check to see if the pen is calibrated
CALLED BY: GLOBAL
PASS: Nothing
RETURN: Carry = Clear if pen is calibrated
= Set if not
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 12/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
BSCheckCalibration proc far
uses ax, cx, dx, si, ds
.enter
segmov ds, cs, cx
mov si, offset calibrateCategory ; ds:si = category
mov dx, offset calibrateKey ; cx:dx = string
clr ax ; assume FALSE
call InitFileReadBoolean
cmp ax, TRUE ; pen calibrated?
je done ; yes, and carry is clear
stc
done:
.leave
ret
BSCheckCalibration endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSSetCalibration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the calibration to be TRUE or FALSE
CALLED BY: GLOBAL
PASS: AX = TRUE or FALSE
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 12/ 7/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
calibrateCategory char "system",0
calibrateKey char "penCalibrated",0
BSSetCalibration proc far
uses cx, dx, si, ds
.enter
segmov ds, cs, cx
mov si, offset calibrateCategory ; ds:si = category
mov dx, offset calibrateKey ; cx:dx = string
call InitFileWriteBoolean
call InitFileCommit
.leave
ret
BSSetCalibration endp
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/animation/css_interpolation_type.h"
#include <memory>
#include <utility>
#include "base/memory/ptr_util.h"
#include "third_party/blink/renderer/core/animation/css_interpolation_environment.h"
#include "third_party/blink/renderer/core/animation/string_keyframe.h"
#include "third_party/blink/renderer/core/css/computed_style_css_value_mapping.h"
#include "third_party/blink/renderer/core/css/css_custom_property_declaration.h"
#include "third_party/blink/renderer/core/css/css_inherited_value.h"
#include "third_party/blink/renderer/core/css/css_initial_value.h"
#include "third_party/blink/renderer/core/css/css_revert_value.h"
#include "third_party/blink/renderer/core/css/css_unset_value.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/css_variable_reference_value.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/property_registration.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_cascade.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/data_equivalency.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
namespace blink {
class ResolvedVariableChecker : public CSSInterpolationType::ConversionChecker {
public:
ResolvedVariableChecker(CSSPropertyID property,
const CSSValue* variable_reference,
const CSSValue* resolved_value)
: property_(property),
variable_reference_(variable_reference),
resolved_value_(resolved_value) {}
private:
bool IsValid(const InterpolationEnvironment& environment,
const InterpolationValue&) const final {
const auto& css_environment = To<CSSInterpolationEnvironment>(environment);
// TODO(alancutter): Just check the variables referenced instead of doing a
// full CSSValue resolve.
const CSSValue* resolved_value = css_environment.Resolve(
PropertyHandle(CSSProperty::Get(property_)), variable_reference_);
return DataEquivalent(resolved_value_.Get(), resolved_value);
}
CSSPropertyID property_;
Persistent<const CSSValue> variable_reference_;
Persistent<const CSSValue> resolved_value_;
};
class InheritedCustomPropertyChecker
: public CSSInterpolationType::CSSConversionChecker {
public:
InheritedCustomPropertyChecker(const AtomicString& name,
bool is_inherited_property,
const CSSValue* inherited_value,
const CSSValue* initial_value)
: name_(name),
is_inherited_property_(is_inherited_property),
inherited_value_(inherited_value),
initial_value_(initial_value) {}
private:
bool IsValid(const StyleResolverState& state,
const InterpolationValue&) const final {
const CSSValue* inherited_value =
state.ParentStyle()->GetVariableValue(name_, is_inherited_property_);
if (!inherited_value) {
inherited_value = initial_value_.Get();
}
return DataEquivalent(inherited_value_.Get(), inherited_value);
}
const AtomicString& name_;
const bool is_inherited_property_;
Persistent<const CSSValue> inherited_value_;
Persistent<const CSSValue> initial_value_;
};
class ResolvedRegisteredCustomPropertyChecker
: public InterpolationType::ConversionChecker {
public:
ResolvedRegisteredCustomPropertyChecker(
const CSSCustomPropertyDeclaration& declaration,
scoped_refptr<CSSVariableData> resolved_tokens)
: declaration_(declaration),
resolved_tokens_(std::move(resolved_tokens)) {}
private:
bool IsValid(const InterpolationEnvironment& environment,
const InterpolationValue&) const final {
const auto& css_environment = To<CSSInterpolationEnvironment>(environment);
const CSSValue* resolved = css_environment.Resolve(
PropertyHandle(declaration_->GetName()), declaration_);
scoped_refptr<CSSVariableData> resolved_tokens = nullptr;
if (const auto* decl = DynamicTo<CSSCustomPropertyDeclaration>(resolved))
resolved_tokens = decl->Value();
return DataEquivalent(resolved_tokens, resolved_tokens_);
}
Persistent<const CSSCustomPropertyDeclaration> declaration_;
scoped_refptr<CSSVariableData> resolved_tokens_;
};
class RevertChecker : public CSSInterpolationType::ConversionChecker {
public:
RevertChecker(const PropertyHandle& property_handle,
const CSSValue* resolved_value)
: property_handle_(property_handle), resolved_value_(resolved_value) {
DCHECK(RuntimeEnabledFeatures::CSSRevertEnabled());
}
private:
bool IsValid(const InterpolationEnvironment& environment,
const InterpolationValue&) const final {
const auto& css_environment = To<CSSInterpolationEnvironment>(environment);
const CSSValue* current_resolved_value = css_environment.Resolve(
property_handle_, cssvalue::CSSRevertValue::Create());
return DataEquivalent(resolved_value_.Get(), current_resolved_value);
}
PropertyHandle property_handle_;
Persistent<const CSSValue> resolved_value_;
};
CSSInterpolationType::CSSInterpolationType(
PropertyHandle property,
const PropertyRegistration* registration)
: InterpolationType(property), registration_(registration) {
DCHECK(!GetProperty().IsCSSCustomProperty() || registration);
DCHECK(!CssProperty().IsShorthand());
}
InterpolationValue CSSInterpolationType::MaybeConvertSingle(
const PropertySpecificKeyframe& keyframe,
const InterpolationEnvironment& environment,
const InterpolationValue& underlying,
ConversionCheckers& conversion_checkers) const {
InterpolationValue result = MaybeConvertSingleInternal(
keyframe, environment, underlying, conversion_checkers);
if (result && keyframe.Composite() !=
EffectModel::CompositeOperation::kCompositeReplace) {
return PreInterpolationCompositeIfNeeded(std::move(result), underlying,
keyframe.Composite(),
conversion_checkers);
}
return result;
}
InterpolationValue CSSInterpolationType::MaybeConvertSingleInternal(
const PropertySpecificKeyframe& keyframe,
const InterpolationEnvironment& environment,
const InterpolationValue& underlying,
ConversionCheckers& conversion_checkers) const {
const CSSValue* value = To<CSSPropertySpecificKeyframe>(keyframe).Value();
const auto& css_environment = To<CSSInterpolationEnvironment>(environment);
const StyleResolverState& state = css_environment.GetState();
if (!value)
return MaybeConvertNeutral(underlying, conversion_checkers);
if (GetProperty().IsCSSCustomProperty()) {
return MaybeConvertCustomPropertyDeclaration(
To<CSSCustomPropertyDeclaration>(*value), environment,
conversion_checkers);
}
if (value->IsVariableReferenceValue() ||
value->IsPendingSubstitutionValue()) {
const CSSValue* resolved_value =
css_environment.Resolve(GetProperty(), value);
DCHECK(resolved_value);
conversion_checkers.push_back(std::make_unique<ResolvedVariableChecker>(
CssProperty().PropertyID(), value, resolved_value));
value = resolved_value;
}
if (value->IsRevertValue()) {
DCHECK(RuntimeEnabledFeatures::CSSRevertEnabled());
value = css_environment.Resolve(GetProperty(), value);
DCHECK(value);
conversion_checkers.push_back(
std::make_unique<RevertChecker>(GetProperty(), value));
}
bool is_inherited = CssProperty().IsInherited();
if (value->IsInitialValue() || (value->IsUnsetValue() && !is_inherited)) {
return MaybeConvertInitial(state, conversion_checkers);
}
if (value->IsInheritedValue() || (value->IsUnsetValue() && is_inherited)) {
return MaybeConvertInherit(state, conversion_checkers);
}
return MaybeConvertValue(*value, &state, conversion_checkers);
}
InterpolationValue CSSInterpolationType::MaybeConvertCustomPropertyDeclaration(
const CSSCustomPropertyDeclaration& declaration,
const InterpolationEnvironment& environment,
ConversionCheckers& conversion_checkers) const {
const auto& css_environment = To<CSSInterpolationEnvironment>(environment);
const StyleResolverState& state = css_environment.GetState();
const AtomicString& name = declaration.GetName();
DCHECK_EQ(GetProperty().CustomPropertyName(), name);
const CSSValue* value = &declaration;
value = css_environment.Resolve(GetProperty(), value);
DCHECK(value) << "CSSVarCycleInterpolationType should have handled nullptr";
if (declaration.IsRevert()) {
DCHECK(RuntimeEnabledFeatures::CSSRevertEnabled());
conversion_checkers.push_back(
std::make_unique<RevertChecker>(GetProperty(), value));
}
if (const auto* resolved_declaration =
DynamicTo<CSSCustomPropertyDeclaration>(value)) {
// If Resolve returned a different CSSCustomPropertyDeclaration, var()
// references were substituted.
if (resolved_declaration != &declaration) {
conversion_checkers.push_back(
std::make_unique<ResolvedRegisteredCustomPropertyChecker>(
declaration, resolved_declaration->Value()));
}
}
// Unfortunately we transport CSS-wide keywords inside the
// CSSCustomPropertyDeclaration. Expand those keywords into real CSSValues
// if present.
bool is_inherited = Registration().Inherits();
if (const auto* resolved_declaration =
DynamicTo<CSSCustomPropertyDeclaration>(value)) {
if (resolved_declaration->IsInitial(is_inherited))
value = CSSInitialValue::Create();
else if (resolved_declaration->IsInherit(is_inherited))
value = CSSInheritedValue::Create();
}
// Handle CSS-wide keywords (except 'revert', which should have been
// handled already).
DCHECK(!value->IsRevertValue());
if (value->IsInitialValue() || (value->IsUnsetValue() && !is_inherited)) {
value = Registration().Initial();
} else if (value->IsInheritedValue() ||
(value->IsUnsetValue() && is_inherited)) {
value = state.ParentStyle()->GetVariableValue(name, is_inherited);
if (!value) {
value = Registration().Initial();
}
conversion_checkers.push_back(
std::make_unique<InheritedCustomPropertyChecker>(
name, is_inherited, value, Registration().Initial()));
}
if (const auto* resolved_declaration =
DynamicTo<CSSCustomPropertyDeclaration>(value)) {
DCHECK(resolved_declaration->Value());
value = resolved_declaration->Value()->ParseForSyntax(
registration_->Syntax(),
state.GetDocument().GetExecutionContext()->GetSecureContextMode());
if (!value)
return nullptr;
}
DCHECK(value);
return MaybeConvertValue(*value, &state, conversion_checkers);
}
InterpolationValue CSSInterpolationType::MaybeConvertUnderlyingValue(
const InterpolationEnvironment& environment) const {
const ComputedStyle& style =
To<CSSInterpolationEnvironment>(environment).Style();
if (!GetProperty().IsCSSCustomProperty()) {
return MaybeConvertStandardPropertyUnderlyingValue(style);
}
const PropertyHandle property = GetProperty();
const AtomicString& name = property.CustomPropertyName();
const CSSValue* underlying_value =
style.GetVariableValue(name, Registration().Inherits());
if (!underlying_value)
return nullptr;
// TODO(alancutter): Remove the need for passing in conversion checkers.
ConversionCheckers dummy_conversion_checkers;
return MaybeConvertValue(*underlying_value, nullptr,
dummy_conversion_checkers);
}
void CSSInterpolationType::Apply(
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value,
InterpolationEnvironment& environment) const {
StyleResolverState& state =
To<CSSInterpolationEnvironment>(environment).GetState();
if (GetProperty().IsCSSCustomProperty()) {
ApplyCustomPropertyValue(interpolable_value, non_interpolable_value, state);
return;
}
ApplyStandardPropertyValue(interpolable_value, non_interpolable_value, state);
}
void CSSInterpolationType::ApplyCustomPropertyValue(
const InterpolableValue& interpolable_value,
const NonInterpolableValue* non_interpolable_value,
StyleResolverState& state) const {
DCHECK(GetProperty().IsCSSCustomProperty());
const CSSValue* css_value =
CreateCSSValue(interpolable_value, non_interpolable_value, state);
DCHECK(!css_value->IsCustomPropertyDeclaration());
// TODO(alancutter): Defer tokenization of the CSSValue until it is needed.
String string_value = css_value->CssText();
CSSTokenizer tokenizer(string_value);
const auto tokens = tokenizer.TokenizeToEOF();
bool is_animation_tainted = true;
bool needs_variable_resolution = false;
scoped_refptr<CSSVariableData> variable_data = CSSVariableData::Create(
CSSParserTokenRange(tokens), is_animation_tainted,
needs_variable_resolution, KURL(), WTF::TextEncoding());
const PropertyHandle property = GetProperty();
// TODO(andruud): Avoid making the CSSCustomPropertyDeclaration by allowing
// any CSSValue in CustomProperty::ApplyValue.
const CSSValue* value = MakeGarbageCollected<CSSCustomPropertyDeclaration>(
property.CustomPropertyName(), std::move(variable_data));
StyleBuilder::ApplyProperty(GetProperty().GetCSSPropertyName(), state,
*value);
}
} // namespace blink
|
SECTION .text
; Load GDT and set selectors for a flat memory model.
load_gdt:
cli ; Make sure that interrupts are disabled at this point.
lgdt [gdt_desc] ; Load the GDT.
jmp CODE_SEG:.fill_seg_reg ; Implicitly set CS register via far JMP to the.
.fill_seg_reg: ; Set all segment registers (except CS) to the data segment.
mov eax, DATA_SEG
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
mov ss, eax
jmp gdt_loaded
|
; A044162: Numbers n such that string 3,3 occurs in the base 7 representation of n but not of n-1.
; Submitted by Jamie Morken(s2.)
; 24,73,122,168,220,269,318,367,416,465,511,563,612,661,710,759,808,854,906,955,1004,1053,1102,1151,1176,1249,1298,1347,1396,1445,1494,1540,1592,1641,1690,1739,1788,1837,1883,1935,1984
mov $3,$0
mul $0,6
add $0,3
mov $1,49
gcd $1,$0
div $1,2
mov $2,$3
mul $2,49
sub $2,$1
mov $0,$2
add $0,24
|
SECTION "sec", ROM0
db BANK(noexist)
|
AREA RESET,DATA,Readonly
EXPORT __Vectors
__Vectors
DCD 0x40000000
DCD Reset_Handler
ALIGN
AREA mycode,Code,Readonly
ENTRY
EXPORT Reset_Handler
Reset_Handler
LDR R0,=NUM1
LDR R5,RESULT
MOV R4,#8
UP
LDRB R1,[R0],#4
AND R1,#0X0F
ADD R1,#0X30
SUB R4,#1
BNE UP
STOP B STOP
NUM1 DCD 0X01,0X02,0X03,0X04,0X05,0X06,0X07,0X08
AREA data,DATA,READWRITE
RESULT DCD 0
END |
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB "Upper-case letter from A to Z are-$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, PROMPT
MOV AH, 9
INT 21H
MOV CX, 26
MOV AH, 2
MOV DL, 65
@LOOP:
INT 21H
INC DL
DEC CX
JNZ @LOOP
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
|
; A005892: Truncated square numbers: 7*n^2 + 4*n + 1.
; 1,12,37,76,129,196,277,372,481,604,741,892,1057,1236,1429,1636,1857,2092,2341,2604,2881,3172,3477,3796,4129,4476,4837,5212,5601,6004,6421,6852,7297,7756,8229,8716,9217,9732,10261,10804,11361,11932,12517,13116,13729,14356,14997,15652,16321,17004,17701,18412,19137,19876,20629,21396,22177,22972,23781,24604,25441,26292,27157,28036,28929,29836,30757,31692,32641,33604,34581,35572,36577,37596,38629,39676,40737,41812,42901,44004,45121,46252,47397,48556,49729,50916,52117,53332,54561,55804,57061,58332,59617,60916,62229,63556,64897,66252,67621,69004,70401,71812,73237,74676,76129,77596,79077,80572,82081,83604,85141,86692,88257,89836,91429,93036,94657,96292,97941,99604,101281,102972,104677,106396,108129,109876,111637,113412,115201,117004,118821,120652,122497,124356,126229,128116,130017,131932,133861,135804,137761,139732,141717,143716,145729,147756,149797,151852,153921,156004,158101,160212,162337,164476,166629,168796,170977,173172,175381,177604,179841,182092,184357,186636,188929,191236,193557,195892,198241,200604,202981,205372,207777,210196,212629,215076,217537,220012,222501,225004,227521,230052,232597,235156,237729,240316,242917,245532,248161,250804,253461,256132,258817,261516,264229,266956,269697,272452,275221,278004,280801,283612,286437,289276,292129,294996,297877,300772,303681,306604,309541,312492,315457,318436,321429,324436,327457,330492,333541,336604,339681,342772,345877,348996,352129,355276,358437,361612,364801,368004,371221,374452,377697,380956,384229,387516,390817,394132,397461,400804,404161,407532,410917,414316,417729,421156,424597,428052,431521,435004
mov $1,7
mul $1,$0
add $1,4
mul $1,$0
add $1,1
|
; A292893: E.g.f.: exp(x * (1 - exp(x))).
; Submitted by Christian Krause
; 1,0,-2,-3,8,55,84,-637,-4992,-10593,92060,1012099,3642000,-18733585,-354606084,-2157876645,2003383424,175455790399,1766183783868,5436448194707,-96997103373360,-1770215099996721,-13073420293290148,22275369715313131,1919483837248530432,25727409505350631775,131957322742718261724,-1667552470430932379997,-48147084407656975332592,-549747934784345848330193,-1362809556091319575322820,75445725905887973942139899,1673921716235323026581640960,17072507539124939400592107135,-14722184534905594411580012164
mov $4,$0
add $0,1
lpb $0
sub $0,1
mov $2,$4
add $2,1
sub $2,$1
pow $2,$1
mov $3,$4
bin $3,$1
add $1,1
mul $3,$2
mul $5,-1
add $5,$3
lpe
mov $0,$5
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x11260, %r13
nop
nop
nop
sub %rbp, %rbp
movl $0x61626364, (%r13)
sub $48578, %r15
lea addresses_WT_ht+0x15ab0, %rsi
sub $56955, %rdx
mov $0x6162636465666768, %rbx
movq %rbx, %xmm5
movups %xmm5, (%rsi)
nop
and $32677, %r13
lea addresses_WT_ht+0x5a00, %rsi
lea addresses_WT_ht+0x12d60, %rdi
xor %r15, %r15
mov $110, %rcx
rep movsl
nop
add $51824, %rdx
lea addresses_normal_ht+0x3a60, %rbx
and %rdx, %rdx
mov (%rbx), %r13
nop
nop
nop
sub $49292, %rcx
lea addresses_WT_ht+0x1b260, %rsi
lea addresses_WT_ht+0x1e0dd, %rdi
nop
xor %r15, %r15
mov $72, %rcx
rep movsb
nop
dec %rbp
lea addresses_A_ht+0x1c5e0, %r13
clflush (%r13)
sub %rdx, %rdx
mov $0x6162636465666768, %rbx
movq %rbx, %xmm4
vmovups %ymm4, (%r13)
nop
nop
nop
nop
cmp $59376, %rbx
lea addresses_UC_ht+0x1260, %r15
nop
nop
nop
nop
mfence
mov $0x6162636465666768, %rbp
movq %rbp, %xmm6
vmovups %ymm6, (%r15)
nop
nop
and $195, %rsi
lea addresses_D_ht+0x1360, %rcx
nop
nop
nop
sub %rsi, %rsi
mov (%rcx), %ebx
nop
nop
nop
inc %rcx
lea addresses_UC_ht+0x16be0, %rdi
nop
nop
nop
nop
nop
add %rbx, %rbx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm3
vmovups %ymm3, (%rdi)
xor $16427, %rbp
lea addresses_UC_ht+0x1a60, %rdi
nop
xor $9066, %r15
mov (%rdi), %ebp
nop
nop
nop
add %rbx, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %rax
push %rdx
// Faulty Load
lea addresses_UC+0x14260, %rdx
nop
nop
add %rax, %rax
mov (%rdx), %r10
lea oracles, %rdx
and $0xff, %r10
shlq $12, %r10
mov (%rdx,%r10,1), %r10
pop %rdx
pop %rax
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 4}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_normal_ht', 'congruent': 11}}
{'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 6}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 11}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 8}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 7}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 9}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
; Learn Multi platform Z80 Assembly Programming... With Vampires!
;Please see my website at www.chibiakumas.com/z80/
;for the 'textbook', useful resources and video tutorials
;File Multiplatform Bitmap Fonts
;Version V1.0
;Date 2018/6/13
;Content Simulates firmware font functions using a 2 bit Bitmap font of 96 or 64 chars - this is platform independent
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_PrintChar:
push hl ;Push like crazy!
push bc ;For maximum register protection!
push de
push af
ScreenStartDrawing ;For Sam Coupe
ifdef BMP_UppercaseOnlyFont ;We can use a smaller 64 char font with no uppercase letters to save ram
cp 'a'
jr c,BMP_PrintCharSkip ;Char is not a problem
cp 'z'+1
jr nc,BMP_PrintCharSkip ;Char is not a problem
sub 32 ;Convert Lower to uppercase
BMP_PrintCharSkip:
endif
sub ' ' ;We don't have any chars below 32 (Space)
ld h,0
ld l,a
add hl,hl ;8 bytes per char - so move to correct char
add hl,hl
add hl,hl
ld de,BitmapFont ;Add Location of Bitmap font
add hl,de
ex de,hl
ld bc,&0000;<--SM
TextCursorBytePos_Plus2:
call GetScreenPos ;Move text cursor to predefined location
ld b,8
BitmapCharAgain:
ld a,(de)
SetScrByteBW ;Use our 1 bit converter
inc de
call GetNextLine
dec b
jp nz,BitmapCharAgain ;repeat for 8 lines
ld a,(TextCursorBytePos_Plus2-1)
add CharByteWidth ;Move across no bytes for system
cp ScreenWidth*CharByteWidth
jr nz,BMP_PrintCharPosOK
ld a,(TextCursorBytePos_Plus2-2)
add 8 ;Move down 8 lines
ld (TextCursorBytePos_Plus2-2),a
xor a
BMP_PrintCharPosOK:
ld (TextCursorBytePos_Plus2-1),a
ScreenStopDrawing ;For Sam Coupe
pop af ;Restore all registers
pop de
pop bc
pop hl
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_NewLine: ;Newline Command
push hl
call BMP_GetCursorPos
ld h,0 ;Move X to 0
inc l ;Move down a line
call BMP_Locate
pop hl
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_GetCursorPos:
ld hl,(TextCursorBytePos_Plus2-2)
rrc l ;Convert bytepos to char line
rrc l
rrc l
if BuildCPCv+BuildENTv
ifdef ScrColor16
rrc h ;Convert bytepos to char column
endif
rrc h
endif
if BuildSAMv+BuildMSXv
rrc h
rrc h
endif
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_Locate: ;Locate command, H=X, L=Y
push af
ld a,ScreenHeight
cp l
jp nc,BMP_LocateOK
pop af
jp BMP_CLS ;Off the screen, then CLS (no scroll, sorry!)
BMP_LocateOK:
pop af
push hl
rlc l ;convert char to pixel line
rlc l
rlc l
if BuildCPCv+BuildENTv
ifdef ScrColor16
rlc h
endif
rlc h
endif
if BuildSAMv+BuildMSXv
rlc h ;Convert Xpos according to number of bytesperchar
rlc h
endif
ld (TextCursorBytePos_Plus2-2),hl
pop hl
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_CLS:
ld bc,&0000 ;Clear the screen with our 1 bit byte command - this isn't very fast, but it's compatible!
call GetScreenPos
ld c,ScreenHeight*8
BMP_CLSAgainY:
ld b,ScreenWidth
xor a ;0 byte
BMP_CLSAgainX:
SetScrByteBW ;Send it to screen
djnz BMP_CLSAgainX
call GetNextLine
dec c
jr nz,BMP_CLSAgainY
ld hl,&0000
call BMP_Locate ;Move cursor to 0,0
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BMP_PrintString:
ld a,(hl) ;Print a '255' terminated string
cp 255
ret z
inc hl
call BMP_PrintChar
jr BMP_PrintString
|
; Copyright Oliver Kowalke 2009.
; 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)
; ----------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ----------------------------------------------------------------------------------
; | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ----------------------------------------------------------------------------------
; | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
; ----------------------------------------------------------------------------------
; | 0xe40 | 0x44 | 0x48 | 0x4c | 0x50 | 0x54 | 0x58 | 0x5c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
; ----------------------------------------------------------------------------------
; | 0x60 | 0x64 | 0x68 | 0x6c | 0x70 | 0x74 | 0x78 | 0x7c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 32 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
; ----------------------------------------------------------------------------------
; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
; ----------------------------------------------------------------------------------
; | 0xa0 | 0xa4 | 0xa8 | 0xac | 0xb0 | 0xb4 | 0xb8 | 0xbc |
; ----------------------------------------------------------------------------------
; | fc_mxcsr|fc_x87_cw| <alignment> | fbr_strg | fc_dealloc |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
; ----------------------------------------------------------------------------------
; | 0xc0 | 0xc4 | 0xc8 | 0xcc | 0xd0 | 0xd4 | 0xd8 | 0xdc |
; ----------------------------------------------------------------------------------
; | limit | base | R12 | R13 |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
; ----------------------------------------------------------------------------------
; | 0xe0 | 0xe4 | 0xe8 | 0xec | 0xf0 | 0xf4 | 0xf8 | 0xfc |
; ----------------------------------------------------------------------------------
; | R14 | R15 | RDI | RSI |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
; ----------------------------------------------------------------------------------
; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
; ----------------------------------------------------------------------------------
; | RBX | RBP | hidden | RIP |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
; ----------------------------------------------------------------------------------
; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
; ----------------------------------------------------------------------------------
; | parameter area |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
; ----------------------------------------------------------------------------------
; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
; ----------------------------------------------------------------------------------
; | FCTX | DATA | |
; ----------------------------------------------------------------------------------
.code
jump_fcontext PROC FRAME
.endprolog
; prepare stack
lea rsp, [rsp-0118h]
IFNDEF BOOST_USE_TSX
; save XMM storage
movaps [rsp], xmm6
movaps [rsp+010h], xmm7
movaps [rsp+020h], xmm8
movaps [rsp+030h], xmm9
movaps [rsp+040h], xmm10
movaps [rsp+050h], xmm11
movaps [rsp+060h], xmm12
movaps [rsp+070h], xmm13
movaps [rsp+080h], xmm14
movaps [rsp+090h], xmm15
; save MMX control- and status-word
stmxcsr [rsp+0a0h]
; save x87 control-word
fnstcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; save fiber local storage
mov rax, [r10+020h]
mov [rsp+0b0h], rax
; save current deallocation stack
mov rax, [r10+01478h]
mov [rsp+0b8h], rax
; save current stack limit
mov rax, [r10+010h]
mov [rsp+0c0h], rax
; save current stack base
mov rax, [r10+08h]
mov [rsp+0c8h], rax
mov [rsp+0d0h], r12 ; save R12
mov [rsp+0d8h], r13 ; save R13
mov [rsp+0e0h], r14 ; save R14
mov [rsp+0e8h], r15 ; save R15
mov [rsp+0f0h], rdi ; save RDI
mov [rsp+0f8h], rsi ; save RSI
mov [rsp+0100h], rbx ; save RBX
mov [rsp+0108h], rbp ; save RBP
mov [rsp+0110h], rcx ; save hidden address of transport_t
; preserve RSP (pointing to context-data) in R9
mov r9, rsp
; restore RSP (pointing to context-data) from RDX
mov rsp, rdx
IFNDEF BOOST_USE_TSX
; restore XMM storage
movaps xmm6, [rsp]
movaps xmm7, [rsp+010h]
movaps xmm8, [rsp+020h]
movaps xmm9, [rsp+030h]
movaps xmm10, [rsp+040h]
movaps xmm11, [rsp+050h]
movaps xmm12, [rsp+060h]
movaps xmm13, [rsp+070h]
movaps xmm14, [rsp+080h]
movaps xmm15, [rsp+090h]
; restore MMX control- and status-word
ldmxcsr [rsp+0a0h]
; save x87 control-word
fldcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; restore fiber local storage
mov rax, [rsp+0b0h]
mov [r10+020h], rax
; restore current deallocation stack
mov rax, [rsp+0b8h]
mov [r10+01478h], rax
; restore current stack limit
mov rax, [rsp+0c0h]
mov [r10+010h], rax
; restore current stack base
mov rax, [rsp+0c8h]
mov [r10+08h], rax
mov r12, [rsp+0d0h] ; restore R12
mov r13, [rsp+0d8h] ; restore R13
mov r14, [rsp+0e0h] ; restore R14
mov r15, [rsp+0e8h] ; restore R15
mov rdi, [rsp+0f0h] ; restore RDI
mov rsi, [rsp+0f8h] ; restore RSI
mov rbx, [rsp+0100h] ; restore RBX
mov rbp, [rsp+0108h] ; restore RBP
mov rax, [rsp+0110h] ; restore hidden address of transport_t
; prepare stack
lea rsp, [rsp+0118h]
; load return-address
pop r10
; transport_t returned in RAX
; return parent fcontext_t
mov [rax], r9
; return data
mov [rax+08h], r8
; transport_t as 1.arg of context-function
mov rcx, rax
; indirect jump to context
jmp r10
jump_fcontext ENDP
END
|
#include "cmp_enemyAi.h"
#include "levelsystem.h"
using namespace sf;
using namespace std;
static const Vector2i directions[] = { { 1, 0 },{ 0, 1 },{ 0, -1},{ -1, 0} };
EnemyAICom::EnemyAICom(Entity* p) : _direction(directions[(rand() % 4)]), _state(ROAMING), ActorMovementComponent(p) {
}
void EnemyAICom::update(float dt) {
// Movement
// Amount to move
const auto mva = (float)(dt * _speed);
// Current position
const Vector2f pos = _parent->getPosition();
// Next position
const Vector2f newpos = pos + _direction * mva;
// Inverse of our current direction
const Vector2i baddir = -1 * Vector2i(_direction);
// Random new direction
Vector2i newdir = directions[(rand() % 4)];
switch (_state) {
case ROAMING:
if (ls::getTileAt(newpos) == ls::WALL) {
_state = ROTATING;
}
else {
move(_direction * mva);
}
break;
case ROTATING:
while (
// Don't reverse
newdir == baddir || ls::getTileAt(pos + (Vector2f(newdir) * 25.0f)) == ls::WALL) {
// Pick new direction
newdir = directions[rand() % 4];
}
_direction = Vector2f(newdir);
_state = ROTATED;
break;
case ROTATED:
// Have we left the waypoint?
if (ls::getTileAt(pos) != ls::WAYPOINT) {
_state = ROAMING; // YES
}
move(_direction * mva); // NO
break;
case DEADEND:
break;
default:
break;
}
ActorMovementComponent::update(dt);
} |
_zombie: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(void)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 10 sub $0x10,%esp
if(fork() > 0)
9: e8 72 02 00 00 call 280 <fork>
e: 85 c0 test %eax,%eax
10: 7e 0c jle 1e <main+0x1e>
sleep(5); // Let child exit before parent.
12: c7 04 24 05 00 00 00 movl $0x5,(%esp)
19: e8 fa 02 00 00 call 318 <sleep>
exit();
1e: e8 65 02 00 00 call 288 <exit>
23: 90 nop
00000024 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
24: 55 push %ebp
25: 89 e5 mov %esp,%ebp
27: 57 push %edi
28: 53 push %ebx
asm volatile("cld; rep stosb" :
29: 8b 4d 08 mov 0x8(%ebp),%ecx
2c: 8b 55 10 mov 0x10(%ebp),%edx
2f: 8b 45 0c mov 0xc(%ebp),%eax
32: 89 cb mov %ecx,%ebx
34: 89 df mov %ebx,%edi
36: 89 d1 mov %edx,%ecx
38: fc cld
39: f3 aa rep stos %al,%es:(%edi)
3b: 89 ca mov %ecx,%edx
3d: 89 fb mov %edi,%ebx
3f: 89 5d 08 mov %ebx,0x8(%ebp)
42: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
45: 5b pop %ebx
46: 5f pop %edi
47: 5d pop %ebp
48: c3 ret
00000049 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
49: 55 push %ebp
4a: 89 e5 mov %esp,%ebp
4c: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
4f: 8b 45 08 mov 0x8(%ebp),%eax
52: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
55: 8b 45 0c mov 0xc(%ebp),%eax
58: 0f b6 10 movzbl (%eax),%edx
5b: 8b 45 08 mov 0x8(%ebp),%eax
5e: 88 10 mov %dl,(%eax)
60: 8b 45 08 mov 0x8(%ebp),%eax
63: 0f b6 00 movzbl (%eax),%eax
66: 84 c0 test %al,%al
68: 0f 95 c0 setne %al
6b: 83 45 08 01 addl $0x1,0x8(%ebp)
6f: 83 45 0c 01 addl $0x1,0xc(%ebp)
73: 84 c0 test %al,%al
75: 75 de jne 55 <strcpy+0xc>
;
return os;
77: 8b 45 fc mov -0x4(%ebp),%eax
}
7a: c9 leave
7b: c3 ret
0000007c <strcmp>:
int
strcmp(const char *p, const char *q)
{
7c: 55 push %ebp
7d: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
7f: eb 08 jmp 89 <strcmp+0xd>
p++, q++;
81: 83 45 08 01 addl $0x1,0x8(%ebp)
85: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
89: 8b 45 08 mov 0x8(%ebp),%eax
8c: 0f b6 00 movzbl (%eax),%eax
8f: 84 c0 test %al,%al
91: 74 10 je a3 <strcmp+0x27>
93: 8b 45 08 mov 0x8(%ebp),%eax
96: 0f b6 10 movzbl (%eax),%edx
99: 8b 45 0c mov 0xc(%ebp),%eax
9c: 0f b6 00 movzbl (%eax),%eax
9f: 38 c2 cmp %al,%dl
a1: 74 de je 81 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
a3: 8b 45 08 mov 0x8(%ebp),%eax
a6: 0f b6 00 movzbl (%eax),%eax
a9: 0f b6 d0 movzbl %al,%edx
ac: 8b 45 0c mov 0xc(%ebp),%eax
af: 0f b6 00 movzbl (%eax),%eax
b2: 0f b6 c0 movzbl %al,%eax
b5: 89 d1 mov %edx,%ecx
b7: 29 c1 sub %eax,%ecx
b9: 89 c8 mov %ecx,%eax
}
bb: 5d pop %ebp
bc: c3 ret
000000bd <strlen>:
uint
strlen(char *s)
{
bd: 55 push %ebp
be: 89 e5 mov %esp,%ebp
c0: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
c3: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
ca: eb 04 jmp d0 <strlen+0x13>
cc: 83 45 fc 01 addl $0x1,-0x4(%ebp)
d0: 8b 45 fc mov -0x4(%ebp),%eax
d3: 03 45 08 add 0x8(%ebp),%eax
d6: 0f b6 00 movzbl (%eax),%eax
d9: 84 c0 test %al,%al
db: 75 ef jne cc <strlen+0xf>
;
return n;
dd: 8b 45 fc mov -0x4(%ebp),%eax
}
e0: c9 leave
e1: c3 ret
000000e2 <memset>:
void*
memset(void *dst, int c, uint n)
{
e2: 55 push %ebp
e3: 89 e5 mov %esp,%ebp
e5: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
e8: 8b 45 10 mov 0x10(%ebp),%eax
eb: 89 44 24 08 mov %eax,0x8(%esp)
ef: 8b 45 0c mov 0xc(%ebp),%eax
f2: 89 44 24 04 mov %eax,0x4(%esp)
f6: 8b 45 08 mov 0x8(%ebp),%eax
f9: 89 04 24 mov %eax,(%esp)
fc: e8 23 ff ff ff call 24 <stosb>
return dst;
101: 8b 45 08 mov 0x8(%ebp),%eax
}
104: c9 leave
105: c3 ret
00000106 <strchr>:
char*
strchr(const char *s, char c)
{
106: 55 push %ebp
107: 89 e5 mov %esp,%ebp
109: 83 ec 04 sub $0x4,%esp
10c: 8b 45 0c mov 0xc(%ebp),%eax
10f: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
112: eb 14 jmp 128 <strchr+0x22>
if(*s == c)
114: 8b 45 08 mov 0x8(%ebp),%eax
117: 0f b6 00 movzbl (%eax),%eax
11a: 3a 45 fc cmp -0x4(%ebp),%al
11d: 75 05 jne 124 <strchr+0x1e>
return (char*)s;
11f: 8b 45 08 mov 0x8(%ebp),%eax
122: eb 13 jmp 137 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
124: 83 45 08 01 addl $0x1,0x8(%ebp)
128: 8b 45 08 mov 0x8(%ebp),%eax
12b: 0f b6 00 movzbl (%eax),%eax
12e: 84 c0 test %al,%al
130: 75 e2 jne 114 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
132: b8 00 00 00 00 mov $0x0,%eax
}
137: c9 leave
138: c3 ret
00000139 <gets>:
char*
gets(char *buf, int max)
{
139: 55 push %ebp
13a: 89 e5 mov %esp,%ebp
13c: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
13f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
146: eb 44 jmp 18c <gets+0x53>
cc = read(0, &c, 1);
148: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
14f: 00
150: 8d 45 ef lea -0x11(%ebp),%eax
153: 89 44 24 04 mov %eax,0x4(%esp)
157: c7 04 24 00 00 00 00 movl $0x0,(%esp)
15e: e8 3d 01 00 00 call 2a0 <read>
163: 89 45 f4 mov %eax,-0xc(%ebp)
if(cc < 1)
166: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
16a: 7e 2d jle 199 <gets+0x60>
break;
buf[i++] = c;
16c: 8b 45 f0 mov -0x10(%ebp),%eax
16f: 03 45 08 add 0x8(%ebp),%eax
172: 0f b6 55 ef movzbl -0x11(%ebp),%edx
176: 88 10 mov %dl,(%eax)
178: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(c == '\n' || c == '\r')
17c: 0f b6 45 ef movzbl -0x11(%ebp),%eax
180: 3c 0a cmp $0xa,%al
182: 74 16 je 19a <gets+0x61>
184: 0f b6 45 ef movzbl -0x11(%ebp),%eax
188: 3c 0d cmp $0xd,%al
18a: 74 0e je 19a <gets+0x61>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
18c: 8b 45 f0 mov -0x10(%ebp),%eax
18f: 83 c0 01 add $0x1,%eax
192: 3b 45 0c cmp 0xc(%ebp),%eax
195: 7c b1 jl 148 <gets+0xf>
197: eb 01 jmp 19a <gets+0x61>
cc = read(0, &c, 1);
if(cc < 1)
break;
199: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
19a: 8b 45 f0 mov -0x10(%ebp),%eax
19d: 03 45 08 add 0x8(%ebp),%eax
1a0: c6 00 00 movb $0x0,(%eax)
return buf;
1a3: 8b 45 08 mov 0x8(%ebp),%eax
}
1a6: c9 leave
1a7: c3 ret
000001a8 <stat>:
int
stat(char *n, struct stat *st)
{
1a8: 55 push %ebp
1a9: 89 e5 mov %esp,%ebp
1ab: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1ae: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1b5: 00
1b6: 8b 45 08 mov 0x8(%ebp),%eax
1b9: 89 04 24 mov %eax,(%esp)
1bc: e8 07 01 00 00 call 2c8 <open>
1c1: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd < 0)
1c4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1c8: 79 07 jns 1d1 <stat+0x29>
return -1;
1ca: b8 ff ff ff ff mov $0xffffffff,%eax
1cf: eb 23 jmp 1f4 <stat+0x4c>
r = fstat(fd, st);
1d1: 8b 45 0c mov 0xc(%ebp),%eax
1d4: 89 44 24 04 mov %eax,0x4(%esp)
1d8: 8b 45 f0 mov -0x10(%ebp),%eax
1db: 89 04 24 mov %eax,(%esp)
1de: e8 fd 00 00 00 call 2e0 <fstat>
1e3: 89 45 f4 mov %eax,-0xc(%ebp)
close(fd);
1e6: 8b 45 f0 mov -0x10(%ebp),%eax
1e9: 89 04 24 mov %eax,(%esp)
1ec: e8 bf 00 00 00 call 2b0 <close>
return r;
1f1: 8b 45 f4 mov -0xc(%ebp),%eax
}
1f4: c9 leave
1f5: c3 ret
000001f6 <atoi>:
int
atoi(const char *s)
{
1f6: 55 push %ebp
1f7: 89 e5 mov %esp,%ebp
1f9: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
1fc: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
203: eb 24 jmp 229 <atoi+0x33>
n = n*10 + *s++ - '0';
205: 8b 55 fc mov -0x4(%ebp),%edx
208: 89 d0 mov %edx,%eax
20a: c1 e0 02 shl $0x2,%eax
20d: 01 d0 add %edx,%eax
20f: 01 c0 add %eax,%eax
211: 89 c2 mov %eax,%edx
213: 8b 45 08 mov 0x8(%ebp),%eax
216: 0f b6 00 movzbl (%eax),%eax
219: 0f be c0 movsbl %al,%eax
21c: 8d 04 02 lea (%edx,%eax,1),%eax
21f: 83 e8 30 sub $0x30,%eax
222: 89 45 fc mov %eax,-0x4(%ebp)
225: 83 45 08 01 addl $0x1,0x8(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
229: 8b 45 08 mov 0x8(%ebp),%eax
22c: 0f b6 00 movzbl (%eax),%eax
22f: 3c 2f cmp $0x2f,%al
231: 7e 0a jle 23d <atoi+0x47>
233: 8b 45 08 mov 0x8(%ebp),%eax
236: 0f b6 00 movzbl (%eax),%eax
239: 3c 39 cmp $0x39,%al
23b: 7e c8 jle 205 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
23d: 8b 45 fc mov -0x4(%ebp),%eax
}
240: c9 leave
241: c3 ret
00000242 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
242: 55 push %ebp
243: 89 e5 mov %esp,%ebp
245: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
248: 8b 45 08 mov 0x8(%ebp),%eax
24b: 89 45 f8 mov %eax,-0x8(%ebp)
src = vsrc;
24e: 8b 45 0c mov 0xc(%ebp),%eax
251: 89 45 fc mov %eax,-0x4(%ebp)
while(n-- > 0)
254: eb 13 jmp 269 <memmove+0x27>
*dst++ = *src++;
256: 8b 45 fc mov -0x4(%ebp),%eax
259: 0f b6 10 movzbl (%eax),%edx
25c: 8b 45 f8 mov -0x8(%ebp),%eax
25f: 88 10 mov %dl,(%eax)
261: 83 45 f8 01 addl $0x1,-0x8(%ebp)
265: 83 45 fc 01 addl $0x1,-0x4(%ebp)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
269: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
26d: 0f 9f c0 setg %al
270: 83 6d 10 01 subl $0x1,0x10(%ebp)
274: 84 c0 test %al,%al
276: 75 de jne 256 <memmove+0x14>
*dst++ = *src++;
return vdst;
278: 8b 45 08 mov 0x8(%ebp),%eax
}
27b: c9 leave
27c: c3 ret
27d: 90 nop
27e: 90 nop
27f: 90 nop
00000280 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
280: b8 01 00 00 00 mov $0x1,%eax
285: cd 40 int $0x40
287: c3 ret
00000288 <exit>:
SYSCALL(exit)
288: b8 02 00 00 00 mov $0x2,%eax
28d: cd 40 int $0x40
28f: c3 ret
00000290 <wait>:
SYSCALL(wait)
290: b8 03 00 00 00 mov $0x3,%eax
295: cd 40 int $0x40
297: c3 ret
00000298 <pipe>:
SYSCALL(pipe)
298: b8 04 00 00 00 mov $0x4,%eax
29d: cd 40 int $0x40
29f: c3 ret
000002a0 <read>:
SYSCALL(read)
2a0: b8 05 00 00 00 mov $0x5,%eax
2a5: cd 40 int $0x40
2a7: c3 ret
000002a8 <write>:
SYSCALL(write)
2a8: b8 10 00 00 00 mov $0x10,%eax
2ad: cd 40 int $0x40
2af: c3 ret
000002b0 <close>:
SYSCALL(close)
2b0: b8 15 00 00 00 mov $0x15,%eax
2b5: cd 40 int $0x40
2b7: c3 ret
000002b8 <kill>:
SYSCALL(kill)
2b8: b8 06 00 00 00 mov $0x6,%eax
2bd: cd 40 int $0x40
2bf: c3 ret
000002c0 <exec>:
SYSCALL(exec)
2c0: b8 07 00 00 00 mov $0x7,%eax
2c5: cd 40 int $0x40
2c7: c3 ret
000002c8 <open>:
SYSCALL(open)
2c8: b8 0f 00 00 00 mov $0xf,%eax
2cd: cd 40 int $0x40
2cf: c3 ret
000002d0 <mknod>:
SYSCALL(mknod)
2d0: b8 11 00 00 00 mov $0x11,%eax
2d5: cd 40 int $0x40
2d7: c3 ret
000002d8 <unlink>:
SYSCALL(unlink)
2d8: b8 12 00 00 00 mov $0x12,%eax
2dd: cd 40 int $0x40
2df: c3 ret
000002e0 <fstat>:
SYSCALL(fstat)
2e0: b8 08 00 00 00 mov $0x8,%eax
2e5: cd 40 int $0x40
2e7: c3 ret
000002e8 <link>:
SYSCALL(link)
2e8: b8 13 00 00 00 mov $0x13,%eax
2ed: cd 40 int $0x40
2ef: c3 ret
000002f0 <mkdir>:
SYSCALL(mkdir)
2f0: b8 14 00 00 00 mov $0x14,%eax
2f5: cd 40 int $0x40
2f7: c3 ret
000002f8 <chdir>:
SYSCALL(chdir)
2f8: b8 09 00 00 00 mov $0x9,%eax
2fd: cd 40 int $0x40
2ff: c3 ret
00000300 <dup>:
SYSCALL(dup)
300: b8 0a 00 00 00 mov $0xa,%eax
305: cd 40 int $0x40
307: c3 ret
00000308 <getpid>:
SYSCALL(getpid)
308: b8 0b 00 00 00 mov $0xb,%eax
30d: cd 40 int $0x40
30f: c3 ret
00000310 <sbrk>:
SYSCALL(sbrk)
310: b8 0c 00 00 00 mov $0xc,%eax
315: cd 40 int $0x40
317: c3 ret
00000318 <sleep>:
SYSCALL(sleep)
318: b8 0d 00 00 00 mov $0xd,%eax
31d: cd 40 int $0x40
31f: c3 ret
00000320 <uptime>:
SYSCALL(uptime)
320: b8 0e 00 00 00 mov $0xe,%eax
325: cd 40 int $0x40
327: c3 ret
00000328 <count>:
//add
SYSCALL(count)
328: b8 16 00 00 00 mov $0x16,%eax
32d: cd 40 int $0x40
32f: c3 ret
00000330 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
330: 55 push %ebp
331: 89 e5 mov %esp,%ebp
333: 83 ec 28 sub $0x28,%esp
336: 8b 45 0c mov 0xc(%ebp),%eax
339: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
33c: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
343: 00
344: 8d 45 f4 lea -0xc(%ebp),%eax
347: 89 44 24 04 mov %eax,0x4(%esp)
34b: 8b 45 08 mov 0x8(%ebp),%eax
34e: 89 04 24 mov %eax,(%esp)
351: e8 52 ff ff ff call 2a8 <write>
}
356: c9 leave
357: c3 ret
00000358 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
358: 55 push %ebp
359: 89 e5 mov %esp,%ebp
35b: 53 push %ebx
35c: 83 ec 44 sub $0x44,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
35f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
366: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
36a: 74 17 je 383 <printint+0x2b>
36c: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
370: 79 11 jns 383 <printint+0x2b>
neg = 1;
372: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
379: 8b 45 0c mov 0xc(%ebp),%eax
37c: f7 d8 neg %eax
37e: 89 45 f4 mov %eax,-0xc(%ebp)
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
381: eb 06 jmp 389 <printint+0x31>
neg = 1;
x = -xx;
} else {
x = xx;
383: 8b 45 0c mov 0xc(%ebp),%eax
386: 89 45 f4 mov %eax,-0xc(%ebp)
}
i = 0;
389: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
do{
buf[i++] = digits[x % base];
390: 8b 4d ec mov -0x14(%ebp),%ecx
393: 8b 5d 10 mov 0x10(%ebp),%ebx
396: 8b 45 f4 mov -0xc(%ebp),%eax
399: ba 00 00 00 00 mov $0x0,%edx
39e: f7 f3 div %ebx
3a0: 89 d0 mov %edx,%eax
3a2: 0f b6 80 dc 07 00 00 movzbl 0x7dc(%eax),%eax
3a9: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
3ad: 83 45 ec 01 addl $0x1,-0x14(%ebp)
}while((x /= base) != 0);
3b1: 8b 45 10 mov 0x10(%ebp),%eax
3b4: 89 45 d4 mov %eax,-0x2c(%ebp)
3b7: 8b 45 f4 mov -0xc(%ebp),%eax
3ba: ba 00 00 00 00 mov $0x0,%edx
3bf: f7 75 d4 divl -0x2c(%ebp)
3c2: 89 45 f4 mov %eax,-0xc(%ebp)
3c5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3c9: 75 c5 jne 390 <printint+0x38>
if(neg)
3cb: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3cf: 74 2a je 3fb <printint+0xa3>
buf[i++] = '-';
3d1: 8b 45 ec mov -0x14(%ebp),%eax
3d4: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
3d9: 83 45 ec 01 addl $0x1,-0x14(%ebp)
while(--i >= 0)
3dd: eb 1d jmp 3fc <printint+0xa4>
putc(fd, buf[i]);
3df: 8b 45 ec mov -0x14(%ebp),%eax
3e2: 0f b6 44 05 dc movzbl -0x24(%ebp,%eax,1),%eax
3e7: 0f be c0 movsbl %al,%eax
3ea: 89 44 24 04 mov %eax,0x4(%esp)
3ee: 8b 45 08 mov 0x8(%ebp),%eax
3f1: 89 04 24 mov %eax,(%esp)
3f4: e8 37 ff ff ff call 330 <putc>
3f9: eb 01 jmp 3fc <printint+0xa4>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
3fb: 90 nop
3fc: 83 6d ec 01 subl $0x1,-0x14(%ebp)
400: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
404: 79 d9 jns 3df <printint+0x87>
putc(fd, buf[i]);
}
406: 83 c4 44 add $0x44,%esp
409: 5b pop %ebx
40a: 5d pop %ebp
40b: c3 ret
0000040c <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
40c: 55 push %ebp
40d: 89 e5 mov %esp,%ebp
40f: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
412: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
ap = (uint*)(void*)&fmt + 1;
419: 8d 45 0c lea 0xc(%ebp),%eax
41c: 83 c0 04 add $0x4,%eax
41f: 89 45 f4 mov %eax,-0xc(%ebp)
for(i = 0; fmt[i]; i++){
422: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
429: e9 7e 01 00 00 jmp 5ac <printf+0x1a0>
c = fmt[i] & 0xff;
42e: 8b 55 0c mov 0xc(%ebp),%edx
431: 8b 45 ec mov -0x14(%ebp),%eax
434: 8d 04 02 lea (%edx,%eax,1),%eax
437: 0f b6 00 movzbl (%eax),%eax
43a: 0f be c0 movsbl %al,%eax
43d: 25 ff 00 00 00 and $0xff,%eax
442: 89 45 e8 mov %eax,-0x18(%ebp)
if(state == 0){
445: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
449: 75 2c jne 477 <printf+0x6b>
if(c == '%'){
44b: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
44f: 75 0c jne 45d <printf+0x51>
state = '%';
451: c7 45 f0 25 00 00 00 movl $0x25,-0x10(%ebp)
458: e9 4b 01 00 00 jmp 5a8 <printf+0x19c>
} else {
putc(fd, c);
45d: 8b 45 e8 mov -0x18(%ebp),%eax
460: 0f be c0 movsbl %al,%eax
463: 89 44 24 04 mov %eax,0x4(%esp)
467: 8b 45 08 mov 0x8(%ebp),%eax
46a: 89 04 24 mov %eax,(%esp)
46d: e8 be fe ff ff call 330 <putc>
472: e9 31 01 00 00 jmp 5a8 <printf+0x19c>
}
} else if(state == '%'){
477: 83 7d f0 25 cmpl $0x25,-0x10(%ebp)
47b: 0f 85 27 01 00 00 jne 5a8 <printf+0x19c>
if(c == 'd'){
481: 83 7d e8 64 cmpl $0x64,-0x18(%ebp)
485: 75 2d jne 4b4 <printf+0xa8>
printint(fd, *ap, 10, 1);
487: 8b 45 f4 mov -0xc(%ebp),%eax
48a: 8b 00 mov (%eax),%eax
48c: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
493: 00
494: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
49b: 00
49c: 89 44 24 04 mov %eax,0x4(%esp)
4a0: 8b 45 08 mov 0x8(%ebp),%eax
4a3: 89 04 24 mov %eax,(%esp)
4a6: e8 ad fe ff ff call 358 <printint>
ap++;
4ab: 83 45 f4 04 addl $0x4,-0xc(%ebp)
4af: e9 ed 00 00 00 jmp 5a1 <printf+0x195>
} else if(c == 'x' || c == 'p'){
4b4: 83 7d e8 78 cmpl $0x78,-0x18(%ebp)
4b8: 74 06 je 4c0 <printf+0xb4>
4ba: 83 7d e8 70 cmpl $0x70,-0x18(%ebp)
4be: 75 2d jne 4ed <printf+0xe1>
printint(fd, *ap, 16, 0);
4c0: 8b 45 f4 mov -0xc(%ebp),%eax
4c3: 8b 00 mov (%eax),%eax
4c5: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
4cc: 00
4cd: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
4d4: 00
4d5: 89 44 24 04 mov %eax,0x4(%esp)
4d9: 8b 45 08 mov 0x8(%ebp),%eax
4dc: 89 04 24 mov %eax,(%esp)
4df: e8 74 fe ff ff call 358 <printint>
ap++;
4e4: 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'){
4e8: e9 b4 00 00 00 jmp 5a1 <printf+0x195>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
4ed: 83 7d e8 73 cmpl $0x73,-0x18(%ebp)
4f1: 75 46 jne 539 <printf+0x12d>
s = (char*)*ap;
4f3: 8b 45 f4 mov -0xc(%ebp),%eax
4f6: 8b 00 mov (%eax),%eax
4f8: 89 45 e4 mov %eax,-0x1c(%ebp)
ap++;
4fb: 83 45 f4 04 addl $0x4,-0xc(%ebp)
if(s == 0)
4ff: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
503: 75 27 jne 52c <printf+0x120>
s = "(null)";
505: c7 45 e4 d3 07 00 00 movl $0x7d3,-0x1c(%ebp)
while(*s != 0){
50c: eb 1f jmp 52d <printf+0x121>
putc(fd, *s);
50e: 8b 45 e4 mov -0x1c(%ebp),%eax
511: 0f b6 00 movzbl (%eax),%eax
514: 0f be c0 movsbl %al,%eax
517: 89 44 24 04 mov %eax,0x4(%esp)
51b: 8b 45 08 mov 0x8(%ebp),%eax
51e: 89 04 24 mov %eax,(%esp)
521: e8 0a fe ff ff call 330 <putc>
s++;
526: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
52a: eb 01 jmp 52d <printf+0x121>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
52c: 90 nop
52d: 8b 45 e4 mov -0x1c(%ebp),%eax
530: 0f b6 00 movzbl (%eax),%eax
533: 84 c0 test %al,%al
535: 75 d7 jne 50e <printf+0x102>
537: eb 68 jmp 5a1 <printf+0x195>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
539: 83 7d e8 63 cmpl $0x63,-0x18(%ebp)
53d: 75 1d jne 55c <printf+0x150>
putc(fd, *ap);
53f: 8b 45 f4 mov -0xc(%ebp),%eax
542: 8b 00 mov (%eax),%eax
544: 0f be c0 movsbl %al,%eax
547: 89 44 24 04 mov %eax,0x4(%esp)
54b: 8b 45 08 mov 0x8(%ebp),%eax
54e: 89 04 24 mov %eax,(%esp)
551: e8 da fd ff ff call 330 <putc>
ap++;
556: 83 45 f4 04 addl $0x4,-0xc(%ebp)
55a: eb 45 jmp 5a1 <printf+0x195>
} else if(c == '%'){
55c: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
560: 75 17 jne 579 <printf+0x16d>
putc(fd, c);
562: 8b 45 e8 mov -0x18(%ebp),%eax
565: 0f be c0 movsbl %al,%eax
568: 89 44 24 04 mov %eax,0x4(%esp)
56c: 8b 45 08 mov 0x8(%ebp),%eax
56f: 89 04 24 mov %eax,(%esp)
572: e8 b9 fd ff ff call 330 <putc>
577: eb 28 jmp 5a1 <printf+0x195>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
579: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
580: 00
581: 8b 45 08 mov 0x8(%ebp),%eax
584: 89 04 24 mov %eax,(%esp)
587: e8 a4 fd ff ff call 330 <putc>
putc(fd, c);
58c: 8b 45 e8 mov -0x18(%ebp),%eax
58f: 0f be c0 movsbl %al,%eax
592: 89 44 24 04 mov %eax,0x4(%esp)
596: 8b 45 08 mov 0x8(%ebp),%eax
599: 89 04 24 mov %eax,(%esp)
59c: e8 8f fd ff ff call 330 <putc>
}
state = 0;
5a1: 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++){
5a8: 83 45 ec 01 addl $0x1,-0x14(%ebp)
5ac: 8b 55 0c mov 0xc(%ebp),%edx
5af: 8b 45 ec mov -0x14(%ebp),%eax
5b2: 8d 04 02 lea (%edx,%eax,1),%eax
5b5: 0f b6 00 movzbl (%eax),%eax
5b8: 84 c0 test %al,%al
5ba: 0f 85 6e fe ff ff jne 42e <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
5c0: c9 leave
5c1: c3 ret
5c2: 90 nop
5c3: 90 nop
000005c4 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5c4: 55 push %ebp
5c5: 89 e5 mov %esp,%ebp
5c7: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
5ca: 8b 45 08 mov 0x8(%ebp),%eax
5cd: 83 e8 08 sub $0x8,%eax
5d0: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5d3: a1 f8 07 00 00 mov 0x7f8,%eax
5d8: 89 45 fc mov %eax,-0x4(%ebp)
5db: eb 24 jmp 601 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5dd: 8b 45 fc mov -0x4(%ebp),%eax
5e0: 8b 00 mov (%eax),%eax
5e2: 3b 45 fc cmp -0x4(%ebp),%eax
5e5: 77 12 ja 5f9 <free+0x35>
5e7: 8b 45 f8 mov -0x8(%ebp),%eax
5ea: 3b 45 fc cmp -0x4(%ebp),%eax
5ed: 77 24 ja 613 <free+0x4f>
5ef: 8b 45 fc mov -0x4(%ebp),%eax
5f2: 8b 00 mov (%eax),%eax
5f4: 3b 45 f8 cmp -0x8(%ebp),%eax
5f7: 77 1a ja 613 <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)
5f9: 8b 45 fc mov -0x4(%ebp),%eax
5fc: 8b 00 mov (%eax),%eax
5fe: 89 45 fc mov %eax,-0x4(%ebp)
601: 8b 45 f8 mov -0x8(%ebp),%eax
604: 3b 45 fc cmp -0x4(%ebp),%eax
607: 76 d4 jbe 5dd <free+0x19>
609: 8b 45 fc mov -0x4(%ebp),%eax
60c: 8b 00 mov (%eax),%eax
60e: 3b 45 f8 cmp -0x8(%ebp),%eax
611: 76 ca jbe 5dd <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
613: 8b 45 f8 mov -0x8(%ebp),%eax
616: 8b 40 04 mov 0x4(%eax),%eax
619: c1 e0 03 shl $0x3,%eax
61c: 89 c2 mov %eax,%edx
61e: 03 55 f8 add -0x8(%ebp),%edx
621: 8b 45 fc mov -0x4(%ebp),%eax
624: 8b 00 mov (%eax),%eax
626: 39 c2 cmp %eax,%edx
628: 75 24 jne 64e <free+0x8a>
bp->s.size += p->s.ptr->s.size;
62a: 8b 45 f8 mov -0x8(%ebp),%eax
62d: 8b 50 04 mov 0x4(%eax),%edx
630: 8b 45 fc mov -0x4(%ebp),%eax
633: 8b 00 mov (%eax),%eax
635: 8b 40 04 mov 0x4(%eax),%eax
638: 01 c2 add %eax,%edx
63a: 8b 45 f8 mov -0x8(%ebp),%eax
63d: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
640: 8b 45 fc mov -0x4(%ebp),%eax
643: 8b 00 mov (%eax),%eax
645: 8b 10 mov (%eax),%edx
647: 8b 45 f8 mov -0x8(%ebp),%eax
64a: 89 10 mov %edx,(%eax)
64c: eb 0a jmp 658 <free+0x94>
} else
bp->s.ptr = p->s.ptr;
64e: 8b 45 fc mov -0x4(%ebp),%eax
651: 8b 10 mov (%eax),%edx
653: 8b 45 f8 mov -0x8(%ebp),%eax
656: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
658: 8b 45 fc mov -0x4(%ebp),%eax
65b: 8b 40 04 mov 0x4(%eax),%eax
65e: c1 e0 03 shl $0x3,%eax
661: 03 45 fc add -0x4(%ebp),%eax
664: 3b 45 f8 cmp -0x8(%ebp),%eax
667: 75 20 jne 689 <free+0xc5>
p->s.size += bp->s.size;
669: 8b 45 fc mov -0x4(%ebp),%eax
66c: 8b 50 04 mov 0x4(%eax),%edx
66f: 8b 45 f8 mov -0x8(%ebp),%eax
672: 8b 40 04 mov 0x4(%eax),%eax
675: 01 c2 add %eax,%edx
677: 8b 45 fc mov -0x4(%ebp),%eax
67a: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
67d: 8b 45 f8 mov -0x8(%ebp),%eax
680: 8b 10 mov (%eax),%edx
682: 8b 45 fc mov -0x4(%ebp),%eax
685: 89 10 mov %edx,(%eax)
687: eb 08 jmp 691 <free+0xcd>
} else
p->s.ptr = bp;
689: 8b 45 fc mov -0x4(%ebp),%eax
68c: 8b 55 f8 mov -0x8(%ebp),%edx
68f: 89 10 mov %edx,(%eax)
freep = p;
691: 8b 45 fc mov -0x4(%ebp),%eax
694: a3 f8 07 00 00 mov %eax,0x7f8
}
699: c9 leave
69a: c3 ret
0000069b <morecore>:
static Header*
morecore(uint nu)
{
69b: 55 push %ebp
69c: 89 e5 mov %esp,%ebp
69e: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
6a1: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6a8: 77 07 ja 6b1 <morecore+0x16>
nu = 4096;
6aa: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6b1: 8b 45 08 mov 0x8(%ebp),%eax
6b4: c1 e0 03 shl $0x3,%eax
6b7: 89 04 24 mov %eax,(%esp)
6ba: e8 51 fc ff ff call 310 <sbrk>
6bf: 89 45 f0 mov %eax,-0x10(%ebp)
if(p == (char*)-1)
6c2: 83 7d f0 ff cmpl $0xffffffff,-0x10(%ebp)
6c6: 75 07 jne 6cf <morecore+0x34>
return 0;
6c8: b8 00 00 00 00 mov $0x0,%eax
6cd: eb 22 jmp 6f1 <morecore+0x56>
hp = (Header*)p;
6cf: 8b 45 f0 mov -0x10(%ebp),%eax
6d2: 89 45 f4 mov %eax,-0xc(%ebp)
hp->s.size = nu;
6d5: 8b 45 f4 mov -0xc(%ebp),%eax
6d8: 8b 55 08 mov 0x8(%ebp),%edx
6db: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
6de: 8b 45 f4 mov -0xc(%ebp),%eax
6e1: 83 c0 08 add $0x8,%eax
6e4: 89 04 24 mov %eax,(%esp)
6e7: e8 d8 fe ff ff call 5c4 <free>
return freep;
6ec: a1 f8 07 00 00 mov 0x7f8,%eax
}
6f1: c9 leave
6f2: c3 ret
000006f3 <malloc>:
void*
malloc(uint nbytes)
{
6f3: 55 push %ebp
6f4: 89 e5 mov %esp,%ebp
6f6: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6f9: 8b 45 08 mov 0x8(%ebp),%eax
6fc: 83 c0 07 add $0x7,%eax
6ff: c1 e8 03 shr $0x3,%eax
702: 83 c0 01 add $0x1,%eax
705: 89 45 f4 mov %eax,-0xc(%ebp)
if((prevp = freep) == 0){
708: a1 f8 07 00 00 mov 0x7f8,%eax
70d: 89 45 f0 mov %eax,-0x10(%ebp)
710: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
714: 75 23 jne 739 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
716: c7 45 f0 f0 07 00 00 movl $0x7f0,-0x10(%ebp)
71d: 8b 45 f0 mov -0x10(%ebp),%eax
720: a3 f8 07 00 00 mov %eax,0x7f8
725: a1 f8 07 00 00 mov 0x7f8,%eax
72a: a3 f0 07 00 00 mov %eax,0x7f0
base.s.size = 0;
72f: c7 05 f4 07 00 00 00 movl $0x0,0x7f4
736: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
739: 8b 45 f0 mov -0x10(%ebp),%eax
73c: 8b 00 mov (%eax),%eax
73e: 89 45 ec mov %eax,-0x14(%ebp)
if(p->s.size >= nunits){
741: 8b 45 ec mov -0x14(%ebp),%eax
744: 8b 40 04 mov 0x4(%eax),%eax
747: 3b 45 f4 cmp -0xc(%ebp),%eax
74a: 72 4d jb 799 <malloc+0xa6>
if(p->s.size == nunits)
74c: 8b 45 ec mov -0x14(%ebp),%eax
74f: 8b 40 04 mov 0x4(%eax),%eax
752: 3b 45 f4 cmp -0xc(%ebp),%eax
755: 75 0c jne 763 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
757: 8b 45 ec mov -0x14(%ebp),%eax
75a: 8b 10 mov (%eax),%edx
75c: 8b 45 f0 mov -0x10(%ebp),%eax
75f: 89 10 mov %edx,(%eax)
761: eb 26 jmp 789 <malloc+0x96>
else {
p->s.size -= nunits;
763: 8b 45 ec mov -0x14(%ebp),%eax
766: 8b 40 04 mov 0x4(%eax),%eax
769: 89 c2 mov %eax,%edx
76b: 2b 55 f4 sub -0xc(%ebp),%edx
76e: 8b 45 ec mov -0x14(%ebp),%eax
771: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
774: 8b 45 ec mov -0x14(%ebp),%eax
777: 8b 40 04 mov 0x4(%eax),%eax
77a: c1 e0 03 shl $0x3,%eax
77d: 01 45 ec add %eax,-0x14(%ebp)
p->s.size = nunits;
780: 8b 45 ec mov -0x14(%ebp),%eax
783: 8b 55 f4 mov -0xc(%ebp),%edx
786: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
789: 8b 45 f0 mov -0x10(%ebp),%eax
78c: a3 f8 07 00 00 mov %eax,0x7f8
return (void*)(p + 1);
791: 8b 45 ec mov -0x14(%ebp),%eax
794: 83 c0 08 add $0x8,%eax
797: eb 38 jmp 7d1 <malloc+0xde>
}
if(p == freep)
799: a1 f8 07 00 00 mov 0x7f8,%eax
79e: 39 45 ec cmp %eax,-0x14(%ebp)
7a1: 75 1b jne 7be <malloc+0xcb>
if((p = morecore(nunits)) == 0)
7a3: 8b 45 f4 mov -0xc(%ebp),%eax
7a6: 89 04 24 mov %eax,(%esp)
7a9: e8 ed fe ff ff call 69b <morecore>
7ae: 89 45 ec mov %eax,-0x14(%ebp)
7b1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
7b5: 75 07 jne 7be <malloc+0xcb>
return 0;
7b7: b8 00 00 00 00 mov $0x0,%eax
7bc: eb 13 jmp 7d1 <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){
7be: 8b 45 ec mov -0x14(%ebp),%eax
7c1: 89 45 f0 mov %eax,-0x10(%ebp)
7c4: 8b 45 ec mov -0x14(%ebp),%eax
7c7: 8b 00 mov (%eax),%eax
7c9: 89 45 ec mov %eax,-0x14(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
7cc: e9 70 ff ff ff jmp 741 <malloc+0x4e>
}
7d1: c9 leave
7d2: c3 ret
|
; A026848: a(n) = T(2n,n-4), T given by A026736.
; Submitted by Christian Krause
; 1,11,79,471,2535,12809,62067,292085,1345718,6102780,27343148,121359692,534632836,2341151646,10201950700,44278673806,191540714294,826265471868,3555992623850,15273547250820,65491352071266,280412963707416,1199139733653938,5122386805967008,21860877244203565,93219716126808755,397225853967221319,1691589194760243919,7199671997298043443,30628038157820707365,130238311222532920359,553595659764861026113,2352336476257824218777,9992524557752276340023,42435975437652533396305,180172617110267584944603
mov $3,$0
lpb $0
mov $2,$3
add $2,$0
add $2,8
bin $2,$0
sub $0,1
add $1,$2
cmp $2,$1
add $3,2
sub $3,$2
lpe
mov $0,$1
add $0,1
|
;
; Size-optimized LZSA2 decompressor by spke (v.1 02-09/06/2019, 140 bytes);
; with improvements by uniabis (30/07/2019, -1 byte, +3% speed and support for Hitachi HD64180).
;
; The data must be compressed using the command line compressor by Emmanuel Marty
; The compression is done as follows:
;
; lzsa.exe -f2 -r <sourcefile> <outfile>
;
; where option -r asks for the generation of raw (frame-less) data.
;
; The decompression is done in the standard way:
;
; ld hl,FirstByteOfCompressedData
; ld de,FirstByteOfMemoryForDecompressedData
; call DecompressLZSA2
;
; Backward compression is also supported; you can compress files backward using:
;
; lzsa.exe -f2 -r -b <sourcefile> <outfile>
;
; and decompress the resulting files using:
;
; ld hl,LastByteOfCompressedData
; ld de,LastByteOfMemoryForDecompressedData
; call DecompressLZSA2
;
; (do not forget to uncomment the BACKWARD_DECOMPRESS option in the decompressor).
;
; Of course, LZSA2 compression algorithms are (c) 2019 Emmanuel Marty,
; see https://github.com/emmanuel-marty/lzsa for more information
;
; Drop me an email if you have any comments/ideas/suggestions: zxintrospec@gmail.com
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
;
; DEFINE BACKWARD_DECOMPRESS ; uncomment for data compressed with option -b
; DEFINE HD64180 ; uncomment for systems using Hitachi HD64180
IFNDEF BACKWARD_DECOMPRESS
MACRO NEXT_HL
inc hl
ENDM
MACRO ADD_OFFSET
ex de,hl : add hl,de
ENDM
MACRO BLOCKCOPY
ldir
ENDM
ELSE
MACRO NEXT_HL
dec hl
ENDM
MACRO ADD_OFFSET
push hl : or a : sbc hl,de : pop de ; 11+4+15+10 = 40t / 5 bytes
ENDM
MACRO BLOCKCOPY
lddr
ENDM
ENDIF
IFNDEF HD64180
MACRO LD_IY_DE
ld iyl,e : ld iyh,d
ENDM
MACRO LD_DE_IY
ld e,iyl : ld d,iyh
ENDM
ELSE
MACRO LD_IY_DE
push de : pop iy
ENDM
MACRO LD_DE_IY
push iy : pop de
ENDM
ENDIF
@DecompressLZSA2:
xor a : ld b,a : exa : jr ReadToken
CASE00x: call ReadNibble
ld e,a : ld a,c
cp %00100000 : rl e : jr SaveOffset
CASE0xx ld d,#FF : cp %01000000 : jr c,CASE00x
CASE01x: cp %01100000 : rl d
OffsetReadE: ld e,(hl) : NEXT_HL
SaveOffset: LD_IY_DE
MatchLen: and %00000111 : add 2 : cp 9 : call z,ExtendedCode
CopyMatch: ld c,a
ex (sp),hl ; BC = len, DE = -offset, HL = dest, SP -> [src]
ADD_OFFSET ; BC = len, DE = dest, HL = dest+(-offset), SP -> [src]
BLOCKCOPY ; BC = 0, DE = dest
pop hl ; HL = src
ReadToken: ld a,(hl) : NEXT_HL : push af
and %00011000 : jr z,NoLiterals
rrca : rrca : rrca
call pe,ExtendedCode
ld c,a
BLOCKCOPY
NoLiterals: pop af : push de
or a : jp p,CASE0xx
CASE1xx cp %11000000 : jr nc,CASE11x
CASE10x: call ReadNibble
ld d,a : ld a,c
cp %10100000 : rl d
dec d : dec d : DB #CA ; jr OffsetReadE ; #CA is JP Z,.. to skip all commands in CASE110 before jr OffsetReadE
CASE110: ld d,(hl) : NEXT_HL : jr OffsetReadE
CASE11x cp %11100000 : jr c,CASE110
CASE111: LD_DE_IY : jr MatchLen
ExtendedCode: call ReadNibble : inc a : jr z,ExtraByte
sub #F0+1 : add c : ret
ExtraByte ld a,15 : add c : add (hl) : NEXT_HL : ret nc
ld a,(hl) : NEXT_HL
ld b,(hl) : NEXT_HL : ret nz
pop de : pop de ; RET is not needed, because RET from ReadNibble is sufficient
ReadNibble: ld c,a : xor a : exa : ret m
UpdateNibble ld a,(hl) : or #F0 : exa
ld a,(hl) : NEXT_HL : or #0F
rrca : rrca : rrca : rrca : ret
|
.data
TIME: .space 12 # 3 * (4 bytes) <--> three memory words (blocks) to store day, month and year
TIME_1: .space 12
TIME_2: .space 12
new_line: "\n"
input_day: .asciiz "Nhap ngay DAY: "
input_month: .asciiz "Nhap thang MONTH: "
input_year: .asciiz "Nhap nam YEAR: "
intro_string: .asciiz "----------Ban hay chon 1 trong cac thao tac duoi day----------\n"
first_choice: .asciiz "1. Xuat chuoi TIME theo dinh dang DD/MM/YYYY\n"
second_choice: .asciiz "2. Chuyen doi chuoi TIME thanh mot trong cac dinh dang sau:\n"
sec_choice_a: .asciiz " A. MM/DD/YYYY\n"
sec_choice_b: .asciiz " B. Month DD, YYYY\n"
sec_choice_c: .asciiz " C. DD Month, YYYY\n"
third_choice: .asciiz "3. Cho biet ngay vua nhap la ngay thu may trong tuan.\n"
sub_output1_third_choice: .asciiz "Ngay vua nhap la ngay thu ";
sub_output2_third_choice: .asciiz " trong tuan.\n"
fourth_choice: .asciiz "4. Kiem tra nam trong chuoi TIME co phai la nam nhuan khong.\n"
output_leap_yr: .asciiz "Nam nhap vao la nam nhuan.\n"
output_n_lp_yr: .asciiz "Nam nhap vao khong phai la nam nhuan.\n"
fifth_choice: .asciiz "5. Cho biet khoang thoi gian giua chuoi TIME_1 va TIME_2.\n"
output1_fifth_choice: .asciiz "Khoang thoi gian giua hai chuoi "
and_str: .asciiz " va "
output3_fifth_choice: .asciiz " la: "
sixth_choice: .asciiz "6. Cho biet 2 nam nhuan gan nhat voi nam trong chuoi TIME.\n"
output1_sixth_choice: .asciiz "Hai nam nhuan gan nhat voi nam "
output2_sixth_choice: .asciiz " la: "
seventh_choice: .asciiz "7. Kiem tra bo du lieu dau vao khi nhap, neu du lieu khong hop le thi yeu cau nguoi dung nhap lai.\n"
output_valid_date: .asciiz "Bo du lieu nhap vao hop le.\n"
output_invalid_date: .asciiz "Bo du lieu nhap vao khong hop le.\n"
input_choice: .asciiz "Lua chon: "
output_result: .asciiz "Ket qua: "
.text
|
; A269876: Number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 43", based on the 5-celled von Neumann neighborhood.
; 1,5,5,37,13,97,25,185,41,301,61,445,85,617,113,817,145,1045,181,1301,221,1585,265,1897,313,2237,365,2605,421,3001,481,3425,545,3877,613,4357,685,4865,761,5401,841,5965,925,6557,1013,7177,1105,7825,1201,8501
mov $7,$0
mov $9,2
lpb $9
clr $0,7
mov $0,$7
sub $9,1
add $0,$9
sub $0,1
mov $2,$0
lpb $2
sub $2,1
add $3,$0
add $0,2
add $1,$3
trn $2,1
lpe
mov $10,$9
lpb $10
mov $8,$1
sub $10,1
lpe
lpe
lpb $7
mov $7,0
sub $8,$1
lpe
mov $1,$8
mul $1,4
add $1,1
|
INCBIN "data.bin", 123, 0
|
;Palindrome check
org 100h
mov si,offset input ;load starting address of str into si
mov di,end ;load last address of str into di
mov ax,len ;load length into ax
cmp ax,0001h ;if string length is 0 or 1, string is a palindrome
jle done ;jumps if length <= 1
mov bx,0002h ;store 02h in bx
div bx ;divide ax by bx
mov cx,ax ;load ax which is half length of string; into cx
f: ;comparing characters from front and back
mov al,[si] ;load character pointed by si into al
mov bl,[di] ;load character pointed by di into bl
inc si ;incrementing si
dec di ;decrementing di
cmp al,bl ;compare al and bl
jne break ;if al != bl, exit from loop
loop f ;loop instruction
jmp done ;if no mismatch found, string is palindrome
break:
mov sol,'N' ;store 'N' into sol, in case of mismaatch
done:
ret
input db 'kayak' ;input
end equ $-1 ;address of last character
len equ $ - input ;length of input
sol db 'Y' ;storing 'Y' for palindrome |
; empty ASM file just to trigger the help option tests
; The test itself is written in the CLI file as bash script
|
// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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 "BlackboxTests.hpp"
#include "PubSubReader.hpp"
#include "PubSubWriter.hpp"
#include <fastrtps/xmlparser/XMLProfileManager.h>
#include <rtps/transport/test_UDPv4Transport.h>
#include <gtest/gtest.h>
#include <tuple>
using namespace eprosima::fastrtps;
using namespace eprosima::fastdds::rtps;
enum communication_type
{
TRANSPORT,
INTRAPROCESS,
DATASHARING
};
using test_params = std::tuple<communication_type, rtps::MemoryManagementPolicy>;
class PubSubHistory : public testing::TestWithParam<test_params>
{
public:
void SetUp() override
{
LibrarySettingsAttributes library_settings;
switch (std::get<0>(GetParam()))
{
case INTRAPROCESS:
library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_FULL;
xmlparser::XMLProfileManager::library_settings(library_settings);
break;
case DATASHARING:
enable_datasharing = true;
break;
case TRANSPORT:
default:
break;
}
mem_policy_ = std::get<1>(GetParam());
switch (mem_policy_)
{
case rtps::PREALLOCATED_MEMORY_MODE:
case rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE:
will_use_datasharing = enable_datasharing;
break;
default:
break;
}
}
void TearDown() override
{
LibrarySettingsAttributes library_settings;
switch (std::get<0>(GetParam()))
{
case INTRAPROCESS:
library_settings.intraprocess_delivery = IntraprocessDeliveryType::INTRAPROCESS_OFF;
xmlparser::XMLProfileManager::library_settings(library_settings);
break;
case DATASHARING:
enable_datasharing = false;
break;
case TRANSPORT:
default:
break;
}
will_use_datasharing = false;
}
protected:
rtps::MemoryManagementPolicy mem_policy_;
bool will_use_datasharing = false;
};
// Test created to check bug #1568 (Github #34)
TEST_P(PubSubHistory, PubSubAsNonReliableKeepLastReaderSmallDepth)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).
history_depth(2).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
// Needs a deeper pool for datasharing
// because reader does not process anything until everything is sent
writer.reliability(eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS)
.resource_limits_extra_samples(10).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
while (data.size() > 1)
{
auto expected_data(data);
// Send data
writer.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
std::this_thread::sleep_for(std::chrono::milliseconds(500));
reader.startReception(expected_data);
// Block reader until reception finished or timeout.
size_t current_received = reader.block_for_at_least(2);
reader.stopReception();
// Should be received only two samples.
ASSERT_EQ(current_received, 2u);
data = reader.data_not_received();
}
}
//Test created to deal with Issue 39 on Github
TEST_P(PubSubHistory, CacheChangeReleaseTest)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
//Reader Config
reader.reliability(eprosima::fastrtps::BEST_EFFORT_RELIABILITY_QOS);
reader.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS);
reader.history_depth(1);
reader.resource_limits_allocated_samples(1);
reader.resource_limits_max_samples(1);
reader.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_allocated_samples(1);
writer.resource_limits_max_samples(1);
writer.history_kind(KEEP_LAST_HISTORY_QOS);
writer.history_depth(1);
writer.reliability(BEST_EFFORT_RELIABILITY_QOS);
writer.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
reader.startReception(data);
writer.send(data);
ASSERT_TRUE(data.empty());
size_t current_received = reader.block_for_all(std::chrono::seconds(3));
ASSERT_GE(current_received, static_cast<size_t>(1));
}
// Test created to check bug #1555 (Github #31)
TEST_P(PubSubHistory, PubSubAsReliableKeepLastReaderSmallDepth)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).
history_depth(2).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_extra_samples(10).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
size_t num_messages = 0;
while (data.size() > 1)
{
auto data_backup(data);
num_messages += data.size();
decltype(data) expected_data;
expected_data.push_back(data_backup.back()); data_backup.pop_back();
expected_data.push_back(data_backup.back()); data_backup.pop_back();
// Send data
writer.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), num_messages);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
// Should be received only two samples.
reader.startReception(expected_data);
// Block reader until reception finished or timeout.
reader.block_for_all();
reader.stopReception();
data = data_backup;
}
}
// Test created to check bug #1738 (Github #54)
TEST_P(PubSubHistory, PubSubAsReliableKeepLastWriterSmallDepth)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).
history_depth(2).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
reader.startReception(data);
// Send data
writer.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
// Block reader until reception finished or timeout.
reader.block_for_at_least(2);
}
// Test created to check bug #1558 (Github #33)
TEST(PubSubHistory, PubSubKeepAll)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).init();
ASSERT_TRUE(reader.isInitialized());
writer.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).
max_blocking_time({0, 0}).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
size_t num_messages = 0;
while (!data.empty())
{
auto expected_data(data);
num_messages += data.size();
// Send data
writer.send(data);
for (auto& value : data)
{
expected_data.remove(value);
}
// In this test the history has 20 max_samples.
ASSERT_LE(expected_data.size(), 2u);
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), num_messages);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
reader.startReception(expected_data);
// Block reader until reception finished or timeout.
reader.block_for_all();
reader.stopReception();
}
}
// Test created to check bug #1558 (Github #33)
TEST(PubSubHistory, PubSubKeepAllTransient)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).init();
ASSERT_TRUE(reader.isInitialized());
writer.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).
durability_kind(eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS).
max_blocking_time({0, 0}).
resource_limits_allocated_samples(2).
resource_limits_max_samples(2).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
size_t num_messages = 0;
while (!data.empty())
{
auto expected_data(data);
num_messages += data.size();
// Send data
writer.send(data);
for (auto& value : data)
{
expected_data.remove(value);
}
// In this test the history has 20 max_samples.
ASSERT_LE(expected_data.size(), 2u);
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), num_messages);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
reader.startReception(expected_data);
// Block reader until reception finished or timeout.
reader.block_for_all();
reader.stopReception();
}
}
TEST_P(PubSubHistory, PubReliableKeepAllSubNonReliable)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).
resource_limits_allocated_samples(1).
resource_limits_max_samples(1).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator();
reader.startReception(data);
// Send data
writer.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
// Block reader until reception finished or timeout.
reader.block_for_at_least(2);
}
//Verify that Cachechanges are removed from History when the a Writer unmatches
TEST_P(PubSubHistory, StatefulReaderCacheChangeRelease)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.history_depth(2).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.history_depth(2).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator(2);
auto expected_data(data);
writer.send(data);
ASSERT_TRUE(data.empty());
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), 2);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
writer.destroy();
std::this_thread::sleep_for(std::chrono::seconds(1));
reader.startReception(expected_data);
ASSERT_EQ(reader.getReceivedCount(), 0u);
}
template<typename T>
void send_async_data(
PubSubWriter<T>& writer,
std::list<typename T::type> data_to_send)
{
// Send data
writer.send(data_to_send);
// In this test all data should be sent.
ASSERT_TRUE(data_to_send.empty());
}
TEST_P(PubSubHistory, PubSubAsReliableMultithreadKeepLast1)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.history_depth(1).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
if (enable_datasharing)
{
// on datasharing we need to give time to the reader to process the data
// before reusing it
writer.resource_limits_extra_samples(200);
}
writer.history_depth(1).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator(300);
reader.startReception(data);
std::thread thr1(&send_async_data<HelloWorldType>, std::ref(writer),
std::list<HelloWorld>(data.begin(), std::next(data.begin(), 100)));
std::thread thr2(&send_async_data<HelloWorldType>, std::ref(writer),
std::list<HelloWorld>(std::next(data.begin(), 100), std::next(data.begin(), 200)));
std::thread thr3(&send_async_data<HelloWorldType>, std::ref(writer),
std::list<HelloWorld>(std::next(data.begin(), 200), data.end()));
thr1.join();
thr2.join();
thr3.join();
// Block reader until reception finished or timeout.
reader.block_for_at_least(105);
}
// Test created to check bug #6319 (Github #708)
TEST_P(PubSubHistory, PubSubAsReliableKeepLastReaderSmallDepthTwoPublishers)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer2(TEST_TOPIC_NAME);
reader
.reliability(RELIABLE_RELIABILITY_QOS)
.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS)
.history_depth(1)
.resource_limits_allocated_samples(1)
.resource_limits_max_samples(1);
writer.max_blocking_time({ 120, 0 });
writer2.max_blocking_time({ 120, 0 });
reader.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
writer2.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer2.isInitialized());
// Wait for discovery.
writer.wait_discovery();
writer2.wait_discovery();
reader.wait_discovery(std::chrono::seconds::zero(), 2);
HelloWorld data;
data.message("Hello world!");
// First writer sends two samples (reader would only keep the last one)
data.index(1u);
ASSERT_TRUE(writer.send_sample(data));
data.index(2u);
ASSERT_TRUE(writer.send_sample(data));
// Wait for reader to acknowledge samples
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), 2);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
// Second writer sends one sample (reader should discard previous one)
data.index(3u);
ASSERT_TRUE(writer2.send_sample(data));
// Wait for reader to acknowledge sample
if (enable_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), 3);
}
else
{
writer2.waitForAllAcked(std::chrono::seconds(3));
}
// Only last sample should be present
HelloWorld received;
ASSERT_TRUE(reader.takeNextData(&received));
ASSERT_EQ(received.index(), 3u);
}
TEST_P(PubSubHistory, PubSubAsReliableKeepLastWithKey)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator();
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
reader.stopReception();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepAllWithKeyAndMaxSamplesPerInstance)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_instances(keys)
.resource_limits_max_samples_per_instance(1)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(1)));
data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
TEST(PubSubHistory, PubSubAsReliableKeepAllWithKeyAndMaxSamplesPerInstanceAndLifespan)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
constexpr uint32_t keys = 2;
constexpr uint32_t samples_per_instance = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).init();
ASSERT_TRUE(reader.isInitialized());
// Lifespan period in milliseconds
constexpr uint32_t lifespan_ms = 1000;
constexpr uint32_t max_block_time_ms = 500;
auto testTransport = std::make_shared<test_UDPv4TransportDescriptor>();
writer.resource_limits_max_instances(keys)
.resource_limits_max_samples_per_instance(samples_per_instance)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.max_blocking_time(max_block_time_ms * 1e-3)
.lifespan_period(lifespan_ms * 1e-3)
.disable_builtin_transport()
.add_user_transport_to_pparams(testTransport)
.init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
test_UDPv4Transport::test_UDPv4Transport_ShutdownAllNetwork = true;
auto data = default_keyedhelloworld_data_generator(2);
// Send data
writer.send(data);
std::this_thread::sleep_for(std::chrono::milliseconds(lifespan_ms - 10));
data = default_keyedhelloworld_data_generator(4);
reader.startReception(data);
std::thread thread([]()
{
std::this_thread::sleep_for(std::chrono::milliseconds(20));
test_UDPv4Transport::test_UDPv4Transport_ShutdownAllNetwork = false;
});
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
thread.join();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepAllWithKeyAndInfiniteMaxSamplesPerInstance)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_instances(keys)
.resource_limits_max_samples_per_instance(0)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(1)));
data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepAllWithKeyAndInfiniteMaxInstances)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_instances(0)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(1)));
data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepAllWithKeyAndMaxSamples)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_instances(keys)
.resource_limits_max_samples(2)
.resource_limits_allocated_samples(2)
.resource_limits_max_samples_per_instance(2)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(1)));
data = default_keyedhelloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepAllWithoutKeyAndMaxSamples)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.resource_limits_max_samples(2)
.resource_limits_allocated_samples(2)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_helloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(1)));
data = default_helloworld_data_generator(2);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
TEST_P(PubSubHistory, PubSubAsReliableKeepLastReaderSmallDepthWithKey)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
uint32_t depth = 2;
reader.history_depth(depth).
resource_limits_max_samples(keys * depth).
resource_limits_allocated_samples(keys * depth).
resource_limits_max_instances(keys).
resource_limits_max_samples_per_instance(depth).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.history_depth(depth).
resource_limits_max_samples(keys * depth).
resource_limits_allocated_samples(keys * depth).
resource_limits_max_instances(keys).
resource_limits_max_samples_per_instance(depth).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
//We want the number of messages to be multiple of keys*depth
auto data = default_keyedhelloworld_data_generator(3 * keys * depth);
while (data.size() > 1)
{
auto expected_data(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
std::this_thread::sleep_for(std::chrono::milliseconds(500));
reader.startReception(expected_data);
size_t current_received = reader.block_for_at_least(keys * depth);
reader.stopReception();
ASSERT_EQ(current_received, keys * depth);
data = reader.data_not_received();
}
}
// Regression test for redmine bug #12419
// It uses a test transport to drop some DATA messages, in order to force unordered reception.
TEST_P(PubSubHistory, PubSubAsReliableKeepLastWithKeyUnorderedReception)
{
PubSubReader<KeyedHelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<KeyedHelloWorldType> writer(TEST_TOPIC_NAME);
uint32_t keys = 2;
uint32_t depth = 10;
reader.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).
history_depth(depth).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
auto testTransport = std::make_shared<test_UDPv4TransportDescriptor>();
testTransport->dropDataMessagesPercentage = 25;
writer.resource_limits_max_instances(keys).
reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS).
history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS).
history_depth(depth).mem_policy(mem_policy_).
disable_builtin_transport().add_user_transport_to_pparams(testTransport).
init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data = default_keyedhelloworld_data_generator(keys * depth);
reader.startReception(data);
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
reader.stopReception();
}
bool comparator(
HelloWorld first,
HelloWorld second)
{
return first.index() < second.index();
}
/*!
* @fn TEST(PubSubHistory, ReliableTransientLocalKeepLast1)
* @brief This test checks the correct functionality of transient local, keep last 1 late-joiners.
*
* The test creates a Reliable, Transient Local Writer with a Keep Last 10 history, and send ten samples throughout the
* network.
* Then it creates a Reliable, Transient Local Reader with a Keep Last 1 history and waits until both of them discover
* each other.
* When the Writer discovers the late-joiner, resends the samples it has on the history (in this case all). And the
* reader upon receiving them, as it is Keep Last 1, discards all the samples except the last one.
* Finally, the test checks that the last sequence number received is the one corresponding to the tenth sample.
*/
TEST_P(PubSubHistory, ReliableTransientLocalKeepLast1)
{
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
writer.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.durability_kind(eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS)
.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS)
.history_depth(10)
.resource_limits_allocated_samples(10)
.resource_limits_max_samples(10).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
auto data = default_helloworld_data_generator();
auto expected_data = data;
writer.send(data);
reader.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.durability_kind(eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS)
.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS)
.history_depth(1).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.wait_discovery();
reader.wait_discovery();
ASSERT_FALSE(expected_data.empty());
std::this_thread::sleep_for(std::chrono::milliseconds(500));
reader.startReception(expected_data);
eprosima::fastrtps::rtps::SequenceNumber_t seq;
seq.low = 10;
reader.block_for_seq(seq);
ASSERT_EQ(reader.get_last_sequence_received().low, 10u);
}
TEST_P(PubSubHistory, ReliableTransientLocalKeepLast1Data300Kb)
{
PubSubReader<Data1mbType> reader(TEST_TOPIC_NAME);
PubSubWriter<Data1mbType> writer(TEST_TOPIC_NAME);
auto data = default_data300kb_data_generator();
auto reader_data = data;
writer
.history_depth(static_cast<int32_t>(data.size()))
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.durability_kind(eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Send data
writer.send(data);
ASSERT_TRUE(data.empty());
ASSERT_FALSE(reader_data.empty());
reader
.history_kind(eprosima::fastrtps::KEEP_LAST_HISTORY_QOS)
.history_depth(1)
.reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS)
.durability_kind(eprosima::fastrtps::TRANSIENT_LOCAL_DURABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
// Because its volatile the durability
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
reader.startReception(reader_data);
eprosima::fastrtps::rtps::SequenceNumber_t seq;
seq.low = 10;
reader.block_for_seq(seq);
ASSERT_EQ(reader.get_last_sequence_received().low, 10u);
}
// Test created to check bug #8945
/*!
* @fn TEST(PubSubHistory, WriterWithoutReadersTransientLocal)
* @brief This test checks that the writer doesn't fill its history while there are no readers matched.
*
* The test creates a Reliable, Transient Local Writer with a Keep All history, and its resources limited to
* 13 samples.
* Then it creates a Reliable, Transient Local Reader with a Keep Last 1 history and waits until both of them discover
* each other.
* When both of them are matched, the writer sends 13 samples, asserting that all of them have been sent and the
* reader starts its reception.
* After that, the reader is destroyed, meaning that the writer runs out of readers. Even if there are no readers,
* it has to continue sending the remaining samples, deleting the old ones if the history is filled up.
*/
TEST_P(PubSubHistory, WriterWithoutReadersTransientLocal)
{
PubSubWriter<Data1mbType> writer(TEST_TOPIC_NAME);
writer
.history_kind(KEEP_ALL_HISTORY_QOS)
.durability_kind(TRANSIENT_LOCAL_DURABILITY_QOS)
.reliability(RELIABLE_RELIABILITY_QOS)
.resource_limits_allocated_samples(13)
.resource_limits_max_samples(13)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Remove the reader
PubSubReader<Data1mbType> reader(TEST_TOPIC_NAME);
reader
.reliability(RELIABLE_RELIABILITY_QOS)
.durability_kind(TRANSIENT_LOCAL_DURABILITY_QOS)
.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
auto data1 = default_data300kb_data_generator(13);
auto data2 = default_data300kb_data_generator(14);
auto unreceived_data = default_data300kb_data_generator(27);
// Send data
writer.send(data1);
// In this test all data should be sent.
ASSERT_TRUE(data1.empty());
reader.startReception(unreceived_data);
reader.destroy();
// Send data
writer.send(data2);
// In this test all data should be sent.
ASSERT_TRUE(data2.empty());
}
TEST_P(PubSubHistory, WriterUnmatchClearsHistory)
{
// A reader that READS instead of TAKE
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME, false);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer2(TEST_TOPIC_NAME);
//Reader with limited history size
reader.history_depth(2).reliability(RELIABLE_RELIABILITY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
// Wait for discovery.
writer.wait_discovery();
reader.wait_discovery();
// Writer fills the reader's history
auto data = default_helloworld_data_generator(2);
reader.startReception(data);
writer.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
// Writer's undiscovery should free the reader's history
writer.destroy();
reader.wait_writer_undiscovery();
// Create another writer and send more data
// Reader should be able to get the new data
writer2.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS).mem_policy(mem_policy_).init();
ASSERT_TRUE(writer2.isInitialized());
writer2.wait_discovery();
reader.wait_discovery();
data = default_helloworld_data_generator(2);
reader.startReception(data);
writer2.send(data);
ASSERT_TRUE(data.empty());
reader.block_for_all();
}
// Regression test for #11743
/*!
* @fn TEST(PubSubHistory, KeepAllWriterContinueSendingAfterReaderMatched)
* @brief This test checks that the writer doesn't block writing samples when meet a Datasharing Volatile reader.
*
* The test creates a Reliable, Transient Local Writer with a Keep All history, and its resources limited to
* 1 samples.
* Then it creates a Reliable, Volatile Reader.
* Writer will be the first discovering and then sends a sample.
* Reader could discover the writer when the writer already put the sample in the Datasharing history for the reader.
* The Volatile reader should be able to acks these kind of samples.
*
* Writer will be able then to send a second sample.
*/
TEST_P(PubSubHistory, KeepAllWriterContinueSendingAfterReaderMatched)
{
PubSubReader<HelloWorldType> reader(TEST_TOPIC_NAME);
PubSubWriter<HelloWorldType> writer(TEST_TOPIC_NAME);
reader.reliability(RELIABLE_RELIABILITY_QOS);
writer.reliability(RELIABLE_RELIABILITY_QOS)
.history_kind(eprosima::fastrtps::KEEP_ALL_HISTORY_QOS)
.resource_limits_allocated_samples(1)
.resource_limits_max_samples(1);
writer.mem_policy(mem_policy_).init();
ASSERT_TRUE(writer.isInitialized());
reader.mem_policy(mem_policy_).init();
ASSERT_TRUE(reader.isInitialized());
writer.wait_discovery();
HelloWorld data;
data.message("Hello world!");
data.index(1u);
ASSERT_TRUE(writer.send_sample(data));
reader.wait_discovery();
// Second writer sends one sample (reader should discard previous one)
data.index(2u);
uint32_t expected_value = data.index();
if (will_use_datasharing)
{
if (reader.wait_for_all_received(std::chrono::seconds(3), 1))
{
ASSERT_FALSE(writer.send_sample(data));
expected_value = 1;
}
else
{
ASSERT_TRUE(writer.send_sample(data));
}
}
else
{
ASSERT_TRUE(writer.send_sample(data));
}
if (will_use_datasharing)
{
reader.wait_for_all_received(std::chrono::seconds(3), expected_value);
}
else
{
writer.waitForAllAcked(std::chrono::seconds(3));
}
// Only one sample should be present
HelloWorld received;
ASSERT_TRUE(reader.takeNextData(&received));
ASSERT_EQ(received.index(), expected_value);
ASSERT_TRUE(writer.waitForAllAcked(std::chrono::seconds(3)));
}
#ifdef INSTANTIATE_TEST_SUITE_P
#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w)
#else
#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_CASE_P(x, y, z, w)
#endif // ifdef INSTANTIATE_TEST_SUITE_P
GTEST_INSTANTIATE_TEST_MACRO(PubSubHistory,
PubSubHistory,
testing::Combine(
testing::Values(TRANSPORT, INTRAPROCESS, DATASHARING),
testing::Values(
rtps::PREALLOCATED_MEMORY_MODE,
rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE,
rtps::DYNAMIC_RESERVE_MEMORY_MODE,
rtps::DYNAMIC_REUSABLE_MEMORY_MODE)),
[](const testing::TestParamInfo<PubSubHistory::ParamType>& info)
{
std::string suffix;
switch (std::get<1>(info.param))
{
default:
case rtps::PREALLOCATED_MEMORY_MODE:
suffix = "_PREALLOCATED";
break;
case rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE:
suffix = "_PREALLOCATED_WITH_REALLOC";
break;
case rtps::DYNAMIC_RESERVE_MEMORY_MODE:
suffix = "_DYNAMIC_RESERVE";
break;
case rtps::DYNAMIC_REUSABLE_MEMORY_MODE:
suffix = "_DYNAMIC_REUSABLE";
break;
}
switch (std::get<0>(info.param))
{
case INTRAPROCESS:
return "Intraprocess" + suffix;
break;
case DATASHARING:
return "Datasharing" + suffix;
break;
case TRANSPORT:
default:
return "Transport" + suffix;
}
});
|
; A025997: Expansion of 1/((1-2x)(1-5x)(1-8x)(1-9x)).
; Submitted by Jon Maiga
; 1,24,375,4850,56481,616164,6434155,65146950,644889861,6275802104,60272841135,572861926650,5399415089641,50546032304844,470534835243315,4359828735795950,40238834684119821,370153792218396384
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16316 ; Expansion of 1/((1-2x)(1-8x)(1-9x)).
mul $1,5
add $1,$0
lpe
mov $0,$1
|
; unsigned char esx_f_open_p3(unsigned char *filename,unsigned char mode,struct esx_p3_hdr *h)
SECTION code_esxdos
PUBLIC _esx_f_open_p3
EXTERN l0_esx_f_open_p3_callee
_esx_f_open_p3:
pop bc
pop hl
dec sp
pop af
pop de
push de
push af
inc sp
push hl
push bc
jp l0_esx_f_open_p3_callee
|
main:
add $s1 $zero $zero # (comentario)
bne $t0 $zero exit
addi $t0 $zero 6
addi $t1 $zero 12
# (comentario)
sw $t0, 23($t1)
j volta
addi $t2 $zero 3
and $s1, $s2, $zero
slt $s1, $s2, $zero
volta: beq $t0 $zero exit
sub $s0 $s0 $t1
lw $t0, -42($t1)
add $t1 $t1 $t2
jr $ra
addi $t0 $t0 -1
xor $t2, $t3, $t4
exit:
jal volta
or $s4, $s5, $s6 |
CeladonCity_h:
db OVERWORLD ; tileset
db CELADON_CITY_HEIGHT, CELADON_CITY_WIDTH ; dimensions (y, x)
dw CeladonCity_Blocks ; blocks
dw CeladonCity_TextPointers ; texts
dw CeladonCity_Script ; scripts
db WEST | EAST ; connections
WEST_MAP_CONNECTION CELADON_CITY, ROUTE_16, 4, 0, Route16_Blocks
EAST_MAP_CONNECTION CELADON_CITY, ROUTE_7, 4, 0, Route7_Blocks, 1
dw CeladonCity_Object ; objects
|
SFX_Battle_22_Ch7:
noisenote 2, 13, 2, 50
noisenote 15, 15, 2, 67
endchannel
|
;
; OSCA C Library
;
; ANSI Video handling
;
; BEL - chr(7) Beep it out
;
;
; Stefano Bodrato - June 2012
;
;
; $Id: f_ansi_bel.asm,v 1.5 2016-06-12 16:06:42 dom Exp $
;
SECTION code_clib
PUBLIC ansi_BEL
INCLUDE "osca.def"
INCLUDE "flos.def"
.ansi_BEL
di
ld hl,0
ld e,2
call kjt_read_sysram_flat
push af
ld hl,1
ld e,2
call kjt_read_sysram_flat
push af
ld hl,0
ld e,2
ld a,$80 ;put 1st byte square wave
call kjt_write_sysram_flat
ld hl,1
ld e,2
ld a,$7f ;put 2nd byte square wave
call kjt_write_sysram_flat
;-----------------------------------------------------------------------------------------
in a,(sys_audio_enable)
and @11111110
out (sys_audio_enable),a ;stop channel 0 playback
in a,(sys_vreg_read) ;wait for the beginning of a scan line
and $40 ;(ie: after audio DMA) This is so that all the
ld b,a ;audio registers are cleanly initialized
.dma_loop
in a,(sys_vreg_read)
and $40
cp b
jr z,dma_loop
ld hl,0 ;Sample location * WORD POINTER IN SAMPLE RAM*
ld b,h ;(EG: 0=$20000,1=$20002)
ld c,audchan0_loc
out (c),l ;write sample address to relevant port
ld hl,1 ;sample length * IN WORDS *
ld b,h
ld c,audchan0_len
out (c),l ;set sample length to relevant port
ld hl,$4000 ;period = clock ticks between sample bytes
ld b,h
ld c,audchan0_per
out (c),l ;set sample period to relevant port
ld a,64
out (audchan0_vol),a ;set sample volume to relevant port (64 = full volume)
in a,(sys_audio_enable)
or @00000001
out (sys_audio_enable),a ;start channel 0 playback
xor a
ld b,50 ; sleep abt 200 milliseconds
.bdelay
call kjt_timer_wait
djnz bdelay
in a,(sys_audio_enable)
and @11111110
out (sys_audio_enable),a ;stop channel 0 playback
ld hl,1
ld e,2
pop af
call kjt_write_sysram_flat
ld hl,0
ld e,2
pop af
call kjt_write_sysram_flat
ei
ret
|
_env: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "user.h"
char *envp[] = environ;
int main(int argc, char *argv[]){
//char *envData;
int i = 0;
for(i=0;envp[i]>0;i++){
0: a1 18 0a 00 00 mov 0xa18,%eax
5: 85 c0 test %eax,%eax
7: 74 3c je 45 <main+0x45>
#include "types.h"
#include "stat.h"
#include "user.h"
char *envp[] = environ;
int main(int argc, char *argv[]){
9: 8d 4c 24 04 lea 0x4(%esp),%ecx
d: 83 e4 f0 and $0xfffffff0,%esp
10: ff 71 fc pushl -0x4(%ecx)
13: 55 push %ebp
14: 89 e5 mov %esp,%ebp
16: 53 push %ebx
17: 51 push %ecx
18: bb 18 0a 00 00 mov $0xa18,%ebx
//char *envData;
int i = 0;
for(i=0;envp[i]>0;i++){
//envData = envp[i];
printf(1,"%s\n",envp[i]);
1d: 83 ec 04 sub $0x4,%esp
20: 83 c3 04 add $0x4,%ebx
23: 50 push %eax
24: 68 00 07 00 00 push $0x700
29: 6a 01 push $0x1
2b: e8 b0 03 00 00 call 3e0 <printf>
#include "user.h"
char *envp[] = environ;
int main(int argc, char *argv[]){
//char *envData;
int i = 0;
for(i=0;envp[i]>0;i++){
30: 8b 03 mov (%ebx),%eax
32: 83 c4 10 add $0x10,%esp
35: 85 c0 test %eax,%eax
37: 75 e4 jne 1d <main+0x1d>
//envData = envp[i];
printf(1,"%s\n",envp[i]);
}
//printf(1,"Avaiable env %d\n",i);
return 0;
}
39: 8d 65 f8 lea -0x8(%ebp),%esp
3c: 31 c0 xor %eax,%eax
3e: 59 pop %ecx
3f: 5b pop %ebx
40: 5d pop %ebp
41: 8d 61 fc lea -0x4(%ecx),%esp
44: c3 ret
45: 31 c0 xor %eax,%eax
47: c3 ret
48: 66 90 xchg %ax,%ax
4a: 66 90 xchg %ax,%ax
4c: 66 90 xchg %ax,%ax
4e: 66 90 xchg %ax,%ax
00000050 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
50: 55 push %ebp
51: 89 e5 mov %esp,%ebp
53: 53 push %ebx
54: 8b 45 08 mov 0x8(%ebp),%eax
57: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
5a: 89 c2 mov %eax,%edx
5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
60: 83 c1 01 add $0x1,%ecx
63: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
67: 83 c2 01 add $0x1,%edx
6a: 84 db test %bl,%bl
6c: 88 5a ff mov %bl,-0x1(%edx)
6f: 75 ef jne 60 <strcpy+0x10>
;
return os;
}
71: 5b pop %ebx
72: 5d pop %ebp
73: c3 ret
74: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
7a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000080 <strcmp>:
int
strcmp(const char *p, const char *q)
{
80: 55 push %ebp
81: 89 e5 mov %esp,%ebp
83: 56 push %esi
84: 53 push %ebx
85: 8b 55 08 mov 0x8(%ebp),%edx
88: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
8b: 0f b6 02 movzbl (%edx),%eax
8e: 0f b6 19 movzbl (%ecx),%ebx
91: 84 c0 test %al,%al
93: 75 1e jne b3 <strcmp+0x33>
95: eb 29 jmp c0 <strcmp+0x40>
97: 89 f6 mov %esi,%esi
99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
a0: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
a3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
a6: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
a9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
ad: 84 c0 test %al,%al
af: 74 0f je c0 <strcmp+0x40>
b1: 89 f1 mov %esi,%ecx
b3: 38 d8 cmp %bl,%al
b5: 74 e9 je a0 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
b7: 29 d8 sub %ebx,%eax
}
b9: 5b pop %ebx
ba: 5e pop %esi
bb: 5d pop %ebp
bc: c3 ret
bd: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
c0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
c2: 29 d8 sub %ebx,%eax
}
c4: 5b pop %ebx
c5: 5e pop %esi
c6: 5d pop %ebp
c7: c3 ret
c8: 90 nop
c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000000d0 <strlen>:
uint
strlen(char *s)
{
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
d6: 80 39 00 cmpb $0x0,(%ecx)
d9: 74 12 je ed <strlen+0x1d>
db: 31 d2 xor %edx,%edx
dd: 8d 76 00 lea 0x0(%esi),%esi
e0: 83 c2 01 add $0x1,%edx
e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
e7: 89 d0 mov %edx,%eax
e9: 75 f5 jne e0 <strlen+0x10>
;
return n;
}
eb: 5d pop %ebp
ec: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
ed: 31 c0 xor %eax,%eax
;
return n;
}
ef: 5d pop %ebp
f0: c3 ret
f1: eb 0d jmp 100 <memset>
f3: 90 nop
f4: 90 nop
f5: 90 nop
f6: 90 nop
f7: 90 nop
f8: 90 nop
f9: 90 nop
fa: 90 nop
fb: 90 nop
fc: 90 nop
fd: 90 nop
fe: 90 nop
ff: 90 nop
00000100 <memset>:
void*
memset(void *dst, int c, uint n)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 57 push %edi
104: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
107: 8b 4d 10 mov 0x10(%ebp),%ecx
10a: 8b 45 0c mov 0xc(%ebp),%eax
10d: 89 d7 mov %edx,%edi
10f: fc cld
110: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
112: 89 d0 mov %edx,%eax
114: 5f pop %edi
115: 5d pop %ebp
116: c3 ret
117: 89 f6 mov %esi,%esi
119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000120 <strchr>:
char*
strchr(const char *s, char c)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 53 push %ebx
124: 8b 45 08 mov 0x8(%ebp),%eax
127: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
12a: 0f b6 10 movzbl (%eax),%edx
12d: 84 d2 test %dl,%dl
12f: 74 1d je 14e <strchr+0x2e>
if(*s == c)
131: 38 d3 cmp %dl,%bl
133: 89 d9 mov %ebx,%ecx
135: 75 0d jne 144 <strchr+0x24>
137: eb 17 jmp 150 <strchr+0x30>
139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
140: 38 ca cmp %cl,%dl
142: 74 0c je 150 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
144: 83 c0 01 add $0x1,%eax
147: 0f b6 10 movzbl (%eax),%edx
14a: 84 d2 test %dl,%dl
14c: 75 f2 jne 140 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
14e: 31 c0 xor %eax,%eax
}
150: 5b pop %ebx
151: 5d pop %ebp
152: c3 ret
153: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000160 <gets>:
char*
gets(char *buf, int max)
{
160: 55 push %ebp
161: 89 e5 mov %esp,%ebp
163: 57 push %edi
164: 56 push %esi
165: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
166: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
168: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
16b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
16e: eb 29 jmp 199 <gets+0x39>
cc = read(0, &c, 1);
170: 83 ec 04 sub $0x4,%esp
173: 6a 01 push $0x1
175: 57 push %edi
176: 6a 00 push $0x0
178: e8 2d 01 00 00 call 2aa <read>
if(cc < 1)
17d: 83 c4 10 add $0x10,%esp
180: 85 c0 test %eax,%eax
182: 7e 1d jle 1a1 <gets+0x41>
break;
buf[i++] = c;
184: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
188: 8b 55 08 mov 0x8(%ebp),%edx
18b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
18d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
18f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
193: 74 1b je 1b0 <gets+0x50>
195: 3c 0d cmp $0xd,%al
197: 74 17 je 1b0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
199: 8d 5e 01 lea 0x1(%esi),%ebx
19c: 3b 5d 0c cmp 0xc(%ebp),%ebx
19f: 7c cf jl 170 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1a1: 8b 45 08 mov 0x8(%ebp),%eax
1a4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1a8: 8d 65 f4 lea -0xc(%ebp),%esp
1ab: 5b pop %ebx
1ac: 5e pop %esi
1ad: 5f pop %edi
1ae: 5d pop %ebp
1af: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1b0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1b3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1b5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
1b9: 8d 65 f4 lea -0xc(%ebp),%esp
1bc: 5b pop %ebx
1bd: 5e pop %esi
1be: 5f pop %edi
1bf: 5d pop %ebp
1c0: c3 ret
1c1: eb 0d jmp 1d0 <stat>
1c3: 90 nop
1c4: 90 nop
1c5: 90 nop
1c6: 90 nop
1c7: 90 nop
1c8: 90 nop
1c9: 90 nop
1ca: 90 nop
1cb: 90 nop
1cc: 90 nop
1cd: 90 nop
1ce: 90 nop
1cf: 90 nop
000001d0 <stat>:
int
stat(char *n, struct stat *st)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 56 push %esi
1d4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1d5: 83 ec 08 sub $0x8,%esp
1d8: 6a 00 push $0x0
1da: ff 75 08 pushl 0x8(%ebp)
1dd: e8 f0 00 00 00 call 2d2 <open>
if(fd < 0)
1e2: 83 c4 10 add $0x10,%esp
1e5: 85 c0 test %eax,%eax
1e7: 78 27 js 210 <stat+0x40>
return -1;
r = fstat(fd, st);
1e9: 83 ec 08 sub $0x8,%esp
1ec: ff 75 0c pushl 0xc(%ebp)
1ef: 89 c3 mov %eax,%ebx
1f1: 50 push %eax
1f2: e8 f3 00 00 00 call 2ea <fstat>
1f7: 89 c6 mov %eax,%esi
close(fd);
1f9: 89 1c 24 mov %ebx,(%esp)
1fc: e8 b9 00 00 00 call 2ba <close>
return r;
201: 83 c4 10 add $0x10,%esp
204: 89 f0 mov %esi,%eax
}
206: 8d 65 f8 lea -0x8(%ebp),%esp
209: 5b pop %ebx
20a: 5e pop %esi
20b: 5d pop %ebp
20c: c3 ret
20d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
210: b8 ff ff ff ff mov $0xffffffff,%eax
215: eb ef jmp 206 <stat+0x36>
217: 89 f6 mov %esi,%esi
219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000220 <atoi>:
return r;
}
int
atoi(const char *s)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 53 push %ebx
224: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
227: 0f be 11 movsbl (%ecx),%edx
22a: 8d 42 d0 lea -0x30(%edx),%eax
22d: 3c 09 cmp $0x9,%al
22f: b8 00 00 00 00 mov $0x0,%eax
234: 77 1f ja 255 <atoi+0x35>
236: 8d 76 00 lea 0x0(%esi),%esi
239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
240: 8d 04 80 lea (%eax,%eax,4),%eax
243: 83 c1 01 add $0x1,%ecx
246: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
24a: 0f be 11 movsbl (%ecx),%edx
24d: 8d 5a d0 lea -0x30(%edx),%ebx
250: 80 fb 09 cmp $0x9,%bl
253: 76 eb jbe 240 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
255: 5b pop %ebx
256: 5d pop %ebp
257: c3 ret
258: 90 nop
259: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000260 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 56 push %esi
264: 53 push %ebx
265: 8b 5d 10 mov 0x10(%ebp),%ebx
268: 8b 45 08 mov 0x8(%ebp),%eax
26b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
26e: 85 db test %ebx,%ebx
270: 7e 14 jle 286 <memmove+0x26>
272: 31 d2 xor %edx,%edx
274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
278: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
27c: 88 0c 10 mov %cl,(%eax,%edx,1)
27f: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
282: 39 da cmp %ebx,%edx
284: 75 f2 jne 278 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
286: 5b pop %ebx
287: 5e pop %esi
288: 5d pop %ebp
289: c3 ret
0000028a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
28a: b8 01 00 00 00 mov $0x1,%eax
28f: cd 40 int $0x40
291: c3 ret
00000292 <exit>:
SYSCALL(exit)
292: b8 02 00 00 00 mov $0x2,%eax
297: cd 40 int $0x40
299: c3 ret
0000029a <wait>:
SYSCALL(wait)
29a: b8 03 00 00 00 mov $0x3,%eax
29f: cd 40 int $0x40
2a1: c3 ret
000002a2 <pipe>:
SYSCALL(pipe)
2a2: b8 04 00 00 00 mov $0x4,%eax
2a7: cd 40 int $0x40
2a9: c3 ret
000002aa <read>:
SYSCALL(read)
2aa: b8 05 00 00 00 mov $0x5,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <write>:
SYSCALL(write)
2b2: b8 10 00 00 00 mov $0x10,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <close>:
SYSCALL(close)
2ba: b8 15 00 00 00 mov $0x15,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <kill>:
SYSCALL(kill)
2c2: b8 06 00 00 00 mov $0x6,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <exec>:
SYSCALL(exec)
2ca: b8 07 00 00 00 mov $0x7,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <open>:
SYSCALL(open)
2d2: b8 0f 00 00 00 mov $0xf,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <mknod>:
SYSCALL(mknod)
2da: b8 11 00 00 00 mov $0x11,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <unlink>:
SYSCALL(unlink)
2e2: b8 12 00 00 00 mov $0x12,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <fstat>:
SYSCALL(fstat)
2ea: b8 08 00 00 00 mov $0x8,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <link>:
SYSCALL(link)
2f2: b8 13 00 00 00 mov $0x13,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <mkdir>:
SYSCALL(mkdir)
2fa: b8 14 00 00 00 mov $0x14,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <chdir>:
SYSCALL(chdir)
302: b8 09 00 00 00 mov $0x9,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <dup>:
SYSCALL(dup)
30a: b8 0a 00 00 00 mov $0xa,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <getpid>:
SYSCALL(getpid)
312: b8 0b 00 00 00 mov $0xb,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <sbrk>:
SYSCALL(sbrk)
31a: b8 0c 00 00 00 mov $0xc,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <sleep>:
SYSCALL(sleep)
322: b8 0d 00 00 00 mov $0xd,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <uptime>:
SYSCALL(uptime)
32a: b8 0e 00 00 00 mov $0xe,%eax
32f: cd 40 int $0x40
331: c3 ret
332: 66 90 xchg %ax,%ax
334: 66 90 xchg %ax,%ax
336: 66 90 xchg %ax,%ax
338: 66 90 xchg %ax,%ax
33a: 66 90 xchg %ax,%ax
33c: 66 90 xchg %ax,%ax
33e: 66 90 xchg %ax,%ax
00000340 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
340: 55 push %ebp
341: 89 e5 mov %esp,%ebp
343: 57 push %edi
344: 56 push %esi
345: 53 push %ebx
346: 89 c6 mov %eax,%esi
348: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
34b: 8b 5d 08 mov 0x8(%ebp),%ebx
34e: 85 db test %ebx,%ebx
350: 74 7e je 3d0 <printint+0x90>
352: 89 d0 mov %edx,%eax
354: c1 e8 1f shr $0x1f,%eax
357: 84 c0 test %al,%al
359: 74 75 je 3d0 <printint+0x90>
neg = 1;
x = -xx;
35b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
35d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
364: f7 d8 neg %eax
366: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
369: 31 ff xor %edi,%edi
36b: 8d 5d d7 lea -0x29(%ebp),%ebx
36e: 89 ce mov %ecx,%esi
370: eb 08 jmp 37a <printint+0x3a>
372: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
378: 89 cf mov %ecx,%edi
37a: 31 d2 xor %edx,%edx
37c: 8d 4f 01 lea 0x1(%edi),%ecx
37f: f7 f6 div %esi
381: 0f b6 92 70 07 00 00 movzbl 0x770(%edx),%edx
}while((x /= base) != 0);
388: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
38a: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
38d: 75 e9 jne 378 <printint+0x38>
if(neg)
38f: 8b 45 c4 mov -0x3c(%ebp),%eax
392: 8b 75 c0 mov -0x40(%ebp),%esi
395: 85 c0 test %eax,%eax
397: 74 08 je 3a1 <printint+0x61>
buf[i++] = '-';
399: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
39e: 8d 4f 02 lea 0x2(%edi),%ecx
3a1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
3a5: 8d 76 00 lea 0x0(%esi),%esi
3a8: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3ab: 83 ec 04 sub $0x4,%esp
3ae: 83 ef 01 sub $0x1,%edi
3b1: 6a 01 push $0x1
3b3: 53 push %ebx
3b4: 56 push %esi
3b5: 88 45 d7 mov %al,-0x29(%ebp)
3b8: e8 f5 fe ff ff call 2b2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
3bd: 83 c4 10 add $0x10,%esp
3c0: 39 df cmp %ebx,%edi
3c2: 75 e4 jne 3a8 <printint+0x68>
putc(fd, buf[i]);
}
3c4: 8d 65 f4 lea -0xc(%ebp),%esp
3c7: 5b pop %ebx
3c8: 5e pop %esi
3c9: 5f pop %edi
3ca: 5d pop %ebp
3cb: c3 ret
3cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
3d0: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3d2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3d9: eb 8b jmp 366 <printint+0x26>
3db: 90 nop
3dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000003e0 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
3e0: 55 push %ebp
3e1: 89 e5 mov %esp,%ebp
3e3: 57 push %edi
3e4: 56 push %esi
3e5: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3e6: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
3e9: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3ec: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
3ef: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3f2: 89 45 d0 mov %eax,-0x30(%ebp)
3f5: 0f b6 1e movzbl (%esi),%ebx
3f8: 83 c6 01 add $0x1,%esi
3fb: 84 db test %bl,%bl
3fd: 0f 84 b0 00 00 00 je 4b3 <printf+0xd3>
403: 31 d2 xor %edx,%edx
405: eb 39 jmp 440 <printf+0x60>
407: 89 f6 mov %esi,%esi
409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
410: 83 f8 25 cmp $0x25,%eax
413: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
416: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
41b: 74 18 je 435 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
41d: 8d 45 e2 lea -0x1e(%ebp),%eax
420: 83 ec 04 sub $0x4,%esp
423: 88 5d e2 mov %bl,-0x1e(%ebp)
426: 6a 01 push $0x1
428: 50 push %eax
429: 57 push %edi
42a: e8 83 fe ff ff call 2b2 <write>
42f: 8b 55 d4 mov -0x2c(%ebp),%edx
432: 83 c4 10 add $0x10,%esp
435: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
438: 0f b6 5e ff movzbl -0x1(%esi),%ebx
43c: 84 db test %bl,%bl
43e: 74 73 je 4b3 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
440: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
442: 0f be cb movsbl %bl,%ecx
445: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
448: 74 c6 je 410 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
44a: 83 fa 25 cmp $0x25,%edx
44d: 75 e6 jne 435 <printf+0x55>
if(c == 'd'){
44f: 83 f8 64 cmp $0x64,%eax
452: 0f 84 f8 00 00 00 je 550 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
458: 81 e1 f7 00 00 00 and $0xf7,%ecx
45e: 83 f9 70 cmp $0x70,%ecx
461: 74 5d je 4c0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
463: 83 f8 73 cmp $0x73,%eax
466: 0f 84 84 00 00 00 je 4f0 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
46c: 83 f8 63 cmp $0x63,%eax
46f: 0f 84 ea 00 00 00 je 55f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
475: 83 f8 25 cmp $0x25,%eax
478: 0f 84 c2 00 00 00 je 540 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
47e: 8d 45 e7 lea -0x19(%ebp),%eax
481: 83 ec 04 sub $0x4,%esp
484: c6 45 e7 25 movb $0x25,-0x19(%ebp)
488: 6a 01 push $0x1
48a: 50 push %eax
48b: 57 push %edi
48c: e8 21 fe ff ff call 2b2 <write>
491: 83 c4 0c add $0xc,%esp
494: 8d 45 e6 lea -0x1a(%ebp),%eax
497: 88 5d e6 mov %bl,-0x1a(%ebp)
49a: 6a 01 push $0x1
49c: 50 push %eax
49d: 57 push %edi
49e: 83 c6 01 add $0x1,%esi
4a1: e8 0c fe ff ff call 2b2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4a6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
4aa: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4ad: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4af: 84 db test %bl,%bl
4b1: 75 8d jne 440 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
4b3: 8d 65 f4 lea -0xc(%ebp),%esp
4b6: 5b pop %ebx
4b7: 5e pop %esi
4b8: 5f pop %edi
4b9: 5d pop %ebp
4ba: c3 ret
4bb: 90 nop
4bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
4c0: 83 ec 0c sub $0xc,%esp
4c3: b9 10 00 00 00 mov $0x10,%ecx
4c8: 6a 00 push $0x0
4ca: 8b 5d d0 mov -0x30(%ebp),%ebx
4cd: 89 f8 mov %edi,%eax
4cf: 8b 13 mov (%ebx),%edx
4d1: e8 6a fe ff ff call 340 <printint>
ap++;
4d6: 89 d8 mov %ebx,%eax
4d8: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4db: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
4dd: 83 c0 04 add $0x4,%eax
4e0: 89 45 d0 mov %eax,-0x30(%ebp)
4e3: e9 4d ff ff ff jmp 435 <printf+0x55>
4e8: 90 nop
4e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
4f0: 8b 45 d0 mov -0x30(%ebp),%eax
4f3: 8b 18 mov (%eax),%ebx
ap++;
4f5: 83 c0 04 add $0x4,%eax
4f8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
4fb: b8 68 07 00 00 mov $0x768,%eax
500: 85 db test %ebx,%ebx
502: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
505: 0f b6 03 movzbl (%ebx),%eax
508: 84 c0 test %al,%al
50a: 74 23 je 52f <printf+0x14f>
50c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
510: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
513: 8d 45 e3 lea -0x1d(%ebp),%eax
516: 83 ec 04 sub $0x4,%esp
519: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
51b: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
51e: 50 push %eax
51f: 57 push %edi
520: e8 8d fd ff ff call 2b2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
525: 0f b6 03 movzbl (%ebx),%eax
528: 83 c4 10 add $0x10,%esp
52b: 84 c0 test %al,%al
52d: 75 e1 jne 510 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
52f: 31 d2 xor %edx,%edx
531: e9 ff fe ff ff jmp 435 <printf+0x55>
536: 8d 76 00 lea 0x0(%esi),%esi
539: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
540: 83 ec 04 sub $0x4,%esp
543: 88 5d e5 mov %bl,-0x1b(%ebp)
546: 8d 45 e5 lea -0x1b(%ebp),%eax
549: 6a 01 push $0x1
54b: e9 4c ff ff ff jmp 49c <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
550: 83 ec 0c sub $0xc,%esp
553: b9 0a 00 00 00 mov $0xa,%ecx
558: 6a 01 push $0x1
55a: e9 6b ff ff ff jmp 4ca <printf+0xea>
55f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
562: 83 ec 04 sub $0x4,%esp
565: 8b 03 mov (%ebx),%eax
567: 6a 01 push $0x1
569: 88 45 e4 mov %al,-0x1c(%ebp)
56c: 8d 45 e4 lea -0x1c(%ebp),%eax
56f: 50 push %eax
570: 57 push %edi
571: e8 3c fd ff ff call 2b2 <write>
576: e9 5b ff ff ff jmp 4d6 <printf+0xf6>
57b: 66 90 xchg %ax,%ax
57d: 66 90 xchg %ax,%ax
57f: 90 nop
00000580 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
580: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
581: a1 2c 0a 00 00 mov 0xa2c,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
586: 89 e5 mov %esp,%ebp
588: 57 push %edi
589: 56 push %esi
58a: 53 push %ebx
58b: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
58e: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
590: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
593: 39 c8 cmp %ecx,%eax
595: 73 19 jae 5b0 <free+0x30>
597: 89 f6 mov %esi,%esi
599: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
5a0: 39 d1 cmp %edx,%ecx
5a2: 72 1c jb 5c0 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5a4: 39 d0 cmp %edx,%eax
5a6: 73 18 jae 5c0 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
5a8: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5aa: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5ac: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5ae: 72 f0 jb 5a0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5b0: 39 d0 cmp %edx,%eax
5b2: 72 f4 jb 5a8 <free+0x28>
5b4: 39 d1 cmp %edx,%ecx
5b6: 73 f0 jae 5a8 <free+0x28>
5b8: 90 nop
5b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
5c0: 8b 73 fc mov -0x4(%ebx),%esi
5c3: 8d 3c f1 lea (%ecx,%esi,8),%edi
5c6: 39 d7 cmp %edx,%edi
5c8: 74 19 je 5e3 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
5ca: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
5cd: 8b 50 04 mov 0x4(%eax),%edx
5d0: 8d 34 d0 lea (%eax,%edx,8),%esi
5d3: 39 f1 cmp %esi,%ecx
5d5: 74 23 je 5fa <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
5d7: 89 08 mov %ecx,(%eax)
freep = p;
5d9: a3 2c 0a 00 00 mov %eax,0xa2c
}
5de: 5b pop %ebx
5df: 5e pop %esi
5e0: 5f pop %edi
5e1: 5d pop %ebp
5e2: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
5e3: 03 72 04 add 0x4(%edx),%esi
5e6: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
5e9: 8b 10 mov (%eax),%edx
5eb: 8b 12 mov (%edx),%edx
5ed: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
5f0: 8b 50 04 mov 0x4(%eax),%edx
5f3: 8d 34 d0 lea (%eax,%edx,8),%esi
5f6: 39 f1 cmp %esi,%ecx
5f8: 75 dd jne 5d7 <free+0x57>
p->s.size += bp->s.size;
5fa: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
5fd: a3 2c 0a 00 00 mov %eax,0xa2c
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
602: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
605: 8b 53 f8 mov -0x8(%ebx),%edx
608: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
60a: 5b pop %ebx
60b: 5e pop %esi
60c: 5f pop %edi
60d: 5d pop %ebp
60e: c3 ret
60f: 90 nop
00000610 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
610: 55 push %ebp
611: 89 e5 mov %esp,%ebp
613: 57 push %edi
614: 56 push %esi
615: 53 push %ebx
616: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
619: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
61c: 8b 15 2c 0a 00 00 mov 0xa2c,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
622: 8d 78 07 lea 0x7(%eax),%edi
625: c1 ef 03 shr $0x3,%edi
628: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
62b: 85 d2 test %edx,%edx
62d: 0f 84 a3 00 00 00 je 6d6 <malloc+0xc6>
633: 8b 02 mov (%edx),%eax
635: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
638: 39 cf cmp %ecx,%edi
63a: 76 74 jbe 6b0 <malloc+0xa0>
63c: 81 ff 00 10 00 00 cmp $0x1000,%edi
642: be 00 10 00 00 mov $0x1000,%esi
647: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
64e: 0f 43 f7 cmovae %edi,%esi
651: ba 00 80 00 00 mov $0x8000,%edx
656: 81 ff ff 0f 00 00 cmp $0xfff,%edi
65c: 0f 46 da cmovbe %edx,%ebx
65f: eb 10 jmp 671 <malloc+0x61>
661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
668: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
66a: 8b 48 04 mov 0x4(%eax),%ecx
66d: 39 cf cmp %ecx,%edi
66f: 76 3f jbe 6b0 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
671: 39 05 2c 0a 00 00 cmp %eax,0xa2c
677: 89 c2 mov %eax,%edx
679: 75 ed jne 668 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
67b: 83 ec 0c sub $0xc,%esp
67e: 53 push %ebx
67f: e8 96 fc ff ff call 31a <sbrk>
if(p == (char*)-1)
684: 83 c4 10 add $0x10,%esp
687: 83 f8 ff cmp $0xffffffff,%eax
68a: 74 1c je 6a8 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
68c: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
68f: 83 ec 0c sub $0xc,%esp
692: 83 c0 08 add $0x8,%eax
695: 50 push %eax
696: e8 e5 fe ff ff call 580 <free>
return freep;
69b: 8b 15 2c 0a 00 00 mov 0xa2c,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
6a1: 83 c4 10 add $0x10,%esp
6a4: 85 d2 test %edx,%edx
6a6: 75 c0 jne 668 <malloc+0x58>
return 0;
6a8: 31 c0 xor %eax,%eax
6aa: eb 1c jmp 6c8 <malloc+0xb8>
6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
6b0: 39 cf cmp %ecx,%edi
6b2: 74 1c je 6d0 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
6b4: 29 f9 sub %edi,%ecx
6b6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
6b9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
6bc: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
6bf: 89 15 2c 0a 00 00 mov %edx,0xa2c
return (void*)(p + 1);
6c5: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
6c8: 8d 65 f4 lea -0xc(%ebp),%esp
6cb: 5b pop %ebx
6cc: 5e pop %esi
6cd: 5f pop %edi
6ce: 5d pop %ebp
6cf: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
6d0: 8b 08 mov (%eax),%ecx
6d2: 89 0a mov %ecx,(%edx)
6d4: eb e9 jmp 6bf <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
6d6: c7 05 2c 0a 00 00 30 movl $0xa30,0xa2c
6dd: 0a 00 00
6e0: c7 05 30 0a 00 00 30 movl $0xa30,0xa30
6e7: 0a 00 00
base.s.size = 0;
6ea: b8 30 0a 00 00 mov $0xa30,%eax
6ef: c7 05 34 0a 00 00 00 movl $0x0,0xa34
6f6: 00 00 00
6f9: e9 3e ff ff ff jmp 63c <malloc+0x2c>
|
#pragma once
#include <SFML/Graphics.hpp>
#include "space_object.hpp"
#include "../definitions/celestial_body_definition.hpp"
namespace space
{
class Engine;
class CelestialBody : public SpaceObject
{
public:
// Fields
const CelestialBodyDefinition &celestialBodyDefinition;
// Constructor
CelestialBody(const ObjectId &id, const CelestialBodyDefinition &definition) : SpaceObject(id), celestialBodyDefinition(definition) { }
// Methods
protected:
// Methods
void setTransformFromLocation();
};
} // space |
; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR NIRVANA+ ENGINE - by Einar Saukas
;
; See "nirvana+.h" for further details
; ----------------------------------------------------------------
; void NIRVANA_fillT(unsigned int attr, unsigned int lin, unsigned int col)
; callee
SECTION code_clib
SECTION code_nirvanam
PUBLIC NIRVANAM_fillT_callee
EXTERN asm_NIRVANAM_fillT_di
NIRVANAM_fillT_callee:
pop hl ; RET address
pop de ; col
pop bc
ld d,c ; lin
ex (sp),hl ; attr
ld a,l
jp asm_NIRVANAM_fillT_di
|
SECTION code_driver
SECTION code_driver_tty
PUBLIC asm_tty_param_bbbb_action
EXTERN asm_tty_state_get_4
EXTERN asm_tty_state_param_store
asm_tty_param_bbbb_action:
; c = action code
; stack = & tty.action
; command code has one parameter and action is invoked
ld de,asm_tty_state_get_4
jp asm_tty_state_param_store
|
// Copyright 2015 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/compiler/wasm-compiler.h"
#include <memory>
#include "src/base/optional.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/base/platform/platform.h"
#include "src/base/platform/wrappers.h"
#include "src/base/small-vector.h"
#include "src/base/v8-fallthrough.h"
#include "src/base/vector.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/assembler.h"
#include "src/codegen/code-factory.h"
#include "src/codegen/compiler.h"
#include "src/codegen/interface-descriptors-inl.h"
#include "src/codegen/machine-type.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/compiler/backend/code-generator.h"
#include "src/compiler/backend/instruction-selector.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/diamond.h"
#include "src/compiler/graph-assembler.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/graph.h"
#include "src/compiler/int64-lowering.h"
#include "src/compiler/linkage.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/pipeline.h"
#include "src/compiler/zone-stats.h"
#include "src/execution/isolate-inl.h"
#include "src/heap/factory.h"
#include "src/logging/counters.h"
#include "src/logging/log.h"
#include "src/objects/heap-number.h"
#include "src/roots/roots.h"
#include "src/tracing/trace-event.h"
#include "src/trap-handler/trap-handler.h"
#include "src/wasm/code-space-access.h"
#include "src/wasm/function-body-decoder-impl.h"
#include "src/wasm/function-compiler.h"
#include "src/wasm/graph-builder-interface.h"
#include "src/wasm/jump-table-assembler.h"
#include "src/wasm/memory-tracing.h"
#include "src/wasm/object-access.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-constants.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-linkage.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-opcodes-inl.h"
namespace v8 {
namespace internal {
namespace compiler {
namespace {
#define FATAL_UNSUPPORTED_OPCODE(opcode) \
FATAL("Unsupported opcode 0x%x:%s", (opcode), \
wasm::WasmOpcodes::OpcodeName(opcode));
MachineType assert_size(int expected_size, MachineType type) {
DCHECK_EQ(expected_size, ElementSizeInBytes(type.representation()));
return type;
}
#define WASM_INSTANCE_OBJECT_SIZE(name) \
(WasmInstanceObject::k##name##OffsetEnd - \
WasmInstanceObject::k##name##Offset + 1) // NOLINT(whitespace/indent)
#define LOAD_MUTABLE_INSTANCE_FIELD(name, type) \
gasm_->LoadFromObject( \
assert_size(WASM_INSTANCE_OBJECT_SIZE(name), type), GetInstance(), \
wasm::ObjectAccess::ToTagged(WasmInstanceObject::k##name##Offset))
// TODO(11510): Using LoadImmutable for tagged values causes registers to be
// spilled and added to the safepoint table, resulting in large code size
// regressions. A possible solution would be to not spill the register at all,
// but rather reload the value from memory. This will require non-trivial
// changes in the register allocator and instuction selector.
#define LOAD_INSTANCE_FIELD(name, type) \
(CanBeTaggedOrCompressedPointer((type).representation()) \
? LOAD_MUTABLE_INSTANCE_FIELD(name, type) \
: gasm_->LoadImmutable( \
assert_size(WASM_INSTANCE_OBJECT_SIZE(name), type), \
GetInstance(), \
wasm::ObjectAccess::ToTagged( \
WasmInstanceObject::k##name##Offset)))
#define LOAD_ROOT(root_name, factory_name) \
(parameter_mode_ == kNoSpecialParameterMode \
? graph()->NewNode(mcgraph()->common()->HeapConstant( \
isolate_->factory()->factory_name())) \
: gasm_->LoadImmutable( \
MachineType::Pointer(), BuildLoadIsolateRoot(), \
IsolateData::root_slot_offset(RootIndex::k##root_name)))
bool ContainsSimd(const wasm::FunctionSig* sig) {
for (auto type : sig->all()) {
if (type == wasm::kWasmS128) return true;
}
return false;
}
bool ContainsInt64(const wasm::FunctionSig* sig) {
for (auto type : sig->all()) {
if (type == wasm::kWasmI64) return true;
}
return false;
}
constexpr Builtin WasmRuntimeStubIdToBuiltinName(
wasm::WasmCode::RuntimeStubId runtime_stub_id) {
switch (runtime_stub_id) {
#define DEF_CASE(name) \
case wasm::WasmCode::k##name: \
return Builtin::k##name;
#define DEF_TRAP_CASE(name) DEF_CASE(ThrowWasm##name)
WASM_RUNTIME_STUB_LIST(DEF_CASE, DEF_TRAP_CASE)
#undef DEF_CASE
#undef DEF_TRAP_CASE
default:
UNREACHABLE();
}
}
CallDescriptor* GetBuiltinCallDescriptor(
Builtin name, Zone* zone, StubCallMode stub_mode,
bool needs_frame_state = false,
Operator::Properties properties = Operator::kNoProperties) {
CallInterfaceDescriptor interface_descriptor =
Builtins::CallInterfaceDescriptorFor(name);
return Linkage::GetStubCallDescriptor(
zone, // zone
interface_descriptor, // descriptor
interface_descriptor.GetStackParameterCount(), // stack parameter count
needs_frame_state ? CallDescriptor::kNeedsFrameState
: CallDescriptor::kNoFlags, // flags
properties, // properties
stub_mode); // stub call mode
}
ObjectAccess ObjectAccessForGCStores(wasm::ValueType type) {
return ObjectAccess(
MachineType::TypeForRepresentation(type.machine_representation(),
!type.is_packed()),
type.is_reference() ? kFullWriteBarrier : kNoWriteBarrier);
}
} // namespace
JSWasmCallData::JSWasmCallData(const wasm::FunctionSig* wasm_signature)
: result_needs_conversion_(wasm_signature->return_count() == 1 &&
wasm_signature->GetReturn().kind() ==
wasm::kI64) {
arg_needs_conversion_.resize(wasm_signature->parameter_count());
for (size_t i = 0; i < wasm_signature->parameter_count(); i++) {
wasm::ValueType type = wasm_signature->GetParam(i);
arg_needs_conversion_[i] = type.kind() == wasm::kI64;
}
}
class WasmGraphAssembler : public GraphAssembler {
public:
WasmGraphAssembler(MachineGraph* mcgraph, Zone* zone)
: GraphAssembler(mcgraph, zone), simplified_(zone) {}
template <typename... Args>
Node* CallRuntimeStub(wasm::WasmCode::RuntimeStubId stub_id, Args*... args) {
auto* call_descriptor = GetBuiltinCallDescriptor(
WasmRuntimeStubIdToBuiltinName(stub_id), temp_zone(),
StubCallMode::kCallWasmRuntimeStub);
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
Node* call_target = mcgraph()->RelocatableIntPtrConstant(
stub_id, RelocInfo::WASM_STUB_CALL);
return Call(call_descriptor, call_target, args...);
}
template <typename... Args>
Node* CallBuiltin(Builtin name, Operator::Properties properties,
Args*... args) {
auto* call_descriptor = GetBuiltinCallDescriptor(
name, temp_zone(), StubCallMode::kCallBuiltinPointer, false,
properties);
Node* call_target = GetBuiltinPointerTarget(name);
return Call(call_descriptor, call_target, args...);
}
void MergeControlToEnd(Node* node) {
NodeProperties::MergeControlToEnd(graph(), mcgraph()->common(), node);
}
void AssertFalse(Node* condition) {
#if DEBUG
if (FLAG_debug_code) {
auto ok = MakeLabel();
GotoIfNot(condition, &ok);
Unreachable();
Bind(&ok);
}
#endif
}
Node* GetBuiltinPointerTarget(Builtin builtin) {
static_assert(std::is_same<Smi, BuiltinPtr>(), "BuiltinPtr must be Smi");
return NumberConstant(static_cast<int>(builtin));
}
// Sets {true_node} and {false_node} to their corresponding Branch outputs.
// Returns the Branch node. Does not change control().
Node* Branch(Node* cond, Node** true_node, Node** false_node,
BranchHint hint) {
DCHECK_NOT_NULL(cond);
Node* branch =
graph()->NewNode(mcgraph()->common()->Branch(hint), cond, control());
*true_node = graph()->NewNode(mcgraph()->common()->IfTrue(), branch);
*false_node = graph()->NewNode(mcgraph()->common()->IfFalse(), branch);
return branch;
}
Node* NumberConstant(volatile double value) {
return graph()->NewNode(mcgraph()->common()->NumberConstant(value));
}
// Helper functions for dealing with HeapObjects.
// Rule of thumb: if access to a given field in an object is required in
// at least two places, put a helper function here.
Node* Allocate(int size) {
AllowLargeObjects allow_large = size < kMaxRegularHeapObjectSize
? AllowLargeObjects::kFalse
: AllowLargeObjects::kTrue;
return Allocate(Int32Constant(size), allow_large);
}
Node* Allocate(Node* size,
AllowLargeObjects allow_large = AllowLargeObjects::kTrue) {
return AddNode(
graph()->NewNode(simplified_.AllocateRaw(
Type::Any(), AllocationType::kYoung, allow_large),
size, effect(), control()));
}
Node* LoadFromObject(MachineType type, Node* base, Node* offset) {
return AddNode(graph()->NewNode(
simplified_.LoadFromObject(ObjectAccess(type, kNoWriteBarrier)), base,
offset, effect(), control()));
}
Node* LoadFromObject(MachineType type, Node* base, int offset) {
return LoadFromObject(type, base, IntPtrConstant(offset));
}
Node* LoadImmutable(LoadRepresentation rep, Node* base, Node* offset) {
return AddNode(graph()->NewNode(mcgraph()->machine()->LoadImmutable(rep),
base, offset));
}
Node* LoadImmutable(LoadRepresentation rep, Node* base, int offset) {
return LoadImmutable(rep, base, IntPtrConstant(offset));
}
Node* StoreToObject(ObjectAccess access, Node* base, Node* offset,
Node* value) {
return AddNode(graph()->NewNode(simplified_.StoreToObject(access), base,
offset, value, effect(), control()));
}
Node* StoreToObject(ObjectAccess access, Node* base, int offset,
Node* value) {
return StoreToObject(access, base, IntPtrConstant(offset), value);
}
Node* IsI31(Node* object) {
if (COMPRESS_POINTERS_BOOL) {
return Word32Equal(Word32And(object, Int32Constant(kSmiTagMask)),
Int32Constant(kSmiTag));
} else {
return WordEqual(WordAnd(object, IntPtrConstant(kSmiTagMask)),
IntPtrConstant(kSmiTag));
}
}
// Maps and their contents.
Node* LoadMap(Node* object) {
Node* map_word = LoadFromObject(MachineType::TaggedPointer(), object,
HeapObject::kMapOffset - kHeapObjectTag);
#ifdef V8_MAP_PACKING
return UnpackMapWord(map_word);
#else
return map_word;
#endif
}
void StoreMap(Node* heap_object, Node* map) {
ObjectAccess access(MachineType::TaggedPointer(), kMapWriteBarrier);
#ifdef V8_MAP_PACKING
map = PackMapWord(map);
#endif
StoreToObject(access, heap_object, HeapObject::kMapOffset - kHeapObjectTag,
map);
}
Node* LoadInstanceType(Node* map) {
return LoadFromObject(
MachineType::Uint16(), map,
wasm::ObjectAccess::ToTagged(Map::kInstanceTypeOffset));
}
Node* LoadWasmTypeInfo(Node* map) {
int offset = Map::kConstructorOrBackPointerOrNativeContextOffset;
return LoadFromObject(MachineType::TaggedPointer(), map,
wasm::ObjectAccess::ToTagged(offset));
}
Node* LoadSupertypes(Node* wasm_type_info) {
return LoadFromObject(
MachineType::TaggedPointer(), wasm_type_info,
wasm::ObjectAccess::ToTagged(WasmTypeInfo::kSupertypesOffset));
}
// FixedArrays.
Node* LoadFixedArrayLengthAsSmi(Node* fixed_array) {
return LoadFromObject(
MachineType::TaggedSigned(), fixed_array,
wasm::ObjectAccess::ToTagged(FixedArray::kLengthOffset));
}
Node* LoadFixedArrayElement(Node* fixed_array, Node* index_intptr,
MachineType type = MachineType::AnyTagged()) {
Node* offset = IntAdd(
IntMul(index_intptr, IntPtrConstant(kTaggedSize)),
IntPtrConstant(wasm::ObjectAccess::ToTagged(FixedArray::kHeaderSize)));
return LoadFromObject(type, fixed_array, offset);
}
Node* LoadFixedArrayElement(Node* array, int index, MachineType type) {
return LoadFromObject(
type, array,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(index));
}
Node* LoadFixedArrayElementSmi(Node* array, int index) {
return LoadFixedArrayElement(array, index, MachineType::TaggedSigned());
}
Node* LoadFixedArrayElementPtr(Node* array, int index) {
return LoadFixedArrayElement(array, index, MachineType::TaggedPointer());
}
Node* LoadFixedArrayElementAny(Node* array, int index) {
return LoadFixedArrayElement(array, index, MachineType::AnyTagged());
}
Node* StoreFixedArrayElement(Node* array, int index, Node* value,
ObjectAccess access) {
return StoreToObject(
access, array,
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(index), value);
}
Node* StoreFixedArrayElementSmi(Node* array, int index, Node* value) {
return StoreFixedArrayElement(
array, index, value,
ObjectAccess(MachineType::TaggedSigned(), kNoWriteBarrier));
}
Node* StoreFixedArrayElementAny(Node* array, int index, Node* value) {
return StoreFixedArrayElement(
array, index, value,
ObjectAccess(MachineType::AnyTagged(), kFullWriteBarrier));
}
// Functions, SharedFunctionInfos, FunctionData.
Node* LoadSharedFunctionInfo(Node* js_function) {
return LoadFromObject(
MachineType::TaggedPointer(), js_function,
wasm::ObjectAccess::SharedFunctionInfoOffsetInTaggedJSFunction());
}
Node* LoadContextFromJSFunction(Node* js_function) {
return LoadFromObject(
MachineType::TaggedPointer(), js_function,
wasm::ObjectAccess::ContextOffsetInTaggedJSFunction());
}
Node* LoadFunctionDataFromJSFunction(Node* js_function) {
Node* shared = LoadSharedFunctionInfo(js_function);
return LoadFromObject(
MachineType::TaggedPointer(), shared,
wasm::ObjectAccess::ToTagged(SharedFunctionInfo::kFunctionDataOffset));
}
Node* LoadExportedFunctionIndexAsSmi(Node* exported_function_data) {
return LoadFromObject(MachineType::TaggedSigned(), exported_function_data,
wasm::ObjectAccess::ToTagged(
WasmExportedFunctionData::kFunctionIndexOffset));
}
Node* LoadExportedFunctionInstance(Node* exported_function_data) {
return LoadFromObject(MachineType::TaggedPointer(), exported_function_data,
wasm::ObjectAccess::ToTagged(
WasmExportedFunctionData::kInstanceOffset));
}
// JavaScript objects.
Node* LoadJSArrayElements(Node* js_array) {
return LoadFromObject(
MachineType::AnyTagged(), js_array,
wasm::ObjectAccess::ToTagged(JSObject::kElementsOffset));
}
// WasmGC objects.
Node* FieldOffset(const wasm::StructType* type, uint32_t field_index) {
return IntPtrConstant(wasm::ObjectAccess::ToTagged(
WasmStruct::kHeaderSize + type->field_offset(field_index)));
}
Node* StoreStructField(Node* struct_object, const wasm::StructType* type,
uint32_t field_index, Node* value) {
return StoreToObject(ObjectAccessForGCStores(type->field(field_index)),
struct_object, FieldOffset(type, field_index), value);
}
Node* WasmArrayElementOffset(Node* index, wasm::ValueType element_type) {
Node* index_intptr =
mcgraph()->machine()->Is64() ? ChangeInt32ToInt64(index) : index;
return IntAdd(
IntPtrConstant(wasm::ObjectAccess::ToTagged(WasmArray::kHeaderSize)),
IntMul(index_intptr,
IntPtrConstant(element_type.element_size_bytes())));
}
Node* LoadWasmArrayLength(Node* array) {
return LoadFromObject(
MachineType::Uint32(), array,
wasm::ObjectAccess::ToTagged(WasmArray::kLengthOffset));
}
Node* IsDataRefMap(Node* map) {
Node* instance_type = LoadInstanceType(map);
// We're going to test a range of WasmObject instance types with a single
// unsigned comparison.
Node* comparison_value =
Int32Sub(instance_type, Int32Constant(FIRST_WASM_OBJECT_TYPE));
return Uint32LessThanOrEqual(
comparison_value,
Int32Constant(LAST_WASM_OBJECT_TYPE - FIRST_WASM_OBJECT_TYPE));
}
// Generic HeapObject helpers.
Node* HasInstanceType(Node* heap_object, InstanceType type) {
Node* map = LoadMap(heap_object);
Node* instance_type = LoadInstanceType(map);
return Word32Equal(instance_type, Int32Constant(type));
}
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
private:
SimplifiedOperatorBuilder simplified_;
};
WasmGraphBuilder::WasmGraphBuilder(
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* source_position_table,
Parameter0Mode parameter_mode, Isolate* isolate)
: gasm_(std::make_unique<WasmGraphAssembler>(mcgraph, zone)),
zone_(zone),
mcgraph_(mcgraph),
env_(env),
has_simd_(ContainsSimd(sig)),
sig_(sig),
source_position_table_(source_position_table),
parameter_mode_(parameter_mode),
isolate_(isolate) {
DCHECK_EQ(isolate == nullptr, parameter_mode_ != kNoSpecialParameterMode);
DCHECK_IMPLIES(env && env->bounds_checks == wasm::kTrapHandler,
trap_handler::IsTrapHandlerEnabled());
DCHECK_NOT_NULL(mcgraph_);
}
// Destructor define here where the definition of {WasmGraphAssembler} is
// available.
WasmGraphBuilder::~WasmGraphBuilder() = default;
void WasmGraphBuilder::Start(unsigned params) {
Node* start = graph()->NewNode(mcgraph()->common()->Start(params));
graph()->SetStart(start);
SetEffectControl(start);
// Initialize parameter nodes.
parameters_ = zone_->NewArray<Node*>(params);
for (unsigned i = 0; i < params; i++) {
parameters_[i] = nullptr;
}
// Initialize instance node.
switch (parameter_mode_) {
case kInstanceMode:
instance_node_ = Param(wasm::kWasmInstanceParameterIndex);
break;
case kNoSpecialParameterMode:
instance_node_ = gasm_->LoadExportedFunctionInstance(
gasm_->LoadFunctionDataFromJSFunction(
Param(Linkage::kJSCallClosureParamIndex, "%closure")));
break;
case kWasmApiFunctionRefMode:
// We need an instance node anyway, because FromJS() needs to pass it to
// the WasmIsValidRefValue runtime function.
instance_node_ = UndefinedValue();
break;
}
graph()->SetEnd(graph()->NewNode(mcgraph()->common()->End(0)));
}
Node* WasmGraphBuilder::Param(int index, const char* debug_name) {
DCHECK_NOT_NULL(graph()->start());
// Turbofan allows negative parameter indices.
static constexpr int kMinParameterIndex = -1;
DCHECK_GE(index, kMinParameterIndex);
int array_index = index - kMinParameterIndex;
if (parameters_[array_index] == nullptr) {
parameters_[array_index] = graph()->NewNode(
mcgraph()->common()->Parameter(index, debug_name), graph()->start());
}
return parameters_[array_index];
}
Node* WasmGraphBuilder::Loop(Node* entry) {
return graph()->NewNode(mcgraph()->common()->Loop(1), entry);
}
void WasmGraphBuilder::TerminateLoop(Node* effect, Node* control) {
Node* terminate =
graph()->NewNode(mcgraph()->common()->Terminate(), effect, control);
gasm_->MergeControlToEnd(terminate);
}
Node* WasmGraphBuilder::LoopExit(Node* loop_node) {
DCHECK(loop_node->opcode() == IrOpcode::kLoop);
Node* loop_exit =
graph()->NewNode(mcgraph()->common()->LoopExit(), control(), loop_node);
Node* loop_exit_effect = graph()->NewNode(
mcgraph()->common()->LoopExitEffect(), effect(), loop_exit);
SetEffectControl(loop_exit_effect, loop_exit);
return loop_exit;
}
Node* WasmGraphBuilder::LoopExitValue(Node* value,
MachineRepresentation representation) {
DCHECK(control()->opcode() == IrOpcode::kLoopExit);
return graph()->NewNode(mcgraph()->common()->LoopExitValue(representation),
value, control());
}
void WasmGraphBuilder::TerminateThrow(Node* effect, Node* control) {
Node* terminate =
graph()->NewNode(mcgraph()->common()->Throw(), effect, control);
gasm_->MergeControlToEnd(terminate);
}
bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) {
return phi && IrOpcode::IsPhiOpcode(phi->opcode()) &&
NodeProperties::GetControlInput(phi) == merge;
}
bool WasmGraphBuilder::ThrowsException(Node* node, Node** if_success,
Node** if_exception) {
if (node->op()->HasProperty(compiler::Operator::kNoThrow)) {
return false;
}
*if_success = graph()->NewNode(mcgraph()->common()->IfSuccess(), node);
*if_exception =
graph()->NewNode(mcgraph()->common()->IfException(), node, node);
return true;
}
void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) {
DCHECK(IrOpcode::IsMergeOpcode(merge->opcode()));
merge->AppendInput(mcgraph()->zone(), from);
int new_size = merge->InputCount();
NodeProperties::ChangeOp(
merge, mcgraph()->common()->ResizeMergeOrPhi(merge->op(), new_size));
}
void WasmGraphBuilder::AppendToPhi(Node* phi, Node* from) {
DCHECK(IrOpcode::IsPhiOpcode(phi->opcode()));
int new_size = phi->InputCount();
phi->InsertInput(mcgraph()->zone(), phi->InputCount() - 1, from);
NodeProperties::ChangeOp(
phi, mcgraph()->common()->ResizeMergeOrPhi(phi->op(), new_size));
}
template <typename... Nodes>
Node* WasmGraphBuilder::Merge(Node* fst, Nodes*... args) {
return graph()->NewNode(this->mcgraph()->common()->Merge(1 + sizeof...(args)),
fst, args...);
}
Node* WasmGraphBuilder::Merge(unsigned count, Node** controls) {
return graph()->NewNode(mcgraph()->common()->Merge(count), count, controls);
}
Node* WasmGraphBuilder::Phi(wasm::ValueType type, unsigned count,
Node** vals_and_control) {
DCHECK(IrOpcode::IsMergeOpcode(vals_and_control[count]->opcode()));
DCHECK_EQ(vals_and_control[count]->op()->ControlInputCount(), count);
return graph()->NewNode(
mcgraph()->common()->Phi(type.machine_representation(), count), count + 1,
vals_and_control);
}
Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects_and_control) {
DCHECK(IrOpcode::IsMergeOpcode(effects_and_control[count]->opcode()));
return graph()->NewNode(mcgraph()->common()->EffectPhi(count), count + 1,
effects_and_control);
}
Node* WasmGraphBuilder::RefNull() { return LOAD_ROOT(NullValue, null_value); }
Node* WasmGraphBuilder::RefFunc(uint32_t function_index) {
return gasm_->CallRuntimeStub(wasm::WasmCode::kWasmRefFunc,
gasm_->Uint32Constant(function_index));
}
Node* WasmGraphBuilder::RefAsNonNull(Node* arg,
wasm::WasmCodePosition position) {
if (!FLAG_experimental_wasm_skip_null_checks) {
TrapIfTrue(wasm::kTrapIllegalCast, gasm_->WordEqual(arg, RefNull()),
position);
}
return arg;
}
Node* WasmGraphBuilder::NoContextConstant() {
return mcgraph()->IntPtrConstant(0);
}
Node* WasmGraphBuilder::GetInstance() { return instance_node_.get(); }
Node* WasmGraphBuilder::BuildLoadIsolateRoot() {
switch (parameter_mode_) {
case kInstanceMode:
// For wasm functions, the IsolateRoot is loaded from the instance node so
// that the generated code is Isolate independent.
return LOAD_INSTANCE_FIELD(IsolateRoot, MachineType::Pointer());
case kWasmApiFunctionRefMode:
// Note: Even if V8_HEAP_SANDBOX, the pointer to the isolate root is not
// encoded, much like the case above. TODO(manoskouk): Decode the pointer
// here if that changes.
return gasm_->Load(
MachineType::Pointer(), Param(0),
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kIsolateRootOffset));
case kNoSpecialParameterMode:
return mcgraph()->IntPtrConstant(isolate_->isolate_root());
}
}
Node* WasmGraphBuilder::Int32Constant(int32_t value) {
return mcgraph()->Int32Constant(value);
}
Node* WasmGraphBuilder::Int64Constant(int64_t value) {
return mcgraph()->Int64Constant(value);
}
Node* WasmGraphBuilder::UndefinedValue() {
return LOAD_ROOT(UndefinedValue, undefined_value);
}
void WasmGraphBuilder::StackCheck(wasm::WasmCodePosition position) {
DCHECK_NOT_NULL(env_); // Wrappers don't get stack checks.
if (!FLAG_wasm_stack_checks || !env_->runtime_exception_support) {
return;
}
Node* limit_address =
LOAD_INSTANCE_FIELD(StackLimitAddress, MachineType::Pointer());
Node* limit = gasm_->LoadFromObject(MachineType::Pointer(), limit_address, 0);
Node* check = SetEffect(graph()->NewNode(
mcgraph()->machine()->StackPointerGreaterThan(StackCheckKind::kWasm),
limit, effect()));
Node* if_true;
Node* if_false;
gasm_->Branch(check, &if_true, &if_false, BranchHint::kTrue);
if (stack_check_call_operator_ == nullptr) {
// Build and cache the stack check call operator and the constant
// representing the stack check code.
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
stack_check_code_node_.set(mcgraph()->RelocatableIntPtrConstant(
wasm::WasmCode::kWasmStackGuard, RelocInfo::WASM_STUB_CALL));
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), // zone
NoContextDescriptor{}, // descriptor
0, // stack parameter count
CallDescriptor::kNoFlags, // flags
Operator::kNoProperties, // properties
StubCallMode::kCallWasmRuntimeStub); // stub call mode
stack_check_call_operator_ = mcgraph()->common()->Call(call_descriptor);
}
Node* call =
graph()->NewNode(stack_check_call_operator_.get(),
stack_check_code_node_.get(), effect(), if_false);
SetSourcePosition(call, position);
DCHECK_GT(call->op()->ControlOutputCount(), 0);
Node* merge = graph()->NewNode(mcgraph()->common()->Merge(2), if_true, call);
DCHECK_GT(call->op()->EffectOutputCount(), 0);
Node* ephi = graph()->NewNode(mcgraph()->common()->EffectPhi(2), effect(),
call, merge);
SetEffectControl(ephi, merge);
}
void WasmGraphBuilder::PatchInStackCheckIfNeeded() {
if (!needs_stack_check_) return;
Node* start = graph()->start();
// Place a stack check which uses a dummy node as control and effect.
Node* dummy = graph()->NewNode(mcgraph()->common()->Dead());
SetEffectControl(dummy);
// The function-prologue stack check is associated with position 0, which
// is never a position of any instruction in the function.
StackCheck(0);
// In testing, no steck checks were emitted. Nothing to rewire then.
if (effect() == dummy) return;
// Now patch all control uses of {start} to use {control} and all effect uses
// to use {effect} instead. We exclude Projection nodes: Projections pointing
// to start are floating control, and we want it to point directly to start
// because of restrictions later in the pipeline (specifically, loop
// unrolling).
// Then rewire the dummy node to use start instead.
NodeProperties::ReplaceUses(start, start, effect(), control());
{
// We need an intermediate vector because we are not allowed to modify a use
// while traversing uses().
std::vector<Node*> projections;
for (Node* use : control()->uses()) {
if (use->opcode() == IrOpcode::kProjection) projections.emplace_back(use);
}
for (Node* use : projections) {
use->ReplaceInput(NodeProperties::FirstControlIndex(use), start);
}
}
NodeProperties::ReplaceUses(dummy, nullptr, start, start);
}
Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
wasm::WasmCodePosition position) {
const Operator* op;
MachineOperatorBuilder* m = mcgraph()->machine();
switch (opcode) {
case wasm::kExprI32Add:
op = m->Int32Add();
break;
case wasm::kExprI32Sub:
op = m->Int32Sub();
break;
case wasm::kExprI32Mul:
op = m->Int32Mul();
break;
case wasm::kExprI32DivS:
return BuildI32DivS(left, right, position);
case wasm::kExprI32DivU:
return BuildI32DivU(left, right, position);
case wasm::kExprI32RemS:
return BuildI32RemS(left, right, position);
case wasm::kExprI32RemU:
return BuildI32RemU(left, right, position);
case wasm::kExprI32And:
op = m->Word32And();
break;
case wasm::kExprI32Ior:
op = m->Word32Or();
break;
case wasm::kExprI32Xor:
op = m->Word32Xor();
break;
case wasm::kExprI32Shl:
op = m->Word32Shl();
right = MaskShiftCount32(right);
break;
case wasm::kExprI32ShrU:
op = m->Word32Shr();
right = MaskShiftCount32(right);
break;
case wasm::kExprI32ShrS:
op = m->Word32Sar();
right = MaskShiftCount32(right);
break;
case wasm::kExprI32Ror:
op = m->Word32Ror();
right = MaskShiftCount32(right);
break;
case wasm::kExprI32Rol:
if (m->Word32Rol().IsSupported()) {
op = m->Word32Rol().op();
right = MaskShiftCount32(right);
break;
}
return BuildI32Rol(left, right);
case wasm::kExprI32Eq:
op = m->Word32Equal();
break;
case wasm::kExprI32Ne:
return Invert(Binop(wasm::kExprI32Eq, left, right));
case wasm::kExprI32LtS:
op = m->Int32LessThan();
break;
case wasm::kExprI32LeS:
op = m->Int32LessThanOrEqual();
break;
case wasm::kExprI32LtU:
op = m->Uint32LessThan();
break;
case wasm::kExprI32LeU:
op = m->Uint32LessThanOrEqual();
break;
case wasm::kExprI32GtS:
op = m->Int32LessThan();
std::swap(left, right);
break;
case wasm::kExprI32GeS:
op = m->Int32LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprI32GtU:
op = m->Uint32LessThan();
std::swap(left, right);
break;
case wasm::kExprI32GeU:
op = m->Uint32LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprI64And:
op = m->Word64And();
break;
case wasm::kExprI64Add:
op = m->Int64Add();
break;
case wasm::kExprI64Sub:
op = m->Int64Sub();
break;
case wasm::kExprI64Mul:
op = m->Int64Mul();
break;
case wasm::kExprI64DivS:
return BuildI64DivS(left, right, position);
case wasm::kExprI64DivU:
return BuildI64DivU(left, right, position);
case wasm::kExprI64RemS:
return BuildI64RemS(left, right, position);
case wasm::kExprI64RemU:
return BuildI64RemU(left, right, position);
case wasm::kExprI64Ior:
op = m->Word64Or();
break;
case wasm::kExprI64Xor:
op = m->Word64Xor();
break;
case wasm::kExprI64Shl:
op = m->Word64Shl();
right = MaskShiftCount64(right);
break;
case wasm::kExprI64ShrU:
op = m->Word64Shr();
right = MaskShiftCount64(right);
break;
case wasm::kExprI64ShrS:
op = m->Word64Sar();
right = MaskShiftCount64(right);
break;
case wasm::kExprI64Eq:
op = m->Word64Equal();
break;
case wasm::kExprI64Ne:
return Invert(Binop(wasm::kExprI64Eq, left, right));
case wasm::kExprI64LtS:
op = m->Int64LessThan();
break;
case wasm::kExprI64LeS:
op = m->Int64LessThanOrEqual();
break;
case wasm::kExprI64LtU:
op = m->Uint64LessThan();
break;
case wasm::kExprI64LeU:
op = m->Uint64LessThanOrEqual();
break;
case wasm::kExprI64GtS:
op = m->Int64LessThan();
std::swap(left, right);
break;
case wasm::kExprI64GeS:
op = m->Int64LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprI64GtU:
op = m->Uint64LessThan();
std::swap(left, right);
break;
case wasm::kExprI64GeU:
op = m->Uint64LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprI64Ror:
right = MaskShiftCount64(right);
return m->Is64() ? graph()->NewNode(m->Word64Ror(), left, right)
: graph()->NewNode(m->Word64RorLowerable(), left, right,
control());
case wasm::kExprI64Rol:
if (m->Word64Rol().IsSupported()) {
return m->Is64() ? graph()->NewNode(m->Word64Rol().op(), left,
MaskShiftCount64(right))
: graph()->NewNode(m->Word64RolLowerable().op(), left,
MaskShiftCount64(right), control());
} else if (m->Word32Rol().IsSupported()) {
return graph()->NewNode(m->Word64RolLowerable().placeholder(), left,
right, control());
}
return BuildI64Rol(left, right);
case wasm::kExprF32CopySign:
return BuildF32CopySign(left, right);
case wasm::kExprF64CopySign:
return BuildF64CopySign(left, right);
case wasm::kExprF32Add:
op = m->Float32Add();
break;
case wasm::kExprF32Sub:
op = m->Float32Sub();
break;
case wasm::kExprF32Mul:
op = m->Float32Mul();
break;
case wasm::kExprF32Div:
op = m->Float32Div();
break;
case wasm::kExprF32Eq:
op = m->Float32Equal();
break;
case wasm::kExprF32Ne:
return Invert(Binop(wasm::kExprF32Eq, left, right));
case wasm::kExprF32Lt:
op = m->Float32LessThan();
break;
case wasm::kExprF32Ge:
op = m->Float32LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprF32Gt:
op = m->Float32LessThan();
std::swap(left, right);
break;
case wasm::kExprF32Le:
op = m->Float32LessThanOrEqual();
break;
case wasm::kExprF64Add:
op = m->Float64Add();
break;
case wasm::kExprF64Sub:
op = m->Float64Sub();
break;
case wasm::kExprF64Mul:
op = m->Float64Mul();
break;
case wasm::kExprF64Div:
op = m->Float64Div();
break;
case wasm::kExprF64Eq:
op = m->Float64Equal();
break;
case wasm::kExprF64Ne:
return Invert(Binop(wasm::kExprF64Eq, left, right));
case wasm::kExprF64Lt:
op = m->Float64LessThan();
break;
case wasm::kExprF64Le:
op = m->Float64LessThanOrEqual();
break;
case wasm::kExprF64Gt:
op = m->Float64LessThan();
std::swap(left, right);
break;
case wasm::kExprF64Ge:
op = m->Float64LessThanOrEqual();
std::swap(left, right);
break;
case wasm::kExprF32Min:
op = m->Float32Min();
break;
case wasm::kExprF64Min:
op = m->Float64Min();
break;
case wasm::kExprF32Max:
op = m->Float32Max();
break;
case wasm::kExprF64Max:
op = m->Float64Max();
break;
case wasm::kExprF64Pow:
return BuildF64Pow(left, right);
case wasm::kExprF64Atan2:
op = m->Float64Atan2();
break;
case wasm::kExprF64Mod:
return BuildF64Mod(left, right);
case wasm::kExprRefEq:
return gasm_->TaggedEqual(left, right);
case wasm::kExprI32AsmjsDivS:
return BuildI32AsmjsDivS(left, right);
case wasm::kExprI32AsmjsDivU:
return BuildI32AsmjsDivU(left, right);
case wasm::kExprI32AsmjsRemS:
return BuildI32AsmjsRemS(left, right);
case wasm::kExprI32AsmjsRemU:
return BuildI32AsmjsRemU(left, right);
case wasm::kExprI32AsmjsStoreMem8:
return BuildAsmjsStoreMem(MachineType::Int8(), left, right);
case wasm::kExprI32AsmjsStoreMem16:
return BuildAsmjsStoreMem(MachineType::Int16(), left, right);
case wasm::kExprI32AsmjsStoreMem:
return BuildAsmjsStoreMem(MachineType::Int32(), left, right);
case wasm::kExprF32AsmjsStoreMem:
return BuildAsmjsStoreMem(MachineType::Float32(), left, right);
case wasm::kExprF64AsmjsStoreMem:
return BuildAsmjsStoreMem(MachineType::Float64(), left, right);
default:
FATAL_UNSUPPORTED_OPCODE(opcode);
}
return graph()->NewNode(op, left, right);
}
Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
wasm::WasmCodePosition position) {
const Operator* op;
MachineOperatorBuilder* m = mcgraph()->machine();
switch (opcode) {
case wasm::kExprI32Eqz:
return gasm_->Word32Equal(input, Int32Constant(0));
case wasm::kExprF32Abs:
op = m->Float32Abs();
break;
case wasm::kExprF32Neg: {
op = m->Float32Neg();
break;
}
case wasm::kExprF32Sqrt:
op = m->Float32Sqrt();
break;
case wasm::kExprF64Abs:
op = m->Float64Abs();
break;
case wasm::kExprF64Neg: {
op = m->Float64Neg();
break;
}
case wasm::kExprF64Sqrt:
op = m->Float64Sqrt();
break;
case wasm::kExprI32SConvertF32:
case wasm::kExprI32UConvertF32:
case wasm::kExprI32SConvertF64:
case wasm::kExprI32UConvertF64:
case wasm::kExprI32SConvertSatF64:
case wasm::kExprI32UConvertSatF64:
case wasm::kExprI32SConvertSatF32:
case wasm::kExprI32UConvertSatF32:
return BuildIntConvertFloat(input, position, opcode);
case wasm::kExprI32AsmjsSConvertF64:
return BuildI32AsmjsSConvertF64(input);
case wasm::kExprI32AsmjsUConvertF64:
return BuildI32AsmjsUConvertF64(input);
case wasm::kExprF32ConvertF64:
op = m->TruncateFloat64ToFloat32();
break;
case wasm::kExprF64SConvertI32:
op = m->ChangeInt32ToFloat64();
break;
case wasm::kExprF64UConvertI32:
op = m->ChangeUint32ToFloat64();
break;
case wasm::kExprF32SConvertI32:
op = m->RoundInt32ToFloat32();
break;
case wasm::kExprF32UConvertI32:
op = m->RoundUint32ToFloat32();
break;
case wasm::kExprI32AsmjsSConvertF32:
return BuildI32AsmjsSConvertF32(input);
case wasm::kExprI32AsmjsUConvertF32:
return BuildI32AsmjsUConvertF32(input);
case wasm::kExprF64ConvertF32:
op = m->ChangeFloat32ToFloat64();
break;
case wasm::kExprF32ReinterpretI32:
op = m->BitcastInt32ToFloat32();
break;
case wasm::kExprI32ReinterpretF32:
op = m->BitcastFloat32ToInt32();
break;
case wasm::kExprI32Clz:
op = m->Word32Clz();
break;
case wasm::kExprI32Ctz: {
if (m->Word32Ctz().IsSupported()) {
op = m->Word32Ctz().op();
break;
} else if (m->Word32ReverseBits().IsSupported()) {
Node* reversed = graph()->NewNode(m->Word32ReverseBits().op(), input);
Node* result = graph()->NewNode(m->Word32Clz(), reversed);
return result;
} else {
return BuildI32Ctz(input);
}
}
case wasm::kExprI32Popcnt: {
if (m->Word32Popcnt().IsSupported()) {
op = m->Word32Popcnt().op();
break;
} else {
return BuildI32Popcnt(input);
}
}
case wasm::kExprF32Floor: {
if (!m->Float32RoundDown().IsSupported()) return BuildF32Floor(input);
op = m->Float32RoundDown().op();
break;
}
case wasm::kExprF32Ceil: {
if (!m->Float32RoundUp().IsSupported()) return BuildF32Ceil(input);
op = m->Float32RoundUp().op();
break;
}
case wasm::kExprF32Trunc: {
if (!m->Float32RoundTruncate().IsSupported()) return BuildF32Trunc(input);
op = m->Float32RoundTruncate().op();
break;
}
case wasm::kExprF32NearestInt: {
if (!m->Float32RoundTiesEven().IsSupported())
return BuildF32NearestInt(input);
op = m->Float32RoundTiesEven().op();
break;
}
case wasm::kExprF64Floor: {
if (!m->Float64RoundDown().IsSupported()) return BuildF64Floor(input);
op = m->Float64RoundDown().op();
break;
}
case wasm::kExprF64Ceil: {
if (!m->Float64RoundUp().IsSupported()) return BuildF64Ceil(input);
op = m->Float64RoundUp().op();
break;
}
case wasm::kExprF64Trunc: {
if (!m->Float64RoundTruncate().IsSupported()) return BuildF64Trunc(input);
op = m->Float64RoundTruncate().op();
break;
}
case wasm::kExprF64NearestInt: {
if (!m->Float64RoundTiesEven().IsSupported())
return BuildF64NearestInt(input);
op = m->Float64RoundTiesEven().op();
break;
}
case wasm::kExprF64Acos: {
return BuildF64Acos(input);
}
case wasm::kExprF64Asin: {
return BuildF64Asin(input);
}
case wasm::kExprF64Atan:
op = m->Float64Atan();
break;
case wasm::kExprF64Cos: {
op = m->Float64Cos();
break;
}
case wasm::kExprF64Sin: {
op = m->Float64Sin();
break;
}
case wasm::kExprF64Tan: {
op = m->Float64Tan();
break;
}
case wasm::kExprF64Exp: {
op = m->Float64Exp();
break;
}
case wasm::kExprF64Log:
op = m->Float64Log();
break;
case wasm::kExprI32ConvertI64:
op = m->TruncateInt64ToInt32();
break;
case wasm::kExprI64SConvertI32:
op = m->ChangeInt32ToInt64();
break;
case wasm::kExprI64UConvertI32:
op = m->ChangeUint32ToUint64();
break;
case wasm::kExprF64ReinterpretI64:
op = m->BitcastInt64ToFloat64();
break;
case wasm::kExprI64ReinterpretF64:
op = m->BitcastFloat64ToInt64();
break;
case wasm::kExprI64Clz:
return m->Is64()
? graph()->NewNode(m->Word64Clz(), input)
: graph()->NewNode(m->Word64ClzLowerable(), input, control());
case wasm::kExprI64Ctz: {
if (m->Word64Ctz().IsSupported()) {
return m->Is64() ? graph()->NewNode(m->Word64Ctz().op(), input)
: graph()->NewNode(m->Word64CtzLowerable().op(), input,
control());
} else if (m->Is32() && m->Word32Ctz().IsSupported()) {
return graph()->NewNode(m->Word64CtzLowerable().placeholder(), input,
control());
} else if (m->Word64ReverseBits().IsSupported()) {
Node* reversed = graph()->NewNode(m->Word64ReverseBits().op(), input);
Node* result = m->Is64() ? graph()->NewNode(m->Word64Clz(), reversed)
: graph()->NewNode(m->Word64ClzLowerable(),
reversed, control());
return result;
} else {
return BuildI64Ctz(input);
}
}
case wasm::kExprI64Popcnt: {
OptionalOperator popcnt64 = m->Word64Popcnt();
if (popcnt64.IsSupported()) {
op = popcnt64.op();
} else if (m->Is32() && m->Word32Popcnt().IsSupported()) {
op = popcnt64.placeholder();
} else {
return BuildI64Popcnt(input);
}
break;
}
case wasm::kExprI64Eqz:
return gasm_->Word64Equal(input, Int64Constant(0));
case wasm::kExprF32SConvertI64:
if (m->Is32()) {
return BuildF32SConvertI64(input);
}
op = m->RoundInt64ToFloat32();
break;
case wasm::kExprF32UConvertI64:
if (m->Is32()) {
return BuildF32UConvertI64(input);
}
op = m->RoundUint64ToFloat32();
break;
case wasm::kExprF64SConvertI64:
if (m->Is32()) {
return BuildF64SConvertI64(input);
}
op = m->RoundInt64ToFloat64();
break;
case wasm::kExprF64UConvertI64:
if (m->Is32()) {
return BuildF64UConvertI64(input);
}
op = m->RoundUint64ToFloat64();
break;
case wasm::kExprI32SExtendI8:
op = m->SignExtendWord8ToInt32();
break;
case wasm::kExprI32SExtendI16:
op = m->SignExtendWord16ToInt32();
break;
case wasm::kExprI64SExtendI8:
op = m->SignExtendWord8ToInt64();
break;
case wasm::kExprI64SExtendI16:
op = m->SignExtendWord16ToInt64();
break;
case wasm::kExprI64SExtendI32:
op = m->SignExtendWord32ToInt64();
break;
case wasm::kExprI64SConvertF32:
case wasm::kExprI64UConvertF32:
case wasm::kExprI64SConvertF64:
case wasm::kExprI64UConvertF64:
case wasm::kExprI64SConvertSatF32:
case wasm::kExprI64UConvertSatF32:
case wasm::kExprI64SConvertSatF64:
case wasm::kExprI64UConvertSatF64:
return mcgraph()->machine()->Is32()
? BuildCcallConvertFloat(input, position, opcode)
: BuildIntConvertFloat(input, position, opcode);
case wasm::kExprRefIsNull:
return gasm_->WordEqual(input, RefNull());
case wasm::kExprI32AsmjsLoadMem8S:
return BuildAsmjsLoadMem(MachineType::Int8(), input);
case wasm::kExprI32AsmjsLoadMem8U:
return BuildAsmjsLoadMem(MachineType::Uint8(), input);
case wasm::kExprI32AsmjsLoadMem16S:
return BuildAsmjsLoadMem(MachineType::Int16(), input);
case wasm::kExprI32AsmjsLoadMem16U:
return BuildAsmjsLoadMem(MachineType::Uint16(), input);
case wasm::kExprI32AsmjsLoadMem:
return BuildAsmjsLoadMem(MachineType::Int32(), input);
case wasm::kExprF32AsmjsLoadMem:
return BuildAsmjsLoadMem(MachineType::Float32(), input);
case wasm::kExprF64AsmjsLoadMem:
return BuildAsmjsLoadMem(MachineType::Float64(), input);
default:
FATAL_UNSUPPORTED_OPCODE(opcode);
}
return graph()->NewNode(op, input);
}
Node* WasmGraphBuilder::Float32Constant(float value) {
return mcgraph()->Float32Constant(value);
}
Node* WasmGraphBuilder::Float64Constant(double value) {
return mcgraph()->Float64Constant(value);
}
Node* WasmGraphBuilder::Simd128Constant(const uint8_t value[16]) {
has_simd_ = true;
return graph()->NewNode(mcgraph()->machine()->S128Const(value));
}
Node* WasmGraphBuilder::BranchNoHint(Node* cond, Node** true_node,
Node** false_node) {
return gasm_->Branch(cond, true_node, false_node, BranchHint::kNone);
}
Node* WasmGraphBuilder::BranchExpectFalse(Node* cond, Node** true_node,
Node** false_node) {
return gasm_->Branch(cond, true_node, false_node, BranchHint::kFalse);
}
Node* WasmGraphBuilder::BranchExpectTrue(Node* cond, Node** true_node,
Node** false_node) {
return gasm_->Branch(cond, true_node, false_node, BranchHint::kTrue);
}
Node* WasmGraphBuilder::Select(Node *cond, Node* true_node,
Node* false_node, wasm::ValueType type) {
MachineOperatorBuilder* m = mcgraph()->machine();
wasm::ValueKind kind = type.kind();
// Lower to select if supported.
if (kind == wasm::kF32 && m->Float32Select().IsSupported()) {
return mcgraph()->graph()->NewNode(m->Float32Select().op(), cond,
true_node, false_node);
}
if (kind == wasm::kF64 && m->Float64Select().IsSupported()) {
return mcgraph()->graph()->NewNode(m->Float64Select().op(), cond,
true_node, false_node);
}
if (kind == wasm::kI32 && m->Word32Select().IsSupported()) {
return mcgraph()->graph()->NewNode(m->Word32Select().op(), cond, true_node,
false_node);
}
if (kind == wasm::kI64 && m->Word64Select().IsSupported()) {
return mcgraph()->graph()->NewNode(m->Word64Select().op(), cond, true_node,
false_node);
}
// Default to control-flow.
Node* controls[2];
BranchNoHint(cond, &controls[0], &controls[1]);
Node* merge = Merge(2, controls);
SetControl(merge);
Node* inputs[] = {true_node, false_node, merge};
return Phi(type, 2, inputs);
}
TrapId WasmGraphBuilder::GetTrapIdForTrap(wasm::TrapReason reason) {
// TODO(wasm): "!env_" should not happen when compiling an actual wasm
// function.
if (!env_ || !env_->runtime_exception_support) {
// We use TrapId::kInvalid as a marker to tell the code generator
// to generate a call to a testing c-function instead of a runtime
// stub. This code should only be called from a cctest.
return TrapId::kInvalid;
}
switch (reason) {
#define TRAPREASON_TO_TRAPID(name) \
case wasm::k##name: \
static_assert( \
static_cast<int>(TrapId::k##name) == wasm::WasmCode::kThrowWasm##name, \
"trap id mismatch"); \
return TrapId::k##name;
FOREACH_WASM_TRAPREASON(TRAPREASON_TO_TRAPID)
#undef TRAPREASON_TO_TRAPID
default:
UNREACHABLE();
}
}
void WasmGraphBuilder::TrapIfTrue(wasm::TrapReason reason, Node* cond,
wasm::WasmCodePosition position) {
TrapId trap_id = GetTrapIdForTrap(reason);
Node* node = SetControl(graph()->NewNode(mcgraph()->common()->TrapIf(trap_id),
cond, effect(), control()));
SetSourcePosition(node, position);
}
void WasmGraphBuilder::TrapIfFalse(wasm::TrapReason reason, Node* cond,
wasm::WasmCodePosition position) {
TrapId trap_id = GetTrapIdForTrap(reason);
Node* node = SetControl(graph()->NewNode(
mcgraph()->common()->TrapUnless(trap_id), cond, effect(), control()));
SetSourcePosition(node, position);
}
// Add a check that traps if {node} is equal to {val}.
void WasmGraphBuilder::TrapIfEq32(wasm::TrapReason reason, Node* node,
int32_t val,
wasm::WasmCodePosition position) {
Int32Matcher m(node);
if (m.HasResolvedValue() && !m.Is(val)) return;
if (val == 0) {
TrapIfFalse(reason, node, position);
} else {
TrapIfTrue(reason, gasm_->Word32Equal(node, Int32Constant(val)), position);
}
}
// Add a check that traps if {node} is zero.
void WasmGraphBuilder::ZeroCheck32(wasm::TrapReason reason, Node* node,
wasm::WasmCodePosition position) {
TrapIfEq32(reason, node, 0, position);
}
// Add a check that traps if {node} is equal to {val}.
void WasmGraphBuilder::TrapIfEq64(wasm::TrapReason reason, Node* node,
int64_t val,
wasm::WasmCodePosition position) {
Int64Matcher m(node);
if (m.HasResolvedValue() && !m.Is(val)) return;
TrapIfTrue(reason, gasm_->Word64Equal(node, Int64Constant(val)), position);
}
// Add a check that traps if {node} is zero.
void WasmGraphBuilder::ZeroCheck64(wasm::TrapReason reason, Node* node,
wasm::WasmCodePosition position) {
TrapIfEq64(reason, node, 0, position);
}
Node* WasmGraphBuilder::Switch(unsigned count, Node* key) {
// The instruction selector will use {kArchTableSwitch} for large switches,
// which has limited input count, see {InstructionSelector::EmitTableSwitch}.
DCHECK_LE(count, Instruction::kMaxInputCount - 2); // value_range + 2
DCHECK_LE(count, wasm::kV8MaxWasmFunctionBrTableSize + 1); // plus IfDefault
return graph()->NewNode(mcgraph()->common()->Switch(count), key, control());
}
Node* WasmGraphBuilder::IfValue(int32_t value, Node* sw) {
DCHECK_EQ(IrOpcode::kSwitch, sw->opcode());
return graph()->NewNode(mcgraph()->common()->IfValue(value), sw);
}
Node* WasmGraphBuilder::IfDefault(Node* sw) {
DCHECK_EQ(IrOpcode::kSwitch, sw->opcode());
return graph()->NewNode(mcgraph()->common()->IfDefault(), sw);
}
Node* WasmGraphBuilder::Return(base::Vector<Node*> vals) {
unsigned count = static_cast<unsigned>(vals.size());
base::SmallVector<Node*, 8> buf(count + 3);
buf[0] = Int32Constant(0);
if (count > 0) {
memcpy(buf.data() + 1, vals.begin(), sizeof(void*) * count);
}
buf[count + 1] = effect();
buf[count + 2] = control();
Node* ret = graph()->NewNode(mcgraph()->common()->Return(count), count + 3,
buf.data());
gasm_->MergeControlToEnd(ret);
return ret;
}
void WasmGraphBuilder::Trap(wasm::TrapReason reason,
wasm::WasmCodePosition position) {
TrapIfFalse(reason, Int32Constant(0), position);
// Connect control to end via a Throw() node.
TerminateThrow(effect(), control());
}
Node* WasmGraphBuilder::MaskShiftCount32(Node* node) {
static const int32_t kMask32 = 0x1F;
if (!mcgraph()->machine()->Word32ShiftIsSafe()) {
// Shifts by constants are so common we pattern-match them here.
Int32Matcher match(node);
if (match.HasResolvedValue()) {
int32_t masked = (match.ResolvedValue() & kMask32);
if (match.ResolvedValue() != masked) node = Int32Constant(masked);
} else {
node = gasm_->Word32And(node, Int32Constant(kMask32));
}
}
return node;
}
Node* WasmGraphBuilder::MaskShiftCount64(Node* node) {
static const int64_t kMask64 = 0x3F;
if (!mcgraph()->machine()->Word32ShiftIsSafe()) {
// Shifts by constants are so common we pattern-match them here.
Int64Matcher match(node);
if (match.HasResolvedValue()) {
int64_t masked = (match.ResolvedValue() & kMask64);
if (match.ResolvedValue() != masked) node = Int64Constant(masked);
} else {
node = gasm_->Word64And(node, Int64Constant(kMask64));
}
}
return node;
}
namespace {
bool ReverseBytesSupported(MachineOperatorBuilder* m, size_t size_in_bytes) {
switch (size_in_bytes) {
case 4:
case 16:
return true;
case 8:
return m->Is64();
default:
break;
}
return false;
}
} // namespace
Node* WasmGraphBuilder::BuildChangeEndiannessStore(
Node* node, MachineRepresentation mem_rep, wasm::ValueType wasmtype) {
Node* result;
Node* value = node;
MachineOperatorBuilder* m = mcgraph()->machine();
int valueSizeInBytes = wasmtype.element_size_bytes();
int valueSizeInBits = 8 * valueSizeInBytes;
bool isFloat = false;
switch (wasmtype.kind()) {
case wasm::kF64:
value = gasm_->BitcastFloat64ToInt64(node);
isFloat = true;
V8_FALLTHROUGH;
case wasm::kI64:
result = Int64Constant(0);
break;
case wasm::kF32:
value = gasm_->BitcastFloat32ToInt32(node);
isFloat = true;
V8_FALLTHROUGH;
case wasm::kI32:
result = Int32Constant(0);
break;
case wasm::kS128:
DCHECK(ReverseBytesSupported(m, valueSizeInBytes));
break;
default:
UNREACHABLE();
}
if (mem_rep == MachineRepresentation::kWord8) {
// No need to change endianness for byte size, return original node
return node;
}
if (wasmtype == wasm::kWasmI64 && mem_rep < MachineRepresentation::kWord64) {
// In case we store lower part of WasmI64 expression, we can truncate
// upper 32bits
value = gasm_->TruncateInt64ToInt32(value);
valueSizeInBytes = wasm::kWasmI32.element_size_bytes();
valueSizeInBits = 8 * valueSizeInBytes;
if (mem_rep == MachineRepresentation::kWord16) {
value = gasm_->Word32Shl(value, Int32Constant(16));
}
} else if (wasmtype == wasm::kWasmI32 &&
mem_rep == MachineRepresentation::kWord16) {
value = gasm_->Word32Shl(value, Int32Constant(16));
}
int i;
uint32_t shiftCount;
if (ReverseBytesSupported(m, valueSizeInBytes)) {
switch (valueSizeInBytes) {
case 4:
result = gasm_->Word32ReverseBytes(value);
break;
case 8:
result = gasm_->Word64ReverseBytes(value);
break;
case 16:
result = graph()->NewNode(m->Simd128ReverseBytes(), value);
break;
default:
UNREACHABLE();
}
} else {
for (i = 0, shiftCount = valueSizeInBits - 8; i < valueSizeInBits / 2;
i += 8, shiftCount -= 16) {
Node* shiftLower;
Node* shiftHigher;
Node* lowerByte;
Node* higherByte;
DCHECK_LT(0, shiftCount);
DCHECK_EQ(0, (shiftCount + 8) % 16);
if (valueSizeInBits > 32) {
shiftLower = gasm_->Word64Shl(value, Int64Constant(shiftCount));
shiftHigher = gasm_->Word64Shr(value, Int64Constant(shiftCount));
lowerByte = gasm_->Word64And(
shiftLower, Int64Constant(static_cast<uint64_t>(0xFF)
<< (valueSizeInBits - 8 - i)));
higherByte = gasm_->Word64And(
shiftHigher, Int64Constant(static_cast<uint64_t>(0xFF) << i));
result = gasm_->Word64Or(result, lowerByte);
result = gasm_->Word64Or(result, higherByte);
} else {
shiftLower = gasm_->Word32Shl(value, Int32Constant(shiftCount));
shiftHigher = gasm_->Word32Shr(value, Int32Constant(shiftCount));
lowerByte = gasm_->Word32And(
shiftLower, Int32Constant(static_cast<uint32_t>(0xFF)
<< (valueSizeInBits - 8 - i)));
higherByte = gasm_->Word32And(
shiftHigher, Int32Constant(static_cast<uint32_t>(0xFF) << i));
result = gasm_->Word32Or(result, lowerByte);
result = gasm_->Word32Or(result, higherByte);
}
}
}
if (isFloat) {
switch (wasmtype.kind()) {
case wasm::kF64:
result = gasm_->BitcastInt64ToFloat64(result);
break;
case wasm::kF32:
result = gasm_->BitcastInt32ToFloat32(result);
break;
default:
UNREACHABLE();
}
}
return result;
}
Node* WasmGraphBuilder::BuildChangeEndiannessLoad(Node* node,
MachineType memtype,
wasm::ValueType wasmtype) {
Node* result;
Node* value = node;
MachineOperatorBuilder* m = mcgraph()->machine();
int valueSizeInBytes = ElementSizeInBytes(memtype.representation());
int valueSizeInBits = 8 * valueSizeInBytes;
bool isFloat = false;
switch (memtype.representation()) {
case MachineRepresentation::kFloat64:
value = gasm_->BitcastFloat64ToInt64(node);
isFloat = true;
V8_FALLTHROUGH;
case MachineRepresentation::kWord64:
result = Int64Constant(0);
break;
case MachineRepresentation::kFloat32:
value = gasm_->BitcastFloat32ToInt32(node);
isFloat = true;
V8_FALLTHROUGH;
case MachineRepresentation::kWord32:
case MachineRepresentation::kWord16:
result = Int32Constant(0);
break;
case MachineRepresentation::kWord8:
// No need to change endianness for byte size, return original node
return node;
case MachineRepresentation::kSimd128:
DCHECK(ReverseBytesSupported(m, valueSizeInBytes));
break;
default:
UNREACHABLE();
}
int i;
uint32_t shiftCount;
if (ReverseBytesSupported(m, valueSizeInBytes < 4 ? 4 : valueSizeInBytes)) {
switch (valueSizeInBytes) {
case 2:
result = gasm_->Word32ReverseBytes(
gasm_->Word32Shl(value, Int32Constant(16)));
break;
case 4:
result = gasm_->Word32ReverseBytes(value);
break;
case 8:
result = gasm_->Word64ReverseBytes(value);
break;
case 16:
result = graph()->NewNode(m->Simd128ReverseBytes(), value);
break;
default:
UNREACHABLE();
}
} else {
for (i = 0, shiftCount = valueSizeInBits - 8; i < valueSizeInBits / 2;
i += 8, shiftCount -= 16) {
Node* shiftLower;
Node* shiftHigher;
Node* lowerByte;
Node* higherByte;
DCHECK_LT(0, shiftCount);
DCHECK_EQ(0, (shiftCount + 8) % 16);
if (valueSizeInBits > 32) {
shiftLower = gasm_->Word64Shl(value, Int64Constant(shiftCount));
shiftHigher = gasm_->Word64Shr(value, Int64Constant(shiftCount));
lowerByte = gasm_->Word64And(
shiftLower, Int64Constant(static_cast<uint64_t>(0xFF)
<< (valueSizeInBits - 8 - i)));
higherByte = gasm_->Word64And(
shiftHigher, Int64Constant(static_cast<uint64_t>(0xFF) << i));
result = gasm_->Word64Or(result, lowerByte);
result = gasm_->Word64Or(result, higherByte);
} else {
shiftLower = gasm_->Word32Shl(value, Int32Constant(shiftCount));
shiftHigher = gasm_->Word32Shr(value, Int32Constant(shiftCount));
lowerByte = gasm_->Word32And(
shiftLower, Int32Constant(static_cast<uint32_t>(0xFF)
<< (valueSizeInBits - 8 - i)));
higherByte = gasm_->Word32And(
shiftHigher, Int32Constant(static_cast<uint32_t>(0xFF) << i));
result = gasm_->Word32Or(result, lowerByte);
result = gasm_->Word32Or(result, higherByte);
}
}
}
if (isFloat) {
switch (memtype.representation()) {
case MachineRepresentation::kFloat64:
result = gasm_->BitcastInt64ToFloat64(result);
break;
case MachineRepresentation::kFloat32:
result = gasm_->BitcastInt32ToFloat32(result);
break;
default:
UNREACHABLE();
}
}
// We need to sign extend the value
if (memtype.IsSigned()) {
DCHECK(!isFloat);
if (valueSizeInBits < 32) {
Node* shiftBitCount;
// Perform sign extension using following trick
// result = (x << machine_width - type_width) >> (machine_width -
// type_width)
if (wasmtype == wasm::kWasmI64) {
shiftBitCount = Int32Constant(64 - valueSizeInBits);
result = gasm_->Word64Sar(
gasm_->Word64Shl(gasm_->ChangeInt32ToInt64(result), shiftBitCount),
shiftBitCount);
} else if (wasmtype == wasm::kWasmI32) {
shiftBitCount = Int32Constant(32 - valueSizeInBits);
result = gasm_->Word32Sar(gasm_->Word32Shl(result, shiftBitCount),
shiftBitCount);
}
}
}
return result;
}
Node* WasmGraphBuilder::BuildF32CopySign(Node* left, Node* right) {
Node* result = Unop(
wasm::kExprF32ReinterpretI32,
Binop(wasm::kExprI32Ior,
Binop(wasm::kExprI32And, Unop(wasm::kExprI32ReinterpretF32, left),
Int32Constant(0x7FFFFFFF)),
Binop(wasm::kExprI32And, Unop(wasm::kExprI32ReinterpretF32, right),
Int32Constant(0x80000000))));
return result;
}
Node* WasmGraphBuilder::BuildF64CopySign(Node* left, Node* right) {
if (mcgraph()->machine()->Is64()) {
return gasm_->BitcastInt64ToFloat64(
gasm_->Word64Or(gasm_->Word64And(gasm_->BitcastFloat64ToInt64(left),
Int64Constant(0x7FFFFFFFFFFFFFFF)),
gasm_->Word64And(gasm_->BitcastFloat64ToInt64(right),
Int64Constant(0x8000000000000000))));
}
DCHECK(mcgraph()->machine()->Is32());
Node* high_word_left = gasm_->Float64ExtractHighWord32(left);
Node* high_word_right = gasm_->Float64ExtractHighWord32(right);
Node* new_high_word = gasm_->Word32Or(
gasm_->Word32And(high_word_left, Int32Constant(0x7FFFFFFF)),
gasm_->Word32And(high_word_right, Int32Constant(0x80000000)));
return gasm_->Float64InsertHighWord32(left, new_high_word);
}
namespace {
MachineType IntConvertType(wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI32SConvertF32:
case wasm::kExprI32SConvertF64:
case wasm::kExprI32SConvertSatF32:
case wasm::kExprI32SConvertSatF64:
return MachineType::Int32();
case wasm::kExprI32UConvertF32:
case wasm::kExprI32UConvertF64:
case wasm::kExprI32UConvertSatF32:
case wasm::kExprI32UConvertSatF64:
return MachineType::Uint32();
case wasm::kExprI64SConvertF32:
case wasm::kExprI64SConvertF64:
case wasm::kExprI64SConvertSatF32:
case wasm::kExprI64SConvertSatF64:
return MachineType::Int64();
case wasm::kExprI64UConvertF32:
case wasm::kExprI64UConvertF64:
case wasm::kExprI64UConvertSatF32:
case wasm::kExprI64UConvertSatF64:
return MachineType::Uint64();
default:
UNREACHABLE();
}
}
MachineType FloatConvertType(wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI32SConvertF32:
case wasm::kExprI32UConvertF32:
case wasm::kExprI32SConvertSatF32:
case wasm::kExprI64SConvertF32:
case wasm::kExprI64UConvertF32:
case wasm::kExprI32UConvertSatF32:
case wasm::kExprI64SConvertSatF32:
case wasm::kExprI64UConvertSatF32:
return MachineType::Float32();
case wasm::kExprI32SConvertF64:
case wasm::kExprI32UConvertF64:
case wasm::kExprI64SConvertF64:
case wasm::kExprI64UConvertF64:
case wasm::kExprI32SConvertSatF64:
case wasm::kExprI32UConvertSatF64:
case wasm::kExprI64SConvertSatF64:
case wasm::kExprI64UConvertSatF64:
return MachineType::Float64();
default:
UNREACHABLE();
}
}
const Operator* ConvertOp(WasmGraphBuilder* builder, wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI32SConvertF32:
return builder->mcgraph()->machine()->TruncateFloat32ToInt32(
TruncateKind::kSetOverflowToMin);
case wasm::kExprI32SConvertSatF32:
return builder->mcgraph()->machine()->TruncateFloat32ToInt32(
TruncateKind::kArchitectureDefault);
case wasm::kExprI32UConvertF32:
return builder->mcgraph()->machine()->TruncateFloat32ToUint32(
TruncateKind::kSetOverflowToMin);
case wasm::kExprI32UConvertSatF32:
return builder->mcgraph()->machine()->TruncateFloat32ToUint32(
TruncateKind::kArchitectureDefault);
case wasm::kExprI32SConvertF64:
case wasm::kExprI32SConvertSatF64:
return builder->mcgraph()->machine()->ChangeFloat64ToInt32();
case wasm::kExprI32UConvertF64:
case wasm::kExprI32UConvertSatF64:
return builder->mcgraph()->machine()->TruncateFloat64ToUint32();
case wasm::kExprI64SConvertF32:
case wasm::kExprI64SConvertSatF32:
return builder->mcgraph()->machine()->TryTruncateFloat32ToInt64();
case wasm::kExprI64UConvertF32:
case wasm::kExprI64UConvertSatF32:
return builder->mcgraph()->machine()->TryTruncateFloat32ToUint64();
case wasm::kExprI64SConvertF64:
case wasm::kExprI64SConvertSatF64:
return builder->mcgraph()->machine()->TryTruncateFloat64ToInt64();
case wasm::kExprI64UConvertF64:
case wasm::kExprI64UConvertSatF64:
return builder->mcgraph()->machine()->TryTruncateFloat64ToUint64();
default:
UNREACHABLE();
}
}
wasm::WasmOpcode ConvertBackOp(wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI32SConvertF32:
case wasm::kExprI32SConvertSatF32:
return wasm::kExprF32SConvertI32;
case wasm::kExprI32UConvertF32:
case wasm::kExprI32UConvertSatF32:
return wasm::kExprF32UConvertI32;
case wasm::kExprI32SConvertF64:
case wasm::kExprI32SConvertSatF64:
return wasm::kExprF64SConvertI32;
case wasm::kExprI32UConvertF64:
case wasm::kExprI32UConvertSatF64:
return wasm::kExprF64UConvertI32;
default:
UNREACHABLE();
}
}
bool IsTrappingConvertOp(wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI32SConvertF32:
case wasm::kExprI32UConvertF32:
case wasm::kExprI32SConvertF64:
case wasm::kExprI32UConvertF64:
case wasm::kExprI64SConvertF32:
case wasm::kExprI64UConvertF32:
case wasm::kExprI64SConvertF64:
case wasm::kExprI64UConvertF64:
return true;
case wasm::kExprI32SConvertSatF64:
case wasm::kExprI32UConvertSatF64:
case wasm::kExprI32SConvertSatF32:
case wasm::kExprI32UConvertSatF32:
case wasm::kExprI64SConvertSatF32:
case wasm::kExprI64UConvertSatF32:
case wasm::kExprI64SConvertSatF64:
case wasm::kExprI64UConvertSatF64:
return false;
default:
UNREACHABLE();
}
}
Node* Zero(WasmGraphBuilder* builder, const MachineType& ty) {
switch (ty.representation()) {
case MachineRepresentation::kWord32:
return builder->Int32Constant(0);
case MachineRepresentation::kWord64:
return builder->Int64Constant(0);
case MachineRepresentation::kFloat32:
return builder->Float32Constant(0.0);
case MachineRepresentation::kFloat64:
return builder->Float64Constant(0.0);
default:
UNREACHABLE();
}
}
Node* Min(WasmGraphBuilder* builder, const MachineType& ty) {
switch (ty.semantic()) {
case MachineSemantic::kInt32:
return builder->Int32Constant(std::numeric_limits<int32_t>::min());
case MachineSemantic::kUint32:
return builder->Int32Constant(std::numeric_limits<uint32_t>::min());
case MachineSemantic::kInt64:
return builder->Int64Constant(std::numeric_limits<int64_t>::min());
case MachineSemantic::kUint64:
return builder->Int64Constant(std::numeric_limits<uint64_t>::min());
default:
UNREACHABLE();
}
}
Node* Max(WasmGraphBuilder* builder, const MachineType& ty) {
switch (ty.semantic()) {
case MachineSemantic::kInt32:
return builder->Int32Constant(std::numeric_limits<int32_t>::max());
case MachineSemantic::kUint32:
return builder->Int32Constant(std::numeric_limits<uint32_t>::max());
case MachineSemantic::kInt64:
return builder->Int64Constant(std::numeric_limits<int64_t>::max());
case MachineSemantic::kUint64:
return builder->Int64Constant(std::numeric_limits<uint64_t>::max());
default:
UNREACHABLE();
}
}
wasm::WasmOpcode TruncOp(const MachineType& ty) {
switch (ty.representation()) {
case MachineRepresentation::kFloat32:
return wasm::kExprF32Trunc;
case MachineRepresentation::kFloat64:
return wasm::kExprF64Trunc;
default:
UNREACHABLE();
}
}
wasm::WasmOpcode NeOp(const MachineType& ty) {
switch (ty.representation()) {
case MachineRepresentation::kFloat32:
return wasm::kExprF32Ne;
case MachineRepresentation::kFloat64:
return wasm::kExprF64Ne;
default:
UNREACHABLE();
}
}
wasm::WasmOpcode LtOp(const MachineType& ty) {
switch (ty.representation()) {
case MachineRepresentation::kFloat32:
return wasm::kExprF32Lt;
case MachineRepresentation::kFloat64:
return wasm::kExprF64Lt;
default:
UNREACHABLE();
}
}
Node* ConvertTrapTest(WasmGraphBuilder* builder, wasm::WasmOpcode opcode,
const MachineType& int_ty, const MachineType& float_ty,
Node* trunc, Node* converted_value) {
if (int_ty.representation() == MachineRepresentation::kWord32) {
Node* check = builder->Unop(ConvertBackOp(opcode), converted_value);
return builder->Binop(NeOp(float_ty), trunc, check);
}
return builder->graph()->NewNode(builder->mcgraph()->common()->Projection(1),
trunc, builder->graph()->start());
}
Node* ConvertSaturateTest(WasmGraphBuilder* builder, wasm::WasmOpcode opcode,
const MachineType& int_ty,
const MachineType& float_ty, Node* trunc,
Node* converted_value) {
Node* test = ConvertTrapTest(builder, opcode, int_ty, float_ty, trunc,
converted_value);
if (int_ty.representation() == MachineRepresentation::kWord64) {
test = builder->Binop(wasm::kExprI64Eq, test, builder->Int64Constant(0));
}
return test;
}
} // namespace
Node* WasmGraphBuilder::BuildIntConvertFloat(Node* input,
wasm::WasmCodePosition position,
wasm::WasmOpcode opcode) {
const MachineType int_ty = IntConvertType(opcode);
const MachineType float_ty = FloatConvertType(opcode);
const Operator* conv_op = ConvertOp(this, opcode);
Node* trunc = nullptr;
Node* converted_value = nullptr;
const bool is_int32 =
int_ty.representation() == MachineRepresentation::kWord32;
if (is_int32) {
trunc = Unop(TruncOp(float_ty), input);
converted_value = graph()->NewNode(conv_op, trunc);
} else {
trunc = graph()->NewNode(conv_op, input);
converted_value = graph()->NewNode(mcgraph()->common()->Projection(0),
trunc, graph()->start());
}
if (IsTrappingConvertOp(opcode)) {
Node* test =
ConvertTrapTest(this, opcode, int_ty, float_ty, trunc, converted_value);
if (is_int32) {
TrapIfTrue(wasm::kTrapFloatUnrepresentable, test, position);
} else {
ZeroCheck64(wasm::kTrapFloatUnrepresentable, test, position);
}
return converted_value;
}
if (mcgraph()->machine()->SatConversionIsSafe()) {
return converted_value;
}
Node* test = ConvertSaturateTest(this, opcode, int_ty, float_ty, trunc,
converted_value);
Diamond tl_d(graph(), mcgraph()->common(), test, BranchHint::kFalse);
tl_d.Chain(control());
Node* nan_test = Binop(NeOp(float_ty), input, input);
Diamond nan_d(graph(), mcgraph()->common(), nan_test, BranchHint::kFalse);
nan_d.Nest(tl_d, true);
Node* neg_test = Binop(LtOp(float_ty), input, Zero(this, float_ty));
Diamond sat_d(graph(), mcgraph()->common(), neg_test, BranchHint::kNone);
sat_d.Nest(nan_d, false);
Node* sat_val =
sat_d.Phi(int_ty.representation(), Min(this, int_ty), Max(this, int_ty));
Node* nan_val =
nan_d.Phi(int_ty.representation(), Zero(this, int_ty), sat_val);
return tl_d.Phi(int_ty.representation(), nan_val, converted_value);
}
Node* WasmGraphBuilder::BuildI32AsmjsSConvertF32(Node* input) {
// asm.js must use the wacky JS semantics.
return gasm_->TruncateFloat64ToWord32(gasm_->ChangeFloat32ToFloat64(input));
}
Node* WasmGraphBuilder::BuildI32AsmjsSConvertF64(Node* input) {
// asm.js must use the wacky JS semantics.
return gasm_->TruncateFloat64ToWord32(input);
}
Node* WasmGraphBuilder::BuildI32AsmjsUConvertF32(Node* input) {
// asm.js must use the wacky JS semantics.
return gasm_->TruncateFloat64ToWord32(gasm_->ChangeFloat32ToFloat64(input));
}
Node* WasmGraphBuilder::BuildI32AsmjsUConvertF64(Node* input) {
// asm.js must use the wacky JS semantics.
return gasm_->TruncateFloat64ToWord32(input);
}
Node* WasmGraphBuilder::BuildBitCountingCall(Node* input, ExternalReference ref,
MachineRepresentation input_type) {
Node* stack_slot_param = StoreArgsInStackSlot({{input_type, input}});
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* function = gasm_->ExternalConstant(ref);
return BuildCCall(&sig, function, stack_slot_param);
}
Node* WasmGraphBuilder::BuildI32Ctz(Node* input) {
return BuildBitCountingCall(input, ExternalReference::wasm_word32_ctz(),
MachineRepresentation::kWord32);
}
Node* WasmGraphBuilder::BuildI64Ctz(Node* input) {
return Unop(wasm::kExprI64UConvertI32,
BuildBitCountingCall(input, ExternalReference::wasm_word64_ctz(),
MachineRepresentation::kWord64));
}
Node* WasmGraphBuilder::BuildI32Popcnt(Node* input) {
return BuildBitCountingCall(input, ExternalReference::wasm_word32_popcnt(),
MachineRepresentation::kWord32);
}
Node* WasmGraphBuilder::BuildI64Popcnt(Node* input) {
return Unop(
wasm::kExprI64UConvertI32,
BuildBitCountingCall(input, ExternalReference::wasm_word64_popcnt(),
MachineRepresentation::kWord64));
}
Node* WasmGraphBuilder::BuildF32Trunc(Node* input) {
MachineType type = MachineType::Float32();
ExternalReference ref = ExternalReference::wasm_f32_trunc();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32Floor(Node* input) {
MachineType type = MachineType::Float32();
ExternalReference ref = ExternalReference::wasm_f32_floor();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32Ceil(Node* input) {
MachineType type = MachineType::Float32();
ExternalReference ref = ExternalReference::wasm_f32_ceil();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32NearestInt(Node* input) {
MachineType type = MachineType::Float32();
ExternalReference ref = ExternalReference::wasm_f32_nearest_int();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Trunc(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::wasm_f64_trunc();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Floor(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::wasm_f64_floor();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Ceil(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::wasm_f64_ceil();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64NearestInt(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::wasm_f64_nearest_int();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Acos(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::f64_acos_wrapper_function();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Asin(Node* input) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::f64_asin_wrapper_function();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64Pow(Node* left, Node* right) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::wasm_float64_pow();
return BuildCFuncInstruction(ref, type, left, right);
}
Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) {
MachineType type = MachineType::Float64();
ExternalReference ref = ExternalReference::f64_mod_wrapper_function();
return BuildCFuncInstruction(ref, type, left, right);
}
Node* WasmGraphBuilder::BuildCFuncInstruction(ExternalReference ref,
MachineType type, Node* input0,
Node* input1) {
// We do truncation by calling a C function which calculates the result.
// The input is passed to the C function as a byte buffer holding the two
// input doubles. We reserve this byte buffer as a stack slot, store the
// parameters in this buffer slots, pass a pointer to the buffer to the C
// function, and after calling the C function we collect the return value from
// the buffer.
Node* stack_slot;
if (input1) {
stack_slot = StoreArgsInStackSlot(
{{type.representation(), input0}, {type.representation(), input1}});
} else {
stack_slot = StoreArgsInStackSlot({{type.representation(), input0}});
}
MachineType sig_types[] = {MachineType::Pointer()};
MachineSignature sig(0, 1, sig_types);
Node* function = gasm_->ExternalConstant(ref);
BuildCCall(&sig, function, stack_slot);
return gasm_->LoadFromObject(type, stack_slot, 0);
}
Node* WasmGraphBuilder::BuildF32SConvertI64(Node* input) {
// TODO(titzer/bradnelson): Check handlng of asm.js case.
return BuildIntToFloatConversionInstruction(
input, ExternalReference::wasm_int64_to_float32(),
MachineRepresentation::kWord64, MachineType::Float32());
}
Node* WasmGraphBuilder::BuildF32UConvertI64(Node* input) {
// TODO(titzer/bradnelson): Check handlng of asm.js case.
return BuildIntToFloatConversionInstruction(
input, ExternalReference::wasm_uint64_to_float32(),
MachineRepresentation::kWord64, MachineType::Float32());
}
Node* WasmGraphBuilder::BuildF64SConvertI64(Node* input) {
return BuildIntToFloatConversionInstruction(
input, ExternalReference::wasm_int64_to_float64(),
MachineRepresentation::kWord64, MachineType::Float64());
}
Node* WasmGraphBuilder::BuildF64UConvertI64(Node* input) {
return BuildIntToFloatConversionInstruction(
input, ExternalReference::wasm_uint64_to_float64(),
MachineRepresentation::kWord64, MachineType::Float64());
}
Node* WasmGraphBuilder::BuildIntToFloatConversionInstruction(
Node* input, ExternalReference ref,
MachineRepresentation parameter_representation,
const MachineType result_type) {
int stack_slot_size =
std::max(ElementSizeInBytes(parameter_representation),
ElementSizeInBytes(result_type.representation()));
Node* stack_slot =
graph()->NewNode(mcgraph()->machine()->StackSlot(stack_slot_size));
auto store_rep =
StoreRepresentation(parameter_representation, kNoWriteBarrier);
gasm_->Store(store_rep, stack_slot, 0, input);
MachineType sig_types[] = {MachineType::Pointer()};
MachineSignature sig(0, 1, sig_types);
Node* function = gasm_->ExternalConstant(ref);
BuildCCall(&sig, function, stack_slot);
return gasm_->LoadFromObject(result_type, stack_slot, 0);
}
namespace {
ExternalReference convert_ccall_ref(wasm::WasmOpcode opcode) {
switch (opcode) {
case wasm::kExprI64SConvertF32:
case wasm::kExprI64SConvertSatF32:
return ExternalReference::wasm_float32_to_int64();
case wasm::kExprI64UConvertF32:
case wasm::kExprI64UConvertSatF32:
return ExternalReference::wasm_float32_to_uint64();
case wasm::kExprI64SConvertF64:
case wasm::kExprI64SConvertSatF64:
return ExternalReference::wasm_float64_to_int64();
case wasm::kExprI64UConvertF64:
case wasm::kExprI64UConvertSatF64:
return ExternalReference::wasm_float64_to_uint64();
default:
UNREACHABLE();
}
}
} // namespace
Node* WasmGraphBuilder::BuildCcallConvertFloat(Node* input,
wasm::WasmCodePosition position,
wasm::WasmOpcode opcode) {
const MachineType int_ty = IntConvertType(opcode);
const MachineType float_ty = FloatConvertType(opcode);
ExternalReference call_ref = convert_ccall_ref(opcode);
int stack_slot_size = std::max(ElementSizeInBytes(int_ty.representation()),
ElementSizeInBytes(float_ty.representation()));
Node* stack_slot =
graph()->NewNode(mcgraph()->machine()->StackSlot(stack_slot_size));
auto store_rep =
StoreRepresentation(float_ty.representation(), kNoWriteBarrier);
gasm_->Store(store_rep, stack_slot, 0, input);
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* function = gasm_->ExternalConstant(call_ref);
Node* overflow = BuildCCall(&sig, function, stack_slot);
if (IsTrappingConvertOp(opcode)) {
ZeroCheck32(wasm::kTrapFloatUnrepresentable, overflow, position);
return gasm_->LoadFromObject(int_ty, stack_slot, 0);
}
Node* test = Binop(wasm::kExprI32Eq, overflow, Int32Constant(0), position);
Diamond tl_d(graph(), mcgraph()->common(), test, BranchHint::kFalse);
tl_d.Chain(control());
Node* nan_test = Binop(NeOp(float_ty), input, input);
Diamond nan_d(graph(), mcgraph()->common(), nan_test, BranchHint::kFalse);
nan_d.Nest(tl_d, true);
Node* neg_test = Binop(LtOp(float_ty), input, Zero(this, float_ty));
Diamond sat_d(graph(), mcgraph()->common(), neg_test, BranchHint::kNone);
sat_d.Nest(nan_d, false);
Node* sat_val =
sat_d.Phi(int_ty.representation(), Min(this, int_ty), Max(this, int_ty));
Node* load = gasm_->LoadFromObject(int_ty, stack_slot, 0);
Node* nan_val =
nan_d.Phi(int_ty.representation(), Zero(this, int_ty), sat_val);
return tl_d.Phi(int_ty.representation(), nan_val, load);
}
Node* WasmGraphBuilder::MemoryGrow(Node* input) {
needs_stack_check_ = true;
if (!env_->module->is_memory64) {
// For 32-bit memories, just call the builtin.
return gasm_->CallRuntimeStub(wasm::WasmCode::kWasmMemoryGrow, input);
}
// If the input is not a positive int32, growing will always fail
// (growing negative or requesting >= 256 TB).
Node* old_effect = effect();
Diamond is_32_bit(graph(), mcgraph()->common(),
gasm_->Uint64LessThanOrEqual(input, Int64Constant(kMaxInt)),
BranchHint::kTrue);
is_32_bit.Chain(control());
SetControl(is_32_bit.if_true);
Node* grow_result = gasm_->ChangeInt32ToInt64(gasm_->CallRuntimeStub(
wasm::WasmCode::kWasmMemoryGrow, gasm_->TruncateInt64ToInt32(input)));
Node* diamond_result = is_32_bit.Phi(MachineRepresentation::kWord64,
grow_result, gasm_->Int64Constant(-1));
SetEffectControl(is_32_bit.EffectPhi(effect(), old_effect), is_32_bit.merge);
return diamond_result;
}
Node* WasmGraphBuilder::Throw(uint32_t tag_index, const wasm::WasmTag* tag,
const base::Vector<Node*> values,
wasm::WasmCodePosition position) {
needs_stack_check_ = true;
uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(tag);
Node* values_array =
gasm_->CallRuntimeStub(wasm::WasmCode::kWasmAllocateFixedArray,
gasm_->IntPtrConstant(encoded_size));
SetSourcePosition(values_array, position);
uint32_t index = 0;
const wasm::WasmTagSig* sig = tag->sig;
MachineOperatorBuilder* m = mcgraph()->machine();
for (size_t i = 0; i < sig->parameter_count(); ++i) {
Node* value = values[i];
switch (sig->GetParam(i).kind()) {
case wasm::kF32:
value = gasm_->BitcastFloat32ToInt32(value);
V8_FALLTHROUGH;
case wasm::kI32:
BuildEncodeException32BitValue(values_array, &index, value);
break;
case wasm::kF64:
value = gasm_->BitcastFloat64ToInt64(value);
V8_FALLTHROUGH;
case wasm::kI64: {
Node* upper32 = gasm_->TruncateInt64ToInt32(
Binop(wasm::kExprI64ShrU, value, Int64Constant(32)));
BuildEncodeException32BitValue(values_array, &index, upper32);
Node* lower32 = gasm_->TruncateInt64ToInt32(value);
BuildEncodeException32BitValue(values_array, &index, lower32);
break;
}
case wasm::kS128:
BuildEncodeException32BitValue(
values_array, &index,
graph()->NewNode(m->I32x4ExtractLane(0), value));
BuildEncodeException32BitValue(
values_array, &index,
graph()->NewNode(m->I32x4ExtractLane(1), value));
BuildEncodeException32BitValue(
values_array, &index,
graph()->NewNode(m->I32x4ExtractLane(2), value));
BuildEncodeException32BitValue(
values_array, &index,
graph()->NewNode(m->I32x4ExtractLane(3), value));
break;
case wasm::kRef:
case wasm::kOptRef:
case wasm::kRtt:
case wasm::kRttWithDepth:
gasm_->StoreFixedArrayElementAny(values_array, index, value);
++index;
break;
case wasm::kI8:
case wasm::kI16:
case wasm::kVoid:
case wasm::kBottom:
UNREACHABLE();
}
}
DCHECK_EQ(encoded_size, index);
Node* exception_tag = LoadTagFromTable(tag_index);
Node* throw_call = gasm_->CallRuntimeStub(wasm::WasmCode::kWasmThrow,
exception_tag, values_array);
SetSourcePosition(throw_call, position);
return throw_call;
}
void WasmGraphBuilder::BuildEncodeException32BitValue(Node* values_array,
uint32_t* index,
Node* value) {
Node* upper_halfword_as_smi =
BuildChangeUint31ToSmi(gasm_->Word32Shr(value, Int32Constant(16)));
gasm_->StoreFixedArrayElementSmi(values_array, *index, upper_halfword_as_smi);
++(*index);
Node* lower_halfword_as_smi =
BuildChangeUint31ToSmi(gasm_->Word32And(value, Int32Constant(0xFFFFu)));
gasm_->StoreFixedArrayElementSmi(values_array, *index, lower_halfword_as_smi);
++(*index);
}
Node* WasmGraphBuilder::BuildDecodeException32BitValue(Node* values_array,
uint32_t* index) {
Node* upper = BuildChangeSmiToInt32(
gasm_->LoadFixedArrayElementSmi(values_array, *index));
(*index)++;
upper = gasm_->Word32Shl(upper, Int32Constant(16));
Node* lower = BuildChangeSmiToInt32(
gasm_->LoadFixedArrayElementSmi(values_array, *index));
(*index)++;
Node* value = gasm_->Word32Or(upper, lower);
return value;
}
Node* WasmGraphBuilder::BuildDecodeException64BitValue(Node* values_array,
uint32_t* index) {
Node* upper = Binop(wasm::kExprI64Shl,
Unop(wasm::kExprI64UConvertI32,
BuildDecodeException32BitValue(values_array, index)),
Int64Constant(32));
Node* lower = Unop(wasm::kExprI64UConvertI32,
BuildDecodeException32BitValue(values_array, index));
return Binop(wasm::kExprI64Ior, upper, lower);
}
Node* WasmGraphBuilder::Rethrow(Node* except_obj) {
// TODO(v8:8091): Currently the message of the original exception is not being
// preserved when rethrown to the console. The pending message will need to be
// saved when caught and restored here while being rethrown.
return gasm_->CallRuntimeStub(wasm::WasmCode::kWasmRethrow, except_obj);
}
Node* WasmGraphBuilder::ExceptionTagEqual(Node* caught_tag,
Node* expected_tag) {
return gasm_->WordEqual(caught_tag, expected_tag);
}
Node* WasmGraphBuilder::LoadTagFromTable(uint32_t tag_index) {
Node* tags_table =
LOAD_INSTANCE_FIELD(TagsTable, MachineType::TaggedPointer());
Node* tag = gasm_->LoadFixedArrayElementPtr(tags_table, tag_index);
return tag;
}
Node* WasmGraphBuilder::GetExceptionTag(Node* except_obj) {
return gasm_->CallBuiltin(
Builtin::kWasmGetOwnProperty, Operator::kEliminatable, except_obj,
LOAD_ROOT(wasm_exception_tag_symbol, wasm_exception_tag_symbol),
LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer()));
}
Node* WasmGraphBuilder::GetExceptionValues(Node* except_obj,
const wasm::WasmTag* tag,
base::Vector<Node*> values) {
Node* values_array = gasm_->CallBuiltin(
Builtin::kWasmGetOwnProperty, Operator::kEliminatable, except_obj,
LOAD_ROOT(wasm_exception_values_symbol, wasm_exception_values_symbol),
LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer()));
uint32_t index = 0;
const wasm::WasmTagSig* sig = tag->sig;
DCHECK_EQ(sig->parameter_count(), values.size());
for (size_t i = 0; i < sig->parameter_count(); ++i) {
Node* value;
switch (sig->GetParam(i).kind()) {
case wasm::kI32:
value = BuildDecodeException32BitValue(values_array, &index);
break;
case wasm::kI64:
value = BuildDecodeException64BitValue(values_array, &index);
break;
case wasm::kF32: {
value = Unop(wasm::kExprF32ReinterpretI32,
BuildDecodeException32BitValue(values_array, &index));
break;
}
case wasm::kF64: {
value = Unop(wasm::kExprF64ReinterpretI64,
BuildDecodeException64BitValue(values_array, &index));
break;
}
case wasm::kS128:
value = graph()->NewNode(
mcgraph()->machine()->I32x4Splat(),
BuildDecodeException32BitValue(values_array, &index));
value = graph()->NewNode(
mcgraph()->machine()->I32x4ReplaceLane(1), value,
BuildDecodeException32BitValue(values_array, &index));
value = graph()->NewNode(
mcgraph()->machine()->I32x4ReplaceLane(2), value,
BuildDecodeException32BitValue(values_array, &index));
value = graph()->NewNode(
mcgraph()->machine()->I32x4ReplaceLane(3), value,
BuildDecodeException32BitValue(values_array, &index));
break;
case wasm::kRef:
case wasm::kOptRef:
case wasm::kRtt:
case wasm::kRttWithDepth:
value = gasm_->LoadFixedArrayElementAny(values_array, index);
++index;
break;
case wasm::kI8:
case wasm::kI16:
case wasm::kVoid:
case wasm::kBottom:
UNREACHABLE();
}
values[i] = value;
}
DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(tag));
return values_array;
}
Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
wasm::WasmCodePosition position) {
ZeroCheck32(wasm::kTrapDivByZero, right, position);
Node* before = control();
Node* denom_is_m1;
Node* denom_is_not_m1;
BranchExpectFalse(gasm_->Word32Equal(right, Int32Constant(-1)), &denom_is_m1,
&denom_is_not_m1);
SetControl(denom_is_m1);
TrapIfEq32(wasm::kTrapDivUnrepresentable, left, kMinInt, position);
if (control() != denom_is_m1) {
SetControl(Merge(denom_is_not_m1, control()));
} else {
SetControl(before);
}
return gasm_->Int32Div(left, right);
}
Node* WasmGraphBuilder::BuildI32RemS(Node* left, Node* right,
wasm::WasmCodePosition position) {
MachineOperatorBuilder* m = mcgraph()->machine();
ZeroCheck32(wasm::kTrapRemByZero, right, position);
Diamond d(graph(), mcgraph()->common(),
gasm_->Word32Equal(right, Int32Constant(-1)), BranchHint::kFalse);
d.Chain(control());
return d.Phi(MachineRepresentation::kWord32, Int32Constant(0),
graph()->NewNode(m->Int32Mod(), left, right, d.if_false));
}
Node* WasmGraphBuilder::BuildI32DivU(Node* left, Node* right,
wasm::WasmCodePosition position) {
ZeroCheck32(wasm::kTrapDivByZero, right, position);
return gasm_->Uint32Div(left, right);
}
Node* WasmGraphBuilder::BuildI32RemU(Node* left, Node* right,
wasm::WasmCodePosition position) {
ZeroCheck32(wasm::kTrapRemByZero, right, position);
return gasm_->Uint32Mod(left, right);
}
Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
MachineOperatorBuilder* m = mcgraph()->machine();
Int32Matcher mr(right);
if (mr.HasResolvedValue()) {
if (mr.ResolvedValue() == 0) {
return Int32Constant(0);
} else if (mr.ResolvedValue() == -1) {
// The result is the negation of the left input.
return gasm_->Int32Sub(Int32Constant(0), left);
}
return gasm_->Int32Div(left, right);
}
// asm.js semantics return 0 on divide or mod by zero.
if (m->Int32DivIsSafe()) {
// The hardware instruction does the right thing (e.g. arm).
return gasm_->Int32Div(left, right);
}
// Check denominator for zero.
Diamond z(graph(), mcgraph()->common(),
gasm_->Word32Equal(right, Int32Constant(0)), BranchHint::kFalse);
z.Chain(control());
// Check denominator for -1. (avoid minint / -1 case).
Diamond n(graph(), mcgraph()->common(),
gasm_->Word32Equal(right, Int32Constant(-1)), BranchHint::kFalse);
n.Chain(z.if_false);
Node* div = graph()->NewNode(m->Int32Div(), left, right, n.if_false);
Node* neg = gasm_->Int32Sub(Int32Constant(0), left);
return z.Phi(MachineRepresentation::kWord32, Int32Constant(0),
n.Phi(MachineRepresentation::kWord32, neg, div));
}
Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
CommonOperatorBuilder* c = mcgraph()->common();
MachineOperatorBuilder* m = mcgraph()->machine();
Node* const zero = Int32Constant(0);
Int32Matcher mr(right);
if (mr.HasResolvedValue()) {
if (mr.ResolvedValue() == 0 || mr.ResolvedValue() == -1) {
return zero;
}
return gasm_->Int32Mod(left, right);
}
// General case for signed integer modulus, with optimization for (unknown)
// power of 2 right hand side.
//
// if 0 < right then
// msk = right - 1
// if right & msk != 0 then
// left % right
// else
// if left < 0 then
// -(-left & msk)
// else
// left & msk
// else
// if right < -1 then
// left % right
// else
// zero
//
// Note: We do not use the Diamond helper class here, because it really hurts
// readability with nested diamonds.
Node* const minus_one = Int32Constant(-1);
const Operator* const merge_op = c->Merge(2);
const Operator* const phi_op = c->Phi(MachineRepresentation::kWord32, 2);
Node* check0 = gasm_->Int32LessThan(zero, right);
Node* branch0 =
graph()->NewNode(c->Branch(BranchHint::kTrue), check0, control());
Node* if_true0 = graph()->NewNode(c->IfTrue(), branch0);
Node* true0;
{
Node* msk = graph()->NewNode(m->Int32Add(), right, minus_one);
Node* check1 = graph()->NewNode(m->Word32And(), right, msk);
Node* branch1 = graph()->NewNode(c->Branch(), check1, if_true0);
Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
Node* false1;
{
Node* check2 = graph()->NewNode(m->Int32LessThan(), left, zero);
Node* branch2 =
graph()->NewNode(c->Branch(BranchHint::kFalse), check2, if_false1);
Node* if_true2 = graph()->NewNode(c->IfTrue(), branch2);
Node* true2 = graph()->NewNode(
m->Int32Sub(), zero,
graph()->NewNode(m->Word32And(),
graph()->NewNode(m->Int32Sub(), zero, left), msk));
Node* if_false2 = graph()->NewNode(c->IfFalse(), branch2);
Node* false2 = graph()->NewNode(m->Word32And(), left, msk);
if_false1 = graph()->NewNode(merge_op, if_true2, if_false2);
false1 = graph()->NewNode(phi_op, true2, false2, if_false1);
}
if_true0 = graph()->NewNode(merge_op, if_true1, if_false1);
true0 = graph()->NewNode(phi_op, true1, false1, if_true0);
}
Node* if_false0 = graph()->NewNode(c->IfFalse(), branch0);
Node* false0;
{
Node* check1 = graph()->NewNode(m->Int32LessThan(), right, minus_one);
Node* branch1 =
graph()->NewNode(c->Branch(BranchHint::kTrue), check1, if_false0);
Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
Node* false1 = zero;
if_false0 = graph()->NewNode(merge_op, if_true1, if_false1);
false0 = graph()->NewNode(phi_op, true1, false1, if_false0);
}
Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
return graph()->NewNode(phi_op, true0, false0, merge0);
}
Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
MachineOperatorBuilder* m = mcgraph()->machine();
// asm.js semantics return 0 on divide or mod by zero.
if (m->Uint32DivIsSafe()) {
// The hardware instruction does the right thing (e.g. arm).
return gasm_->Uint32Div(left, right);
}
// Explicit check for x % 0.
Diamond z(graph(), mcgraph()->common(),
gasm_->Word32Equal(right, Int32Constant(0)), BranchHint::kFalse);
z.Chain(control());
return z.Phi(MachineRepresentation::kWord32, Int32Constant(0),
graph()->NewNode(mcgraph()->machine()->Uint32Div(), left, right,
z.if_false));
}
Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
// asm.js semantics return 0 on divide or mod by zero.
// Explicit check for x % 0.
Diamond z(graph(), mcgraph()->common(),
gasm_->Word32Equal(right, Int32Constant(0)), BranchHint::kFalse);
z.Chain(control());
Node* rem = graph()->NewNode(mcgraph()->machine()->Uint32Mod(), left, right,
z.if_false);
return z.Phi(MachineRepresentation::kWord32, Int32Constant(0), rem);
}
Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
wasm::WasmCodePosition position) {
if (mcgraph()->machine()->Is32()) {
return BuildDiv64Call(left, right, ExternalReference::wasm_int64_div(),
MachineType::Int64(), wasm::kTrapDivByZero, position);
}
ZeroCheck64(wasm::kTrapDivByZero, right, position);
Node* before = control();
Node* denom_is_m1;
Node* denom_is_not_m1;
BranchExpectFalse(gasm_->Word64Equal(right, Int64Constant(-1)), &denom_is_m1,
&denom_is_not_m1);
SetControl(denom_is_m1);
TrapIfEq64(wasm::kTrapDivUnrepresentable, left,
std::numeric_limits<int64_t>::min(), position);
if (control() != denom_is_m1) {
SetControl(Merge(denom_is_not_m1, control()));
} else {
SetControl(before);
}
return gasm_->Int64Div(left, right);
}
Node* WasmGraphBuilder::BuildI64RemS(Node* left, Node* right,
wasm::WasmCodePosition position) {
if (mcgraph()->machine()->Is32()) {
return BuildDiv64Call(left, right, ExternalReference::wasm_int64_mod(),
MachineType::Int64(), wasm::kTrapRemByZero, position);
}
ZeroCheck64(wasm::kTrapRemByZero, right, position);
Diamond d(mcgraph()->graph(), mcgraph()->common(),
gasm_->Word64Equal(right, Int64Constant(-1)));
d.Chain(control());
Node* rem = graph()->NewNode(mcgraph()->machine()->Int64Mod(), left, right,
d.if_false);
return d.Phi(MachineRepresentation::kWord64, Int64Constant(0), rem);
}
Node* WasmGraphBuilder::BuildI64DivU(Node* left, Node* right,
wasm::WasmCodePosition position) {
if (mcgraph()->machine()->Is32()) {
return BuildDiv64Call(left, right, ExternalReference::wasm_uint64_div(),
MachineType::Int64(), wasm::kTrapDivByZero, position);
}
ZeroCheck64(wasm::kTrapDivByZero, right, position);
return gasm_->Uint64Div(left, right);
}
Node* WasmGraphBuilder::BuildI64RemU(Node* left, Node* right,
wasm::WasmCodePosition position) {
if (mcgraph()->machine()->Is32()) {
return BuildDiv64Call(left, right, ExternalReference::wasm_uint64_mod(),
MachineType::Int64(), wasm::kTrapRemByZero, position);
}
ZeroCheck64(wasm::kTrapRemByZero, right, position);
return gasm_->Uint64Mod(left, right);
}
Node* WasmGraphBuilder::BuildDiv64Call(Node* left, Node* right,
ExternalReference ref,
MachineType result_type,
wasm::TrapReason trap_zero,
wasm::WasmCodePosition position) {
Node* stack_slot =
StoreArgsInStackSlot({{MachineRepresentation::kWord64, left},
{MachineRepresentation::kWord64, right}});
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* function = gasm_->ExternalConstant(ref);
Node* call = BuildCCall(&sig, function, stack_slot);
ZeroCheck32(trap_zero, call, position);
TrapIfEq32(wasm::kTrapDivUnrepresentable, call, -1, position);
return gasm_->LoadFromObject(result_type, stack_slot, 0);
}
template <typename... Args>
Node* WasmGraphBuilder::BuildCCall(MachineSignature* sig, Node* function,
Args... args) {
DCHECK_LE(sig->return_count(), 1);
DCHECK_EQ(sizeof...(args), sig->parameter_count());
Node* call_args[] = {function, args..., effect(), control()};
auto call_descriptor =
Linkage::GetSimplifiedCDescriptor(mcgraph()->zone(), sig);
return gasm_->Call(call_descriptor, arraysize(call_args), call_args);
}
Node* WasmGraphBuilder::BuildCallNode(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
wasm::WasmCodePosition position,
Node* instance_node, const Operator* op,
Node* frame_state) {
if (instance_node == nullptr) {
instance_node = GetInstance();
}
needs_stack_check_ = true;
const size_t params = sig->parameter_count();
const size_t has_frame_state = frame_state != nullptr ? 1 : 0;
const size_t extra = 3; // instance_node, effect, and control.
const size_t count = 1 + params + extra + has_frame_state;
// Reallocate the buffer to make space for extra inputs.
base::SmallVector<Node*, 16 + extra> inputs(count);
DCHECK_EQ(1 + params, args.size());
// Make room for the instance_node parameter at index 1, just after code.
inputs[0] = args[0]; // code
inputs[1] = instance_node;
if (params > 0) memcpy(&inputs[2], &args[1], params * sizeof(Node*));
// Add effect and control inputs.
if (has_frame_state != 0) inputs[params + 2] = frame_state;
inputs[params + has_frame_state + 2] = effect();
inputs[params + has_frame_state + 3] = control();
Node* call = graph()->NewNode(op, static_cast<int>(count), inputs.begin());
// Return calls have no effect output. Other calls are the new effect node.
if (op->EffectOutputCount() > 0) SetEffect(call);
DCHECK(position == wasm::kNoCodePosition || position > 0);
if (position > 0) SetSourcePosition(call, position);
return call;
}
Node* WasmGraphBuilder::BuildWasmCall(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position,
Node* instance_node, Node* frame_state) {
CallDescriptor* call_descriptor = GetWasmCallDescriptor(
mcgraph()->zone(), sig, kWasmFunction, frame_state != nullptr);
const Operator* op = mcgraph()->common()->Call(call_descriptor);
Node* call =
BuildCallNode(sig, args, position, instance_node, op, frame_state);
// TODO(manoskouk): If we have kNoThrow calls, do not set them as control.
DCHECK_GT(call->op()->ControlOutputCount(), 0);
SetControl(call);
size_t ret_count = sig->return_count();
if (ret_count == 0) return call; // No return value.
DCHECK_EQ(ret_count, rets.size());
if (ret_count == 1) {
// Only a single return value.
rets[0] = call;
} else {
// Create projections for all return values.
for (size_t i = 0; i < ret_count; i++) {
rets[i] = graph()->NewNode(mcgraph()->common()->Projection(i), call,
graph()->start());
}
}
return call;
}
Node* WasmGraphBuilder::BuildWasmReturnCall(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
wasm::WasmCodePosition position,
Node* instance_node) {
CallDescriptor* call_descriptor =
GetWasmCallDescriptor(mcgraph()->zone(), sig);
const Operator* op = mcgraph()->common()->TailCall(call_descriptor);
Node* call = BuildCallNode(sig, args, position, instance_node, op);
// TODO(manoskouk): If we have kNoThrow calls, do not merge them to end.
DCHECK_GT(call->op()->ControlOutputCount(), 0);
gasm_->MergeControlToEnd(call);
return call;
}
Node* WasmGraphBuilder::BuildImportCall(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position,
int func_index,
IsReturnCall continuation) {
return BuildImportCall(sig, args, rets, position,
gasm_->Uint32Constant(func_index), continuation);
}
Node* WasmGraphBuilder::BuildImportCall(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position,
Node* func_index,
IsReturnCall continuation) {
// Load the imported function refs array from the instance.
Node* imported_function_refs =
LOAD_INSTANCE_FIELD(ImportedFunctionRefs, MachineType::TaggedPointer());
// Access fixed array at {header_size - tag + func_index * kTaggedSize}.
Node* func_index_intptr = BuildChangeUint32ToUintPtr(func_index);
Node* ref_node = gasm_->LoadFixedArrayElement(
imported_function_refs, func_index_intptr, MachineType::TaggedPointer());
// Load the target from the imported_targets array at the offset of
// {func_index}.
Node* func_index_times_pointersize = gasm_->IntMul(
func_index_intptr, gasm_->IntPtrConstant(kSystemPointerSize));
Node* imported_targets =
LOAD_INSTANCE_FIELD(ImportedFunctionTargets, MachineType::Pointer());
Node* target_node = gasm_->LoadFromObject(
MachineType::Pointer(), imported_targets, func_index_times_pointersize);
args[0] = target_node;
switch (continuation) {
case kCallContinues:
return BuildWasmCall(sig, args, rets, position, ref_node);
case kReturnCall:
DCHECK(rets.empty());
return BuildWasmReturnCall(sig, args, position, ref_node);
}
}
Node* WasmGraphBuilder::CallDirect(uint32_t index, base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position) {
DCHECK_NULL(args[0]);
const wasm::FunctionSig* sig = env_->module->functions[index].sig;
if (env_ && index < env_->module->num_imported_functions) {
// Call to an imported function.
return BuildImportCall(sig, args, rets, position, index, kCallContinues);
}
// A direct call to a wasm function defined in this module.
// Just encode the function index. This will be patched at instantiation.
Address code = static_cast<Address>(index);
args[0] = mcgraph()->RelocatableIntPtrConstant(code, RelocInfo::WASM_CALL);
return BuildWasmCall(sig, args, rets, position, nullptr);
}
Node* WasmGraphBuilder::CallIndirect(uint32_t table_index, uint32_t sig_index,
base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position) {
return BuildIndirectCall(table_index, sig_index, args, rets, position,
kCallContinues);
}
void WasmGraphBuilder::LoadIndirectFunctionTable(uint32_t table_index,
Node** ift_size,
Node** ift_sig_ids,
Node** ift_targets,
Node** ift_instances) {
bool needs_dynamic_size = true;
const wasm::WasmTable& table = env_->module->tables[table_index];
if (table.has_maximum_size && table.maximum_size == table.initial_size) {
*ift_size = Int32Constant(table.initial_size);
needs_dynamic_size = false;
}
if (table_index == 0) {
if (needs_dynamic_size) {
*ift_size = LOAD_MUTABLE_INSTANCE_FIELD(IndirectFunctionTableSize,
MachineType::Uint32());
}
*ift_sig_ids = LOAD_MUTABLE_INSTANCE_FIELD(IndirectFunctionTableSigIds,
MachineType::Pointer());
*ift_targets = LOAD_MUTABLE_INSTANCE_FIELD(IndirectFunctionTableTargets,
MachineType::Pointer());
*ift_instances = LOAD_MUTABLE_INSTANCE_FIELD(IndirectFunctionTableRefs,
MachineType::TaggedPointer());
return;
}
Node* ift_tables = LOAD_MUTABLE_INSTANCE_FIELD(IndirectFunctionTables,
MachineType::TaggedPointer());
Node* ift_table = gasm_->LoadFixedArrayElementAny(ift_tables, table_index);
if (needs_dynamic_size) {
*ift_size = gasm_->LoadFromObject(
MachineType::Int32(), ift_table,
wasm::ObjectAccess::ToTagged(WasmIndirectFunctionTable::kSizeOffset));
}
*ift_sig_ids = gasm_->LoadFromObject(
MachineType::Pointer(), ift_table,
wasm::ObjectAccess::ToTagged(WasmIndirectFunctionTable::kSigIdsOffset));
*ift_targets = gasm_->LoadFromObject(
MachineType::Pointer(), ift_table,
wasm::ObjectAccess::ToTagged(WasmIndirectFunctionTable::kTargetsOffset));
*ift_instances = gasm_->LoadFromObject(
MachineType::TaggedPointer(), ift_table,
wasm::ObjectAccess::ToTagged(WasmIndirectFunctionTable::kRefsOffset));
}
Node* WasmGraphBuilder::BuildIndirectCall(uint32_t table_index,
uint32_t sig_index,
base::Vector<Node*> args,
base::Vector<Node*> rets,
wasm::WasmCodePosition position,
IsReturnCall continuation) {
DCHECK_NOT_NULL(args[0]);
DCHECK_NOT_NULL(env_);
// First we have to load the table.
Node* ift_size;
Node* ift_sig_ids;
Node* ift_targets;
Node* ift_instances;
LoadIndirectFunctionTable(table_index, &ift_size, &ift_sig_ids, &ift_targets,
&ift_instances);
const wasm::FunctionSig* sig = env_->module->signature(sig_index);
Node* key = args[0];
// Bounds check against the table size.
Node* in_bounds = gasm_->Uint32LessThan(key, ift_size);
TrapIfFalse(wasm::kTrapTableOutOfBounds, in_bounds, position);
const wasm::ValueType table_type = env_->module->tables[table_index].type;
// Check that the table entry is not null and that the type of the function is
// **identical with** the function type declared at the call site (no
// subtyping of functions is allowed).
// Note: Since null entries are identified by having ift_sig_id (-1), we only
// need one comparison.
// TODO(9495): Change this if we should do full function subtyping instead.
const bool needs_signature_check =
FLAG_experimental_wasm_gc ||
table_type.is_reference_to(wasm::HeapType::kFunc) ||
table_type.is_nullable();
if (needs_signature_check) {
Node* int32_scaled_key =
BuildChangeUint32ToUintPtr(gasm_->Word32Shl(key, Int32Constant(2)));
Node* loaded_sig = gasm_->LoadFromObject(MachineType::Int32(), ift_sig_ids,
int32_scaled_key);
int32_t expected_sig_id = env_->module->canonicalized_type_ids[sig_index];
Node* sig_match =
gasm_->Word32Equal(loaded_sig, Int32Constant(expected_sig_id));
TrapIfFalse(wasm::kTrapFuncSigMismatch, sig_match, position);
}
Node* key_intptr = BuildChangeUint32ToUintPtr(key);
Node* target_instance = gasm_->LoadFixedArrayElement(
ift_instances, key_intptr, MachineType::TaggedPointer());
Node* intptr_scaled_key =
gasm_->IntMul(key_intptr, gasm_->IntPtrConstant(kSystemPointerSize));
Node* target = gasm_->LoadFromObject(MachineType::Pointer(), ift_targets,
intptr_scaled_key);
args[0] = target;
switch (continuation) {
case kCallContinues:
return BuildWasmCall(sig, args, rets, position, target_instance);
case kReturnCall:
return BuildWasmReturnCall(sig, args, position, target_instance);
}
}
Node* WasmGraphBuilder::BuildLoadCallTargetFromExportedFunctionData(
Node* function_data) {
// TODO(saelo) move this code into a common LoadExternalPointer routine?
#ifdef V8_HEAP_SANDBOX
Node* index = gasm_->LoadFromObject(
MachineType::Pointer(), function_data,
wasm::ObjectAccess::ToTagged(WasmFunctionData::kForeignAddressOffset));
Node* isolate_root = BuildLoadIsolateRoot();
Node* table =
gasm_->LoadFromObject(MachineType::Pointer(), isolate_root,
IsolateData::external_pointer_table_offset() +
Internals::kExternalPointerTableBufferOffset);
Node* offset = gasm_->Int32Mul(index, gasm_->Int32Constant(8));
Node* decoded_ptr = gasm_->Load(MachineType::Pointer(), table, offset);
Node* tag = gasm_->IntPtrConstant(~kForeignForeignAddressTag);
return gasm_->WordAnd(decoded_ptr, tag);
#else
return gasm_->LoadFromObject(
MachineType::Pointer(), function_data,
wasm::ObjectAccess::ToTagged(WasmFunctionData::kForeignAddressOffset));
#endif
}
// TODO(9495): Support CAPI function refs.
Node* WasmGraphBuilder::BuildCallRef(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
base::Vector<Node*> rets,
CheckForNull null_check,
IsReturnCall continuation,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference, gasm_->WordEqual(args[0], RefNull()),
position);
}
Node* function_data = gasm_->LoadFunctionDataFromJSFunction(args[0]);
auto load_target = gasm_->MakeLabel();
auto end_label = gasm_->MakeLabel(MachineType::PointerRepresentation());
Node* instance_node = gasm_->LoadFromObject(
MachineType::TaggedPointer(), function_data,
wasm::ObjectAccess::ToTagged(WasmFunctionData::kRefOffset));
Node* target = BuildLoadCallTargetFromExportedFunctionData(function_data);
Node* is_null_target = gasm_->WordEqual(target, gasm_->IntPtrConstant(0));
gasm_->GotoIfNot(is_null_target, &end_label, target);
{
// Compute the call target from the (on-heap) wrapper code. The cached
// target can only be null for WasmJSFunctions.
Node* wrapper_code = gasm_->LoadFromObject(
MachineType::TaggedPointer(), function_data,
wasm::ObjectAccess::ToTagged(
WasmJSFunctionData::kWasmToJsWrapperCodeOffset));
Node* call_target;
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
CHECK(!V8_HEAP_SANDBOX_BOOL); // Not supported yet.
call_target =
gasm_->LoadFromObject(MachineType::Pointer(), wrapper_code,
wasm::ObjectAccess::ToTagged(
CodeDataContainer::kCodeEntryPointOffset));
} else {
call_target = gasm_->IntAdd(
wrapper_code, gasm_->IntPtrConstant(
wasm::ObjectAccess::ToTagged(Code::kHeaderSize)));
}
gasm_->Goto(&end_label, call_target);
}
gasm_->Bind(&end_label);
args[0] = end_label.PhiAt(0);
Node* call = continuation == kCallContinues
? BuildWasmCall(sig, args, rets, position, instance_node)
: BuildWasmReturnCall(sig, args, position, instance_node);
return call;
}
void WasmGraphBuilder::CompareToExternalFunctionAtIndex(
Node* func_ref, uint32_t function_index, Node** success_control,
Node** failure_control) {
// Since we are comparing to a function reference, it is guaranteed that
// instance->wasm_external_functions() has been initialized.
Node* external_functions = gasm_->LoadFromObject(
MachineType::TaggedPointer(), GetInstance(),
wasm::ObjectAccess::ToTagged(
WasmInstanceObject::kWasmExternalFunctionsOffset));
Node* function_ref = gasm_->LoadFixedArrayElement(
external_functions, gasm_->IntPtrConstant(function_index),
MachineType::AnyTagged());
gasm_->Branch(gasm_->WordEqual(function_ref, func_ref), success_control,
failure_control, BranchHint::kTrue);
}
Node* WasmGraphBuilder::CallRef(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
base::Vector<Node*> rets,
WasmGraphBuilder::CheckForNull null_check,
wasm::WasmCodePosition position) {
return BuildCallRef(sig, args, rets, null_check, IsReturnCall::kCallContinues,
position);
}
Node* WasmGraphBuilder::ReturnCallRef(const wasm::FunctionSig* sig,
base::Vector<Node*> args,
WasmGraphBuilder::CheckForNull null_check,
wasm::WasmCodePosition position) {
return BuildCallRef(sig, args, {}, null_check, IsReturnCall::kReturnCall,
position);
}
Node* WasmGraphBuilder::ReturnCall(uint32_t index, base::Vector<Node*> args,
wasm::WasmCodePosition position) {
DCHECK_NULL(args[0]);
const wasm::FunctionSig* sig = env_->module->functions[index].sig;
if (env_ && index < env_->module->num_imported_functions) {
// Return Call to an imported function.
return BuildImportCall(sig, args, {}, position, index, kReturnCall);
}
// A direct tail call to a wasm function defined in this module.
// Just encode the function index. This will be patched during code
// generation.
Address code = static_cast<Address>(index);
args[0] = mcgraph()->RelocatableIntPtrConstant(code, RelocInfo::WASM_CALL);
return BuildWasmReturnCall(sig, args, position, nullptr);
}
Node* WasmGraphBuilder::ReturnCallIndirect(uint32_t table_index,
uint32_t sig_index,
base::Vector<Node*> args,
wasm::WasmCodePosition position) {
return BuildIndirectCall(table_index, sig_index, args, {}, position,
kReturnCall);
}
void WasmGraphBuilder::BrOnNull(Node* ref_object, Node** null_node,
Node** non_null_node) {
BranchExpectFalse(gasm_->WordEqual(ref_object, RefNull()), null_node,
non_null_node);
}
Node* WasmGraphBuilder::BuildI32Rol(Node* left, Node* right) {
// Implement Rol by Ror since TurboFan does not have Rol opcode.
// TODO(weiliang): support Word32Rol opcode in TurboFan.
Int32Matcher m(right);
if (m.HasResolvedValue()) {
return Binop(wasm::kExprI32Ror, left,
Int32Constant(32 - (m.ResolvedValue() & 0x1F)));
} else {
return Binop(wasm::kExprI32Ror, left,
Binop(wasm::kExprI32Sub, Int32Constant(32), right));
}
}
Node* WasmGraphBuilder::BuildI64Rol(Node* left, Node* right) {
// Implement Rol by Ror since TurboFan does not have Rol opcode.
// TODO(weiliang): support Word64Rol opcode in TurboFan.
Int64Matcher m(right);
Node* inv_right = m.HasResolvedValue()
? Int64Constant(64 - (m.ResolvedValue() & 0x3F))
: Binop(wasm::kExprI64Sub, Int64Constant(64), right);
return Binop(wasm::kExprI64Ror, left, inv_right);
}
Node* WasmGraphBuilder::Invert(Node* node) {
return Unop(wasm::kExprI32Eqz, node);
}
Node* WasmGraphBuilder::BuildTruncateIntPtrToInt32(Node* value) {
return mcgraph()->machine()->Is64() ? gasm_->TruncateInt64ToInt32(value)
: value;
}
Node* WasmGraphBuilder::BuildChangeInt32ToIntPtr(Node* value) {
return mcgraph()->machine()->Is64() ? gasm_->ChangeInt32ToInt64(value)
: value;
}
Node* WasmGraphBuilder::BuildChangeIntPtrToInt64(Node* value) {
return mcgraph()->machine()->Is32() ? gasm_->ChangeInt32ToInt64(value)
: value;
}
Node* WasmGraphBuilder::BuildChangeUint32ToUintPtr(Node* node) {
if (mcgraph()->machine()->Is32()) return node;
// Fold instances of ChangeUint32ToUint64(IntConstant) directly.
Uint32Matcher matcher(node);
if (matcher.HasResolvedValue()) {
uintptr_t value = matcher.ResolvedValue();
return mcgraph()->IntPtrConstant(bit_cast<intptr_t>(value));
}
return gasm_->ChangeUint32ToUint64(node);
}
Node* WasmGraphBuilder::BuildSmiShiftBitsConstant() {
return gasm_->IntPtrConstant(kSmiShiftSize + kSmiTagSize);
}
Node* WasmGraphBuilder::BuildSmiShiftBitsConstant32() {
return Int32Constant(kSmiShiftSize + kSmiTagSize);
}
Node* WasmGraphBuilder::BuildChangeInt32ToSmi(Node* value) {
// With pointer compression, only the lower 32 bits are used.
return COMPRESS_POINTERS_BOOL
? gasm_->Word32Shl(value, BuildSmiShiftBitsConstant32())
: gasm_->WordShl(BuildChangeInt32ToIntPtr(value),
BuildSmiShiftBitsConstant());
}
Node* WasmGraphBuilder::BuildChangeUint31ToSmi(Node* value) {
return COMPRESS_POINTERS_BOOL
? gasm_->Word32Shl(value, BuildSmiShiftBitsConstant32())
: gasm_->WordShl(BuildChangeUint32ToUintPtr(value),
BuildSmiShiftBitsConstant());
}
Node* WasmGraphBuilder::BuildChangeSmiToInt32(Node* value) {
return COMPRESS_POINTERS_BOOL
? gasm_->Word32Sar(value, BuildSmiShiftBitsConstant32())
: BuildTruncateIntPtrToInt32(
gasm_->WordSar(value, BuildSmiShiftBitsConstant()));
}
Node* WasmGraphBuilder::BuildChangeSmiToIntPtr(Node* value) {
return COMPRESS_POINTERS_BOOL
? BuildChangeInt32ToIntPtr(
gasm_->Word32Sar(value, BuildSmiShiftBitsConstant32()))
: gasm_->WordSar(value, BuildSmiShiftBitsConstant());
}
Node* WasmGraphBuilder::BuildConvertUint32ToSmiWithSaturation(Node* value,
uint32_t maxval) {
DCHECK(Smi::IsValid(maxval));
Node* max = mcgraph()->Uint32Constant(maxval);
Node* check = gasm_->Uint32LessThanOrEqual(value, max);
Node* valsmi = BuildChangeUint31ToSmi(value);
Node* maxsmi = gasm_->NumberConstant(maxval);
Diamond d(graph(), mcgraph()->common(), check, BranchHint::kTrue);
d.Chain(control());
return d.Phi(MachineRepresentation::kTagged, valsmi, maxsmi);
}
void WasmGraphBuilder::InitInstanceCache(
WasmInstanceCacheNodes* instance_cache) {
// Load the memory start.
instance_cache->mem_start =
LOAD_MUTABLE_INSTANCE_FIELD(MemoryStart, MachineType::UintPtr());
// Load the memory size.
instance_cache->mem_size =
LOAD_MUTABLE_INSTANCE_FIELD(MemorySize, MachineType::UintPtr());
}
void WasmGraphBuilder::PrepareInstanceCacheForLoop(
WasmInstanceCacheNodes* instance_cache, Node* control) {
#define INTRODUCE_PHI(field, rep) \
instance_cache->field = graph()->NewNode(mcgraph()->common()->Phi(rep, 1), \
instance_cache->field, control);
INTRODUCE_PHI(mem_start, MachineType::PointerRepresentation());
INTRODUCE_PHI(mem_size, MachineType::PointerRepresentation());
#undef INTRODUCE_PHI
}
void WasmGraphBuilder::NewInstanceCacheMerge(WasmInstanceCacheNodes* to,
WasmInstanceCacheNodes* from,
Node* merge) {
#define INTRODUCE_PHI(field, rep) \
if (to->field != from->field) { \
Node* vals[] = {to->field, from->field, merge}; \
to->field = graph()->NewNode(mcgraph()->common()->Phi(rep, 2), 3, vals); \
}
INTRODUCE_PHI(mem_start, MachineType::PointerRepresentation());
INTRODUCE_PHI(mem_size, MachineRepresentation::kWord32);
#undef INTRODUCE_PHI
}
void WasmGraphBuilder::MergeInstanceCacheInto(WasmInstanceCacheNodes* to,
WasmInstanceCacheNodes* from,
Node* merge) {
to->mem_size = CreateOrMergeIntoPhi(MachineType::PointerRepresentation(),
merge, to->mem_size, from->mem_size);
to->mem_start = CreateOrMergeIntoPhi(MachineType::PointerRepresentation(),
merge, to->mem_start, from->mem_start);
}
Node* WasmGraphBuilder::CreateOrMergeIntoPhi(MachineRepresentation rep,
Node* merge, Node* tnode,
Node* fnode) {
if (IsPhiWithMerge(tnode, merge)) {
AppendToPhi(tnode, fnode);
} else if (tnode != fnode) {
// Note that it is not safe to use {Buffer} here since this method is used
// via {CheckForException} while the {Buffer} is in use by another method.
uint32_t count = merge->InputCount();
// + 1 for the merge node.
base::SmallVector<Node*, 9> inputs(count + 1);
for (uint32_t j = 0; j < count - 1; j++) inputs[j] = tnode;
inputs[count - 1] = fnode;
inputs[count] = merge;
tnode = graph()->NewNode(mcgraph()->common()->Phi(rep, count), count + 1,
inputs.begin());
}
return tnode;
}
Node* WasmGraphBuilder::CreateOrMergeIntoEffectPhi(Node* merge, Node* tnode,
Node* fnode) {
if (IsPhiWithMerge(tnode, merge)) {
AppendToPhi(tnode, fnode);
} else if (tnode != fnode) {
// Note that it is not safe to use {Buffer} here since this method is used
// via {CheckForException} while the {Buffer} is in use by another method.
uint32_t count = merge->InputCount();
// + 1 for the merge node.
base::SmallVector<Node*, 9> inputs(count + 1);
for (uint32_t j = 0; j < count - 1; j++) {
inputs[j] = tnode;
}
inputs[count - 1] = fnode;
inputs[count] = merge;
tnode = graph()->NewNode(mcgraph()->common()->EffectPhi(count), count + 1,
inputs.begin());
}
return tnode;
}
Node* WasmGraphBuilder::effect() { return gasm_->effect(); }
Node* WasmGraphBuilder::control() { return gasm_->control(); }
Node* WasmGraphBuilder::SetEffect(Node* node) {
SetEffectControl(node, control());
return node;
}
Node* WasmGraphBuilder::SetControl(Node* node) {
SetEffectControl(effect(), node);
return node;
}
void WasmGraphBuilder::SetEffectControl(Node* effect, Node* control) {
gasm_->InitializeEffectControl(effect, control);
}
Node* WasmGraphBuilder::GetImportedMutableGlobals() {
return LOAD_INSTANCE_FIELD(ImportedMutableGlobals, MachineType::UintPtr());
}
void WasmGraphBuilder::GetGlobalBaseAndOffset(MachineType mem_type,
const wasm::WasmGlobal& global,
Node** base_node,
Node** offset_node) {
if (global.mutability && global.imported) {
*base_node = gasm_->LoadFromObject(
MachineType::UintPtr(), GetImportedMutableGlobals(),
Int32Constant(global.index * sizeof(Address)));
*offset_node = Int32Constant(0);
} else {
Node* globals_start =
LOAD_INSTANCE_FIELD(GlobalsStart, MachineType::UintPtr());
*base_node = globals_start;
*offset_node = Int32Constant(global.offset);
if (mem_type == MachineType::Simd128() && global.offset != 0) {
// TODO(titzer,bbudge): code generation for SIMD memory offsets is broken.
*base_node = gasm_->IntAdd(*base_node, *offset_node);
*offset_node = Int32Constant(0);
}
}
}
void WasmGraphBuilder::GetBaseAndOffsetForImportedMutableExternRefGlobal(
const wasm::WasmGlobal& global, Node** base, Node** offset) {
// Load the base from the ImportedMutableGlobalsBuffer of the instance.
Node* buffers = LOAD_INSTANCE_FIELD(ImportedMutableGlobalsBuffers,
MachineType::TaggedPointer());
*base = gasm_->LoadFixedArrayElementAny(buffers, global.index);
// For the offset we need the index of the global in the buffer, and then
// calculate the actual offset from the index. Load the index from the
// ImportedMutableGlobals array of the instance.
Node* index =
gasm_->LoadFromObject(MachineType::UintPtr(), GetImportedMutableGlobals(),
Int32Constant(global.index * sizeof(Address)));
// From the index, calculate the actual offset in the FixedArray. This
// is kHeaderSize + (index * kTaggedSize). kHeaderSize can be acquired with
// wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(0).
Node* index_times_tagged_size = gasm_->IntMul(
BuildChangeUint32ToUintPtr(index), Int32Constant(kTaggedSize));
*offset = gasm_->IntAdd(
index_times_tagged_size,
mcgraph()->IntPtrConstant(
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(0)));
}
Node* WasmGraphBuilder::MemBuffer(uintptr_t offset) {
DCHECK_NOT_NULL(instance_cache_);
Node* mem_start = instance_cache_->mem_start;
DCHECK_NOT_NULL(mem_start);
if (offset == 0) return mem_start;
return gasm_->IntAdd(mem_start, gasm_->UintPtrConstant(offset));
}
Node* WasmGraphBuilder::CurrentMemoryPages() {
// CurrentMemoryPages can not be called from asm.js.
DCHECK_EQ(wasm::kWasmOrigin, env_->module->origin);
DCHECK_NOT_NULL(instance_cache_);
Node* mem_size = instance_cache_->mem_size;
DCHECK_NOT_NULL(mem_size);
Node* result =
gasm_->WordShr(mem_size, Int32Constant(wasm::kWasmPageSizeLog2));
result = env_->module->is_memory64 ? BuildChangeIntPtrToInt64(result)
: BuildTruncateIntPtrToInt32(result);
return result;
}
// Only call this function for code which is not reused across instantiations,
// as we do not patch the embedded js_context.
Node* WasmGraphBuilder::BuildCallToRuntimeWithContext(Runtime::FunctionId f,
Node* js_context,
Node** parameters,
int parameter_count) {
const Runtime::Function* fun = Runtime::FunctionForId(f);
auto call_descriptor = Linkage::GetRuntimeCallDescriptor(
mcgraph()->zone(), f, fun->nargs, Operator::kNoProperties,
CallDescriptor::kNoFlags);
// The CEntryStub is loaded from the IsolateRoot so that generated code is
// Isolate independent. At the moment this is only done for CEntryStub(1).
Node* isolate_root = BuildLoadIsolateRoot();
DCHECK_EQ(1, fun->result_size);
auto centry_id =
Builtin::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit;
Node* centry_stub =
gasm_->LoadFromObject(MachineType::Pointer(), isolate_root,
IsolateData::BuiltinSlotOffset(centry_id));
// TODO(titzer): allow arbitrary number of runtime arguments
// At the moment we only allow 5 parameters. If more parameters are needed,
// increase this constant accordingly.
static const int kMaxParams = 5;
DCHECK_GE(kMaxParams, parameter_count);
Node* inputs[kMaxParams + 6];
int count = 0;
inputs[count++] = centry_stub;
for (int i = 0; i < parameter_count; i++) {
inputs[count++] = parameters[i];
}
inputs[count++] =
mcgraph()->ExternalConstant(ExternalReference::Create(f)); // ref
inputs[count++] = Int32Constant(fun->nargs); // arity
inputs[count++] = js_context; // js_context
inputs[count++] = effect();
inputs[count++] = control();
return gasm_->Call(call_descriptor, count, inputs);
}
Node* WasmGraphBuilder::BuildCallToRuntime(Runtime::FunctionId f,
Node** parameters,
int parameter_count) {
return BuildCallToRuntimeWithContext(f, NoContextConstant(), parameters,
parameter_count);
}
Node* WasmGraphBuilder::GlobalGet(uint32_t index) {
const wasm::WasmGlobal& global = env_->module->globals[index];
if (global.type.is_reference()) {
if (global.mutability && global.imported) {
Node* base = nullptr;
Node* offset = nullptr;
GetBaseAndOffsetForImportedMutableExternRefGlobal(global, &base, &offset);
return gasm_->LoadFromObject(MachineType::AnyTagged(), base, offset);
}
Node* globals_buffer =
LOAD_INSTANCE_FIELD(TaggedGlobalsBuffer, MachineType::TaggedPointer());
return gasm_->LoadFixedArrayElementAny(globals_buffer, global.offset);
}
MachineType mem_type = global.type.machine_type();
if (mem_type.representation() == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
Node* base = nullptr;
Node* offset = nullptr;
GetGlobalBaseAndOffset(mem_type, global, &base, &offset);
// TODO(manoskouk): Cannot use LoadFromObject here due to
// GetGlobalBaseAndOffset pointer arithmetic.
return gasm_->Load(mem_type, base, offset);
}
void WasmGraphBuilder::GlobalSet(uint32_t index, Node* val) {
const wasm::WasmGlobal& global = env_->module->globals[index];
if (global.type.is_reference()) {
if (global.mutability && global.imported) {
Node* base = nullptr;
Node* offset = nullptr;
GetBaseAndOffsetForImportedMutableExternRefGlobal(global, &base, &offset);
gasm_->StoreToObject(
ObjectAccess(MachineType::AnyTagged(), kFullWriteBarrier), base,
offset, val);
return;
}
Node* globals_buffer =
LOAD_INSTANCE_FIELD(TaggedGlobalsBuffer, MachineType::TaggedPointer());
gasm_->StoreFixedArrayElementAny(globals_buffer, global.offset, val);
return;
}
MachineType mem_type = global.type.machine_type();
if (mem_type.representation() == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
Node* base = nullptr;
Node* offset = nullptr;
GetGlobalBaseAndOffset(mem_type, global, &base, &offset);
auto store_rep =
StoreRepresentation(mem_type.representation(), kNoWriteBarrier);
// TODO(manoskouk): Cannot use StoreToObject here due to
// GetGlobalBaseAndOffset pointer arithmetic.
gasm_->Store(store_rep, base, offset, val);
}
Node* WasmGraphBuilder::TableGet(uint32_t table_index, Node* index,
wasm::WasmCodePosition position) {
return gasm_->CallRuntimeStub(wasm::WasmCode::kWasmTableGet,
gasm_->IntPtrConstant(table_index), index);
}
void WasmGraphBuilder::TableSet(uint32_t table_index, Node* index, Node* val,
wasm::WasmCodePosition position) {
gasm_->CallRuntimeStub(wasm::WasmCode::kWasmTableSet,
gasm_->IntPtrConstant(table_index), index, val);
}
Node* WasmGraphBuilder::CheckBoundsAndAlignment(
int8_t access_size, Node* index, uint64_t offset,
wasm::WasmCodePosition position) {
// Atomic operations need bounds checks until the backend can emit protected
// loads.
index =
BoundsCheckMem(access_size, index, offset, position, kNeedsBoundsCheck)
.first;
const uintptr_t align_mask = access_size - 1;
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
// Don't emit an alignment check if the index is a constant.
// TODO(wasm): a constant match is also done above in {BoundsCheckMem}.
UintPtrMatcher match(index);
if (match.HasResolvedValue()) {
uintptr_t effective_offset = match.ResolvedValue() + capped_offset;
if ((effective_offset & align_mask) != 0) {
// statically known to be unaligned; trap.
TrapIfEq32(wasm::kTrapUnalignedAccess, Int32Constant(0), 0, position);
}
return index;
}
// Unlike regular memory accesses, atomic memory accesses should trap if
// the effective offset is misaligned.
// TODO(wasm): this addition is redundant with one inserted by {MemBuffer}.
Node* effective_offset = gasm_->IntAdd(MemBuffer(capped_offset), index);
Node* cond =
gasm_->WordAnd(effective_offset, gasm_->IntPtrConstant(align_mask));
TrapIfFalse(wasm::kTrapUnalignedAccess,
gasm_->Word32Equal(cond, Int32Constant(0)), position);
return index;
}
// Insert code to bounds check a memory access if necessary. Return the
// bounds-checked index, which is guaranteed to have (the equivalent of)
// {uintptr_t} representation.
std::pair<Node*, WasmGraphBuilder::BoundsCheckResult>
WasmGraphBuilder::BoundsCheckMem(uint8_t access_size, Node* index,
uint64_t offset,
wasm::WasmCodePosition position,
EnforceBoundsCheck enforce_check) {
DCHECK_LE(1, access_size);
// If the offset does not fit in a uintptr_t, this can never succeed on this
// machine.
if (offset > std::numeric_limits<uintptr_t>::max() ||
!base::IsInBounds<uintptr_t>(offset, access_size,
env_->max_memory_size)) {
// The access will be out of bounds, even for the largest memory.
TrapIfEq32(wasm::kTrapMemOutOfBounds, Int32Constant(0), 0, position);
return {gasm_->UintPtrConstant(0), kOutOfBounds};
}
// Convert the index to uintptr.
if (!env_->module->is_memory64) {
index = BuildChangeUint32ToUintPtr(index);
} else if (kSystemPointerSize == kInt32Size) {
// In memory64 mode on 32-bit systems, the upper 32 bits need to be zero to
// succeed the bounds check.
DCHECK_NE(wasm::kTrapHandler, env_->bounds_checks);
if (env_->bounds_checks == wasm::kExplicitBoundsChecks) {
Node* high_word = gasm_->TruncateInt64ToInt32(
gasm_->Word64Shr(index, Int32Constant(32)));
TrapIfTrue(wasm::kTrapMemOutOfBounds, high_word, position);
}
// Only use the low word for the following bounds check.
index = gasm_->TruncateInt64ToInt32(index);
}
// If no bounds checks should be performed (for testing), just return the
// converted index and assume it to be in-bounds.
if (env_->bounds_checks == wasm::kNoBoundsChecks) return {index, kInBounds};
// The accessed memory is [index + offset, index + end_offset].
// Check that the last read byte (at {index + end_offset}) is in bounds.
// 1) Check that {end_offset < mem_size}. This also ensures that we can safely
// compute {effective_size} as {mem_size - end_offset)}.
// {effective_size} is >= 1 if condition 1) holds.
// 2) Check that {index + end_offset < mem_size} by
// - computing {effective_size} as {mem_size - end_offset} and
// - checking that {index < effective_size}.
uintptr_t end_offset = offset + access_size - 1u;
UintPtrMatcher match(index);
if (match.HasResolvedValue() && end_offset <= env_->min_memory_size &&
match.ResolvedValue() < env_->min_memory_size - end_offset) {
// The input index is a constant and everything is statically within
// bounds of the smallest possible memory.
return {index, kInBounds};
}
if (env_->bounds_checks == wasm::kTrapHandler &&
enforce_check == kCanOmitBoundsCheck) {
return {index, kTrapHandler};
}
Node* mem_size = instance_cache_->mem_size;
Node* end_offset_node = mcgraph_->UintPtrConstant(end_offset);
if (end_offset > env_->min_memory_size) {
// The end offset is larger than the smallest memory.
// Dynamically check the end offset against the dynamic memory size.
Node* cond = gasm_->UintLessThan(end_offset_node, mem_size);
TrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
}
// This produces a positive number since {end_offset <= min_size <= mem_size}.
Node* effective_size = gasm_->IntSub(mem_size, end_offset_node);
// Introduce the actual bounds check.
Node* cond = gasm_->UintLessThan(index, effective_size);
TrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
return {index, kDynamicallyChecked};
}
const Operator* WasmGraphBuilder::GetSafeLoadOperator(int offset,
wasm::ValueType type) {
int alignment = offset % type.element_size_bytes();
MachineType mach_type = type.machine_type();
if (COMPRESS_POINTERS_BOOL && mach_type.IsTagged()) {
// We are loading tagged value from off-heap location, so we need to load
// it as a full word otherwise we will not be able to decompress it.
mach_type = MachineType::Pointer();
}
if (alignment == 0 || mcgraph()->machine()->UnalignedLoadSupported(
type.machine_representation())) {
return mcgraph()->machine()->Load(mach_type);
}
return mcgraph()->machine()->UnalignedLoad(mach_type);
}
const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset,
wasm::ValueType type) {
int alignment = offset % type.element_size_bytes();
MachineRepresentation rep = type.machine_representation();
if (COMPRESS_POINTERS_BOOL && IsAnyTagged(rep)) {
// We are storing tagged value to off-heap location, so we need to store
// it as a full word otherwise we will not be able to decompress it.
rep = MachineType::PointerRepresentation();
}
if (alignment == 0 || mcgraph()->machine()->UnalignedStoreSupported(rep)) {
StoreRepresentation store_rep(rep, WriteBarrierKind::kNoWriteBarrier);
return mcgraph()->machine()->Store(store_rep);
}
UnalignedStoreRepresentation store_rep(rep);
return mcgraph()->machine()->UnalignedStore(store_rep);
}
void WasmGraphBuilder::TraceFunctionEntry(wasm::WasmCodePosition position) {
Node* call = BuildCallToRuntime(Runtime::kWasmTraceEnter, nullptr, 0);
SetSourcePosition(call, position);
}
void WasmGraphBuilder::TraceFunctionExit(base::Vector<Node*> vals,
wasm::WasmCodePosition position) {
Node* info = gasm_->IntPtrConstant(0);
size_t num_returns = vals.size();
if (num_returns == 1) {
wasm::ValueType return_type = sig_->GetReturn(0);
MachineRepresentation rep = return_type.machine_representation();
int size = ElementSizeInBytes(rep);
info = gasm_->StackSlot(size, size);
gasm_->Store(StoreRepresentation(rep, kNoWriteBarrier), info,
Int32Constant(0), vals[0]);
}
Node* call = BuildCallToRuntime(Runtime::kWasmTraceExit, &info, 1);
SetSourcePosition(call, position);
}
void WasmGraphBuilder::TraceMemoryOperation(bool is_store,
MachineRepresentation rep,
Node* index, uintptr_t offset,
wasm::WasmCodePosition position) {
int kAlign = 4; // Ensure that the LSB is 0, such that this looks like a Smi.
TNode<RawPtrT> info =
gasm_->StackSlot(sizeof(wasm::MemoryTracingInfo), kAlign);
Node* effective_offset = gasm_->IntAdd(gasm_->UintPtrConstant(offset), index);
auto store = [&](int field_offset, MachineRepresentation rep, Node* data) {
gasm_->Store(StoreRepresentation(rep, kNoWriteBarrier), info,
Int32Constant(field_offset), data);
};
// Store effective_offset, is_store, and mem_rep.
store(offsetof(wasm::MemoryTracingInfo, offset),
MachineType::PointerRepresentation(), effective_offset);
store(offsetof(wasm::MemoryTracingInfo, is_store),
MachineRepresentation::kWord8, Int32Constant(is_store ? 1 : 0));
store(offsetof(wasm::MemoryTracingInfo, mem_rep),
MachineRepresentation::kWord8, Int32Constant(static_cast<int>(rep)));
Node* args[] = {info};
Node* call =
BuildCallToRuntime(Runtime::kWasmTraceMemory, args, arraysize(args));
SetSourcePosition(call, position);
}
namespace {
LoadTransformation GetLoadTransformation(
MachineType memtype, wasm::LoadTransformationKind transform) {
switch (transform) {
case wasm::LoadTransformationKind::kSplat: {
if (memtype == MachineType::Int8()) {
return LoadTransformation::kS128Load8Splat;
} else if (memtype == MachineType::Int16()) {
return LoadTransformation::kS128Load16Splat;
} else if (memtype == MachineType::Int32()) {
return LoadTransformation::kS128Load32Splat;
} else if (memtype == MachineType::Int64()) {
return LoadTransformation::kS128Load64Splat;
}
break;
}
case wasm::LoadTransformationKind::kExtend: {
if (memtype == MachineType::Int8()) {
return LoadTransformation::kS128Load8x8S;
} else if (memtype == MachineType::Uint8()) {
return LoadTransformation::kS128Load8x8U;
} else if (memtype == MachineType::Int16()) {
return LoadTransformation::kS128Load16x4S;
} else if (memtype == MachineType::Uint16()) {
return LoadTransformation::kS128Load16x4U;
} else if (memtype == MachineType::Int32()) {
return LoadTransformation::kS128Load32x2S;
} else if (memtype == MachineType::Uint32()) {
return LoadTransformation::kS128Load32x2U;
}
break;
}
case wasm::LoadTransformationKind::kZeroExtend: {
if (memtype == MachineType::Int32()) {
return LoadTransformation::kS128Load32Zero;
} else if (memtype == MachineType::Int64()) {
return LoadTransformation::kS128Load64Zero;
}
break;
}
}
UNREACHABLE();
}
MemoryAccessKind GetMemoryAccessKind(
MachineGraph* mcgraph, MachineRepresentation memrep,
WasmGraphBuilder::BoundsCheckResult bounds_check_result) {
if (bounds_check_result == WasmGraphBuilder::kTrapHandler) {
// Protected instructions do not come in an 'unaligned' flavor, so the trap
// handler can currently only be used on systems where all memory accesses
// are allowed to be unaligned.
DCHECK(memrep == MachineRepresentation::kWord8 ||
mcgraph->machine()->UnalignedLoadSupported(memrep));
return MemoryAccessKind::kProtected;
}
if (memrep != MachineRepresentation::kWord8 &&
!mcgraph->machine()->UnalignedLoadSupported(memrep)) {
return MemoryAccessKind::kUnaligned;
}
return MemoryAccessKind::kNormal;
}
} // namespace
// S390 simulator does not execute BE code, hence needs to also check if we are
// running on a LE simulator.
// TODO(miladfar): Remove SIM once V8_TARGET_BIG_ENDIAN includes the Sim.
#if defined(V8_TARGET_BIG_ENDIAN) || defined(V8_TARGET_ARCH_S390_LE_SIM)
Node* WasmGraphBuilder::LoadTransformBigEndian(
wasm::ValueType type, MachineType memtype,
wasm::LoadTransformationKind transform, Node* index, uint64_t offset,
uint32_t alignment, wasm::WasmCodePosition position) {
#define LOAD_EXTEND(num_lanes, bytes_per_load, replace_lane) \
result = graph()->NewNode(mcgraph()->machine()->S128Zero()); \
Node* values[num_lanes]; \
for (int i = 0; i < num_lanes; i++) { \
values[i] = LoadMem(type, memtype, index, offset + i * bytes_per_load, \
alignment, position); \
if (memtype.IsSigned()) { \
/* sign extend */ \
values[i] = graph()->NewNode(mcgraph()->machine()->ChangeInt32ToInt64(), \
values[i]); \
} else { \
/* zero extend */ \
values[i] = graph()->NewNode( \
mcgraph()->machine()->ChangeUint32ToUint64(), values[i]); \
} \
} \
for (int lane = 0; lane < num_lanes; lane++) { \
result = graph()->NewNode(mcgraph()->machine()->replace_lane(lane), \
result, values[lane]); \
}
Node* result;
LoadTransformation transformation = GetLoadTransformation(memtype, transform);
switch (transformation) {
case LoadTransformation::kS128Load8Splat: {
result = LoadMem(type, memtype, index, offset, alignment, position);
result = graph()->NewNode(mcgraph()->machine()->I8x16Splat(), result);
break;
}
case LoadTransformation::kS128Load8x8S:
case LoadTransformation::kS128Load8x8U: {
LOAD_EXTEND(8, 1, I16x8ReplaceLane)
break;
}
case LoadTransformation::kS128Load16Splat: {
result = LoadMem(type, memtype, index, offset, alignment, position);
result = graph()->NewNode(mcgraph()->machine()->I16x8Splat(), result);
break;
}
case LoadTransformation::kS128Load16x4S:
case LoadTransformation::kS128Load16x4U: {
LOAD_EXTEND(4, 2, I32x4ReplaceLane)
break;
}
case LoadTransformation::kS128Load32Splat: {
result = LoadMem(type, memtype, index, offset, alignment, position);
result = graph()->NewNode(mcgraph()->machine()->I32x4Splat(), result);
break;
}
case LoadTransformation::kS128Load32x2S:
case LoadTransformation::kS128Load32x2U: {
LOAD_EXTEND(2, 4, I64x2ReplaceLane)
break;
}
case LoadTransformation::kS128Load64Splat: {
result = LoadMem(type, memtype, index, offset, alignment, position);
result = graph()->NewNode(mcgraph()->machine()->I64x2Splat(), result);
break;
}
case LoadTransformation::kS128Load32Zero: {
result = graph()->NewNode(mcgraph()->machine()->S128Zero());
result = graph()->NewNode(
mcgraph()->machine()->I32x4ReplaceLane(0), result,
LoadMem(type, memtype, index, offset, alignment, position));
break;
}
case LoadTransformation::kS128Load64Zero: {
result = graph()->NewNode(mcgraph()->machine()->S128Zero());
result = graph()->NewNode(
mcgraph()->machine()->I64x2ReplaceLane(0), result,
LoadMem(type, memtype, index, offset, alignment, position));
break;
}
default:
UNREACHABLE();
}
return result;
#undef LOAD_EXTEND
}
#endif
Node* WasmGraphBuilder::LoadLane(wasm::ValueType type, MachineType memtype,
Node* value, Node* index, uint64_t offset,
uint32_t alignment, uint8_t laneidx,
wasm::WasmCodePosition position) {
has_simd_ = true;
Node* load;
uint8_t access_size = memtype.MemSize();
BoundsCheckResult bounds_check_result;
std::tie(index, bounds_check_result) =
BoundsCheckMem(access_size, index, offset, position, kCanOmitBoundsCheck);
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
#if defined(V8_TARGET_BIG_ENDIAN) || defined(V8_TARGET_ARCH_S390_LE_SIM)
load = LoadMem(type, memtype, index, offset, alignment, position);
if (memtype == MachineType::Int8()) {
load = graph()->NewNode(mcgraph()->machine()->I8x16ReplaceLane(laneidx),
value, load);
} else if (memtype == MachineType::Int16()) {
load = graph()->NewNode(mcgraph()->machine()->I16x8ReplaceLane(laneidx),
value, load);
} else if (memtype == MachineType::Int32()) {
load = graph()->NewNode(mcgraph()->machine()->I32x4ReplaceLane(laneidx),
value, load);
} else if (memtype == MachineType::Int64()) {
load = graph()->NewNode(mcgraph()->machine()->I64x2ReplaceLane(laneidx),
value, load);
} else {
UNREACHABLE();
}
#else
MemoryAccessKind load_kind = GetMemoryAccessKind(
mcgraph_, memtype.representation(), bounds_check_result);
load = SetEffect(graph()->NewNode(
mcgraph()->machine()->LoadLane(load_kind, memtype, laneidx),
MemBuffer(capped_offset), index, value, effect(), control()));
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(load, position);
}
#endif
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(false, memtype.representation(), index, capped_offset,
position);
}
return load;
}
Node* WasmGraphBuilder::LoadTransform(wasm::ValueType type, MachineType memtype,
wasm::LoadTransformationKind transform,
Node* index, uint64_t offset,
uint32_t alignment,
wasm::WasmCodePosition position) {
has_simd_ = true;
Node* load;
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
#if defined(V8_TARGET_BIG_ENDIAN) || defined(V8_TARGET_ARCH_S390_LE_SIM)
// LoadTransform cannot efficiently be executed on BE machines as a
// single operation since loaded bytes need to be reversed first,
// therefore we divide them into separate "load" and "operation" nodes.
load = LoadTransformBigEndian(type, memtype, transform, index, offset,
alignment, position);
USE(GetMemoryAccessKind);
#else
// Wasm semantics throw on OOB. Introduce explicit bounds check and
// conditioning when not using the trap handler.
// Load extends always load 8 bytes.
uint8_t access_size = transform == wasm::LoadTransformationKind::kExtend
? 8
: memtype.MemSize();
BoundsCheckResult bounds_check_result;
std::tie(index, bounds_check_result) =
BoundsCheckMem(access_size, index, offset, position, kCanOmitBoundsCheck);
LoadTransformation transformation = GetLoadTransformation(memtype, transform);
MemoryAccessKind load_kind = GetMemoryAccessKind(
mcgraph_, memtype.representation(), bounds_check_result);
load = SetEffect(graph()->NewNode(
mcgraph()->machine()->LoadTransform(load_kind, transformation),
MemBuffer(capped_offset), index, effect(), control()));
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(load, position);
}
#endif
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(false, memtype.representation(), index, capped_offset,
position);
}
return load;
}
Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
Node* index, uint64_t offset,
uint32_t alignment,
wasm::WasmCodePosition position) {
Node* load;
if (memtype.representation() == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
// Wasm semantics throw on OOB. Introduce explicit bounds check and
// conditioning when not using the trap handler.
BoundsCheckResult bounds_check_result;
std::tie(index, bounds_check_result) = BoundsCheckMem(
memtype.MemSize(), index, offset, position, kCanOmitBoundsCheck);
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
switch (GetMemoryAccessKind(mcgraph_, memtype.representation(),
bounds_check_result)) {
case MemoryAccessKind::kUnaligned:
load = gasm_->LoadUnaligned(memtype, MemBuffer(capped_offset), index);
break;
case MemoryAccessKind::kProtected:
load = gasm_->ProtectedLoad(memtype, MemBuffer(capped_offset), index);
SetSourcePosition(load, position);
break;
case MemoryAccessKind::kNormal:
load = gasm_->Load(memtype, MemBuffer(capped_offset), index);
break;
}
#if defined(V8_TARGET_BIG_ENDIAN)
load = BuildChangeEndiannessLoad(load, memtype, type);
#endif
if (type == wasm::kWasmI64 &&
ElementSizeInBytes(memtype.representation()) < 8) {
// TODO(titzer): TF zeroes the upper bits of 64-bit loads for subword sizes.
load = memtype.IsSigned()
? gasm_->ChangeInt32ToInt64(load) // sign extend
: gasm_->ChangeUint32ToUint64(load); // zero extend
}
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(false, memtype.representation(), index, capped_offset,
position);
}
return load;
}
void WasmGraphBuilder::StoreLane(MachineRepresentation mem_rep, Node* index,
uint64_t offset, uint32_t alignment, Node* val,
uint8_t laneidx,
wasm::WasmCodePosition position,
wasm::ValueType type) {
has_simd_ = true;
BoundsCheckResult bounds_check_result;
std::tie(index, bounds_check_result) =
BoundsCheckMem(i::ElementSizeInBytes(mem_rep), index, offset, position,
kCanOmitBoundsCheck);
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
#if defined(V8_TARGET_BIG_ENDIAN) || defined(V8_TARGET_ARCH_S390_LE_SIM)
Node* output;
if (mem_rep == MachineRepresentation::kWord8) {
output =
graph()->NewNode(mcgraph()->machine()->I8x16ExtractLaneS(laneidx), val);
} else if (mem_rep == MachineRepresentation::kWord16) {
output =
graph()->NewNode(mcgraph()->machine()->I16x8ExtractLaneS(laneidx), val);
} else if (mem_rep == MachineRepresentation::kWord32) {
output =
graph()->NewNode(mcgraph()->machine()->I32x4ExtractLane(laneidx), val);
} else if (mem_rep == MachineRepresentation::kWord64) {
output =
graph()->NewNode(mcgraph()->machine()->I64x2ExtractLane(laneidx), val);
} else {
UNREACHABLE();
}
StoreMem(mem_rep, index, offset, alignment, output, position, type);
#else
MemoryAccessKind load_kind =
GetMemoryAccessKind(mcgraph_, mem_rep, bounds_check_result);
Node* store = SetEffect(graph()->NewNode(
mcgraph()->machine()->StoreLane(load_kind, mem_rep, laneidx),
MemBuffer(capped_offset), index, val, effect(), control()));
if (load_kind == MemoryAccessKind::kProtected) {
SetSourcePosition(store, position);
}
#endif
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(true, mem_rep, index, capped_offset, position);
}
}
void WasmGraphBuilder::StoreMem(MachineRepresentation mem_rep, Node* index,
uint64_t offset, uint32_t alignment, Node* val,
wasm::WasmCodePosition position,
wasm::ValueType type) {
if (mem_rep == MachineRepresentation::kSimd128) {
has_simd_ = true;
}
BoundsCheckResult bounds_check_result;
std::tie(index, bounds_check_result) =
BoundsCheckMem(i::ElementSizeInBytes(mem_rep), index, offset, position,
kCanOmitBoundsCheck);
#if defined(V8_TARGET_BIG_ENDIAN)
val = BuildChangeEndiannessStore(val, mem_rep, type);
#endif
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
switch (GetMemoryAccessKind(mcgraph_, mem_rep, bounds_check_result)) {
case MemoryAccessKind::kUnaligned:
gasm_->StoreUnaligned(UnalignedStoreRepresentation{mem_rep},
MemBuffer(capped_offset), index, val);
break;
case MemoryAccessKind::kProtected:
SetSourcePosition(
gasm_->ProtectedStore(mem_rep, MemBuffer(capped_offset), index, val),
position);
break;
case MemoryAccessKind::kNormal:
gasm_->Store(StoreRepresentation{mem_rep, kNoWriteBarrier},
MemBuffer(capped_offset), index, val);
break;
}
if (FLAG_trace_wasm_memory) {
TraceMemoryOperation(true, mem_rep, index, capped_offset, position);
}
}
Node* WasmGraphBuilder::BuildAsmjsLoadMem(MachineType type, Node* index) {
DCHECK_NOT_NULL(instance_cache_);
Node* mem_start = instance_cache_->mem_start;
Node* mem_size = instance_cache_->mem_size;
DCHECK_NOT_NULL(mem_start);
DCHECK_NOT_NULL(mem_size);
// Asm.js semantics are defined in terms of typed arrays, hence OOB
// reads return {undefined} coerced to the result type (0 for integers, NaN
// for float and double).
// Note that we check against the memory size ignoring the size of the
// stored value, which is conservative if misaligned. Technically, asm.js
// should never have misaligned accesses.
index = BuildChangeUint32ToUintPtr(index);
Diamond bounds_check(graph(), mcgraph()->common(),
gasm_->UintLessThan(index, mem_size), BranchHint::kTrue);
bounds_check.Chain(control());
Node* load = graph()->NewNode(mcgraph()->machine()->Load(type), mem_start,
index, effect(), bounds_check.if_true);
SetEffectControl(bounds_check.EffectPhi(load, effect()), bounds_check.merge);
Node* oob_value;
switch (type.representation()) {
case MachineRepresentation::kWord8:
case MachineRepresentation::kWord16:
case MachineRepresentation::kWord32:
oob_value = Int32Constant(0);
break;
case MachineRepresentation::kWord64:
oob_value = Int64Constant(0);
break;
case MachineRepresentation::kFloat32:
oob_value = Float32Constant(std::numeric_limits<float>::quiet_NaN());
break;
case MachineRepresentation::kFloat64:
oob_value = Float64Constant(std::numeric_limits<double>::quiet_NaN());
break;
default:
UNREACHABLE();
}
return bounds_check.Phi(type.representation(), load, oob_value);
}
Node* WasmGraphBuilder::BuildAsmjsStoreMem(MachineType type, Node* index,
Node* val) {
DCHECK_NOT_NULL(instance_cache_);
Node* mem_start = instance_cache_->mem_start;
Node* mem_size = instance_cache_->mem_size;
DCHECK_NOT_NULL(mem_start);
DCHECK_NOT_NULL(mem_size);
// Asm.js semantics are to ignore OOB writes.
// Note that we check against the memory size ignoring the size of the
// stored value, which is conservative if misaligned. Technically, asm.js
// should never have misaligned accesses.
Diamond bounds_check(graph(), mcgraph()->common(),
gasm_->Uint32LessThan(index, mem_size),
BranchHint::kTrue);
bounds_check.Chain(control());
index = BuildChangeUint32ToUintPtr(index);
const Operator* store_op = mcgraph()->machine()->Store(StoreRepresentation(
type.representation(), WriteBarrierKind::kNoWriteBarrier));
Node* store = graph()->NewNode(store_op, mem_start, index, val, effect(),
bounds_check.if_true);
SetEffectControl(bounds_check.EffectPhi(store, effect()), bounds_check.merge);
return val;
}
Node* WasmGraphBuilder::BuildF64x2Ceil(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f64x2_ceil();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64x2Floor(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f64x2_floor();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64x2Trunc(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f64x2_trunc();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF64x2NearestInt(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f64x2_nearest_int();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32x4Ceil(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f32x4_ceil();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32x4Floor(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f32x4_floor();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32x4Trunc(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f32x4_trunc();
return BuildCFuncInstruction(ref, type, input);
}
Node* WasmGraphBuilder::BuildF32x4NearestInt(Node* input) {
MachineType type = MachineType::Simd128();
ExternalReference ref = ExternalReference::wasm_f32x4_nearest_int();
return BuildCFuncInstruction(ref, type, input);
}
void WasmGraphBuilder::PrintDebugName(Node* node) {
PrintF("#%d:%s", node->id(), node->op()->mnemonic());
}
Graph* WasmGraphBuilder::graph() { return mcgraph()->graph(); }
namespace {
Signature<MachineRepresentation>* CreateMachineSignature(
Zone* zone, const wasm::FunctionSig* sig,
WasmGraphBuilder::CallOrigin origin) {
Signature<MachineRepresentation>::Builder builder(zone, sig->return_count(),
sig->parameter_count());
for (auto ret : sig->returns()) {
if (origin == WasmGraphBuilder::kCalledFromJS) {
builder.AddReturn(MachineRepresentation::kTagged);
} else {
builder.AddReturn(ret.machine_representation());
}
}
for (auto param : sig->parameters()) {
if (origin == WasmGraphBuilder::kCalledFromJS) {
// Parameters coming from JavaScript are always tagged values. Especially
// when the signature says that it's an I64 value, then a BigInt object is
// provided by JavaScript, and not two 32-bit parameters.
builder.AddParam(MachineRepresentation::kTagged);
} else {
builder.AddParam(param.machine_representation());
}
}
return builder.Build();
}
} // namespace
void WasmGraphBuilder::AddInt64LoweringReplacement(
CallDescriptor* original, CallDescriptor* replacement) {
if (!lowering_special_case_) {
lowering_special_case_ = std::make_unique<Int64LoweringSpecialCase>();
}
lowering_special_case_->replacements.insert({original, replacement});
}
CallDescriptor* WasmGraphBuilder::GetI32AtomicWaitCallDescriptor() {
if (i32_atomic_wait_descriptor_) return i32_atomic_wait_descriptor_;
i32_atomic_wait_descriptor_ = GetBuiltinCallDescriptor(
Builtin::kWasmI32AtomicWait64, zone_, StubCallMode::kCallWasmRuntimeStub);
AddInt64LoweringReplacement(
i32_atomic_wait_descriptor_,
GetBuiltinCallDescriptor(Builtin::kWasmI32AtomicWait32, zone_,
StubCallMode::kCallWasmRuntimeStub));
return i32_atomic_wait_descriptor_;
}
CallDescriptor* WasmGraphBuilder::GetI64AtomicWaitCallDescriptor() {
if (i64_atomic_wait_descriptor_) return i64_atomic_wait_descriptor_;
i64_atomic_wait_descriptor_ = GetBuiltinCallDescriptor(
Builtin::kWasmI64AtomicWait64, zone_, StubCallMode::kCallWasmRuntimeStub);
AddInt64LoweringReplacement(
i64_atomic_wait_descriptor_,
GetBuiltinCallDescriptor(Builtin::kWasmI64AtomicWait32, zone_,
StubCallMode::kCallWasmRuntimeStub));
return i64_atomic_wait_descriptor_;
}
void WasmGraphBuilder::LowerInt64(Signature<MachineRepresentation>* sig) {
if (mcgraph()->machine()->Is64()) return;
Int64Lowering r(mcgraph()->graph(), mcgraph()->machine(), mcgraph()->common(),
gasm_->simplified(), mcgraph()->zone(), sig,
std::move(lowering_special_case_));
r.LowerGraph();
}
void WasmGraphBuilder::LowerInt64(CallOrigin origin) {
LowerInt64(CreateMachineSignature(mcgraph()->zone(), sig_, origin));
}
void WasmGraphBuilder::SetSourcePosition(Node* node,
wasm::WasmCodePosition position) {
DCHECK_NE(position, wasm::kNoCodePosition);
if (source_position_table_) {
source_position_table_->SetSourcePosition(node, SourcePosition(position));
}
}
Node* WasmGraphBuilder::S128Zero() {
has_simd_ = true;
return graph()->NewNode(mcgraph()->machine()->S128Zero());
}
Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, Node* const* inputs) {
has_simd_ = true;
switch (opcode) {
case wasm::kExprF64x2Splat:
return graph()->NewNode(mcgraph()->machine()->F64x2Splat(), inputs[0]);
case wasm::kExprF64x2Abs:
return graph()->NewNode(mcgraph()->machine()->F64x2Abs(), inputs[0]);
case wasm::kExprF64x2Neg:
return graph()->NewNode(mcgraph()->machine()->F64x2Neg(), inputs[0]);
case wasm::kExprF64x2Sqrt:
return graph()->NewNode(mcgraph()->machine()->F64x2Sqrt(), inputs[0]);
case wasm::kExprF64x2Add:
return graph()->NewNode(mcgraph()->machine()->F64x2Add(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Sub:
return graph()->NewNode(mcgraph()->machine()->F64x2Sub(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Mul:
return graph()->NewNode(mcgraph()->machine()->F64x2Mul(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Div:
return graph()->NewNode(mcgraph()->machine()->F64x2Div(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Min:
return graph()->NewNode(mcgraph()->machine()->F64x2Min(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Max:
return graph()->NewNode(mcgraph()->machine()->F64x2Max(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Eq:
return graph()->NewNode(mcgraph()->machine()->F64x2Eq(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Ne:
return graph()->NewNode(mcgraph()->machine()->F64x2Ne(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Lt:
return graph()->NewNode(mcgraph()->machine()->F64x2Lt(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Le:
return graph()->NewNode(mcgraph()->machine()->F64x2Le(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Gt:
return graph()->NewNode(mcgraph()->machine()->F64x2Lt(), inputs[1],
inputs[0]);
case wasm::kExprF64x2Ge:
return graph()->NewNode(mcgraph()->machine()->F64x2Le(), inputs[1],
inputs[0]);
case wasm::kExprF64x2Qfma:
return graph()->NewNode(mcgraph()->machine()->F64x2Qfma(), inputs[0],
inputs[1], inputs[2]);
case wasm::kExprF64x2Qfms:
return graph()->NewNode(mcgraph()->machine()->F64x2Qfms(), inputs[0],
inputs[1], inputs[2]);
case wasm::kExprF64x2Pmin:
return graph()->NewNode(mcgraph()->machine()->F64x2Pmin(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Pmax:
return graph()->NewNode(mcgraph()->machine()->F64x2Pmax(), inputs[0],
inputs[1]);
case wasm::kExprF64x2Ceil:
// Architecture support for F64x2Ceil and Float64RoundUp is the same.
if (!mcgraph()->machine()->Float64RoundUp().IsSupported())
return BuildF64x2Ceil(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F64x2Ceil(), inputs[0]);
case wasm::kExprF64x2Floor:
// Architecture support for F64x2Floor and Float64RoundDown is the same.
if (!mcgraph()->machine()->Float64RoundDown().IsSupported())
return BuildF64x2Floor(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F64x2Floor(), inputs[0]);
case wasm::kExprF64x2Trunc:
// Architecture support for F64x2Trunc and Float64RoundTruncate is the
// same.
if (!mcgraph()->machine()->Float64RoundTruncate().IsSupported())
return BuildF64x2Trunc(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F64x2Trunc(), inputs[0]);
case wasm::kExprF64x2NearestInt:
// Architecture support for F64x2NearestInt and Float64RoundTiesEven is
// the same.
if (!mcgraph()->machine()->Float64RoundTiesEven().IsSupported())
return BuildF64x2NearestInt(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F64x2NearestInt(),
inputs[0]);
case wasm::kExprF64x2ConvertLowI32x4S:
return graph()->NewNode(mcgraph()->machine()->F64x2ConvertLowI32x4S(),
inputs[0]);
case wasm::kExprF64x2ConvertLowI32x4U:
return graph()->NewNode(mcgraph()->machine()->F64x2ConvertLowI32x4U(),
inputs[0]);
case wasm::kExprF64x2PromoteLowF32x4:
return graph()->NewNode(mcgraph()->machine()->F64x2PromoteLowF32x4(),
inputs[0]);
case wasm::kExprF32x4Splat:
return graph()->NewNode(mcgraph()->machine()->F32x4Splat(), inputs[0]);
case wasm::kExprF32x4SConvertI32x4:
return graph()->NewNode(mcgraph()->machine()->F32x4SConvertI32x4(),
inputs[0]);
case wasm::kExprF32x4UConvertI32x4:
return graph()->NewNode(mcgraph()->machine()->F32x4UConvertI32x4(),
inputs[0]);
case wasm::kExprF32x4Abs:
return graph()->NewNode(mcgraph()->machine()->F32x4Abs(), inputs[0]);
case wasm::kExprF32x4Neg:
return graph()->NewNode(mcgraph()->machine()->F32x4Neg(), inputs[0]);
case wasm::kExprF32x4Sqrt:
return graph()->NewNode(mcgraph()->machine()->F32x4Sqrt(), inputs[0]);
case wasm::kExprF32x4RecipApprox:
return graph()->NewNode(mcgraph()->machine()->F32x4RecipApprox(),
inputs[0]);
case wasm::kExprF32x4RecipSqrtApprox:
return graph()->NewNode(mcgraph()->machine()->F32x4RecipSqrtApprox(),
inputs[0]);
case wasm::kExprF32x4Add:
return graph()->NewNode(mcgraph()->machine()->F32x4Add(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Sub:
return graph()->NewNode(mcgraph()->machine()->F32x4Sub(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Mul:
return graph()->NewNode(mcgraph()->machine()->F32x4Mul(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Div:
return graph()->NewNode(mcgraph()->machine()->F32x4Div(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Min:
return graph()->NewNode(mcgraph()->machine()->F32x4Min(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Max:
return graph()->NewNode(mcgraph()->machine()->F32x4Max(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Eq:
return graph()->NewNode(mcgraph()->machine()->F32x4Eq(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Ne:
return graph()->NewNode(mcgraph()->machine()->F32x4Ne(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Lt:
return graph()->NewNode(mcgraph()->machine()->F32x4Lt(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Le:
return graph()->NewNode(mcgraph()->machine()->F32x4Le(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Gt:
return graph()->NewNode(mcgraph()->machine()->F32x4Lt(), inputs[1],
inputs[0]);
case wasm::kExprF32x4Ge:
return graph()->NewNode(mcgraph()->machine()->F32x4Le(), inputs[1],
inputs[0]);
case wasm::kExprF32x4Qfma:
return graph()->NewNode(mcgraph()->machine()->F32x4Qfma(), inputs[0],
inputs[1], inputs[2]);
case wasm::kExprF32x4Qfms:
return graph()->NewNode(mcgraph()->machine()->F32x4Qfms(), inputs[0],
inputs[1], inputs[2]);
case wasm::kExprF32x4Pmin:
return graph()->NewNode(mcgraph()->machine()->F32x4Pmin(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Pmax:
return graph()->NewNode(mcgraph()->machine()->F32x4Pmax(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Ceil:
// Architecture support for F32x4Ceil and Float32RoundUp is the same.
if (!mcgraph()->machine()->Float32RoundUp().IsSupported())
return BuildF32x4Ceil(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F32x4Ceil(), inputs[0]);
case wasm::kExprF32x4Floor:
// Architecture support for F32x4Floor and Float32RoundDown is the same.
if (!mcgraph()->machine()->Float32RoundDown().IsSupported())
return BuildF32x4Floor(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F32x4Floor(), inputs[0]);
case wasm::kExprF32x4Trunc:
// Architecture support for F32x4Trunc and Float32RoundTruncate is the
// same.
if (!mcgraph()->machine()->Float32RoundTruncate().IsSupported())
return BuildF32x4Trunc(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F32x4Trunc(), inputs[0]);
case wasm::kExprF32x4NearestInt:
// Architecture support for F32x4NearestInt and Float32RoundTiesEven is
// the same.
if (!mcgraph()->machine()->Float32RoundTiesEven().IsSupported())
return BuildF32x4NearestInt(inputs[0]);
return graph()->NewNode(mcgraph()->machine()->F32x4NearestInt(),
inputs[0]);
case wasm::kExprF32x4DemoteF64x2Zero:
return graph()->NewNode(mcgraph()->machine()->F32x4DemoteF64x2Zero(),
inputs[0]);
case wasm::kExprI64x2Splat:
return graph()->NewNode(mcgraph()->machine()->I64x2Splat(), inputs[0]);
case wasm::kExprI64x2Abs:
return graph()->NewNode(mcgraph()->machine()->I64x2Abs(), inputs[0]);
case wasm::kExprI64x2Neg:
return graph()->NewNode(mcgraph()->machine()->I64x2Neg(), inputs[0]);
case wasm::kExprI64x2SConvertI32x4Low:
return graph()->NewNode(mcgraph()->machine()->I64x2SConvertI32x4Low(),
inputs[0]);
case wasm::kExprI64x2SConvertI32x4High:
return graph()->NewNode(mcgraph()->machine()->I64x2SConvertI32x4High(),
inputs[0]);
case wasm::kExprI64x2UConvertI32x4Low:
return graph()->NewNode(mcgraph()->machine()->I64x2UConvertI32x4Low(),
inputs[0]);
case wasm::kExprI64x2UConvertI32x4High:
return graph()->NewNode(mcgraph()->machine()->I64x2UConvertI32x4High(),
inputs[0]);
case wasm::kExprI64x2BitMask:
return graph()->NewNode(mcgraph()->machine()->I64x2BitMask(), inputs[0]);
case wasm::kExprI64x2Shl:
return graph()->NewNode(mcgraph()->machine()->I64x2Shl(), inputs[0],
inputs[1]);
case wasm::kExprI64x2ShrS:
return graph()->NewNode(mcgraph()->machine()->I64x2ShrS(), inputs[0],
inputs[1]);
case wasm::kExprI64x2Add:
return graph()->NewNode(mcgraph()->machine()->I64x2Add(), inputs[0],
inputs[1]);
case wasm::kExprI64x2Sub:
return graph()->NewNode(mcgraph()->machine()->I64x2Sub(), inputs[0],
inputs[1]);
case wasm::kExprI64x2Mul:
return graph()->NewNode(mcgraph()->machine()->I64x2Mul(), inputs[0],
inputs[1]);
case wasm::kExprI64x2Eq:
return graph()->NewNode(mcgraph()->machine()->I64x2Eq(), inputs[0],
inputs[1]);
case wasm::kExprI64x2Ne:
return graph()->NewNode(mcgraph()->machine()->I64x2Ne(), inputs[0],
inputs[1]);
case wasm::kExprI64x2LtS:
return graph()->NewNode(mcgraph()->machine()->I64x2GtS(), inputs[1],
inputs[0]);
case wasm::kExprI64x2LeS:
return graph()->NewNode(mcgraph()->machine()->I64x2GeS(), inputs[1],
inputs[0]);
case wasm::kExprI64x2GtS:
return graph()->NewNode(mcgraph()->machine()->I64x2GtS(), inputs[0],
inputs[1]);
case wasm::kExprI64x2GeS:
return graph()->NewNode(mcgraph()->machine()->I64x2GeS(), inputs[0],
inputs[1]);
case wasm::kExprI64x2ShrU:
return graph()->NewNode(mcgraph()->machine()->I64x2ShrU(), inputs[0],
inputs[1]);
case wasm::kExprI64x2ExtMulLowI32x4S:
return graph()->NewNode(mcgraph()->machine()->I64x2ExtMulLowI32x4S(),
inputs[0], inputs[1]);
case wasm::kExprI64x2ExtMulHighI32x4S:
return graph()->NewNode(mcgraph()->machine()->I64x2ExtMulHighI32x4S(),
inputs[0], inputs[1]);
case wasm::kExprI64x2ExtMulLowI32x4U:
return graph()->NewNode(mcgraph()->machine()->I64x2ExtMulLowI32x4U(),
inputs[0], inputs[1]);
case wasm::kExprI64x2ExtMulHighI32x4U:
return graph()->NewNode(mcgraph()->machine()->I64x2ExtMulHighI32x4U(),
inputs[0], inputs[1]);
case wasm::kExprI32x4Splat:
return graph()->NewNode(mcgraph()->machine()->I32x4Splat(), inputs[0]);
case wasm::kExprI32x4SConvertF32x4:
return graph()->NewNode(mcgraph()->machine()->I32x4SConvertF32x4(),
inputs[0]);
case wasm::kExprI32x4UConvertF32x4:
return graph()->NewNode(mcgraph()->machine()->I32x4UConvertF32x4(),
inputs[0]);
case wasm::kExprI32x4SConvertI16x8Low:
return graph()->NewNode(mcgraph()->machine()->I32x4SConvertI16x8Low(),
inputs[0]);
case wasm::kExprI32x4SConvertI16x8High:
return graph()->NewNode(mcgraph()->machine()->I32x4SConvertI16x8High(),
inputs[0]);
case wasm::kExprI32x4Neg:
return graph()->NewNode(mcgraph()->machine()->I32x4Neg(), inputs[0]);
case wasm::kExprI32x4Shl:
return graph()->NewNode(mcgraph()->machine()->I32x4Shl(), inputs[0],
inputs[1]);
case wasm::kExprI32x4ShrS:
return graph()->NewNode(mcgraph()->machine()->I32x4ShrS(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Add:
return graph()->NewNode(mcgraph()->machine()->I32x4Add(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Sub:
return graph()->NewNode(mcgraph()->machine()->I32x4Sub(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Mul:
return graph()->NewNode(mcgraph()->machine()->I32x4Mul(), inputs[0],
inputs[1]);
case wasm::kExprI32x4MinS:
return graph()->NewNode(mcgraph()->machine()->I32x4MinS(), inputs[0],
inputs[1]);
case wasm::kExprI32x4MaxS:
return graph()->NewNode(mcgraph()->machine()->I32x4MaxS(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Eq:
return graph()->NewNode(mcgraph()->machine()->I32x4Eq(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Ne:
return graph()->NewNode(mcgraph()->machine()->I32x4Ne(), inputs[0],
inputs[1]);
case wasm::kExprI32x4LtS:
return graph()->NewNode(mcgraph()->machine()->I32x4GtS(), inputs[1],
inputs[0]);
case wasm::kExprI32x4LeS:
return graph()->NewNode(mcgraph()->machine()->I32x4GeS(), inputs[1],
inputs[0]);
case wasm::kExprI32x4GtS:
return graph()->NewNode(mcgraph()->machine()->I32x4GtS(), inputs[0],
inputs[1]);
case wasm::kExprI32x4GeS:
return graph()->NewNode(mcgraph()->machine()->I32x4GeS(), inputs[0],
inputs[1]);
case wasm::kExprI32x4UConvertI16x8Low:
return graph()->NewNode(mcgraph()->machine()->I32x4UConvertI16x8Low(),
inputs[0]);
case wasm::kExprI32x4UConvertI16x8High:
return graph()->NewNode(mcgraph()->machine()->I32x4UConvertI16x8High(),
inputs[0]);
case wasm::kExprI32x4ShrU:
return graph()->NewNode(mcgraph()->machine()->I32x4ShrU(), inputs[0],
inputs[1]);
case wasm::kExprI32x4MinU:
return graph()->NewNode(mcgraph()->machine()->I32x4MinU(), inputs[0],
inputs[1]);
case wasm::kExprI32x4MaxU:
return graph()->NewNode(mcgraph()->machine()->I32x4MaxU(), inputs[0],
inputs[1]);
case wasm::kExprI32x4LtU:
return graph()->NewNode(mcgraph()->machine()->I32x4GtU(), inputs[1],
inputs[0]);
case wasm::kExprI32x4LeU:
return graph()->NewNode(mcgraph()->machine()->I32x4GeU(), inputs[1],
inputs[0]);
case wasm::kExprI32x4GtU:
return graph()->NewNode(mcgraph()->machine()->I32x4GtU(), inputs[0],
inputs[1]);
case wasm::kExprI32x4GeU:
return graph()->NewNode(mcgraph()->machine()->I32x4GeU(), inputs[0],
inputs[1]);
case wasm::kExprI32x4Abs:
return graph()->NewNode(mcgraph()->machine()->I32x4Abs(), inputs[0]);
case wasm::kExprI32x4BitMask:
return graph()->NewNode(mcgraph()->machine()->I32x4BitMask(), inputs[0]);
case wasm::kExprI32x4DotI16x8S:
return graph()->NewNode(mcgraph()->machine()->I32x4DotI16x8S(), inputs[0],
inputs[1]);
case wasm::kExprI32x4ExtMulLowI16x8S:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtMulLowI16x8S(),
inputs[0], inputs[1]);
case wasm::kExprI32x4ExtMulHighI16x8S:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtMulHighI16x8S(),
inputs[0], inputs[1]);
case wasm::kExprI32x4ExtMulLowI16x8U:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtMulLowI16x8U(),
inputs[0], inputs[1]);
case wasm::kExprI32x4ExtMulHighI16x8U:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtMulHighI16x8U(),
inputs[0], inputs[1]);
case wasm::kExprI32x4ExtAddPairwiseI16x8S:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtAddPairwiseI16x8S(),
inputs[0]);
case wasm::kExprI32x4ExtAddPairwiseI16x8U:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtAddPairwiseI16x8U(),
inputs[0]);
case wasm::kExprI32x4TruncSatF64x2SZero:
return graph()->NewNode(mcgraph()->machine()->I32x4TruncSatF64x2SZero(),
inputs[0]);
case wasm::kExprI32x4TruncSatF64x2UZero:
return graph()->NewNode(mcgraph()->machine()->I32x4TruncSatF64x2UZero(),
inputs[0]);
case wasm::kExprI16x8Splat:
return graph()->NewNode(mcgraph()->machine()->I16x8Splat(), inputs[0]);
case wasm::kExprI16x8SConvertI8x16Low:
return graph()->NewNode(mcgraph()->machine()->I16x8SConvertI8x16Low(),
inputs[0]);
case wasm::kExprI16x8SConvertI8x16High:
return graph()->NewNode(mcgraph()->machine()->I16x8SConvertI8x16High(),
inputs[0]);
case wasm::kExprI16x8Shl:
return graph()->NewNode(mcgraph()->machine()->I16x8Shl(), inputs[0],
inputs[1]);
case wasm::kExprI16x8ShrS:
return graph()->NewNode(mcgraph()->machine()->I16x8ShrS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8Neg:
return graph()->NewNode(mcgraph()->machine()->I16x8Neg(), inputs[0]);
case wasm::kExprI16x8SConvertI32x4:
return graph()->NewNode(mcgraph()->machine()->I16x8SConvertI32x4(),
inputs[0], inputs[1]);
case wasm::kExprI16x8Add:
return graph()->NewNode(mcgraph()->machine()->I16x8Add(), inputs[0],
inputs[1]);
case wasm::kExprI16x8AddSatS:
return graph()->NewNode(mcgraph()->machine()->I16x8AddSatS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8Sub:
return graph()->NewNode(mcgraph()->machine()->I16x8Sub(), inputs[0],
inputs[1]);
case wasm::kExprI16x8SubSatS:
return graph()->NewNode(mcgraph()->machine()->I16x8SubSatS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8Mul:
return graph()->NewNode(mcgraph()->machine()->I16x8Mul(), inputs[0],
inputs[1]);
case wasm::kExprI16x8MinS:
return graph()->NewNode(mcgraph()->machine()->I16x8MinS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8MaxS:
return graph()->NewNode(mcgraph()->machine()->I16x8MaxS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8Eq:
return graph()->NewNode(mcgraph()->machine()->I16x8Eq(), inputs[0],
inputs[1]);
case wasm::kExprI16x8Ne:
return graph()->NewNode(mcgraph()->machine()->I16x8Ne(), inputs[0],
inputs[1]);
case wasm::kExprI16x8LtS:
return graph()->NewNode(mcgraph()->machine()->I16x8GtS(), inputs[1],
inputs[0]);
case wasm::kExprI16x8LeS:
return graph()->NewNode(mcgraph()->machine()->I16x8GeS(), inputs[1],
inputs[0]);
case wasm::kExprI16x8GtS:
return graph()->NewNode(mcgraph()->machine()->I16x8GtS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8GeS:
return graph()->NewNode(mcgraph()->machine()->I16x8GeS(), inputs[0],
inputs[1]);
case wasm::kExprI16x8UConvertI8x16Low:
return graph()->NewNode(mcgraph()->machine()->I16x8UConvertI8x16Low(),
inputs[0]);
case wasm::kExprI16x8UConvertI8x16High:
return graph()->NewNode(mcgraph()->machine()->I16x8UConvertI8x16High(),
inputs[0]);
case wasm::kExprI16x8UConvertI32x4:
return graph()->NewNode(mcgraph()->machine()->I16x8UConvertI32x4(),
inputs[0], inputs[1]);
case wasm::kExprI16x8ShrU:
return graph()->NewNode(mcgraph()->machine()->I16x8ShrU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8AddSatU:
return graph()->NewNode(mcgraph()->machine()->I16x8AddSatU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8SubSatU:
return graph()->NewNode(mcgraph()->machine()->I16x8SubSatU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8MinU:
return graph()->NewNode(mcgraph()->machine()->I16x8MinU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8MaxU:
return graph()->NewNode(mcgraph()->machine()->I16x8MaxU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8LtU:
return graph()->NewNode(mcgraph()->machine()->I16x8GtU(), inputs[1],
inputs[0]);
case wasm::kExprI16x8LeU:
return graph()->NewNode(mcgraph()->machine()->I16x8GeU(), inputs[1],
inputs[0]);
case wasm::kExprI16x8GtU:
return graph()->NewNode(mcgraph()->machine()->I16x8GtU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8GeU:
return graph()->NewNode(mcgraph()->machine()->I16x8GeU(), inputs[0],
inputs[1]);
case wasm::kExprI16x8RoundingAverageU:
return graph()->NewNode(mcgraph()->machine()->I16x8RoundingAverageU(),
inputs[0], inputs[1]);
case wasm::kExprI16x8Q15MulRSatS:
return graph()->NewNode(mcgraph()->machine()->I16x8Q15MulRSatS(),
inputs[0], inputs[1]);
case wasm::kExprI16x8Abs:
return graph()->NewNode(mcgraph()->machine()->I16x8Abs(), inputs[0]);
case wasm::kExprI16x8BitMask:
return graph()->NewNode(mcgraph()->machine()->I16x8BitMask(), inputs[0]);
case wasm::kExprI16x8ExtMulLowI8x16S:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtMulLowI8x16S(),
inputs[0], inputs[1]);
case wasm::kExprI16x8ExtMulHighI8x16S:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtMulHighI8x16S(),
inputs[0], inputs[1]);
case wasm::kExprI16x8ExtMulLowI8x16U:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtMulLowI8x16U(),
inputs[0], inputs[1]);
case wasm::kExprI16x8ExtMulHighI8x16U:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtMulHighI8x16U(),
inputs[0], inputs[1]);
case wasm::kExprI16x8ExtAddPairwiseI8x16S:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtAddPairwiseI8x16S(),
inputs[0]);
case wasm::kExprI16x8ExtAddPairwiseI8x16U:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtAddPairwiseI8x16U(),
inputs[0]);
case wasm::kExprI8x16Splat:
return graph()->NewNode(mcgraph()->machine()->I8x16Splat(), inputs[0]);
case wasm::kExprI8x16Neg:
return graph()->NewNode(mcgraph()->machine()->I8x16Neg(), inputs[0]);
case wasm::kExprI8x16Shl:
return graph()->NewNode(mcgraph()->machine()->I8x16Shl(), inputs[0],
inputs[1]);
case wasm::kExprI8x16ShrS:
return graph()->NewNode(mcgraph()->machine()->I8x16ShrS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16SConvertI16x8:
return graph()->NewNode(mcgraph()->machine()->I8x16SConvertI16x8(),
inputs[0], inputs[1]);
case wasm::kExprI8x16Add:
return graph()->NewNode(mcgraph()->machine()->I8x16Add(), inputs[0],
inputs[1]);
case wasm::kExprI8x16AddSatS:
return graph()->NewNode(mcgraph()->machine()->I8x16AddSatS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16Sub:
return graph()->NewNode(mcgraph()->machine()->I8x16Sub(), inputs[0],
inputs[1]);
case wasm::kExprI8x16SubSatS:
return graph()->NewNode(mcgraph()->machine()->I8x16SubSatS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16MinS:
return graph()->NewNode(mcgraph()->machine()->I8x16MinS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16MaxS:
return graph()->NewNode(mcgraph()->machine()->I8x16MaxS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16Eq:
return graph()->NewNode(mcgraph()->machine()->I8x16Eq(), inputs[0],
inputs[1]);
case wasm::kExprI8x16Ne:
return graph()->NewNode(mcgraph()->machine()->I8x16Ne(), inputs[0],
inputs[1]);
case wasm::kExprI8x16LtS:
return graph()->NewNode(mcgraph()->machine()->I8x16GtS(), inputs[1],
inputs[0]);
case wasm::kExprI8x16LeS:
return graph()->NewNode(mcgraph()->machine()->I8x16GeS(), inputs[1],
inputs[0]);
case wasm::kExprI8x16GtS:
return graph()->NewNode(mcgraph()->machine()->I8x16GtS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16GeS:
return graph()->NewNode(mcgraph()->machine()->I8x16GeS(), inputs[0],
inputs[1]);
case wasm::kExprI8x16ShrU:
return graph()->NewNode(mcgraph()->machine()->I8x16ShrU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16UConvertI16x8:
return graph()->NewNode(mcgraph()->machine()->I8x16UConvertI16x8(),
inputs[0], inputs[1]);
case wasm::kExprI8x16AddSatU:
return graph()->NewNode(mcgraph()->machine()->I8x16AddSatU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16SubSatU:
return graph()->NewNode(mcgraph()->machine()->I8x16SubSatU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16MinU:
return graph()->NewNode(mcgraph()->machine()->I8x16MinU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16MaxU:
return graph()->NewNode(mcgraph()->machine()->I8x16MaxU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16LtU:
return graph()->NewNode(mcgraph()->machine()->I8x16GtU(), inputs[1],
inputs[0]);
case wasm::kExprI8x16LeU:
return graph()->NewNode(mcgraph()->machine()->I8x16GeU(), inputs[1],
inputs[0]);
case wasm::kExprI8x16GtU:
return graph()->NewNode(mcgraph()->machine()->I8x16GtU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16GeU:
return graph()->NewNode(mcgraph()->machine()->I8x16GeU(), inputs[0],
inputs[1]);
case wasm::kExprI8x16RoundingAverageU:
return graph()->NewNode(mcgraph()->machine()->I8x16RoundingAverageU(),
inputs[0], inputs[1]);
case wasm::kExprI8x16Popcnt:
return graph()->NewNode(mcgraph()->machine()->I8x16Popcnt(), inputs[0]);
case wasm::kExprI8x16Abs:
return graph()->NewNode(mcgraph()->machine()->I8x16Abs(), inputs[0]);
case wasm::kExprI8x16BitMask:
return graph()->NewNode(mcgraph()->machine()->I8x16BitMask(), inputs[0]);
case wasm::kExprS128And:
return graph()->NewNode(mcgraph()->machine()->S128And(), inputs[0],
inputs[1]);
case wasm::kExprS128Or:
return graph()->NewNode(mcgraph()->machine()->S128Or(), inputs[0],
inputs[1]);
case wasm::kExprS128Xor:
return graph()->NewNode(mcgraph()->machine()->S128Xor(), inputs[0],
inputs[1]);
case wasm::kExprS128Not:
return graph()->NewNode(mcgraph()->machine()->S128Not(), inputs[0]);
case wasm::kExprS128Select:
return graph()->NewNode(mcgraph()->machine()->S128Select(), inputs[2],
inputs[0], inputs[1]);
case wasm::kExprS128AndNot:
return graph()->NewNode(mcgraph()->machine()->S128AndNot(), inputs[0],
inputs[1]);
case wasm::kExprI64x2AllTrue:
return graph()->NewNode(mcgraph()->machine()->I64x2AllTrue(), inputs[0]);
case wasm::kExprI32x4AllTrue:
return graph()->NewNode(mcgraph()->machine()->I32x4AllTrue(), inputs[0]);
case wasm::kExprI16x8AllTrue:
return graph()->NewNode(mcgraph()->machine()->I16x8AllTrue(), inputs[0]);
case wasm::kExprV128AnyTrue:
return graph()->NewNode(mcgraph()->machine()->V128AnyTrue(), inputs[0]);
case wasm::kExprI8x16AllTrue:
return graph()->NewNode(mcgraph()->machine()->I8x16AllTrue(), inputs[0]);
case wasm::kExprI8x16Swizzle:
return graph()->NewNode(mcgraph()->machine()->I8x16Swizzle(false),
inputs[0], inputs[1]);
case wasm::kExprI8x16RelaxedSwizzle:
return graph()->NewNode(mcgraph()->machine()->I8x16Swizzle(true),
inputs[0], inputs[1]);
case wasm::kExprI8x16RelaxedLaneSelect:
return graph()->NewNode(mcgraph()->machine()->I8x16RelaxedLaneSelect(),
inputs[0], inputs[1], inputs[2]);
case wasm::kExprI16x8RelaxedLaneSelect:
return graph()->NewNode(mcgraph()->machine()->I16x8RelaxedLaneSelect(),
inputs[0], inputs[1], inputs[2]);
case wasm::kExprI32x4RelaxedLaneSelect:
return graph()->NewNode(mcgraph()->machine()->I32x4RelaxedLaneSelect(),
inputs[0], inputs[1], inputs[2]);
case wasm::kExprI64x2RelaxedLaneSelect:
return graph()->NewNode(mcgraph()->machine()->I64x2RelaxedLaneSelect(),
inputs[0], inputs[1], inputs[2]);
case wasm::kExprF32x4RelaxedMin:
return graph()->NewNode(mcgraph()->machine()->F32x4RelaxedMin(),
inputs[0], inputs[1]);
case wasm::kExprF32x4RelaxedMax:
return graph()->NewNode(mcgraph()->machine()->F32x4RelaxedMax(),
inputs[0], inputs[1]);
case wasm::kExprF64x2RelaxedMin:
return graph()->NewNode(mcgraph()->machine()->F64x2RelaxedMin(),
inputs[0], inputs[1]);
case wasm::kExprF64x2RelaxedMax:
return graph()->NewNode(mcgraph()->machine()->F64x2RelaxedMax(),
inputs[0], inputs[1]);
case wasm::kExprI32x4RelaxedTruncF64x2SZero:
return graph()->NewNode(
mcgraph()->machine()->I32x4RelaxedTruncF64x2SZero(), inputs[0]);
case wasm::kExprI32x4RelaxedTruncF64x2UZero:
return graph()->NewNode(
mcgraph()->machine()->I32x4RelaxedTruncF64x2UZero(), inputs[0]);
case wasm::kExprI32x4RelaxedTruncF32x4S:
return graph()->NewNode(mcgraph()->machine()->I32x4RelaxedTruncF32x4S(),
inputs[0]);
case wasm::kExprI32x4RelaxedTruncF32x4U:
return graph()->NewNode(mcgraph()->machine()->I32x4RelaxedTruncF32x4U(),
inputs[0]);
default:
FATAL_UNSUPPORTED_OPCODE(opcode);
}
}
Node* WasmGraphBuilder::SimdLaneOp(wasm::WasmOpcode opcode, uint8_t lane,
Node* const* inputs) {
has_simd_ = true;
switch (opcode) {
case wasm::kExprF64x2ExtractLane:
return graph()->NewNode(mcgraph()->machine()->F64x2ExtractLane(lane),
inputs[0]);
case wasm::kExprF64x2ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->F64x2ReplaceLane(lane),
inputs[0], inputs[1]);
case wasm::kExprF32x4ExtractLane:
return graph()->NewNode(mcgraph()->machine()->F32x4ExtractLane(lane),
inputs[0]);
case wasm::kExprF32x4ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->F32x4ReplaceLane(lane),
inputs[0], inputs[1]);
case wasm::kExprI64x2ExtractLane:
return graph()->NewNode(mcgraph()->machine()->I64x2ExtractLane(lane),
inputs[0]);
case wasm::kExprI64x2ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->I64x2ReplaceLane(lane),
inputs[0], inputs[1]);
case wasm::kExprI32x4ExtractLane:
return graph()->NewNode(mcgraph()->machine()->I32x4ExtractLane(lane),
inputs[0]);
case wasm::kExprI32x4ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->I32x4ReplaceLane(lane),
inputs[0], inputs[1]);
case wasm::kExprI16x8ExtractLaneS:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtractLaneS(lane),
inputs[0]);
case wasm::kExprI16x8ExtractLaneU:
return graph()->NewNode(mcgraph()->machine()->I16x8ExtractLaneU(lane),
inputs[0]);
case wasm::kExprI16x8ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->I16x8ReplaceLane(lane),
inputs[0], inputs[1]);
case wasm::kExprI8x16ExtractLaneS:
return graph()->NewNode(mcgraph()->machine()->I8x16ExtractLaneS(lane),
inputs[0]);
case wasm::kExprI8x16ExtractLaneU:
return graph()->NewNode(mcgraph()->machine()->I8x16ExtractLaneU(lane),
inputs[0]);
case wasm::kExprI8x16ReplaceLane:
return graph()->NewNode(mcgraph()->machine()->I8x16ReplaceLane(lane),
inputs[0], inputs[1]);
default:
FATAL_UNSUPPORTED_OPCODE(opcode);
}
}
Node* WasmGraphBuilder::Simd8x16ShuffleOp(const uint8_t shuffle[16],
Node* const* inputs) {
has_simd_ = true;
return graph()->NewNode(mcgraph()->machine()->I8x16Shuffle(shuffle),
inputs[0], inputs[1]);
}
Node* WasmGraphBuilder::AtomicOp(wasm::WasmOpcode opcode, Node* const* inputs,
uint32_t alignment, uint64_t offset,
wasm::WasmCodePosition position) {
struct AtomicOpInfo {
enum Type : int8_t {
kNoInput = 0,
kOneInput = 1,
kTwoInputs = 2,
kSpecial
};
using OperatorByType =
const Operator* (MachineOperatorBuilder::*)(MachineType);
using OperatorByRep =
const Operator* (MachineOperatorBuilder::*)(MachineRepresentation);
using OperatorByAtomicLoadRep =
const Operator* (MachineOperatorBuilder::*)(AtomicLoadParameters);
using OperatorByAtomicStoreRep =
const Operator* (MachineOperatorBuilder::*)(AtomicStoreParameters);
const Type type;
const MachineType machine_type;
const OperatorByType operator_by_type = nullptr;
const OperatorByRep operator_by_rep = nullptr;
const OperatorByAtomicLoadRep operator_by_atomic_load_params = nullptr;
const OperatorByAtomicStoreRep operator_by_atomic_store_rep = nullptr;
constexpr AtomicOpInfo(Type t, MachineType m, OperatorByType o)
: type(t), machine_type(m), operator_by_type(o) {}
constexpr AtomicOpInfo(Type t, MachineType m, OperatorByRep o)
: type(t), machine_type(m), operator_by_rep(o) {}
constexpr AtomicOpInfo(Type t, MachineType m, OperatorByAtomicLoadRep o)
: type(t), machine_type(m), operator_by_atomic_load_params(o) {}
constexpr AtomicOpInfo(Type t, MachineType m, OperatorByAtomicStoreRep o)
: type(t), machine_type(m), operator_by_atomic_store_rep(o) {}
// Constexpr, hence just a table lookup in most compilers.
static constexpr AtomicOpInfo Get(wasm::WasmOpcode opcode) {
switch (opcode) {
#define CASE(Name, Type, MachType, Op) \
case wasm::kExpr##Name: \
return {Type, MachineType::MachType(), &MachineOperatorBuilder::Op};
// Binops.
CASE(I32AtomicAdd, kOneInput, Uint32, Word32AtomicAdd)
CASE(I64AtomicAdd, kOneInput, Uint64, Word64AtomicAdd)
CASE(I32AtomicAdd8U, kOneInput, Uint8, Word32AtomicAdd)
CASE(I32AtomicAdd16U, kOneInput, Uint16, Word32AtomicAdd)
CASE(I64AtomicAdd8U, kOneInput, Uint8, Word64AtomicAdd)
CASE(I64AtomicAdd16U, kOneInput, Uint16, Word64AtomicAdd)
CASE(I64AtomicAdd32U, kOneInput, Uint32, Word64AtomicAdd)
CASE(I32AtomicSub, kOneInput, Uint32, Word32AtomicSub)
CASE(I64AtomicSub, kOneInput, Uint64, Word64AtomicSub)
CASE(I32AtomicSub8U, kOneInput, Uint8, Word32AtomicSub)
CASE(I32AtomicSub16U, kOneInput, Uint16, Word32AtomicSub)
CASE(I64AtomicSub8U, kOneInput, Uint8, Word64AtomicSub)
CASE(I64AtomicSub16U, kOneInput, Uint16, Word64AtomicSub)
CASE(I64AtomicSub32U, kOneInput, Uint32, Word64AtomicSub)
CASE(I32AtomicAnd, kOneInput, Uint32, Word32AtomicAnd)
CASE(I64AtomicAnd, kOneInput, Uint64, Word64AtomicAnd)
CASE(I32AtomicAnd8U, kOneInput, Uint8, Word32AtomicAnd)
CASE(I32AtomicAnd16U, kOneInput, Uint16, Word32AtomicAnd)
CASE(I64AtomicAnd8U, kOneInput, Uint8, Word64AtomicAnd)
CASE(I64AtomicAnd16U, kOneInput, Uint16, Word64AtomicAnd)
CASE(I64AtomicAnd32U, kOneInput, Uint32, Word64AtomicAnd)
CASE(I32AtomicOr, kOneInput, Uint32, Word32AtomicOr)
CASE(I64AtomicOr, kOneInput, Uint64, Word64AtomicOr)
CASE(I32AtomicOr8U, kOneInput, Uint8, Word32AtomicOr)
CASE(I32AtomicOr16U, kOneInput, Uint16, Word32AtomicOr)
CASE(I64AtomicOr8U, kOneInput, Uint8, Word64AtomicOr)
CASE(I64AtomicOr16U, kOneInput, Uint16, Word64AtomicOr)
CASE(I64AtomicOr32U, kOneInput, Uint32, Word64AtomicOr)
CASE(I32AtomicXor, kOneInput, Uint32, Word32AtomicXor)
CASE(I64AtomicXor, kOneInput, Uint64, Word64AtomicXor)
CASE(I32AtomicXor8U, kOneInput, Uint8, Word32AtomicXor)
CASE(I32AtomicXor16U, kOneInput, Uint16, Word32AtomicXor)
CASE(I64AtomicXor8U, kOneInput, Uint8, Word64AtomicXor)
CASE(I64AtomicXor16U, kOneInput, Uint16, Word64AtomicXor)
CASE(I64AtomicXor32U, kOneInput, Uint32, Word64AtomicXor)
CASE(I32AtomicExchange, kOneInput, Uint32, Word32AtomicExchange)
CASE(I64AtomicExchange, kOneInput, Uint64, Word64AtomicExchange)
CASE(I32AtomicExchange8U, kOneInput, Uint8, Word32AtomicExchange)
CASE(I32AtomicExchange16U, kOneInput, Uint16, Word32AtomicExchange)
CASE(I64AtomicExchange8U, kOneInput, Uint8, Word64AtomicExchange)
CASE(I64AtomicExchange16U, kOneInput, Uint16, Word64AtomicExchange)
CASE(I64AtomicExchange32U, kOneInput, Uint32, Word64AtomicExchange)
// Compare-exchange.
CASE(I32AtomicCompareExchange, kTwoInputs, Uint32,
Word32AtomicCompareExchange)
CASE(I64AtomicCompareExchange, kTwoInputs, Uint64,
Word64AtomicCompareExchange)
CASE(I32AtomicCompareExchange8U, kTwoInputs, Uint8,
Word32AtomicCompareExchange)
CASE(I32AtomicCompareExchange16U, kTwoInputs, Uint16,
Word32AtomicCompareExchange)
CASE(I64AtomicCompareExchange8U, kTwoInputs, Uint8,
Word64AtomicCompareExchange)
CASE(I64AtomicCompareExchange16U, kTwoInputs, Uint16,
Word64AtomicCompareExchange)
CASE(I64AtomicCompareExchange32U, kTwoInputs, Uint32,
Word64AtomicCompareExchange)
// Load.
CASE(I32AtomicLoad, kNoInput, Uint32, Word32AtomicLoad)
CASE(I64AtomicLoad, kNoInput, Uint64, Word64AtomicLoad)
CASE(I32AtomicLoad8U, kNoInput, Uint8, Word32AtomicLoad)
CASE(I32AtomicLoad16U, kNoInput, Uint16, Word32AtomicLoad)
CASE(I64AtomicLoad8U, kNoInput, Uint8, Word64AtomicLoad)
CASE(I64AtomicLoad16U, kNoInput, Uint16, Word64AtomicLoad)
CASE(I64AtomicLoad32U, kNoInput, Uint32, Word64AtomicLoad)
// Store.
CASE(I32AtomicStore, kOneInput, Uint32, Word32AtomicStore)
CASE(I64AtomicStore, kOneInput, Uint64, Word64AtomicStore)
CASE(I32AtomicStore8U, kOneInput, Uint8, Word32AtomicStore)
CASE(I32AtomicStore16U, kOneInput, Uint16, Word32AtomicStore)
CASE(I64AtomicStore8U, kOneInput, Uint8, Word64AtomicStore)
CASE(I64AtomicStore16U, kOneInput, Uint16, Word64AtomicStore)
CASE(I64AtomicStore32U, kOneInput, Uint32, Word64AtomicStore)
#undef CASE
case wasm::kExprAtomicNotify:
return {kSpecial, MachineType::Int32(), OperatorByType{nullptr}};
case wasm::kExprI32AtomicWait:
return {kSpecial, MachineType::Int32(), OperatorByType{nullptr}};
case wasm::kExprI64AtomicWait:
return {kSpecial, MachineType::Int64(), OperatorByType{nullptr}};
default:
UNREACHABLE();
}
}
};
AtomicOpInfo info = AtomicOpInfo::Get(opcode);
Node* index = CheckBoundsAndAlignment(info.machine_type.MemSize(), inputs[0],
offset, position);
// {offset} is validated to be within uintptr_t range in {BoundsCheckMem}.
uintptr_t capped_offset = static_cast<uintptr_t>(offset);
if (info.type != AtomicOpInfo::kSpecial) {
const Operator* op;
if (info.operator_by_type) {
op = (mcgraph()->machine()->*info.operator_by_type)(info.machine_type);
} else if (info.operator_by_rep) {
op = (mcgraph()->machine()->*info.operator_by_rep)(
info.machine_type.representation());
} else if (info.operator_by_atomic_load_params) {
op = (mcgraph()->machine()->*info.operator_by_atomic_load_params)(
AtomicLoadParameters(info.machine_type, AtomicMemoryOrder::kSeqCst));
} else {
op = (mcgraph()->machine()->*info.operator_by_atomic_store_rep)(
AtomicStoreParameters(info.machine_type.representation(),
WriteBarrierKind::kNoWriteBarrier,
AtomicMemoryOrder::kSeqCst));
}
Node* input_nodes[6] = {MemBuffer(capped_offset), index};
int num_actual_inputs = info.type;
std::copy_n(inputs + 1, num_actual_inputs, input_nodes + 2);
input_nodes[num_actual_inputs + 2] = effect();
input_nodes[num_actual_inputs + 3] = control();
return gasm_->AddNode(
graph()->NewNode(op, num_actual_inputs + 4, input_nodes));
}
// After we've bounds-checked, compute the effective offset.
Node* effective_offset =
gasm_->IntAdd(gasm_->UintPtrConstant(capped_offset), index);
switch (opcode) {
case wasm::kExprAtomicNotify:
return gasm_->CallRuntimeStub(wasm::WasmCode::kWasmAtomicNotify,
effective_offset, inputs[1]);
case wasm::kExprI32AtomicWait: {
auto* call_descriptor = GetI32AtomicWaitCallDescriptor();
intptr_t target = mcgraph()->machine()->Is64()
? wasm::WasmCode::kWasmI32AtomicWait64
: wasm::WasmCode::kWasmI32AtomicWait32;
Node* call_target = mcgraph()->RelocatableIntPtrConstant(
target, RelocInfo::WASM_STUB_CALL);
return gasm_->Call(call_descriptor, call_target, effective_offset,
inputs[1], inputs[2]);
}
case wasm::kExprI64AtomicWait: {
auto* call_descriptor = GetI64AtomicWaitCallDescriptor();
intptr_t target = mcgraph()->machine()->Is64()
? wasm::WasmCode::kWasmI64AtomicWait64
: wasm::WasmCode::kWasmI64AtomicWait32;
Node* call_target = mcgraph()->RelocatableIntPtrConstant(
target, RelocInfo::WASM_STUB_CALL);
return gasm_->Call(call_descriptor, call_target, effective_offset,
inputs[1], inputs[2]);
}
default:
FATAL_UNSUPPORTED_OPCODE(opcode);
}
}
void WasmGraphBuilder::AtomicFence() {
SetEffect(graph()->NewNode(mcgraph()->machine()->MemBarrier(), effect(),
control()));
}
void WasmGraphBuilder::MemoryInit(uint32_t data_segment_index, Node* dst,
Node* src, Node* size,
wasm::WasmCodePosition position) {
// The data segment index must be in bounds since it is required by
// validation.
DCHECK_LT(data_segment_index, env_->module->num_declared_data_segments);
Node* function =
gasm_->ExternalConstant(ExternalReference::wasm_memory_init());
Node* stack_slot = StoreArgsInStackSlot(
{{MachineType::PointerRepresentation(), GetInstance()},
{MachineRepresentation::kWord32, dst},
{MachineRepresentation::kWord32, src},
{MachineRepresentation::kWord32,
gasm_->Uint32Constant(data_segment_index)},
{MachineRepresentation::kWord32, size}});
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* call = BuildCCall(&sig, function, stack_slot);
TrapIfFalse(wasm::kTrapMemOutOfBounds, call, position);
}
void WasmGraphBuilder::DataDrop(uint32_t data_segment_index,
wasm::WasmCodePosition position) {
DCHECK_LT(data_segment_index, env_->module->num_declared_data_segments);
Node* seg_size_array =
LOAD_INSTANCE_FIELD(DataSegmentSizes, MachineType::Pointer());
STATIC_ASSERT(wasm::kV8MaxWasmDataSegments <= kMaxUInt32 >> 2);
auto access = ObjectAccess(MachineType::Int32(), kNoWriteBarrier);
gasm_->StoreToObject(access, seg_size_array, data_segment_index << 2,
Int32Constant(0));
}
Node* WasmGraphBuilder::StoreArgsInStackSlot(
std::initializer_list<std::pair<MachineRepresentation, Node*>> args) {
int slot_size = 0;
for (auto arg : args) {
slot_size += ElementSizeInBytes(arg.first);
}
DCHECK_LT(0, slot_size);
Node* stack_slot =
graph()->NewNode(mcgraph()->machine()->StackSlot(slot_size));
int offset = 0;
for (auto arg : args) {
MachineRepresentation type = arg.first;
Node* value = arg.second;
gasm_->Store(StoreRepresentation(type, kNoWriteBarrier), stack_slot,
Int32Constant(offset), value);
offset += ElementSizeInBytes(type);
}
return stack_slot;
}
void WasmGraphBuilder::MemoryCopy(Node* dst, Node* src, Node* size,
wasm::WasmCodePosition position) {
Node* function =
gasm_->ExternalConstant(ExternalReference::wasm_memory_copy());
Node* stack_slot = StoreArgsInStackSlot(
{{MachineType::PointerRepresentation(), GetInstance()},
{MachineRepresentation::kWord32, dst},
{MachineRepresentation::kWord32, src},
{MachineRepresentation::kWord32, size}});
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* call = BuildCCall(&sig, function, stack_slot);
TrapIfFalse(wasm::kTrapMemOutOfBounds, call, position);
}
void WasmGraphBuilder::MemoryFill(Node* dst, Node* value, Node* size,
wasm::WasmCodePosition position) {
Node* function =
gasm_->ExternalConstant(ExternalReference::wasm_memory_fill());
Node* stack_slot = StoreArgsInStackSlot(
{{MachineType::PointerRepresentation(), GetInstance()},
{MachineRepresentation::kWord32, dst},
{MachineRepresentation::kWord32, value},
{MachineRepresentation::kWord32, size}});
MachineType sig_types[] = {MachineType::Int32(), MachineType::Pointer()};
MachineSignature sig(1, 1, sig_types);
Node* call = BuildCCall(&sig, function, stack_slot);
TrapIfFalse(wasm::kTrapMemOutOfBounds, call, position);
}
void WasmGraphBuilder::TableInit(uint32_t table_index,
uint32_t elem_segment_index, Node* dst,
Node* src, Node* size,
wasm::WasmCodePosition position) {
gasm_->CallRuntimeStub(wasm::WasmCode::kWasmTableInit, dst, src, size,
gasm_->NumberConstant(table_index),
gasm_->NumberConstant(elem_segment_index));
}
void WasmGraphBuilder::ElemDrop(uint32_t elem_segment_index,
wasm::WasmCodePosition position) {
// The elem segment index must be in bounds since it is required by
// validation.
DCHECK_LT(elem_segment_index, env_->module->elem_segments.size());
Node* dropped_elem_segments =
LOAD_INSTANCE_FIELD(DroppedElemSegments, MachineType::Pointer());
auto store_rep =
StoreRepresentation(MachineRepresentation::kWord8, kNoWriteBarrier);
gasm_->Store(store_rep, dropped_elem_segments, elem_segment_index,
Int32Constant(1));
}
void WasmGraphBuilder::TableCopy(uint32_t table_dst_index,
uint32_t table_src_index, Node* dst, Node* src,
Node* size, wasm::WasmCodePosition position) {
gasm_->CallRuntimeStub(wasm::WasmCode::kWasmTableCopy, dst, src, size,
gasm_->NumberConstant(table_dst_index),
gasm_->NumberConstant(table_src_index));
}
Node* WasmGraphBuilder::TableGrow(uint32_t table_index, Node* value,
Node* delta) {
return BuildChangeSmiToInt32(gasm_->CallRuntimeStub(
wasm::WasmCode::kWasmTableGrow,
graph()->NewNode(mcgraph()->common()->NumberConstant(table_index)), delta,
value));
}
Node* WasmGraphBuilder::TableSize(uint32_t table_index) {
Node* tables = LOAD_INSTANCE_FIELD(Tables, MachineType::TaggedPointer());
Node* table = gasm_->LoadFixedArrayElementAny(tables, table_index);
int length_field_size = WasmTableObject::kCurrentLengthOffsetEnd -
WasmTableObject::kCurrentLengthOffset + 1;
Node* length_smi = gasm_->LoadFromObject(
assert_size(length_field_size, MachineType::TaggedSigned()), table,
wasm::ObjectAccess::ToTagged(WasmTableObject::kCurrentLengthOffset));
return BuildChangeSmiToInt32(length_smi);
}
void WasmGraphBuilder::TableFill(uint32_t table_index, Node* start, Node* value,
Node* count) {
gasm_->CallRuntimeStub(
wasm::WasmCode::kWasmTableFill,
graph()->NewNode(mcgraph()->common()->NumberConstant(table_index)), start,
count, value);
}
Node* WasmGraphBuilder::StructNewWithRtt(uint32_t struct_index,
const wasm::StructType* type,
Node* rtt,
base::Vector<Node*> fields) {
int size = WasmStruct::Size(type);
Node* s = gasm_->Allocate(size);
gasm_->StoreMap(s, rtt);
gasm_->StoreToObject(
ObjectAccess(MachineType::TaggedPointer(), kNoWriteBarrier), s,
wasm::ObjectAccess::ToTagged(JSReceiver::kPropertiesOrHashOffset),
LOAD_ROOT(EmptyFixedArray, empty_fixed_array));
for (uint32_t i = 0; i < type->field_count(); i++) {
gasm_->StoreStructField(s, type, i, fields[i]);
}
// If this assert fails then initialization of padding field might be
// necessary.
static_assert(Heap::kMinObjectSizeInTaggedWords == 2 &&
WasmStruct::kHeaderSize == 2 * kTaggedSize,
"empty struct might require initialization of padding field");
return s;
}
Builtin ChooseArrayAllocationBuiltin(wasm::ValueType element_type,
Node* initial_value) {
if (initial_value != nullptr) {
// {initial_value} will be used for initialization after allocation.
return Builtin::kWasmAllocateArray_Uninitialized;
}
if (element_type.is_reference()) {
return Builtin::kWasmAllocateArray_InitNull;
}
return Builtin::kWasmAllocateArray_InitZero;
}
Node* WasmGraphBuilder::ArrayNewWithRtt(uint32_t array_index,
const wasm::ArrayType* type,
Node* length, Node* initial_value,
Node* rtt,
wasm::WasmCodePosition position) {
TrapIfFalse(wasm::kTrapArrayTooLarge,
gasm_->Uint32LessThanOrEqual(
length, gasm_->Uint32Constant(WasmArray::MaxLength(type))),
position);
wasm::ValueType element_type = type->element_type();
// TODO(7748): Consider using gasm_->Allocate().
Builtin stub = ChooseArrayAllocationBuiltin(element_type, initial_value);
// Do NOT mark this as Operator::kEliminatable, because that would cause the
// Call node to have no control inputs, which means it could get scheduled
// before the check/trap above.
Node* a = gasm_->CallBuiltin(
stub, Operator::kNoDeopt | Operator::kNoThrow, rtt, length,
Int32Constant(element_type.element_size_bytes()));
if (initial_value != nullptr) {
// TODO(manoskouk): If the loop is ever removed here, we have to update
// ArrayNewWithRtt() in graph-builder-interface.cc to not mark the current
// loop as non-innermost.
auto loop = gasm_->MakeLoopLabel(MachineRepresentation::kWord32);
auto done = gasm_->MakeLabel();
Node* start_offset =
Int32Constant(wasm::ObjectAccess::ToTagged(WasmArray::kHeaderSize));
Node* element_size = Int32Constant(element_type.element_size_bytes());
Node* end_offset =
gasm_->Int32Add(start_offset, gasm_->Int32Mul(element_size, length));
gasm_->Goto(&loop, start_offset);
gasm_->Bind(&loop);
{
Node* offset = loop.PhiAt(0);
Node* check = gasm_->Uint32LessThan(offset, end_offset);
gasm_->GotoIfNot(check, &done);
gasm_->StoreToObject(ObjectAccessForGCStores(type->element_type()), a,
offset, initial_value);
offset = gasm_->Int32Add(offset, element_size);
gasm_->Goto(&loop, offset);
}
gasm_->Bind(&done);
}
return a;
}
Node* WasmGraphBuilder::ArrayInit(uint32_t array_index,
const wasm::ArrayType* type, Node* rtt,
base::Vector<Node*> elements) {
wasm::ValueType element_type = type->element_type();
// TODO(7748): Consider using gasm_->Allocate().
Node* array =
gasm_->CallBuiltin(Builtin::kWasmAllocateArray_Uninitialized,
Operator::kNoDeopt | Operator::kNoThrow, rtt,
Int32Constant(static_cast<int32_t>(elements.size())),
Int32Constant(element_type.element_size_bytes()));
for (int i = 0; i < static_cast<int>(elements.size()); i++) {
Node* offset =
gasm_->WasmArrayElementOffset(Int32Constant(i), element_type);
gasm_->StoreToObject(ObjectAccessForGCStores(element_type), array, offset,
elements[i]);
}
return array;
}
Node* WasmGraphBuilder::RttCanon(uint32_t type_index) {
Node* maps_list =
LOAD_INSTANCE_FIELD(ManagedObjectMaps, MachineType::TaggedPointer());
return gasm_->LoadFixedArrayElementPtr(maps_list, type_index);
}
Node* WasmGraphBuilder::RttSub(uint32_t type_index, Node* parent_rtt,
WasmRttSubMode mode) {
Builtin target = mode == WasmRttSubMode::kCanonicalize
? Builtin::kWasmAllocateRtt
: Builtin::kWasmAllocateFreshRtt;
return gasm_->CallBuiltin(target, Operator::kEliminatable,
Int32Constant(type_index), parent_rtt);
}
WasmGraphBuilder::Callbacks WasmGraphBuilder::TestCallbacks(
GraphAssemblerLabel<1>* label) {
return {// succeed_if
[=](Node* condition, BranchHint hint) -> void {
gasm_->GotoIf(condition, label, hint, Int32Constant(1));
},
// fail_if
[=](Node* condition, BranchHint hint) -> void {
gasm_->GotoIf(condition, label, hint, Int32Constant(0));
},
// fail_if_not
[=](Node* condition, BranchHint hint) -> void {
gasm_->GotoIfNot(condition, label, hint, Int32Constant(0));
}};
}
WasmGraphBuilder::Callbacks WasmGraphBuilder::CastCallbacks(
GraphAssemblerLabel<0>* label, wasm::WasmCodePosition position) {
return {// succeed_if
[=](Node* condition, BranchHint hint) -> void {
gasm_->GotoIf(condition, label, hint);
},
// fail_if
[=](Node* condition, BranchHint hint) -> void {
TrapIfTrue(wasm::kTrapIllegalCast, condition, position);
},
// fail_if_not
[=](Node* condition, BranchHint hint) -> void {
TrapIfFalse(wasm::kTrapIllegalCast, condition, position);
}};
}
WasmGraphBuilder::Callbacks WasmGraphBuilder::BranchCallbacks(
SmallNodeVector& no_match_controls, SmallNodeVector& no_match_effects,
SmallNodeVector& match_controls, SmallNodeVector& match_effects) {
return {
// succeed_if
[&](Node* condition, BranchHint hint) -> void {
Node* branch = graph()->NewNode(mcgraph()->common()->Branch(hint),
condition, control());
match_controls.emplace_back(
graph()->NewNode(mcgraph()->common()->IfTrue(), branch));
match_effects.emplace_back(effect());
SetControl(graph()->NewNode(mcgraph()->common()->IfFalse(), branch));
},
// fail_if
[&](Node* condition, BranchHint hint) -> void {
Node* branch = graph()->NewNode(mcgraph()->common()->Branch(hint),
condition, control());
no_match_controls.emplace_back(
graph()->NewNode(mcgraph()->common()->IfTrue(), branch));
no_match_effects.emplace_back(effect());
SetControl(graph()->NewNode(mcgraph()->common()->IfFalse(), branch));
},
// fail_if_not
[&](Node* condition, BranchHint hint) -> void {
Node* branch = graph()->NewNode(mcgraph()->common()->Branch(hint),
condition, control());
no_match_controls.emplace_back(
graph()->NewNode(mcgraph()->common()->IfFalse(), branch));
no_match_effects.emplace_back(effect());
SetControl(graph()->NewNode(mcgraph()->common()->IfTrue(), branch));
}};
}
void WasmGraphBuilder::TypeCheck(
Node* object, Node* rtt, WasmGraphBuilder::ObjectReferenceKnowledge config,
bool null_succeeds, Callbacks callbacks) {
if (config.object_can_be_null) {
(null_succeeds ? callbacks.succeed_if : callbacks.fail_if)(
gasm_->WordEqual(object, RefNull()), BranchHint::kFalse);
}
Node* map = gasm_->LoadMap(object);
if (config.reference_kind == kFunction) {
// Currently, the only way for a function to match an rtt is if its map
// is equal to that rtt.
callbacks.fail_if_not(gasm_->TaggedEqual(map, rtt), BranchHint::kTrue);
return;
}
DCHECK(config.reference_kind == kArrayOrStruct);
callbacks.succeed_if(gasm_->TaggedEqual(map, rtt), BranchHint::kTrue);
Node* type_info = gasm_->LoadWasmTypeInfo(map);
Node* supertypes = gasm_->LoadSupertypes(type_info);
Node* supertypes_length =
BuildChangeSmiToInt32(gasm_->LoadFixedArrayLengthAsSmi(supertypes));
Node* rtt_depth =
config.rtt_depth >= 0
? Int32Constant(config.rtt_depth)
: BuildChangeSmiToInt32(gasm_->LoadFixedArrayLengthAsSmi(
gasm_->LoadSupertypes(gasm_->LoadWasmTypeInfo(rtt))));
callbacks.fail_if_not(gasm_->Uint32LessThan(rtt_depth, supertypes_length),
BranchHint::kTrue);
Node* maybe_match = gasm_->LoadFixedArrayElement(
supertypes, rtt_depth, MachineType::TaggedPointer());
callbacks.fail_if_not(gasm_->TaggedEqual(maybe_match, rtt),
BranchHint::kTrue);
}
void WasmGraphBuilder::DataCheck(Node* object, bool object_can_be_null,
Callbacks callbacks) {
if (object_can_be_null) {
callbacks.fail_if(gasm_->WordEqual(object, RefNull()), BranchHint::kFalse);
}
callbacks.fail_if(gasm_->IsI31(object), BranchHint::kFalse);
Node* map = gasm_->LoadMap(object);
callbacks.fail_if_not(gasm_->IsDataRefMap(map), BranchHint::kTrue);
}
void WasmGraphBuilder::FuncCheck(Node* object, bool object_can_be_null,
Callbacks callbacks) {
if (object_can_be_null) {
callbacks.fail_if(gasm_->WordEqual(object, RefNull()), BranchHint::kFalse);
}
callbacks.fail_if(gasm_->IsI31(object), BranchHint::kFalse);
callbacks.fail_if_not(gasm_->HasInstanceType(object, JS_FUNCTION_TYPE),
BranchHint::kTrue);
}
void WasmGraphBuilder::BrOnCastAbs(
Node** match_control, Node** match_effect, Node** no_match_control,
Node** no_match_effect, std::function<void(Callbacks)> type_checker) {
SmallNodeVector no_match_controls, no_match_effects, match_controls,
match_effects;
type_checker(BranchCallbacks(no_match_controls, no_match_effects,
match_controls, match_effects));
match_controls.emplace_back(control());
match_effects.emplace_back(effect());
// Wire up the control/effect nodes.
unsigned count = static_cast<unsigned>(match_controls.size());
DCHECK_EQ(match_controls.size(), match_effects.size());
*match_control = Merge(count, match_controls.data());
// EffectPhis need their control dependency as an additional input.
match_effects.emplace_back(*match_control);
*match_effect = EffectPhi(count, match_effects.data());
DCHECK_EQ(no_match_controls.size(), no_match_effects.size());
// Range is 2..4, so casting to unsigned is safe.
count = static_cast<unsigned>(no_match_controls.size());
*no_match_control = Merge(count, no_match_controls.data());
// EffectPhis need their control dependency as an additional input.
no_match_effects.emplace_back(*no_match_control);
*no_match_effect = EffectPhi(count, no_match_effects.data());
}
Node* WasmGraphBuilder::RefTest(Node* object, Node* rtt,
ObjectReferenceKnowledge config) {
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
TypeCheck(object, rtt, config, false, TestCallbacks(&done));
gasm_->Goto(&done, Int32Constant(1));
gasm_->Bind(&done);
return done.PhiAt(0);
}
Node* WasmGraphBuilder::RefCast(Node* object, Node* rtt,
ObjectReferenceKnowledge config,
wasm::WasmCodePosition position) {
if (!FLAG_experimental_wasm_assume_ref_cast_succeeds) {
auto done = gasm_->MakeLabel();
TypeCheck(object, rtt, config, true, CastCallbacks(&done, position));
gasm_->Goto(&done);
gasm_->Bind(&done);
}
return object;
}
void WasmGraphBuilder::BrOnCast(Node* object, Node* rtt,
ObjectReferenceKnowledge config,
Node** match_control, Node** match_effect,
Node** no_match_control,
Node** no_match_effect) {
BrOnCastAbs(match_control, match_effect, no_match_control, no_match_effect,
[=](Callbacks callbacks) -> void {
return TypeCheck(object, rtt, config, false, callbacks);
});
}
Node* WasmGraphBuilder::RefIsData(Node* object, bool object_can_be_null) {
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
DataCheck(object, object_can_be_null, TestCallbacks(&done));
gasm_->Goto(&done, Int32Constant(1));
gasm_->Bind(&done);
return done.PhiAt(0);
}
Node* WasmGraphBuilder::RefAsData(Node* object, bool object_can_be_null,
wasm::WasmCodePosition position) {
auto done = gasm_->MakeLabel();
DataCheck(object, object_can_be_null, CastCallbacks(&done, position));
gasm_->Goto(&done);
gasm_->Bind(&done);
return object;
}
void WasmGraphBuilder::BrOnData(Node* object, Node* /*rtt*/,
ObjectReferenceKnowledge config,
Node** match_control, Node** match_effect,
Node** no_match_control,
Node** no_match_effect) {
BrOnCastAbs(match_control, match_effect, no_match_control, no_match_effect,
[=](Callbacks callbacks) -> void {
return DataCheck(object, config.object_can_be_null, callbacks);
});
}
Node* WasmGraphBuilder::RefIsFunc(Node* object, bool object_can_be_null) {
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
FuncCheck(object, object_can_be_null, TestCallbacks(&done));
gasm_->Goto(&done, Int32Constant(1));
gasm_->Bind(&done);
return done.PhiAt(0);
}
Node* WasmGraphBuilder::RefAsFunc(Node* object, bool object_can_be_null,
wasm::WasmCodePosition position) {
auto done = gasm_->MakeLabel();
FuncCheck(object, object_can_be_null, CastCallbacks(&done, position));
gasm_->Goto(&done);
gasm_->Bind(&done);
return object;
}
void WasmGraphBuilder::BrOnFunc(Node* object, Node* /*rtt*/,
ObjectReferenceKnowledge config,
Node** match_control, Node** match_effect,
Node** no_match_control,
Node** no_match_effect) {
BrOnCastAbs(match_control, match_effect, no_match_control, no_match_effect,
[=](Callbacks callbacks) -> void {
return FuncCheck(object, config.object_can_be_null, callbacks);
});
}
Node* WasmGraphBuilder::RefIsI31(Node* object) { return gasm_->IsI31(object); }
Node* WasmGraphBuilder::RefAsI31(Node* object,
wasm::WasmCodePosition position) {
TrapIfFalse(wasm::kTrapIllegalCast, gasm_->IsI31(object), position);
return object;
}
void WasmGraphBuilder::BrOnI31(Node* object, Node* /* rtt */,
ObjectReferenceKnowledge /* config */,
Node** match_control, Node** match_effect,
Node** no_match_control,
Node** no_match_effect) {
gasm_->Branch(gasm_->IsI31(object), match_control, no_match_control,
BranchHint::kTrue);
SetControl(*no_match_control);
*match_effect = effect();
*no_match_effect = effect();
}
Node* WasmGraphBuilder::StructGet(Node* struct_object,
const wasm::StructType* struct_type,
uint32_t field_index, CheckForNull null_check,
bool is_signed,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(struct_object, RefNull()), position);
}
// It is not enough to invoke ValueType::machine_type(), because the
// signedness has to be determined by {is_signed}.
MachineType machine_type = MachineType::TypeForRepresentation(
struct_type->field(field_index).machine_representation(), is_signed);
Node* offset = gasm_->FieldOffset(struct_type, field_index);
return gasm_->LoadFromObject(machine_type, struct_object, offset);
}
void WasmGraphBuilder::StructSet(Node* struct_object,
const wasm::StructType* struct_type,
uint32_t field_index, Node* field_value,
CheckForNull null_check,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(struct_object, RefNull()), position);
}
gasm_->StoreStructField(struct_object, struct_type, field_index, field_value);
}
void WasmGraphBuilder::BoundsCheckArray(Node* array, Node* index,
wasm::WasmCodePosition position) {
if (V8_UNLIKELY(FLAG_experimental_wasm_skip_bounds_checks)) return;
Node* length = gasm_->LoadWasmArrayLength(array);
TrapIfFalse(wasm::kTrapArrayOutOfBounds, gasm_->Uint32LessThan(index, length),
position);
}
void WasmGraphBuilder::BoundsCheckArrayCopy(Node* array, Node* index,
Node* length,
wasm::WasmCodePosition position) {
if (V8_UNLIKELY(FLAG_experimental_wasm_skip_bounds_checks)) return;
Node* array_length = gasm_->LoadWasmArrayLength(array);
Node* range_end = gasm_->Int32Add(index, length);
Node* range_valid = gasm_->Word32And(
gasm_->Uint32LessThanOrEqual(range_end, array_length),
gasm_->Uint32LessThanOrEqual(index, range_end)); // No overflow
TrapIfFalse(wasm::kTrapArrayOutOfBounds, range_valid, position);
}
Node* WasmGraphBuilder::ArrayGet(Node* array_object,
const wasm::ArrayType* type, Node* index,
CheckForNull null_check, bool is_signed,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(array_object, RefNull()), position);
}
BoundsCheckArray(array_object, index, position);
MachineType machine_type = MachineType::TypeForRepresentation(
type->element_type().machine_representation(), is_signed);
Node* offset = gasm_->WasmArrayElementOffset(index, type->element_type());
return gasm_->LoadFromObject(machine_type, array_object, offset);
}
void WasmGraphBuilder::ArraySet(Node* array_object, const wasm::ArrayType* type,
Node* index, Node* value,
CheckForNull null_check,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(array_object, RefNull()), position);
}
BoundsCheckArray(array_object, index, position);
Node* offset = gasm_->WasmArrayElementOffset(index, type->element_type());
gasm_->StoreToObject(ObjectAccessForGCStores(type->element_type()),
array_object, offset, value);
}
Node* WasmGraphBuilder::ArrayLen(Node* array_object, CheckForNull null_check,
wasm::WasmCodePosition position) {
if (null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(array_object, RefNull()), position);
}
return gasm_->LoadWasmArrayLength(array_object);
}
// TODO(7748): Add an option to copy in a loop for small array sizes. To find
// the length limit, run test/mjsunit/wasm/array-copy-benchmark.js.
void WasmGraphBuilder::ArrayCopy(Node* dst_array, Node* dst_index,
CheckForNull dst_null_check, Node* src_array,
Node* src_index, CheckForNull src_null_check,
Node* length,
wasm::WasmCodePosition position) {
if (dst_null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(dst_array, RefNull()), position);
}
if (src_null_check == kWithNullCheck) {
TrapIfTrue(wasm::kTrapNullDereference,
gasm_->WordEqual(src_array, RefNull()), position);
}
BoundsCheckArrayCopy(dst_array, dst_index, length, position);
BoundsCheckArrayCopy(src_array, src_index, length, position);
auto skip = gasm_->MakeLabel();
gasm_->GotoIf(gasm_->WordEqual(length, Int32Constant(0)), &skip,
BranchHint::kFalse);
Node* function =
gasm_->ExternalConstant(ExternalReference::wasm_array_copy());
MachineType arg_types[]{
MachineType::TaggedPointer(), MachineType::TaggedPointer(),
MachineType::Uint32(), MachineType::TaggedPointer(),
MachineType::Uint32(), MachineType::Uint32()};
MachineSignature sig(0, 6, arg_types);
BuildCCall(&sig, function, GetInstance(), dst_array, dst_index, src_array,
src_index, length);
gasm_->Goto(&skip);
gasm_->Bind(&skip);
}
// 1 bit V8 Smi tag, 31 bits V8 Smi shift, 1 bit i31ref high-bit truncation.
constexpr int kI31To32BitSmiShift = 33;
Node* WasmGraphBuilder::I31New(Node* input) {
if (SmiValuesAre31Bits()) {
return gasm_->Word32Shl(input, BuildSmiShiftBitsConstant32());
}
DCHECK(SmiValuesAre32Bits());
input = BuildChangeInt32ToIntPtr(input);
return gasm_->WordShl(input, gasm_->IntPtrConstant(kI31To32BitSmiShift));
}
Node* WasmGraphBuilder::I31GetS(Node* input) {
if (SmiValuesAre31Bits()) {
input = BuildTruncateIntPtrToInt32(input);
return gasm_->Word32SarShiftOutZeros(input, BuildSmiShiftBitsConstant32());
}
DCHECK(SmiValuesAre32Bits());
return BuildTruncateIntPtrToInt32(
gasm_->WordSar(input, gasm_->IntPtrConstant(kI31To32BitSmiShift)));
}
Node* WasmGraphBuilder::I31GetU(Node* input) {
if (SmiValuesAre31Bits()) {
input = BuildTruncateIntPtrToInt32(input);
return gasm_->Word32Shr(input, BuildSmiShiftBitsConstant32());
}
DCHECK(SmiValuesAre32Bits());
return BuildTruncateIntPtrToInt32(
gasm_->WordShr(input, gasm_->IntPtrConstant(kI31To32BitSmiShift)));
}
class WasmDecorator final : public GraphDecorator {
public:
explicit WasmDecorator(NodeOriginTable* origins, wasm::Decoder* decoder)
: origins_(origins), decoder_(decoder) {}
void Decorate(Node* node) final {
origins_->SetNodeOrigin(
node, NodeOrigin("wasm graph creation", "n/a",
NodeOrigin::kWasmBytecode, decoder_->position()));
}
private:
compiler::NodeOriginTable* origins_;
wasm::Decoder* decoder_;
};
void WasmGraphBuilder::AddBytecodePositionDecorator(
NodeOriginTable* node_origins, wasm::Decoder* decoder) {
DCHECK_NULL(decorator_);
decorator_ = graph()->zone()->New<WasmDecorator>(node_origins, decoder);
graph()->AddDecorator(decorator_);
}
void WasmGraphBuilder::RemoveBytecodePositionDecorator() {
DCHECK_NOT_NULL(decorator_);
graph()->RemoveDecorator(decorator_);
decorator_ = nullptr;
}
namespace {
// A non-null {isolate} signifies that the generated code is treated as being in
// a JS frame for functions like BuildIsolateRoot().
class WasmWrapperGraphBuilder : public WasmGraphBuilder {
public:
WasmWrapperGraphBuilder(Zone* zone, MachineGraph* mcgraph,
const wasm::FunctionSig* sig,
const wasm::WasmModule* module,
Parameter0Mode parameter_mode, Isolate* isolate,
compiler::SourcePositionTable* spt,
StubCallMode stub_mode, wasm::WasmFeatures features)
: WasmGraphBuilder(nullptr, zone, mcgraph, sig, spt, parameter_mode,
isolate),
module_(module),
stub_mode_(stub_mode),
enabled_features_(features) {}
CallDescriptor* GetI64ToBigIntCallDescriptor() {
if (i64_to_bigint_descriptor_) return i64_to_bigint_descriptor_;
i64_to_bigint_descriptor_ =
GetBuiltinCallDescriptor(Builtin::kI64ToBigInt, zone_, stub_mode_);
AddInt64LoweringReplacement(
i64_to_bigint_descriptor_,
GetBuiltinCallDescriptor(Builtin::kI32PairToBigInt, zone_, stub_mode_));
return i64_to_bigint_descriptor_;
}
CallDescriptor* GetBigIntToI64CallDescriptor(bool needs_frame_state) {
if (bigint_to_i64_descriptor_) return bigint_to_i64_descriptor_;
bigint_to_i64_descriptor_ = GetBuiltinCallDescriptor(
Builtin::kBigIntToI64, zone_, stub_mode_, needs_frame_state);
AddInt64LoweringReplacement(
bigint_to_i64_descriptor_,
GetBuiltinCallDescriptor(Builtin::kBigIntToI32Pair, zone_, stub_mode_));
return bigint_to_i64_descriptor_;
}
Node* GetTargetForBuiltinCall(wasm::WasmCode::RuntimeStubId wasm_stub,
Builtin builtin) {
return (stub_mode_ == StubCallMode::kCallWasmRuntimeStub)
? mcgraph()->RelocatableIntPtrConstant(wasm_stub,
RelocInfo::WASM_STUB_CALL)
: gasm_->GetBuiltinPointerTarget(builtin);
}
Node* BuildChangeInt32ToNumber(Node* value) {
// We expect most integers at runtime to be Smis, so it is important for
// wrapper performance that Smi conversion be inlined.
if (SmiValuesAre32Bits()) {
return BuildChangeInt32ToSmi(value);
}
DCHECK(SmiValuesAre31Bits());
auto builtin = gasm_->MakeDeferredLabel();
auto done = gasm_->MakeLabel(MachineRepresentation::kTagged);
// Double value to test if value can be a Smi, and if so, to convert it.
Node* add = gasm_->Int32AddWithOverflow(value, value);
Node* ovf = gasm_->Projection(1, add);
gasm_->GotoIf(ovf, &builtin);
// If it didn't overflow, the result is {2 * value} as pointer-sized value.
Node* smi_tagged = BuildChangeInt32ToIntPtr(gasm_->Projection(0, add));
gasm_->Goto(&done, smi_tagged);
// Otherwise, call builtin, to convert to a HeapNumber.
gasm_->Bind(&builtin);
CommonOperatorBuilder* common = mcgraph()->common();
Node* target =
GetTargetForBuiltinCall(wasm::WasmCode::kWasmInt32ToHeapNumber,
Builtin::kWasmInt32ToHeapNumber);
if (!int32_to_heapnumber_operator_.is_set()) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), WasmInt32ToHeapNumberDescriptor(), 0,
CallDescriptor::kNoFlags, Operator::kNoProperties, stub_mode_);
int32_to_heapnumber_operator_.set(common->Call(call_descriptor));
}
Node* call =
gasm_->Call(int32_to_heapnumber_operator_.get(), target, value);
gasm_->Goto(&done, call);
gasm_->Bind(&done);
return done.PhiAt(0);
}
Node* BuildChangeTaggedToInt32(Node* value, Node* context,
Node* frame_state) {
// We expect most integers at runtime to be Smis, so it is important for
// wrapper performance that Smi conversion be inlined.
auto builtin = gasm_->MakeDeferredLabel();
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
gasm_->GotoIfNot(IsSmi(value), &builtin);
// If Smi, convert to int32.
Node* smi = BuildChangeSmiToInt32(value);
gasm_->Goto(&done, smi);
// Otherwise, call builtin which changes non-Smi to Int32.
gasm_->Bind(&builtin);
CommonOperatorBuilder* common = mcgraph()->common();
Node* target =
GetTargetForBuiltinCall(wasm::WasmCode::kWasmTaggedNonSmiToInt32,
Builtin::kWasmTaggedNonSmiToInt32);
if (!tagged_non_smi_to_int32_operator_.is_set()) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), WasmTaggedNonSmiToInt32Descriptor(), 0,
frame_state ? CallDescriptor::kNeedsFrameState
: CallDescriptor::kNoFlags,
Operator::kNoProperties, stub_mode_);
tagged_non_smi_to_int32_operator_.set(common->Call(call_descriptor));
}
Node* call = frame_state
? gasm_->Call(tagged_non_smi_to_int32_operator_.get(),
target, value, context, frame_state)
: gasm_->Call(tagged_non_smi_to_int32_operator_.get(),
target, value, context);
SetSourcePosition(call, 1);
gasm_->Goto(&done, call);
gasm_->Bind(&done);
return done.PhiAt(0);
}
Node* BuildChangeFloat32ToNumber(Node* value) {
CommonOperatorBuilder* common = mcgraph()->common();
Node* target = GetTargetForBuiltinCall(wasm::WasmCode::kWasmFloat32ToNumber,
Builtin::kWasmFloat32ToNumber);
if (!float32_to_number_operator_.is_set()) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), WasmFloat32ToNumberDescriptor(), 0,
CallDescriptor::kNoFlags, Operator::kNoProperties, stub_mode_);
float32_to_number_operator_.set(common->Call(call_descriptor));
}
return gasm_->Call(float32_to_number_operator_.get(), target, value);
}
Node* BuildChangeFloat64ToNumber(Node* value) {
CommonOperatorBuilder* common = mcgraph()->common();
Node* target = GetTargetForBuiltinCall(wasm::WasmCode::kWasmFloat64ToNumber,
Builtin::kWasmFloat64ToNumber);
if (!float64_to_number_operator_.is_set()) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), WasmFloat64ToNumberDescriptor(), 0,
CallDescriptor::kNoFlags, Operator::kNoProperties, stub_mode_);
float64_to_number_operator_.set(common->Call(call_descriptor));
}
return gasm_->Call(float64_to_number_operator_.get(), target, value);
}
Node* BuildChangeTaggedToFloat64(Node* value, Node* context,
Node* frame_state) {
CommonOperatorBuilder* common = mcgraph()->common();
Node* target = GetTargetForBuiltinCall(wasm::WasmCode::kWasmTaggedToFloat64,
Builtin::kWasmTaggedToFloat64);
bool needs_frame_state = frame_state != nullptr;
if (!tagged_to_float64_operator_.is_set()) {
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), WasmTaggedToFloat64Descriptor(), 0,
frame_state ? CallDescriptor::kNeedsFrameState
: CallDescriptor::kNoFlags,
Operator::kNoProperties, stub_mode_);
tagged_to_float64_operator_.set(common->Call(call_descriptor));
}
Node* call = needs_frame_state
? gasm_->Call(tagged_to_float64_operator_.get(), target,
value, context, frame_state)
: gasm_->Call(tagged_to_float64_operator_.get(), target,
value, context);
SetSourcePosition(call, 1);
return call;
}
int AddArgumentNodes(base::Vector<Node*> args, int pos, int param_count,
const wasm::FunctionSig* sig) {
// Convert wasm numbers to JS values.
for (int i = 0; i < param_count; ++i) {
Node* param =
Param(i + 1); // Start from index 1 to drop the instance_node.
args[pos++] = ToJS(param, sig->GetParam(i));
}
return pos;
}
Node* ToJS(Node* node, wasm::ValueType type) {
switch (type.kind()) {
case wasm::kI32:
return BuildChangeInt32ToNumber(node);
case wasm::kI64:
return BuildChangeInt64ToBigInt(node);
case wasm::kF32:
return BuildChangeFloat32ToNumber(node);
case wasm::kF64:
return BuildChangeFloat64ToNumber(node);
case wasm::kRef:
case wasm::kOptRef:
switch (type.heap_representation()) {
case wasm::HeapType::kExtern:
case wasm::HeapType::kFunc:
return node;
case wasm::HeapType::kData:
case wasm::HeapType::kEq:
case wasm::HeapType::kI31:
// TODO(7748): Update this when JS interop is settled.
if (type.kind() == wasm::kOptRef) {
auto done =
gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
// Do not wrap {null}.
gasm_->GotoIf(gasm_->WordEqual(node, RefNull()), &done, node);
gasm_->Goto(&done, BuildAllocateObjectWrapper(node));
gasm_->Bind(&done);
return done.PhiAt(0);
} else {
return BuildAllocateObjectWrapper(node);
}
case wasm::HeapType::kAny: {
// Only wrap {node} if it is an array/struct/i31, i.e., do not wrap
// functions and null.
// TODO(7748): Update this when JS interop is settled.
auto done = gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
gasm_->GotoIf(IsSmi(node), &done, BuildAllocateObjectWrapper(node));
// This includes the case where {node == null}.
gasm_->GotoIfNot(gasm_->IsDataRefMap(gasm_->LoadMap(node)), &done,
node);
gasm_->Goto(&done, BuildAllocateObjectWrapper(node));
gasm_->Bind(&done);
return done.PhiAt(0);
}
default:
DCHECK(type.has_index());
if (module_->has_signature(type.ref_index())) {
// Typed function
return node;
}
// If this is reached, then IsJSCompatibleSignature() is too
// permissive.
// TODO(7748): Figure out a JS interop story for arrays and structs.
UNREACHABLE();
}
case wasm::kRtt:
case wasm::kRttWithDepth:
case wasm::kI8:
case wasm::kI16:
case wasm::kS128:
case wasm::kVoid:
case wasm::kBottom:
// If this is reached, then IsJSCompatibleSignature() is too permissive.
// TODO(7748): Figure out what to do for RTTs.
UNREACHABLE();
}
}
// TODO(7748): Temporary solution to allow round-tripping of Wasm objects
// through JavaScript, where they show up as opaque boxes. This will disappear
// once we have a proper WasmGC <-> JS interaction story.
Node* BuildAllocateObjectWrapper(Node* input) {
if (FLAG_wasm_gc_js_interop) return input;
return gasm_->CallBuiltin(
Builtin::kWasmAllocateObjectWrapper, Operator::kEliminatable, input,
LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer()));
}
// Assumes {input} has been checked for validity against the target wasm type.
// Returns the value of the property associated with
// {wasm_wrapped_object_symbol} in {input}, or {input} itself if the property
// is not found.
Node* BuildUnpackObjectWrapper(Node* input) {
if (FLAG_wasm_gc_js_interop) return input;
Node* obj = gasm_->CallBuiltin(
Builtin::kWasmGetOwnProperty, Operator::kEliminatable, input,
LOAD_ROOT(wasm_wrapped_object_symbol, wasm_wrapped_object_symbol),
LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer()));
// Invalid object wrappers (i.e. any other JS object that doesn't have the
// magic hidden property) will return {undefined}. Map that to {null} or
// {input}, depending on the value of {failure}.
Node* undefined = UndefinedValue();
Node* is_undefined = gasm_->WordEqual(obj, undefined);
Diamond check(graph(), mcgraph()->common(), is_undefined,
BranchHint::kFalse);
check.Chain(control());
return check.Phi(MachineRepresentation::kTagged, input, obj);
}
Node* BuildChangeInt64ToBigInt(Node* input) {
Node* target;
if (mcgraph()->machine()->Is64()) {
target = GetTargetForBuiltinCall(wasm::WasmCode::kI64ToBigInt,
Builtin::kI64ToBigInt);
} else {
DCHECK(mcgraph()->machine()->Is32());
// On 32-bit platforms we already set the target to the
// I32PairToBigInt builtin here, so that we don't have to replace the
// target in the int64-lowering.
target = GetTargetForBuiltinCall(wasm::WasmCode::kI32PairToBigInt,
Builtin::kI32PairToBigInt);
}
return gasm_->Call(GetI64ToBigIntCallDescriptor(), target, input);
}
Node* BuildChangeBigIntToInt64(Node* input, Node* context,
Node* frame_state) {
Node* target;
if (mcgraph()->machine()->Is64()) {
target = GetTargetForBuiltinCall(wasm::WasmCode::kBigIntToI64,
Builtin::kBigIntToI64);
} else {
DCHECK(mcgraph()->machine()->Is32());
// On 32-bit platforms we already set the target to the
// BigIntToI32Pair builtin here, so that we don't have to replace the
// target in the int64-lowering.
target = GetTargetForBuiltinCall(wasm::WasmCode::kBigIntToI32Pair,
Builtin::kBigIntToI32Pair);
}
return frame_state ? gasm_->Call(GetBigIntToI64CallDescriptor(true), target,
input, context, frame_state)
: gasm_->Call(GetBigIntToI64CallDescriptor(false),
target, input, context);
}
void BuildCheckValidRefValue(Node* input, Node* js_context,
wasm::ValueType type) {
// Make sure ValueType fits in a Smi.
STATIC_ASSERT(wasm::ValueType::kLastUsedBit + 1 <= kSmiValueSize);
// The instance node is always defined: if an instance is not available, it
// is the undefined value.
Node* inputs[] = {GetInstance(), input,
mcgraph()->IntPtrConstant(
IntToSmi(static_cast<int>(type.raw_bit_field())))};
Node* check = BuildChangeSmiToInt32(BuildCallToRuntimeWithContext(
Runtime::kWasmIsValidRefValue, js_context, inputs, 3));
Diamond type_check(graph(), mcgraph()->common(), check, BranchHint::kTrue);
type_check.Chain(control());
SetControl(type_check.if_false);
Node* old_effect = effect();
BuildCallToRuntimeWithContext(Runtime::kWasmThrowJSTypeError, js_context,
nullptr, 0);
SetEffectControl(type_check.EffectPhi(old_effect, effect()),
type_check.merge);
}
Node* FromJS(Node* input, Node* js_context, wasm::ValueType type,
Node* frame_state = nullptr) {
switch (type.kind()) {
case wasm::kRef:
case wasm::kOptRef: {
switch (type.heap_representation()) {
case wasm::HeapType::kExtern:
return input;
case wasm::HeapType::kAny:
// If this is a wrapper for arrays/structs/i31s, unpack it.
// TODO(7748): Update this when JS interop has settled.
return BuildUnpackObjectWrapper(input);
case wasm::HeapType::kFunc:
BuildCheckValidRefValue(input, js_context, type);
return input;
case wasm::HeapType::kData:
case wasm::HeapType::kEq:
case wasm::HeapType::kI31:
// TODO(7748): Update this when JS interop has settled.
BuildCheckValidRefValue(input, js_context, type);
// This will just return {input} if the object is not wrapped, i.e.
// if it is null (given the check just above).
return BuildUnpackObjectWrapper(input);
default:
if (module_->has_signature(type.ref_index())) {
BuildCheckValidRefValue(input, js_context, type);
return input;
}
// If this is reached, then IsJSCompatibleSignature() is too
// permissive.
UNREACHABLE();
}
}
case wasm::kF32:
return gasm_->TruncateFloat64ToFloat32(
BuildChangeTaggedToFloat64(input, js_context, frame_state));
case wasm::kF64:
return BuildChangeTaggedToFloat64(input, js_context, frame_state);
case wasm::kI32:
return BuildChangeTaggedToInt32(input, js_context, frame_state);
case wasm::kI64:
// i64 values can only come from BigInt.
return BuildChangeBigIntToInt64(input, js_context, frame_state);
case wasm::kRtt:
case wasm::kRttWithDepth:
case wasm::kS128:
case wasm::kI8:
case wasm::kI16:
case wasm::kBottom:
case wasm::kVoid:
// If this is reached, then IsJSCompatibleSignature() is too permissive.
// TODO(7748): Figure out what to do for RTTs.
UNREACHABLE();
}
}
Node* SmiToFloat32(Node* input) {
return gasm_->RoundInt32ToFloat32(BuildChangeSmiToInt32(input));
}
Node* SmiToFloat64(Node* input) {
return gasm_->ChangeInt32ToFloat64(BuildChangeSmiToInt32(input));
}
Node* HeapNumberToFloat64(Node* input) {
return gasm_->LoadFromObject(
MachineType::Float64(), input,
wasm::ObjectAccess::ToTagged(HeapNumber::kValueOffset));
}
Node* FromJSFast(Node* input, wasm::ValueType type) {
switch (type.kind()) {
case wasm::kI32:
return BuildChangeSmiToInt32(input);
case wasm::kF32: {
auto done = gasm_->MakeLabel(MachineRepresentation::kFloat32);
auto heap_number = gasm_->MakeLabel();
gasm_->GotoIfNot(IsSmi(input), &heap_number);
gasm_->Goto(&done, SmiToFloat32(input));
gasm_->Bind(&heap_number);
Node* value =
gasm_->TruncateFloat64ToFloat32(HeapNumberToFloat64(input));
gasm_->Goto(&done, value);
gasm_->Bind(&done);
return done.PhiAt(0);
}
case wasm::kF64: {
auto done = gasm_->MakeLabel(MachineRepresentation::kFloat64);
auto heap_number = gasm_->MakeLabel();
gasm_->GotoIfNot(IsSmi(input), &heap_number);
gasm_->Goto(&done, SmiToFloat64(input));
gasm_->Bind(&heap_number);
gasm_->Goto(&done, HeapNumberToFloat64(input));
gasm_->Bind(&done);
return done.PhiAt(0);
}
case wasm::kRef:
case wasm::kOptRef:
case wasm::kI64:
case wasm::kRtt:
case wasm::kRttWithDepth:
case wasm::kS128:
case wasm::kI8:
case wasm::kI16:
case wasm::kBottom:
case wasm::kVoid:
UNREACHABLE();
}
}
void BuildModifyThreadInWasmFlagHelper(Node* thread_in_wasm_flag_address,
bool new_value) {
if (FLAG_debug_code) {
Node* flag_value = gasm_->LoadFromObject(MachineType::Pointer(),
thread_in_wasm_flag_address, 0);
Node* check =
gasm_->Word32Equal(flag_value, Int32Constant(new_value ? 0 : 1));
Diamond flag_check(graph(), mcgraph()->common(), check,
BranchHint::kTrue);
flag_check.Chain(control());
SetControl(flag_check.if_false);
Node* message_id = gasm_->NumberConstant(static_cast<int32_t>(
new_value ? AbortReason::kUnexpectedThreadInWasmSet
: AbortReason::kUnexpectedThreadInWasmUnset));
Node* old_effect = effect();
Node* call = BuildCallToRuntimeWithContext(
Runtime::kAbort, NoContextConstant(), &message_id, 1);
flag_check.merge->ReplaceInput(1, call);
SetEffectControl(flag_check.EffectPhi(old_effect, effect()),
flag_check.merge);
}
gasm_->StoreToObject(ObjectAccess(MachineType::Int32(), kNoWriteBarrier),
thread_in_wasm_flag_address, 0,
Int32Constant(new_value ? 1 : 0));
}
void BuildModifyThreadInWasmFlag(bool new_value) {
if (!trap_handler::IsTrapHandlerEnabled()) return;
Node* isolate_root = BuildLoadIsolateRoot();
Node* thread_in_wasm_flag_address =
gasm_->LoadFromObject(MachineType::Pointer(), isolate_root,
Isolate::thread_in_wasm_flag_address_offset());
BuildModifyThreadInWasmFlagHelper(thread_in_wasm_flag_address, new_value);
}
class ModifyThreadInWasmFlagScope {
public:
ModifyThreadInWasmFlagScope(
WasmWrapperGraphBuilder* wasm_wrapper_graph_builder,
WasmGraphAssembler* gasm)
: wasm_wrapper_graph_builder_(wasm_wrapper_graph_builder) {
if (!trap_handler::IsTrapHandlerEnabled()) return;
Node* isolate_root = wasm_wrapper_graph_builder_->BuildLoadIsolateRoot();
thread_in_wasm_flag_address_ =
gasm->LoadFromObject(MachineType::Pointer(), isolate_root,
Isolate::thread_in_wasm_flag_address_offset());
wasm_wrapper_graph_builder_->BuildModifyThreadInWasmFlagHelper(
thread_in_wasm_flag_address_, true);
}
~ModifyThreadInWasmFlagScope() {
if (!trap_handler::IsTrapHandlerEnabled()) return;
wasm_wrapper_graph_builder_->BuildModifyThreadInWasmFlagHelper(
thread_in_wasm_flag_address_, false);
}
private:
WasmWrapperGraphBuilder* wasm_wrapper_graph_builder_;
Node* thread_in_wasm_flag_address_;
};
Node* BuildMultiReturnFixedArrayFromIterable(const wasm::FunctionSig* sig,
Node* iterable, Node* context) {
Node* length = BuildChangeUint31ToSmi(
mcgraph()->Uint32Constant(static_cast<uint32_t>(sig->return_count())));
return gasm_->CallBuiltin(Builtin::kIterableToFixedArrayForWasm,
Operator::kEliminatable, iterable, length,
context);
}
// Generate a call to the AllocateJSArray builtin.
Node* BuildCallAllocateJSArray(Node* array_length, Node* context) {
// Since we don't check that args will fit in an array,
// we make sure this is true based on statically known limits.
STATIC_ASSERT(wasm::kV8MaxWasmFunctionReturns <=
JSArray::kInitialMaxFastElementArray);
return gasm_->CallBuiltin(Builtin::kWasmAllocateJSArray,
Operator::kEliminatable, array_length, context);
}
Node* BuildCallAndReturn(bool is_import, Node* js_context,
Node* function_data,
base::SmallVector<Node*, 16> args,
const JSWasmCallData* js_wasm_call_data,
Node* frame_state) {
const int rets_count = static_cast<int>(sig_->return_count());
base::SmallVector<Node*, 1> rets(rets_count);
// Set the ThreadInWasm flag before we do the actual call.
{
ModifyThreadInWasmFlagScope modify_thread_in_wasm_flag_builder(
this, gasm_.get());
if (is_import) {
// Call to an imported function.
// Load function index from {WasmExportedFunctionData}.
Node* function_index = BuildChangeSmiToInt32(
gasm_->LoadExportedFunctionIndexAsSmi(function_data));
BuildImportCall(sig_, base::VectorOf(args), base::VectorOf(rets),
wasm::kNoCodePosition, function_index, kCallContinues);
} else {
// Call to a wasm function defined in this module.
// The (cached) call target is the jump table slot for that function.
args[0] = BuildLoadCallTargetFromExportedFunctionData(function_data);
BuildWasmCall(sig_, base::VectorOf(args), base::VectorOf(rets),
wasm::kNoCodePosition, nullptr, frame_state);
}
}
Node* jsval;
if (sig_->return_count() == 0) {
jsval = UndefinedValue();
} else if (sig_->return_count() == 1) {
jsval = js_wasm_call_data && !js_wasm_call_data->result_needs_conversion()
? rets[0]
: ToJS(rets[0], sig_->GetReturn());
} else {
int32_t return_count = static_cast<int32_t>(sig_->return_count());
Node* size = gasm_->NumberConstant(return_count);
jsval = BuildCallAllocateJSArray(size, js_context);
Node* fixed_array = gasm_->LoadJSArrayElements(jsval);
for (int i = 0; i < return_count; ++i) {
Node* value = ToJS(rets[i], sig_->GetReturn(i));
gasm_->StoreFixedArrayElementAny(fixed_array, i, value);
}
}
return jsval;
}
bool QualifiesForFastTransform(const wasm::FunctionSig*) {
const int wasm_count = static_cast<int>(sig_->parameter_count());
for (int i = 0; i < wasm_count; ++i) {
wasm::ValueType type = sig_->GetParam(i);
switch (type.kind()) {
case wasm::kRef:
case wasm::kOptRef:
case wasm::kI64:
case wasm::kRtt:
case wasm::kRttWithDepth:
case wasm::kS128:
case wasm::kI8:
case wasm::kI16:
case wasm::kBottom:
case wasm::kVoid:
return false;
case wasm::kI32:
case wasm::kF32:
case wasm::kF64:
break;
}
}
return true;
}
Node* IsSmi(Node* input) {
return gasm_->Word32Equal(
gasm_->Word32And(BuildTruncateIntPtrToInt32(input),
Int32Constant(kSmiTagMask)),
Int32Constant(kSmiTag));
}
void CanTransformFast(
Node* input, wasm::ValueType type,
v8::internal::compiler::GraphAssemblerLabel<0>* slow_path) {
switch (type.kind()) {
case wasm::kI32: {
gasm_->GotoIfNot(IsSmi(input), slow_path);
return;
}
case wasm::kF32:
case wasm::kF64: {
auto done = gasm_->MakeLabel();
gasm_->GotoIf(IsSmi(input), &done);
Node* map = gasm_->LoadMap(input);
Node* heap_number_map = LOAD_ROOT(HeapNumberMap, heap_number_map);
Node* is_heap_number = gasm_->WordEqual(heap_number_map, map);
gasm_->GotoIf(is_heap_number, &done);
gasm_->Goto(slow_path);
gasm_->Bind(&done);
return;
}
case wasm::kRef:
case wasm::kOptRef:
case wasm::kI64:
case wasm::kRtt:
case wasm::kRttWithDepth:
case wasm::kS128:
case wasm::kI8:
case wasm::kI16:
case wasm::kBottom:
case wasm::kVoid:
UNREACHABLE();
}
}
void BuildJSToWasmWrapper(bool is_import,
const JSWasmCallData* js_wasm_call_data = nullptr,
Node* frame_state = nullptr) {
const int wasm_param_count = static_cast<int>(sig_->parameter_count());
// Build the start and the JS parameter nodes.
Start(wasm_param_count + 5);
// Create the js_closure and js_context parameters.
Node* js_closure = Param(Linkage::kJSCallClosureParamIndex, "%closure");
Node* js_context = Param(
Linkage::GetJSCallContextParamIndex(wasm_param_count + 1), "%context");
Node* function_data = gasm_->LoadFunctionDataFromJSFunction(js_closure);
if (!wasm::IsJSCompatibleSignature(sig_, module_, enabled_features_)) {
// Throw a TypeError. Use the js_context of the calling javascript
// function (passed as a parameter), such that the generated code is
// js_context independent.
BuildCallToRuntimeWithContext(Runtime::kWasmThrowJSTypeError, js_context,
nullptr, 0);
TerminateThrow(effect(), control());
return;
}
const int args_count = wasm_param_count + 1; // +1 for wasm_code.
// Check whether the signature of the function allows for a fast
// transformation (if any params exist that need transformation).
// Create a fast transformation path, only if it does.
bool include_fast_path = !js_wasm_call_data && wasm_param_count > 0 &&
QualifiesForFastTransform(sig_);
// Prepare Param() nodes. Param() nodes can only be created once,
// so we need to use the same nodes along all possible transformation paths.
base::SmallVector<Node*, 16> params(args_count);
for (int i = 0; i < wasm_param_count; ++i) params[i + 1] = Param(i + 1);
auto done = gasm_->MakeLabel(MachineRepresentation::kTagged);
if (include_fast_path) {
auto slow_path = gasm_->MakeDeferredLabel();
// Check if the params received on runtime can be actually transformed
// using the fast transformation. When a param that cannot be transformed
// fast is encountered, skip checking the rest and fall back to the slow
// path.
for (int i = 0; i < wasm_param_count; ++i) {
CanTransformFast(params[i + 1], sig_->GetParam(i), &slow_path);
}
// Convert JS parameters to wasm numbers using the fast transformation
// and build the call.
base::SmallVector<Node*, 16> args(args_count);
for (int i = 0; i < wasm_param_count; ++i) {
Node* wasm_param = FromJSFast(params[i + 1], sig_->GetParam(i));
args[i + 1] = wasm_param;
}
Node* jsval = BuildCallAndReturn(is_import, js_context, function_data,
args, js_wasm_call_data, frame_state);
gasm_->Goto(&done, jsval);
gasm_->Bind(&slow_path);
}
// Convert JS parameters to wasm numbers using the default transformation
// and build the call.
base::SmallVector<Node*, 16> args(args_count);
for (int i = 0; i < wasm_param_count; ++i) {
bool do_conversion =
!js_wasm_call_data || js_wasm_call_data->arg_needs_conversion(i);
if (do_conversion) {
args[i + 1] =
FromJS(params[i + 1], js_context, sig_->GetParam(i), frame_state);
} else {
Node* wasm_param = params[i + 1];
// For Float32 parameters
// we set UseInfo::CheckedNumberOrOddballAsFloat64 in
// simplified-lowering and we need to add here a conversion from Float64
// to Float32.
if (sig_->GetParam(i).kind() == wasm::kF32) {
wasm_param = gasm_->TruncateFloat64ToFloat32(wasm_param);
}
args[i + 1] = wasm_param;
}
}
Node* jsval = BuildCallAndReturn(is_import, js_context, function_data, args,
js_wasm_call_data, frame_state);
// If both the default and a fast transformation paths are present,
// get the return value based on the path used.
if (include_fast_path) {
gasm_->Goto(&done, jsval);
gasm_->Bind(&done);
Return(done.PhiAt(0));
} else {
Return(jsval);
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromJS);
}
Node* BuildReceiverNode(Node* callable_node, Node* native_context,
Node* undefined_node) {
// Check function strict bit.
Node* shared_function_info = gasm_->LoadSharedFunctionInfo(callable_node);
Node* flags = gasm_->LoadFromObject(
MachineType::Int32(), shared_function_info,
wasm::ObjectAccess::FlagsOffsetInSharedFunctionInfo());
Node* strict_check =
Binop(wasm::kExprI32And, flags,
Int32Constant(SharedFunctionInfo::IsNativeBit::kMask |
SharedFunctionInfo::IsStrictBit::kMask));
// Load global receiver if sloppy else use undefined.
Diamond strict_d(graph(), mcgraph()->common(), strict_check,
BranchHint::kNone);
Node* old_effect = effect();
SetControl(strict_d.if_false);
Node* global_proxy = gasm_->LoadFixedArrayElementPtr(
native_context, Context::GLOBAL_PROXY_INDEX);
SetEffectControl(strict_d.EffectPhi(old_effect, global_proxy),
strict_d.merge);
return strict_d.Phi(MachineRepresentation::kTagged, undefined_node,
global_proxy);
}
// For wasm-to-js wrappers, parameter 0 is a WasmApiFunctionRef.
bool BuildWasmToJSWrapper(WasmImportCallKind kind, int expected_arity) {
int wasm_count = static_cast<int>(sig_->parameter_count());
// Build the start and the parameter nodes.
Start(wasm_count + 3);
Node* native_context = gasm_->Load(
MachineType::TaggedPointer(), Param(0),
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kNativeContextOffset));
if (kind == WasmImportCallKind::kRuntimeTypeError) {
// =======================================================================
// === Runtime TypeError =================================================
// =======================================================================
BuildCallToRuntimeWithContext(Runtime::kWasmThrowJSTypeError,
native_context, nullptr, 0);
TerminateThrow(effect(), control());
return false;
}
Node* callable_node = gasm_->Load(
MachineType::TaggedPointer(), Param(0),
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kCallableOffset));
Node* undefined_node = UndefinedValue();
Node* call = nullptr;
// Clear the ThreadInWasm flag.
BuildModifyThreadInWasmFlag(false);
switch (kind) {
// =======================================================================
// === JS Functions with matching arity ==================================
// =======================================================================
case WasmImportCallKind::kJSFunctionArityMatch: {
base::SmallVector<Node*, 16> args(wasm_count + 7);
int pos = 0;
Node* function_context =
gasm_->LoadContextFromJSFunction(callable_node);
args[pos++] = callable_node; // target callable.
// Determine receiver at runtime.
args[pos++] =
BuildReceiverNode(callable_node, native_context, undefined_node);
auto call_descriptor = Linkage::GetJSCallDescriptor(
graph()->zone(), false, wasm_count + 1, CallDescriptor::kNoFlags);
// Convert wasm numbers to JS values.
pos = AddArgumentNodes(base::VectorOf(args), pos, wasm_count, sig_);
args[pos++] = undefined_node; // new target
args[pos++] =
Int32Constant(JSParameterCount(wasm_count)); // argument count
args[pos++] = function_context;
args[pos++] = effect();
args[pos++] = control();
DCHECK_EQ(pos, args.size());
call = gasm_->Call(call_descriptor, pos, args.begin());
break;
}
// =======================================================================
// === JS Functions with mismatching arity ===============================
// =======================================================================
case WasmImportCallKind::kJSFunctionArityMismatch: {
int pushed_count = std::max(expected_arity, wasm_count);
base::SmallVector<Node*, 16> args(pushed_count + 7);
int pos = 0;
args[pos++] = callable_node; // target callable.
// Determine receiver at runtime.
args[pos++] =
BuildReceiverNode(callable_node, native_context, undefined_node);
// Convert wasm numbers to JS values.
pos = AddArgumentNodes(base::VectorOf(args), pos, wasm_count, sig_);
for (int i = wasm_count; i < expected_arity; ++i) {
args[pos++] = undefined_node;
}
args[pos++] = undefined_node; // new target
args[pos++] =
Int32Constant(JSParameterCount(wasm_count)); // argument count
Node* function_context =
gasm_->LoadContextFromJSFunction(callable_node);
args[pos++] = function_context;
args[pos++] = effect();
args[pos++] = control();
DCHECK_EQ(pos, args.size());
auto call_descriptor = Linkage::GetJSCallDescriptor(
graph()->zone(), false, pushed_count + 1, CallDescriptor::kNoFlags);
call = gasm_->Call(call_descriptor, pos, args.begin());
break;
}
// =======================================================================
// === General case of unknown callable ==================================
// =======================================================================
case WasmImportCallKind::kUseCallBuiltin: {
base::SmallVector<Node*, 16> args(wasm_count + 7);
int pos = 0;
args[pos++] =
gasm_->GetBuiltinPointerTarget(Builtin::kCall_ReceiverIsAny);
args[pos++] = callable_node;
args[pos++] =
Int32Constant(JSParameterCount(wasm_count)); // argument count
args[pos++] = undefined_node; // receiver
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), CallTrampolineDescriptor{}, wasm_count + 1,
CallDescriptor::kNoFlags, Operator::kNoProperties,
StubCallMode::kCallBuiltinPointer);
// Convert wasm numbers to JS values.
pos = AddArgumentNodes(base::VectorOf(args), pos, wasm_count, sig_);
// The native_context is sufficient here, because all kind of callables
// which depend on the context provide their own context. The context
// here is only needed if the target is a constructor to throw a
// TypeError, if the target is a native function, or if the target is a
// callable JSObject, which can only be constructed by the runtime.
args[pos++] = native_context;
args[pos++] = effect();
args[pos++] = control();
DCHECK_EQ(pos, args.size());
call = gasm_->Call(call_descriptor, pos, args.begin());
break;
}
default:
UNREACHABLE();
}
DCHECK_NOT_NULL(call);
SetSourcePosition(call, 0);
// Convert the return value(s) back.
if (sig_->return_count() <= 1) {
Node* val = sig_->return_count() == 0
? Int32Constant(0)
: FromJS(call, native_context, sig_->GetReturn());
BuildModifyThreadInWasmFlag(true);
Return(val);
} else {
Node* fixed_array =
BuildMultiReturnFixedArrayFromIterable(sig_, call, native_context);
base::SmallVector<Node*, 8> wasm_values(sig_->return_count());
for (unsigned i = 0; i < sig_->return_count(); ++i) {
wasm_values[i] = FromJS(gasm_->LoadFixedArrayElementAny(fixed_array, i),
native_context, sig_->GetReturn(i));
}
BuildModifyThreadInWasmFlag(true);
Return(base::VectorOf(wasm_values));
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
return true;
}
void BuildCapiCallWrapper() {
// Set up the graph start.
Start(static_cast<int>(sig_->parameter_count()) +
1 /* offset for first parameter index being -1 */ +
1 /* WasmApiFunctionRef */);
// Store arguments on our stack, then align the stack for calling to C.
int param_bytes = 0;
for (wasm::ValueType type : sig_->parameters()) {
param_bytes += type.element_size_bytes();
}
int return_bytes = 0;
for (wasm::ValueType type : sig_->returns()) {
return_bytes += type.element_size_bytes();
}
int stack_slot_bytes = std::max(param_bytes, return_bytes);
Node* values = stack_slot_bytes == 0
? mcgraph()->IntPtrConstant(0)
: graph()->NewNode(mcgraph()->machine()->StackSlot(
stack_slot_bytes, kDoubleAlignment));
int offset = 0;
int param_count = static_cast<int>(sig_->parameter_count());
for (int i = 0; i < param_count; ++i) {
wasm::ValueType type = sig_->GetParam(i);
// Start from the parameter with index 1 to drop the instance_node.
// TODO(jkummerow): When a values is a reference type, we should pass it
// in a GC-safe way, not just as a raw pointer.
SetEffect(graph()->NewNode(GetSafeStoreOperator(offset, type), values,
Int32Constant(offset), Param(i + 1), effect(),
control()));
offset += type.element_size_bytes();
}
Node* function_node = gasm_->Load(
MachineType::TaggedPointer(), Param(0),
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kCallableOffset));
Node* sfi_data = gasm_->LoadFunctionDataFromJSFunction(function_node);
Node* host_data_foreign =
gasm_->Load(MachineType::AnyTagged(), sfi_data,
wasm::ObjectAccess::ToTagged(
WasmCapiFunctionData::kEmbedderDataOffset));
BuildModifyThreadInWasmFlag(false);
Node* isolate_root = BuildLoadIsolateRoot();
Node* fp_value = graph()->NewNode(mcgraph()->machine()->LoadFramePointer());
gasm_->Store(StoreRepresentation(MachineType::PointerRepresentation(),
kNoWriteBarrier),
isolate_root, Isolate::c_entry_fp_offset(), fp_value);
Node* function = BuildLoadCallTargetFromExportedFunctionData(sfi_data);
// Parameters: Address host_data_foreign, Address arguments.
MachineType host_sig_types[] = {
MachineType::Pointer(), MachineType::Pointer(), MachineType::Pointer()};
MachineSignature host_sig(1, 2, host_sig_types);
Node* return_value =
BuildCCall(&host_sig, function, host_data_foreign, values);
BuildModifyThreadInWasmFlag(true);
Node* old_effect = effect();
Node* exception_branch = graph()->NewNode(
mcgraph()->common()->Branch(BranchHint::kTrue),
gasm_->WordEqual(return_value, mcgraph()->IntPtrConstant(0)),
control());
SetControl(
graph()->NewNode(mcgraph()->common()->IfFalse(), exception_branch));
WasmRethrowExplicitContextDescriptor interface_descriptor;
auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), interface_descriptor,
interface_descriptor.GetStackParameterCount(), CallDescriptor::kNoFlags,
Operator::kNoProperties, StubCallMode::kCallWasmRuntimeStub);
Node* call_target = mcgraph()->RelocatableIntPtrConstant(
wasm::WasmCode::kWasmRethrowExplicitContext, RelocInfo::WASM_STUB_CALL);
Node* context = gasm_->Load(
MachineType::TaggedPointer(), Param(0),
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kNativeContextOffset));
gasm_->Call(call_descriptor, call_target, return_value, context);
TerminateThrow(effect(), control());
SetEffectControl(old_effect, graph()->NewNode(mcgraph()->common()->IfTrue(),
exception_branch));
DCHECK_LT(sig_->return_count(), wasm::kV8MaxWasmFunctionReturns);
size_t return_count = sig_->return_count();
if (return_count == 0) {
Return(Int32Constant(0));
} else {
base::SmallVector<Node*, 8> returns(return_count);
offset = 0;
for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i);
Node* val = SetEffect(
graph()->NewNode(GetSafeLoadOperator(offset, type), values,
Int32Constant(offset), effect(), control()));
returns[i] = val;
offset += type.element_size_bytes();
}
Return(base::VectorOf(returns));
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
}
void BuildJSToJSWrapper() {
int wasm_count = static_cast<int>(sig_->parameter_count());
// Build the start and the parameter nodes.
int param_count = 1 /* closure */ + 1 /* receiver */ + wasm_count +
1 /* new.target */ + 1 /* #arg */ + 1 /* context */;
Start(param_count);
Node* closure = Param(Linkage::kJSCallClosureParamIndex);
Node* context = Param(Linkage::GetJSCallContextParamIndex(wasm_count + 1));
// Throw a TypeError if the signature is incompatible with JavaScript.
if (!wasm::IsJSCompatibleSignature(sig_, module_, enabled_features_)) {
BuildCallToRuntimeWithContext(Runtime::kWasmThrowJSTypeError, context,
nullptr, 0);
TerminateThrow(effect(), control());
return;
}
// Load the original callable from the closure.
Node* func_data = gasm_->LoadFunctionDataFromJSFunction(closure);
Node* ref = gasm_->LoadFromObject(
MachineType::AnyTagged(), func_data,
wasm::ObjectAccess::ToTagged(WasmJSFunctionData::kRefOffset));
Node* callable = gasm_->LoadFromObject(
MachineType::AnyTagged(), ref,
wasm::ObjectAccess::ToTagged(WasmApiFunctionRef::kCallableOffset));
// Call the underlying closure.
base::SmallVector<Node*, 16> args(wasm_count + 7);
int pos = 0;
args[pos++] = gasm_->GetBuiltinPointerTarget(Builtin::kCall_ReceiverIsAny);
args[pos++] = callable;
args[pos++] =
Int32Constant(JSParameterCount(wasm_count)); // argument count
args[pos++] = UndefinedValue(); // receiver
auto call_descriptor = Linkage::GetStubCallDescriptor(
graph()->zone(), CallTrampolineDescriptor{}, wasm_count + 1,
CallDescriptor::kNoFlags, Operator::kNoProperties,
StubCallMode::kCallBuiltinPointer);
// Convert parameter JS values to wasm numbers and back to JS values.
for (int i = 0; i < wasm_count; ++i) {
Node* param = Param(i + 1); // Start from index 1 to skip receiver.
args[pos++] =
ToJS(FromJS(param, context, sig_->GetParam(i)), sig_->GetParam(i));
}
args[pos++] = context;
args[pos++] = effect();
args[pos++] = control();
DCHECK_EQ(pos, args.size());
Node* call = gasm_->Call(call_descriptor, pos, args.begin());
// Convert return JS values to wasm numbers and back to JS values.
Node* jsval;
if (sig_->return_count() == 0) {
jsval = UndefinedValue();
} else if (sig_->return_count() == 1) {
jsval = ToJS(FromJS(call, context, sig_->GetReturn()), sig_->GetReturn());
} else {
Node* fixed_array =
BuildMultiReturnFixedArrayFromIterable(sig_, call, context);
int32_t return_count = static_cast<int32_t>(sig_->return_count());
Node* size = gasm_->NumberConstant(return_count);
jsval = BuildCallAllocateJSArray(size, context);
Node* result_fixed_array = gasm_->LoadJSArrayElements(jsval);
for (unsigned i = 0; i < sig_->return_count(); ++i) {
const auto& type = sig_->GetReturn(i);
Node* elem = gasm_->LoadFixedArrayElementAny(fixed_array, i);
Node* cast = ToJS(FromJS(elem, context, type), type);
gasm_->StoreFixedArrayElementAny(result_fixed_array, i, cast);
}
}
Return(jsval);
}
void BuildCWasmEntry() {
// +1 offset for first parameter index being -1.
Start(CWasmEntryParameters::kNumParameters + 1);
Node* code_entry = Param(CWasmEntryParameters::kCodeEntry);
Node* object_ref = Param(CWasmEntryParameters::kObjectRef);
Node* arg_buffer = Param(CWasmEntryParameters::kArgumentsBuffer);
Node* c_entry_fp = Param(CWasmEntryParameters::kCEntryFp);
Node* fp_value = graph()->NewNode(mcgraph()->machine()->LoadFramePointer());
gasm_->Store(StoreRepresentation(MachineType::PointerRepresentation(),
kNoWriteBarrier),
fp_value, TypedFrameConstants::kFirstPushedFrameValueOffset,
c_entry_fp);
int wasm_arg_count = static_cast<int>(sig_->parameter_count());
base::SmallVector<Node*, 16> args(wasm_arg_count + 4);
int pos = 0;
args[pos++] = code_entry;
args[pos++] = object_ref;
int offset = 0;
for (wasm::ValueType type : sig_->parameters()) {
Node* arg_load = SetEffect(
graph()->NewNode(GetSafeLoadOperator(offset, type), arg_buffer,
Int32Constant(offset), effect(), control()));
args[pos++] = arg_load;
offset += type.element_size_bytes();
}
args[pos++] = effect();
args[pos++] = control();
// Call the wasm code.
auto call_descriptor = GetWasmCallDescriptor(mcgraph()->zone(), sig_);
DCHECK_EQ(pos, args.size());
Node* call = gasm_->Call(call_descriptor, pos, args.begin());
Node* if_success = graph()->NewNode(mcgraph()->common()->IfSuccess(), call);
Node* if_exception =
graph()->NewNode(mcgraph()->common()->IfException(), call, call);
// Handle exception: return it.
SetControl(if_exception);
Return(if_exception);
// Handle success: store the return value(s).
SetControl(if_success);
pos = 0;
offset = 0;
for (wasm::ValueType type : sig_->returns()) {
Node* value = sig_->return_count() == 1
? call
: graph()->NewNode(mcgraph()->common()->Projection(pos),
call, control());
SetEffect(graph()->NewNode(GetSafeStoreOperator(offset, type), arg_buffer,
Int32Constant(offset), value, effect(),
control()));
offset += type.element_size_bytes();
pos++;
}
Return(mcgraph()->IntPtrConstant(0));
if (mcgraph()->machine()->Is32() && ContainsInt64(sig_)) {
// No special lowering should be requested in the C entry.
DCHECK_NULL(lowering_special_case_);
MachineRepresentation sig_reps[] = {
MachineType::PointerRepresentation(), // return value
MachineType::PointerRepresentation(), // target
MachineRepresentation::kTagged, // object_ref
MachineType::PointerRepresentation(), // argv
MachineType::PointerRepresentation() // c_entry_fp
};
Signature<MachineRepresentation> c_entry_sig(1, 4, sig_reps);
Int64Lowering r(mcgraph()->graph(), mcgraph()->machine(),
mcgraph()->common(), gasm_->simplified(),
mcgraph()->zone(), &c_entry_sig);
r.LowerGraph();
}
}
private:
const wasm::WasmModule* module_;
StubCallMode stub_mode_;
SetOncePointer<const Operator> int32_to_heapnumber_operator_;
SetOncePointer<const Operator> tagged_non_smi_to_int32_operator_;
SetOncePointer<const Operator> float32_to_number_operator_;
SetOncePointer<const Operator> float64_to_number_operator_;
SetOncePointer<const Operator> tagged_to_float64_operator_;
wasm::WasmFeatures enabled_features_;
CallDescriptor* bigint_to_i64_descriptor_ = nullptr;
CallDescriptor* i64_to_bigint_descriptor_ = nullptr;
};
} // namespace
void BuildInlinedJSToWasmWrapper(
Zone* zone, MachineGraph* mcgraph, const wasm::FunctionSig* signature,
const wasm::WasmModule* module, Isolate* isolate,
compiler::SourcePositionTable* spt, StubCallMode stub_mode,
wasm::WasmFeatures features, const JSWasmCallData* js_wasm_call_data,
Node* frame_state) {
WasmWrapperGraphBuilder builder(zone, mcgraph, signature, module,
WasmGraphBuilder::kNoSpecialParameterMode,
isolate, spt, stub_mode, features);
builder.BuildJSToWasmWrapper(false, js_wasm_call_data, frame_state);
}
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, const wasm::FunctionSig* sig,
const wasm::WasmModule* module, bool is_import,
const wasm::WasmFeatures& enabled_features) {
//----------------------------------------------------------------------------
// Create the Graph.
//----------------------------------------------------------------------------
std::unique_ptr<Zone> zone = std::make_unique<Zone>(
wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone->New<Graph>(zone.get());
CommonOperatorBuilder* common = zone->New<CommonOperatorBuilder>(zone.get());
MachineOperatorBuilder* machine = zone->New<MachineOperatorBuilder>(
zone.get(), MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements());
MachineGraph* mcgraph = zone->New<MachineGraph>(graph, common, machine);
WasmWrapperGraphBuilder builder(
zone.get(), mcgraph, sig, module,
WasmGraphBuilder::kNoSpecialParameterMode, isolate, nullptr,
StubCallMode::kCallBuiltinPointer, enabled_features);
builder.BuildJSToWasmWrapper(is_import);
//----------------------------------------------------------------------------
// Create the compilation job.
//----------------------------------------------------------------------------
std::unique_ptr<char[]> debug_name = WasmExportedFunction::GetDebugName(sig);
int params = static_cast<int>(sig->parameter_count());
CallDescriptor* incoming = Linkage::GetJSCallDescriptor(
zone.get(), false, params + 1, CallDescriptor::kNoFlags);
return Pipeline::NewWasmHeapStubCompilationJob(
isolate, incoming, std::move(zone), graph, CodeKind::JS_TO_WASM_FUNCTION,
std::move(debug_name), WasmAssemblerOptions());
}
std::pair<WasmImportCallKind, Handle<JSReceiver>> ResolveWasmImportCall(
Handle<JSReceiver> callable, const wasm::FunctionSig* expected_sig,
const wasm::WasmModule* module,
const wasm::WasmFeatures& enabled_features) {
if (WasmExportedFunction::IsWasmExportedFunction(*callable)) {
auto imported_function = Handle<WasmExportedFunction>::cast(callable);
if (!imported_function->MatchesSignature(module, expected_sig)) {
return std::make_pair(WasmImportCallKind::kLinkError, callable);
}
uint32_t func_index =
static_cast<uint32_t>(imported_function->function_index());
if (func_index >=
imported_function->instance().module()->num_imported_functions) {
return std::make_pair(WasmImportCallKind::kWasmToWasm, callable);
}
Isolate* isolate = callable->GetIsolate();
// Resolve the shortcut to the underlying callable and continue.
Handle<WasmInstanceObject> instance(imported_function->instance(), isolate);
ImportedFunctionEntry entry(instance, func_index);
callable = handle(entry.callable(), isolate);
}
if (WasmJSFunction::IsWasmJSFunction(*callable)) {
auto js_function = Handle<WasmJSFunction>::cast(callable);
if (!js_function->MatchesSignature(expected_sig)) {
return std::make_pair(WasmImportCallKind::kLinkError, callable);
}
Isolate* isolate = callable->GetIsolate();
// Resolve the short-cut to the underlying callable and continue.
callable = handle(js_function->GetCallable(), isolate);
}
if (WasmCapiFunction::IsWasmCapiFunction(*callable)) {
auto capi_function = Handle<WasmCapiFunction>::cast(callable);
if (!capi_function->MatchesSignature(expected_sig)) {
return std::make_pair(WasmImportCallKind::kLinkError, callable);
}
return std::make_pair(WasmImportCallKind::kWasmToCapi, callable);
}
// Assuming we are calling to JS, check whether this would be a runtime error.
if (!wasm::IsJSCompatibleSignature(expected_sig, module, enabled_features)) {
return std::make_pair(WasmImportCallKind::kRuntimeTypeError, callable);
}
// For JavaScript calls, determine whether the target has an arity match.
if (callable->IsJSFunction()) {
Handle<JSFunction> function = Handle<JSFunction>::cast(callable);
Handle<SharedFunctionInfo> shared(function->shared(),
function->GetIsolate());
// Check for math intrinsics.
#define COMPARE_SIG_FOR_BUILTIN(name) \
{ \
const wasm::FunctionSig* sig = \
wasm::WasmOpcodes::Signature(wasm::kExpr##name); \
if (!sig) sig = wasm::WasmOpcodes::AsmjsSignature(wasm::kExpr##name); \
DCHECK_NOT_NULL(sig); \
if (*expected_sig == *sig) { \
return std::make_pair(WasmImportCallKind::k##name, callable); \
} \
}
#define COMPARE_SIG_FOR_BUILTIN_F64(name) \
case Builtin::kMath##name: \
COMPARE_SIG_FOR_BUILTIN(F64##name); \
break;
#define COMPARE_SIG_FOR_BUILTIN_F32_F64(name) \
case Builtin::kMath##name: \
COMPARE_SIG_FOR_BUILTIN(F64##name); \
COMPARE_SIG_FOR_BUILTIN(F32##name); \
break;
if (FLAG_wasm_math_intrinsics && shared->HasBuiltinId()) {
switch (shared->builtin_id()) {
COMPARE_SIG_FOR_BUILTIN_F64(Acos);
COMPARE_SIG_FOR_BUILTIN_F64(Asin);
COMPARE_SIG_FOR_BUILTIN_F64(Atan);
COMPARE_SIG_FOR_BUILTIN_F64(Cos);
COMPARE_SIG_FOR_BUILTIN_F64(Sin);
COMPARE_SIG_FOR_BUILTIN_F64(Tan);
COMPARE_SIG_FOR_BUILTIN_F64(Exp);
COMPARE_SIG_FOR_BUILTIN_F64(Log);
COMPARE_SIG_FOR_BUILTIN_F64(Atan2);
COMPARE_SIG_FOR_BUILTIN_F64(Pow);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Min);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Max);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Abs);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Ceil);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Floor);
COMPARE_SIG_FOR_BUILTIN_F32_F64(Sqrt);
case Builtin::kMathFround:
COMPARE_SIG_FOR_BUILTIN(F32ConvertF64);
break;
default:
break;
}
}
#undef COMPARE_SIG_FOR_BUILTIN
#undef COMPARE_SIG_FOR_BUILTIN_F64
#undef COMPARE_SIG_FOR_BUILTIN_F32_F64
if (IsClassConstructor(shared->kind())) {
// Class constructor will throw anyway.
return std::make_pair(WasmImportCallKind::kUseCallBuiltin, callable);
}
if (shared->internal_formal_parameter_count_without_receiver() ==
expected_sig->parameter_count()) {
return std::make_pair(WasmImportCallKind::kJSFunctionArityMatch,
callable);
}
// If function isn't compiled, compile it now.
Isolate* isolate = callable->GetIsolate();
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
if (!is_compiled_scope.is_compiled()) {
Compiler::Compile(isolate, function, Compiler::CLEAR_EXCEPTION,
&is_compiled_scope);
}
return std::make_pair(WasmImportCallKind::kJSFunctionArityMismatch,
callable);
}
// Unknown case. Use the call builtin.
return std::make_pair(WasmImportCallKind::kUseCallBuiltin, callable);
}
namespace {
wasm::WasmOpcode GetMathIntrinsicOpcode(WasmImportCallKind kind,
const char** name_ptr) {
#define CASE(name) \
case WasmImportCallKind::k##name: \
*name_ptr = "WasmMathIntrinsic:" #name; \
return wasm::kExpr##name
switch (kind) {
CASE(F64Acos);
CASE(F64Asin);
CASE(F64Atan);
CASE(F64Cos);
CASE(F64Sin);
CASE(F64Tan);
CASE(F64Exp);
CASE(F64Log);
CASE(F64Atan2);
CASE(F64Pow);
CASE(F64Ceil);
CASE(F64Floor);
CASE(F64Sqrt);
CASE(F64Min);
CASE(F64Max);
CASE(F64Abs);
CASE(F32Min);
CASE(F32Max);
CASE(F32Abs);
CASE(F32Ceil);
CASE(F32Floor);
CASE(F32Sqrt);
CASE(F32ConvertF64);
default:
UNREACHABLE();
}
#undef CASE
}
wasm::WasmCompilationResult CompileWasmMathIntrinsic(
WasmImportCallKind kind, const wasm::FunctionSig* sig) {
DCHECK_EQ(1, sig->return_count());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmMathIntrinsic");
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
// Compile a Wasm function with a single bytecode and let TurboFan
// generate either inlined machine code or a call to a helper.
SourcePositionTable* source_positions = nullptr;
MachineGraph* mcgraph = zone.New<MachineGraph>(
zone.New<Graph>(&zone), zone.New<CommonOperatorBuilder>(&zone),
zone.New<MachineOperatorBuilder>(
&zone, MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()));
wasm::CompilationEnv env(
nullptr, wasm::kNoBoundsChecks,
wasm::RuntimeExceptionSupport::kNoRuntimeExceptionSupport,
wasm::WasmFeatures::All(), wasm::DynamicTiering::kDisabled);
WasmGraphBuilder builder(&env, mcgraph->zone(), mcgraph, sig,
source_positions);
// Set up the graph start.
builder.Start(static_cast<int>(sig->parameter_count() + 1 + 1));
// Generate either a unop or a binop.
Node* node = nullptr;
const char* debug_name = "WasmMathIntrinsic";
auto opcode = GetMathIntrinsicOpcode(kind, &debug_name);
switch (sig->parameter_count()) {
case 1:
node = builder.Unop(opcode, builder.Param(1));
break;
case 2:
node = builder.Binop(opcode, builder.Param(1), builder.Param(2));
break;
default:
UNREACHABLE();
}
builder.Return(node);
// Run the compiler pipeline to generate machine code.
auto call_descriptor = GetWasmCallDescriptor(&zone, sig);
if (mcgraph->machine()->Is32()) {
call_descriptor = GetI32WasmCallDescriptor(&zone, call_descriptor);
}
// The code does not call to JS, but conceptually it is an import wrapper,
// hence use {WASM_TO_JS_FUNCTION} here.
// TODO(wasm): Rename this to {WASM_IMPORT_CALL}?
return Pipeline::GenerateCodeForWasmNativeStub(
call_descriptor, mcgraph, CodeKind::WASM_TO_JS_FUNCTION, debug_name,
WasmStubAssemblerOptions(), source_positions);
}
} // namespace
wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::CompilationEnv* env, WasmImportCallKind kind,
const wasm::FunctionSig* sig, bool source_positions, int expected_arity) {
DCHECK_NE(WasmImportCallKind::kLinkError, kind);
DCHECK_NE(WasmImportCallKind::kWasmToWasm, kind);
// Check for math intrinsics first.
if (FLAG_wasm_math_intrinsics &&
kind >= WasmImportCallKind::kFirstMathIntrinsic &&
kind <= WasmImportCallKind::kLastMathIntrinsic) {
return CompileWasmMathIntrinsic(kind, sig);
}
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmImportCallWrapper");
//----------------------------------------------------------------------------
// Create the Graph
//----------------------------------------------------------------------------
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone.New<Graph>(&zone);
CommonOperatorBuilder* common = zone.New<CommonOperatorBuilder>(&zone);
MachineOperatorBuilder* machine = zone.New<MachineOperatorBuilder>(
&zone, MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements());
MachineGraph* mcgraph = zone.New<MachineGraph>(graph, common, machine);
SourcePositionTable* source_position_table =
source_positions ? zone.New<SourcePositionTable>(graph) : nullptr;
WasmWrapperGraphBuilder builder(
&zone, mcgraph, sig, env->module,
WasmGraphBuilder::kWasmApiFunctionRefMode, nullptr, source_position_table,
StubCallMode::kCallWasmRuntimeStub, env->enabled_features);
builder.BuildWasmToJSWrapper(kind, expected_arity);
// Build a name in the form "wasm-to-js-<kind>-<signature>".
constexpr size_t kMaxNameLen = 128;
char func_name[kMaxNameLen];
int name_prefix_len = SNPrintF(base::VectorOf(func_name, kMaxNameLen),
"wasm-to-js-%d-", static_cast<int>(kind));
PrintSignature(base::VectorOf(func_name, kMaxNameLen) + name_prefix_len, sig,
'-');
// Schedule and compile to machine code.
CallDescriptor* incoming =
GetWasmCallDescriptor(&zone, sig, WasmCallKind::kWasmImportWrapper);
if (machine->Is32()) {
incoming = GetI32WasmCallDescriptor(&zone, incoming);
}
return Pipeline::GenerateCodeForWasmNativeStub(
incoming, mcgraph, CodeKind::WASM_TO_JS_FUNCTION, func_name,
WasmStubAssemblerOptions(), source_position_table);
}
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::NativeModule* native_module,
const wasm::FunctionSig* sig) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmCapiFunction");
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
// TODO(jkummerow): Extract common code into helper method.
SourcePositionTable* source_positions = nullptr;
MachineGraph* mcgraph = zone.New<MachineGraph>(
zone.New<Graph>(&zone), zone.New<CommonOperatorBuilder>(&zone),
zone.New<MachineOperatorBuilder>(
&zone, MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()));
WasmWrapperGraphBuilder builder(
&zone, mcgraph, sig, native_module->module(),
WasmGraphBuilder::kWasmApiFunctionRefMode, nullptr, source_positions,
StubCallMode::kCallWasmRuntimeStub, native_module->enabled_features());
builder.BuildCapiCallWrapper();
// Run the compiler pipeline to generate machine code.
CallDescriptor* call_descriptor =
GetWasmCallDescriptor(&zone, sig, WasmCallKind::kWasmCapiFunction);
if (mcgraph->machine()->Is32()) {
call_descriptor = GetI32WasmCallDescriptor(&zone, call_descriptor);
}
const char* debug_name = "WasmCapiCall";
wasm::WasmCompilationResult result = Pipeline::GenerateCodeForWasmNativeStub(
call_descriptor, mcgraph, CodeKind::WASM_TO_CAPI_FUNCTION, debug_name,
WasmStubAssemblerOptions(), source_positions);
wasm::WasmCode* published_code;
{
wasm::CodeSpaceWriteScope code_space_write_scope(native_module);
std::unique_ptr<wasm::WasmCode> wasm_code = native_module->AddCode(
wasm::kAnonymousFuncIndex, result.code_desc, result.frame_slot_count,
result.tagged_parameter_slots,
result.protected_instructions_data.as_vector(),
result.source_positions.as_vector(), wasm::WasmCode::kWasmToCapiWrapper,
wasm::ExecutionTier::kNone, wasm::kNoDebugging);
published_code = native_module->PublishCode(std::move(wasm_code));
}
return published_code;
}
MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
const wasm::FunctionSig* sig,
WasmImportCallKind kind,
int expected_arity) {
std::unique_ptr<Zone> zone = std::make_unique<Zone>(
isolate->allocator(), ZONE_NAME, kCompressGraphZone);
// Create the Graph
Graph* graph = zone->New<Graph>(zone.get());
CommonOperatorBuilder* common = zone->New<CommonOperatorBuilder>(zone.get());
MachineOperatorBuilder* machine = zone->New<MachineOperatorBuilder>(
zone.get(), MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements());
MachineGraph* mcgraph = zone->New<MachineGraph>(graph, common, machine);
WasmWrapperGraphBuilder builder(zone.get(), mcgraph, sig, nullptr,
WasmGraphBuilder::kWasmApiFunctionRefMode,
nullptr, nullptr,
StubCallMode::kCallBuiltinPointer,
wasm::WasmFeatures::FromIsolate(isolate));
builder.BuildWasmToJSWrapper(kind, expected_arity);
// Build a name in the form "wasm-to-js-<kind>-<signature>".
constexpr size_t kMaxNameLen = 128;
constexpr size_t kNamePrefixLen = 11;
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
memcpy(name_buffer.get(), "wasm-to-js:", kNamePrefixLen);
PrintSignature(
base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig);
// Generate the call descriptor.
CallDescriptor* incoming =
GetWasmCallDescriptor(zone.get(), sig, WasmCallKind::kWasmImportWrapper);
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, incoming, std::move(zone), graph,
CodeKind::WASM_TO_JS_FUNCTION, std::move(name_buffer),
AssemblerOptions::Default(isolate)));
// Compile the wrapper
if (job->ExecuteJob(isolate->counters()->runtime_call_stats()) ==
CompilationJob::FAILED ||
job->FinalizeJob(isolate) == CompilationJob::FAILED) {
return Handle<Code>();
}
Handle<Code> code = job->compilation_info()->code();
return code;
}
MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
const wasm::FunctionSig* sig,
const wasm::WasmModule* module) {
std::unique_ptr<Zone> zone = std::make_unique<Zone>(
isolate->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone->New<Graph>(zone.get());
CommonOperatorBuilder* common = zone->New<CommonOperatorBuilder>(zone.get());
MachineOperatorBuilder* machine = zone->New<MachineOperatorBuilder>(
zone.get(), MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements());
MachineGraph* mcgraph = zone->New<MachineGraph>(graph, common, machine);
WasmWrapperGraphBuilder builder(zone.get(), mcgraph, sig, module,
WasmGraphBuilder::kNoSpecialParameterMode,
isolate, nullptr,
StubCallMode::kCallBuiltinPointer,
wasm::WasmFeatures::FromIsolate(isolate));
builder.BuildJSToJSWrapper();
int wasm_count = static_cast<int>(sig->parameter_count());
CallDescriptor* incoming = Linkage::GetJSCallDescriptor(
zone.get(), false, wasm_count + 1, CallDescriptor::kNoFlags);
// Build a name in the form "js-to-js:<params>:<returns>".
constexpr size_t kMaxNameLen = 128;
constexpr size_t kNamePrefixLen = 9;
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
memcpy(name_buffer.get(), "js-to-js:", kNamePrefixLen);
PrintSignature(
base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig);
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, incoming, std::move(zone), graph,
CodeKind::JS_TO_JS_FUNCTION, std::move(name_buffer),
AssemblerOptions::Default(isolate)));
if (job->ExecuteJob(isolate->counters()->runtime_call_stats()) ==
CompilationJob::FAILED ||
job->FinalizeJob(isolate) == CompilationJob::FAILED) {
return {};
}
Handle<Code> code = job->compilation_info()->code();
return code;
}
Handle<CodeT> CompileCWasmEntry(Isolate* isolate, const wasm::FunctionSig* sig,
const wasm::WasmModule* module) {
std::unique_ptr<Zone> zone = std::make_unique<Zone>(
isolate->allocator(), ZONE_NAME, kCompressGraphZone);
Graph* graph = zone->New<Graph>(zone.get());
CommonOperatorBuilder* common = zone->New<CommonOperatorBuilder>(zone.get());
MachineOperatorBuilder* machine = zone->New<MachineOperatorBuilder>(
zone.get(), MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements());
MachineGraph* mcgraph = zone->New<MachineGraph>(graph, common, machine);
WasmWrapperGraphBuilder builder(zone.get(), mcgraph, sig, module,
WasmGraphBuilder::kWasmApiFunctionRefMode,
nullptr, nullptr,
StubCallMode::kCallBuiltinPointer,
wasm::WasmFeatures::FromIsolate(isolate));
builder.BuildCWasmEntry();
// Schedule and compile to machine code.
MachineType sig_types[] = {MachineType::Pointer(), // return
MachineType::Pointer(), // target
MachineType::AnyTagged(), // object_ref
MachineType::Pointer(), // argv
MachineType::Pointer()}; // c_entry_fp
MachineSignature incoming_sig(1, 4, sig_types);
// Traps need the root register, for TailCallRuntime to call
// Runtime::kThrowWasmError.
CallDescriptor::Flags flags = CallDescriptor::kInitializeRootRegister;
CallDescriptor* incoming =
Linkage::GetSimplifiedCDescriptor(zone.get(), &incoming_sig, flags);
// Build a name in the form "c-wasm-entry:<params>:<returns>".
constexpr size_t kMaxNameLen = 128;
constexpr size_t kNamePrefixLen = 13;
auto name_buffer = std::unique_ptr<char[]>(new char[kMaxNameLen]);
memcpy(name_buffer.get(), "c-wasm-entry:", kNamePrefixLen);
PrintSignature(
base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig);
// Run the compilation job synchronously.
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmHeapStubCompilationJob(
isolate, incoming, std::move(zone), graph, CodeKind::C_WASM_ENTRY,
std::move(name_buffer), AssemblerOptions::Default(isolate)));
CHECK_NE(job->ExecuteJob(isolate->counters()->runtime_call_stats(), nullptr),
CompilationJob::FAILED);
CHECK_NE(job->FinalizeJob(isolate), CompilationJob::FAILED);
#ifdef V8_EXTERNAL_CODE_SPACE
return handle(ToCodeT(*job->compilation_info()->code()), isolate);
#else
return job->compilation_info()->code();
#endif
}
namespace {
bool BuildGraphForWasmFunction(wasm::CompilationEnv* env,
const wasm::FunctionBody& func_body,
int func_index, wasm::WasmFeatures* detected,
MachineGraph* mcgraph,
std::vector<compiler::WasmLoopInfo>* loop_infos,
NodeOriginTable* node_origins,
SourcePositionTable* source_positions) {
// Create a TF graph during decoding.
WasmGraphBuilder builder(env, mcgraph->zone(), mcgraph, func_body.sig,
source_positions);
auto* allocator = wasm::GetWasmEngine()->allocator();
wasm::VoidResult graph_construction_result = wasm::BuildTFGraph(
allocator, env->enabled_features, env->module, &builder, detected,
func_body, loop_infos, node_origins, func_index, wasm::kRegularFunction);
if (graph_construction_result.failed()) {
if (FLAG_trace_wasm_compiler) {
StdoutStream{} << "Compilation failed: "
<< graph_construction_result.error().message()
<< std::endl;
}
return false;
}
auto sig = CreateMachineSignature(mcgraph->zone(), func_body.sig,
WasmGraphBuilder::kCalledFromWasm);
builder.LowerInt64(sig);
return true;
}
base::Vector<const char> GetDebugName(Zone* zone, int index) {
// TODO(herhut): Use name from module if available.
constexpr int kBufferLength = 24;
base::EmbeddedVector<char, kBufferLength> name_vector;
int name_len = SNPrintF(name_vector, "wasm-function#%d", index);
DCHECK(name_len > 0 && name_len < name_vector.length());
char* index_name = zone->NewArray<char>(name_len);
memcpy(index_name, name_vector.begin(), name_len);
return base::Vector<const char>(index_name, name_len);
}
} // namespace
wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
wasm::CompilationEnv* env, const wasm::WireBytesStorage* wire_bytes_storage,
const wasm::FunctionBody& func_body, int func_index, Counters* counters,
wasm::WasmFeatures* detected) {
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileTopTier", "func_index", func_index, "body_size",
func_body.end - func_body.start);
Zone zone(wasm::GetWasmEngine()->allocator(), ZONE_NAME, kCompressGraphZone);
MachineGraph* mcgraph = zone.New<MachineGraph>(
zone.New<Graph>(&zone), zone.New<CommonOperatorBuilder>(&zone),
zone.New<MachineOperatorBuilder>(
&zone, MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags(),
InstructionSelector::AlignmentRequirements()));
OptimizedCompilationInfo info(GetDebugName(&zone, func_index), &zone,
CodeKind::WASM_FUNCTION);
if (env->runtime_exception_support) {
info.set_wasm_runtime_exception_support();
}
if (info.trace_turbo_json()) {
TurboCfgFile tcf;
tcf << AsC1VCompilation(&info);
}
NodeOriginTable* node_origins =
info.trace_turbo_json() ? zone.New<NodeOriginTable>(mcgraph->graph())
: nullptr;
SourcePositionTable* source_positions =
mcgraph->zone()->New<SourcePositionTable>(mcgraph->graph());
std::vector<WasmLoopInfo> loop_infos;
wasm::WasmFeatures unused_detected_features;
if (!detected) detected = &unused_detected_features;
if (!BuildGraphForWasmFunction(env, func_body, func_index, detected, mcgraph,
&loop_infos, node_origins, source_positions)) {
return wasm::WasmCompilationResult{};
}
if (node_origins) {
node_origins->AddDecorator();
}
// Run the compiler pipeline to generate machine code.
auto call_descriptor = GetWasmCallDescriptor(&zone, func_body.sig);
if (mcgraph->machine()->Is32()) {
call_descriptor = GetI32WasmCallDescriptor(&zone, call_descriptor);
}
if (ContainsSimd(func_body.sig) && !CpuFeatures::SupportsWasmSimd128()) {
// Fail compilation if hardware does not support SIMD.
return wasm::WasmCompilationResult{};
}
Pipeline::GenerateCodeForWasmFunction(&info, env, wire_bytes_storage, mcgraph,
call_descriptor, source_positions,
node_origins, func_body, env->module,
func_index, &loop_infos);
if (counters) {
int zone_bytes =
static_cast<int>(mcgraph->graph()->zone()->allocation_size());
counters->wasm_compile_function_peak_memory_bytes()->AddSample(zone_bytes);
if (func_body.end - func_body.start >= 100 * KB) {
counters->wasm_compile_huge_function_peak_memory_bytes()->AddSample(
zone_bytes);
}
}
// If we tiered up only one function for debugging, dump statistics
// immediately.
if (V8_UNLIKELY(FLAG_turbo_stats_wasm && FLAG_wasm_tier_up_filter >= 0)) {
wasm::GetWasmEngine()->DumpTurboStatistics();
}
auto result = info.ReleaseWasmCompilationResult();
CHECK_NOT_NULL(result); // Compilation expected to succeed.
DCHECK_EQ(wasm::ExecutionTier::kTurbofan, result->result_tier);
return std::move(*result);
}
namespace {
// Helper for allocating either an GP or FP reg, or the next stack slot.
class LinkageLocationAllocator {
public:
template <size_t kNumGpRegs, size_t kNumFpRegs>
constexpr LinkageLocationAllocator(const Register (&gp)[kNumGpRegs],
const DoubleRegister (&fp)[kNumFpRegs],
int slot_offset)
: allocator_(wasm::LinkageAllocator(gp, fp)), slot_offset_(slot_offset) {}
LinkageLocation Next(MachineRepresentation rep) {
MachineType type = MachineType::TypeForRepresentation(rep);
if (IsFloatingPoint(rep)) {
if (allocator_.CanAllocateFP(rep)) {
int reg_code = allocator_.NextFpReg(rep);
return LinkageLocation::ForRegister(reg_code, type);
}
} else if (allocator_.CanAllocateGP()) {
int reg_code = allocator_.NextGpReg();
return LinkageLocation::ForRegister(reg_code, type);
}
// Cannot use register; use stack slot.
int index = -1 - (slot_offset_ + allocator_.NextStackSlot(rep));
return LinkageLocation::ForCallerFrameSlot(index, type);
}
int NumStackSlots() const { return allocator_.NumStackSlots(); }
void EndSlotArea() { allocator_.EndSlotArea(); }
private:
wasm::LinkageAllocator allocator_;
// Since params and returns are in different stack frames, we must allocate
// them separately. Parameter slots don't need an offset, but return slots
// must be offset to just before the param slots, using this |slot_offset_|.
int slot_offset_;
};
} // namespace
// General code uses the above configuration data.
CallDescriptor* GetWasmCallDescriptor(Zone* zone, const wasm::FunctionSig* fsig,
WasmCallKind call_kind,
bool need_frame_state) {
// The extra here is to accomodate the instance object as first parameter
// and, when specified, the additional callable.
bool extra_callable_param =
call_kind == kWasmImportWrapper || call_kind == kWasmCapiFunction;
int extra_params = extra_callable_param ? 2 : 1;
LocationSignature::Builder locations(zone, fsig->return_count(),
fsig->parameter_count() + extra_params);
// Add register and/or stack parameter(s).
LinkageLocationAllocator params(
wasm::kGpParamRegisters, wasm::kFpParamRegisters, 0 /* no slot offset */);
// The instance object.
locations.AddParam(params.Next(MachineRepresentation::kTaggedPointer));
const size_t param_offset = 1; // Actual params start here.
// Parameters are separated into two groups (first all untagged, then all
// tagged parameters). This allows for easy iteration of tagged parameters
// during frame iteration.
const size_t parameter_count = fsig->parameter_count();
for (size_t i = 0; i < parameter_count; i++) {
MachineRepresentation param = fsig->GetParam(i).machine_representation();
// Skip tagged parameters (e.g. any-ref).
if (IsAnyTagged(param)) continue;
auto l = params.Next(param);
locations.AddParamAt(i + param_offset, l);
}
// End the untagged area, so tagged slots come after.
params.EndSlotArea();
for (size_t i = 0; i < parameter_count; i++) {
MachineRepresentation param = fsig->GetParam(i).machine_representation();
// Skip untagged parameters.
if (!IsAnyTagged(param)) continue;
auto l = params.Next(param);
locations.AddParamAt(i + param_offset, l);
}
// Import call wrappers have an additional (implicit) parameter, the callable.
// For consistency with JS, we use the JSFunction register.
if (extra_callable_param) {
locations.AddParam(LinkageLocation::ForRegister(
kJSFunctionRegister.code(), MachineType::TaggedPointer()));
}
int parameter_slots = AddArgumentPaddingSlots(params.NumStackSlots());
// Add return location(s).
LinkageLocationAllocator rets(wasm::kGpReturnRegisters,
wasm::kFpReturnRegisters, parameter_slots);
const int return_count = static_cast<int>(locations.return_count_);
for (int i = 0; i < return_count; i++) {
MachineRepresentation ret = fsig->GetReturn(i).machine_representation();
locations.AddReturn(rets.Next(ret));
}
int return_slots = rets.NumStackSlots();
const RegList kCalleeSaveRegisters = 0;
const RegList kCalleeSaveFPRegisters = 0;
// The target for wasm calls is always a code object.
MachineType target_type = MachineType::Pointer();
LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
CallDescriptor::Kind descriptor_kind;
if (call_kind == kWasmFunction) {
descriptor_kind = CallDescriptor::kCallWasmFunction;
} else if (call_kind == kWasmImportWrapper) {
descriptor_kind = CallDescriptor::kCallWasmImportWrapper;
} else {
DCHECK_EQ(call_kind, kWasmCapiFunction);
descriptor_kind = CallDescriptor::kCallWasmCapiFunction;
}
CallDescriptor::Flags flags = need_frame_state
? CallDescriptor::kNeedsFrameState
: CallDescriptor::kNoFlags;
return zone->New<CallDescriptor>( // --
descriptor_kind, // kind
target_type, // target MachineType
target_loc, // target location
locations.Build(), // location_sig
parameter_slots, // parameter slot count
compiler::Operator::kNoProperties, // properties
kCalleeSaveRegisters, // callee-saved registers
kCalleeSaveFPRegisters, // callee-saved fp regs
flags, // flags
"wasm-call", // debug name
StackArgumentOrder::kDefault, // order of the arguments in the stack
0, // allocatable registers
return_slots); // return slot count
}
namespace {
CallDescriptor* ReplaceTypeInCallDescriptorWith(
Zone* zone, const CallDescriptor* call_descriptor, size_t num_replacements,
MachineType input_type, MachineRepresentation output_type) {
size_t parameter_count = call_descriptor->ParameterCount();
size_t return_count = call_descriptor->ReturnCount();
for (size_t i = 0; i < call_descriptor->ParameterCount(); i++) {
if (call_descriptor->GetParameterType(i) == input_type) {
parameter_count += num_replacements - 1;
}
}
for (size_t i = 0; i < call_descriptor->ReturnCount(); i++) {
if (call_descriptor->GetReturnType(i) == input_type) {
return_count += num_replacements - 1;
}
}
if (parameter_count == call_descriptor->ParameterCount() &&
return_count == call_descriptor->ReturnCount()) {
return const_cast<CallDescriptor*>(call_descriptor);
}
LocationSignature::Builder locations(zone, return_count, parameter_count);
// The last parameter may be the special callable parameter. In that case we
// have to preserve it as the last parameter, i.e. we allocate it in the new
// location signature again in the same register.
bool has_callable_param =
(call_descriptor->GetInputLocation(call_descriptor->InputCount() - 1) ==
LinkageLocation::ForRegister(kJSFunctionRegister.code(),
MachineType::TaggedPointer()));
LinkageLocationAllocator params(
wasm::kGpParamRegisters, wasm::kFpParamRegisters, 0 /* no slot offset */);
for (size_t i = 0, e = call_descriptor->ParameterCount() -
(has_callable_param ? 1 : 0);
i < e; i++) {
if (call_descriptor->GetParameterType(i) == input_type) {
for (size_t j = 0; j < num_replacements; j++) {
locations.AddParam(params.Next(output_type));
}
} else {
locations.AddParam(
params.Next(call_descriptor->GetParameterType(i).representation()));
}
}
if (has_callable_param) {
locations.AddParam(LinkageLocation::ForRegister(
kJSFunctionRegister.code(), MachineType::TaggedPointer()));
}
int parameter_slots = AddArgumentPaddingSlots(params.NumStackSlots());
LinkageLocationAllocator rets(wasm::kGpReturnRegisters,
wasm::kFpReturnRegisters, parameter_slots);
for (size_t i = 0; i < call_descriptor->ReturnCount(); i++) {
if (call_descriptor->GetReturnType(i) == input_type) {
for (size_t j = 0; j < num_replacements; j++) {
locations.AddReturn(rets.Next(output_type));
}
} else {
locations.AddReturn(
rets.Next(call_descriptor->GetReturnType(i).representation()));
}
}
int return_slots = rets.NumStackSlots();
return zone->New<CallDescriptor>( // --
call_descriptor->kind(), // kind
call_descriptor->GetInputType(0), // target MachineType
call_descriptor->GetInputLocation(0), // target location
locations.Build(), // location_sig
parameter_slots, // parameter slot count
call_descriptor->properties(), // properties
call_descriptor->CalleeSavedRegisters(), // callee-saved registers
call_descriptor->CalleeSavedFPRegisters(), // callee-saved fp regs
call_descriptor->flags(), // flags
call_descriptor->debug_name(), // debug name
call_descriptor->GetStackArgumentOrder(), // stack order
call_descriptor->AllocatableRegisters(), // allocatable registers
return_slots); // return slot count
}
} // namespace
CallDescriptor* GetI32WasmCallDescriptor(
Zone* zone, const CallDescriptor* call_descriptor) {
return ReplaceTypeInCallDescriptorWith(zone, call_descriptor, 2,
MachineType::Int64(),
MachineRepresentation::kWord32);
}
CallDescriptor* GetI32WasmCallDescriptorForSimd(
Zone* zone, CallDescriptor* call_descriptor) {
return ReplaceTypeInCallDescriptorWith(zone, call_descriptor, 4,
MachineType::Simd128(),
MachineRepresentation::kWord32);
}
AssemblerOptions WasmAssemblerOptions() {
AssemblerOptions options;
// Relocation info required to serialize {WasmCode} for proper functions.
options.record_reloc_info_for_serialization = true;
options.enable_root_relative_access = false;
return options;
}
AssemblerOptions WasmStubAssemblerOptions() {
AssemblerOptions options;
// Relocation info not necessary because stubs are not serialized.
options.record_reloc_info_for_serialization = false;
options.enable_root_relative_access = false;
return options;
}
#undef FATAL_UNSUPPORTED_OPCODE
#undef WASM_INSTANCE_OBJECT_SIZE
#undef LOAD_INSTANCE_FIELD
#undef LOAD_MUTABLE_INSTANCE_FIELD
#undef LOAD_ROOT
} // namespace compiler
} // namespace internal
} // namespace v8
|
db 0 ; species ID placeholder
db 50, 48, 43, 60, 46, 41
; hp atk def spd sat sdf
db WATER, GROUND ; type
db 190 ; catch rate
db 92 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/barboach/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_WATER_2, EGG_WATER_2 ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, TOXIC, HIDDEN_POWER, SNORE, BLIZZARD, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, EARTHQUAKE, RETURN, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, REST, ATTRACT, SURF, WHIRLPOOL, WATERFALL, ICE_BEAM
; end
|
// Number of elements
mov $256 -> rob@in0
loop:
// i = i - 1
rob@out -> pu0@in0
mov $1 -> pu0@in1
mov (subN, 4) -> pu0@opc
pu0@out -> rob@in0
pu0@out -> rob@in0
// 2 copies of mem[i]
(ld, 2) -> lsu@opc
st -> lsu@opc
$0 -> lsu@in1 // load value
pu0@out -> lsu@in0 // load addr
// mem[i] * mem[i]
lsu@out -> pu0@in0
lsu@out -> pu0@in1
mov (mulN, 1) -> pu0@opc
// store addr
pu0@out -> lsu@in0
// store value
pu0@out -> lsu@in1
// loop condition
// (i != 0) -> branch to loop
loop -> cu@in1
rob@out -> cu@in0
// cleanup
rob@out -> null
|
;; Based on code from http://nparker.llx.com/a2/mult.html
;; Signed 8-bit multiply.
;; Inputs: x and y
;; Outputs: high byte of value into a, full 16 bits in RESULT
signed_mpy STX NUM1
STY NUM2
LDA NUM1 ;Compute sign of result
EOR NUM2
PHP ;Save it on the stack
LDA NUM1 ;Is NUM1 negative?
BPL T1
EOR #$FF ;If so, make it positive
CLC
ADC #1
STA NUM1
T1 LDA NUM2 ;Is NUM2 negative?
BPL T2
EOR #$FF ;If so, make it positive
CLC
ADC #1
STA NUM2
T2 JSR unsigned_mpy ;Do the unsigned multiplication
PLP ;Get sign of result
BPL T3
LDA #0 ;If negative, negate result
SEC
SBC RESULT
STA RESULT
LDA #0
SBC RESULT+1
STA RESULT+1
T3 RTS
;; Unsigned 8-bit multiply
;; Inputs: num1 and NUM2
;; Output: in RESULT
unsigned_mpy LDA #$80 ;Preload sentinel bit into RESULT
STA RESULT
ASL A ;Initialize RESULT hi byte to 0
DEC NUM1
L1 LSR NUM2 ;Get low bit of NUM2
BCC L2 ;0 or 1?
ADC NUM1 ;If 1, add (NUM1-1)+1
L2 ROR A ;"Stairstep" shift (catching carry from add)
ROR RESULT
BCC L1 ;When sentinel falls off into carry, we're done
STA RESULT+1
rts
NUM1 byte 0
NUM2 byte 0
RESULT word 0
|
; DV3 Standard Hard Disk Direct Sector Read (16 bit DMA/PIO) 1998 Tony Tebby
section dv3
xdef hd_rdirect16 ; direct sector read (16 bit DMA/PIO)
xref hd_rdirect ; direct sector read
include 'dev8_dv3_keys'
include 'dev8_dv3_hd_keys'
;+++
; This routine reads a sector from a hard disk for direct sector IO
; If the data is at an odd address, it is buffered.
;
; d0 cr sector number
; d7 c p drive ID / number
; a1 c p address to read into
; a3 c p linkage block
; a4 c p drive definition
;
; status return 0, ERR.NC or ERR.MCHK
;
;---
hd_rdirect16
exg a1,d0 ; check if address odd
btst #0,d0
exg d0,a1
beq.s hd_rdirect ; even address
hdrd.reg reg a0/a1
stk_a1 equ 4
movem.l hdrd.reg,-(sp)
lea hdl_buff(a3),a1 ; read into buffer
move.l a1,a0 ; save it
bsr.s hd_rdirect ; read
bne.s hdrd_exit ; failed
move.l stk_a1(sp),a1 ; destination address
move.w ddf_smask(a4),d0
hdrd_loop
move.b (a0)+,(a1)+
dbra d0,hdrd_loop
moveq #0,d0
hdrd_exit
movem.l (sp)+,hdrd.reg
rts
end
|
; DV3 MSDOS Format Table V3.00 1993 Tony Tebby
; adapted for FAT16 driver v3.01 W. Lenerz 2017
; (I only removed the fat12 table)
section dv3
xdef msd_table
include 'dev8_mac_vec'
include 'dev8_dv3_keys'
;+++
; DV3 MSDOS Format Table 4 nibble FAT
;
;---
msd_table
novec ; next
dc.b ddf.msdos ; MSDOS format
dc.b $ff ; MSDOS date
dc.b 0,5,'MSDOS',0,0,0
dc.b 0 ; zero length file has no sector allocated
dc.b 0 ; spare
vec dv3_imdt ; internal to pathname translate
vec dv3_mdit ; pathname to internal translate
vec dv3_imdt ; internal to pathname translate
vec msd_check ; check format
vec msd_drname ; search for name in directory
vec msd_drmake ; make directory
vec msd_drent ; fetch directory entry
vec msd_drefile ; ... for file
novec ; ... selected
vec msd_drsfile ; set directory entry for file
vec msd_sal4 ; sector allocate
vec msd_slc4 ; sector locate
vec msd_str4 ; sector truncate
novec ; scatter load
novec ; scatter save
vec msd_fsel ; format select
vec msd_frmt ; format
novec ; logical group to physical
vec dv3_logp ; logical group to physical
novec ; reset medium information
novec ; set medium name
vec msd_umap ; update map
end
|
/****************************************************************************
* Copyright (C) 2019 RoboMaster.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
***************************************************************************/
#include "serial_device.h"
namespace roborts_sdk {
SerialDevice::SerialDevice(std::string port_name,
int baudrate) :
port_name_(port_name),
baudrate_(baudrate),
data_bits_(8),
parity_bits_('N'),
stop_bits_(1) {}
SerialDevice::~SerialDevice() {
CloseDevice();
}
bool SerialDevice::Init() {
DLOG_INFO << "Attempting to open device " << port_name_ << " with baudrate " << baudrate_;
if (port_name_.c_str() == nullptr) {
port_name_ = "/dev/ttyUSB0";
}
if (OpenDevice() && ConfigDevice()) {
FD_ZERO(&serial_fd_set_);
FD_SET(serial_fd_, &serial_fd_set_);
DLOG_INFO << "...Serial started successfully.";
return true;
} else {
DLOG_ERROR << "...Failed to start serial "<<port_name_;
CloseDevice();
return false;
}
}
bool SerialDevice::OpenDevice() {
#ifdef __arm__
serial_fd_ = open(port_name_.c_str(), O_RDWR | O_NONBLOCK);
#elif __x86_64__
serial_fd_ = open(port_name_.c_str(), O_RDWR | O_NOCTTY);
#else
serial_fd_ = open(port_name_.c_str(), O_RDWR | O_NOCTTY);
#endif
if (serial_fd_ < 0) {
DLOG_ERROR << "cannot open device " << serial_fd_ << " " << port_name_;
return false;
}
return true;
}
bool SerialDevice::CloseDevice() {
close(serial_fd_);
serial_fd_ = -1;
return true;
}
bool SerialDevice::ConfigDevice() {
int st_baud[] = {B4800, B9600, B19200, B38400,
B57600, B115200, B230400, B921600};
int std_rate[] = {4800, 9600, 19200, 38400, 57600, 115200,
230400, 921600, 1000000, 1152000, 3000000};
int i, j;
/* save current port parameter */
if (tcgetattr(serial_fd_, &old_termios_) != 0) {
DLOG_ERROR << "fail to save current port";
return false;
}
memset(&new_termios_, 0, sizeof(new_termios_));
/* config the size of char */
new_termios_.c_cflag |= CLOCAL | CREAD;
new_termios_.c_cflag &= ~CSIZE;
/* config data bit */
switch (data_bits_) {
case 7:new_termios_.c_cflag |= CS7;
break;
case 8:new_termios_.c_cflag |= CS8;
break;
default:new_termios_.c_cflag |= CS8;
break; //8N1 default config
}
/* config the parity bit */
switch (parity_bits_) {
/* odd */
case 'O':
case 'o':new_termios_.c_cflag |= PARENB;
new_termios_.c_cflag |= PARODD;
break;
/* even */
case 'E':
case 'e':new_termios_.c_cflag |= PARENB;
new_termios_.c_cflag &= ~PARODD;
break;
/* none */
case 'N':
case 'n':new_termios_.c_cflag &= ~PARENB;
break;
default:new_termios_.c_cflag &= ~PARENB;
break; //8N1 default config
}
/* config baudrate */
j = sizeof(std_rate) / 4;
for (i = 0; i < j; ++i) {
if (std_rate[i] == baudrate_) {
/* set standard baudrate */
cfsetispeed(&new_termios_, st_baud[i]);
cfsetospeed(&new_termios_, st_baud[i]);
break;
}
}
/* config stop bit */
if (stop_bits_ == 1)
new_termios_.c_cflag &= ~CSTOPB;
else if (stop_bits_ == 2)
new_termios_.c_cflag |= CSTOPB;
else
new_termios_.c_cflag &= ~CSTOPB; //8N1 default config
/* config waiting time & min number of char */
new_termios_.c_cc[VTIME] = 1;
new_termios_.c_cc[VMIN] = 18;
/* using the raw data mode */
new_termios_.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
new_termios_.c_oflag &= ~OPOST;
/* flush the hardware fifo */
tcflush(serial_fd_, TCIFLUSH);
/* activite the configuration */
if ((tcsetattr(serial_fd_, TCSANOW, &new_termios_)) != 0) {
DLOG_ERROR << "failed to activate serial configuration";
return false;
}
return true;
}
int SerialDevice::Read(uint8_t *buf, int len) {
int ret = -1;
if (NULL == buf) {
return -1;
} else {
ret = read(serial_fd_, buf, len);
DLOG_INFO<<"Read once length: "<<ret;
while (ret == 0) {
LOG_ERROR << "Connection closed, try to reconnect.";
while (!Init()) {
usleep(500000);
}
LOG_INFO << "Reconnect Success.";
ret = read(serial_fd_, buf, len);
}
return ret;
}
}
int SerialDevice::Write(const uint8_t *buf, int len) {
return write(serial_fd_, buf, len);
}
}
|
; void __CALLEE__ in_MouseKemp_callee(uchar *buttons, uint *xcoord, uint *ycoord)
; 09.2005 aralbrec
XLIB in_MouseKemp_callee
LIB INMouseKemp
.in_MouseKemp_callee
call INMouseKemp
pop de
pop hl
ld (hl),a
inc hl
xor a
ld (hl),a
pop hl
ld (hl),b
inc hl
ld (hl),a
pop hl
ld (hl),c
ex de,hl
jp (hl)
|
%macro print 2
mov rax,01;
mov rdi,01;
mov rsi,%1;
mov rdx,%2;
syscall;
%endmacro
%macro read 2
mov rax,00;
mov rdi,00;
mov rsi,%1;
mov rdx,%2;
syscall;
%endmacro
section .data
dash: db 10,"-------------------------------------------",10;
lenDash: equ $-dash;
resMsg: db "! = ";
lenResMsg: equ $-resMsg;
errMsg: db "Invalid Command Line Argument Format!";
lenErrMsg: equ $-errMsg;
space: db " ";
newLine: db 10;
section .bss
inAscii: resb 16;
outAscii: resb 16;
number: resq 1;
result: resq 1;
section .data
global _start
_start:
pop rbx;
cmp rbx,2h;
jne argError
pop rbx
pop rbx;
mov rsi,inAscii
call getArgument;
call _AsciiToHex;
mov [number],rax;
mov rbx,rax;
push rbx;
xor rax,rax;
inc rax;
call factorial
mov [result],rax;
print dash,lenDash;
mov rax,[number];
call _HexToAscii;
print outAscii,16;
print resMsg,lenResMsg;
mov rax,[result];
call _HexToAscii;
print outAscii,16;
print dash,lenDash;
print newLine,1;
exit:
mov rax,60;
mov rdi,00;
syscall;
argError:
print newLine,1;
print errMsg,lenErrMsg;
print newLine,1;
print newLine,1;
jmp exit
getArgument:
; DOC-STRING:
; i) Stores the command line argument to the memory location pointed by RSI.
; ii) Stores length of command line argument in RCX
xor rcx,rcx;
xor rax,rax;
begin3:
mov al,byte[rbx];
mov byte[rsi],al;
inc rsi;
inc rbx;
inc rcx;
cmp byte[rbx],0h;
jne begin3;
ret;
factorial:
pop rsi; //pop IP
pop rbx; //No. in Stack
push rsi; //push back IP
cmp rbx,1h;
je endFactorial;
cmp rbx,0h;
je endFactorial;
mul rbx;
dec rbx;
push rbx;
call factorial;
endFactorial:
ret;
_AsciiToHex:; //ASCII in inAscii ----> HEX in RAX
mov rsi,inAscii;
xor rax,rax;
begin1:
cmp byte[rsi],0h; //Compare With Null Character ie: 0h
je end_AsciiToHex;
rol rax,04d;
mov bl,byte[rsi];
cmp bl,39h;
jbe sub30
sub bl,07h;
sub30:
sub bl,30h;
add al,bl;
inc rsi;
jmp begin1;
end_AsciiToHex:
ret
_HexToAscii:; // HEX in RAX -----> ASCII in outAscii
mov rsi,outAscii+15d;
mov rcx,16d
begin2:
xor rdx,rdx;
mov rbx,10h; //16d
div rbx;
cmp dl,09h;
jbe add30;
add dl,07h;
add30:
add dl,30h;
mov byte[rsi],dl;
update:
dec rsi;
dec rcx;
jnz begin2;
end_HexToAscii:
ret |
; A235347: Series reversion of x*(1-3*x^2)/(1-x^2) in odd-order powers.
; Submitted by Christian Krause
; 1,2,14,130,1382,15906,192894,2427522,31405430,415086658,5580629870,76080887042,1049295082630,14613980359010,205246677882078,2903566870820610,41337029956899222,591796707042765954,8514525059135909070,123048063153362454402,1785343913603396041638,25997755243402345012386,379816229907918156775998,5565580921491549002988930,81778291342796926262452662,1204648803858660621476918466,17786610464868727152485460014,263184989591618354500003475458,3902088960176965421506004890310,57961718392401483193930375000034
mov $1,1
mov $3,$0
mul $0,2
add $0,1
mov $4,2
lpb $3
add $0,1
add $2,$1
sub $3,1
mul $1,$3
mul $1,$0
mul $1,2
add $5,$4
div $1,$5
add $2,$1
add $4,2
lpe
mov $0,$2
add $0,1
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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.
;
; Module Name:
;
; Monitor.Asm
;
; Abstract:
;
; AsmMonitor function
;
; Notes:
;
;------------------------------------------------------------------------------
SECTION .text
;------------------------------------------------------------------------------
; UINTN
; EFIAPI
; AsmMonitor (
; IN UINTN Eax,
; IN UINTN Ecx,
; IN UINTN Edx
; );
;------------------------------------------------------------------------------
global ASM_PFX(AsmMonitor)
ASM_PFX(AsmMonitor):
mov eax, [esp + 4]
mov ecx, [esp + 8]
mov edx, [esp + 12]
DB 0xf, 1, 0xc8 ; monitor
ret
|
; A109940: Largest k-digit multiple of n where k is the number of digits in n.
; Submitted by Jamie Morken(s1)
; 9,8,9,8,5,6,7,8,9,90,99,96,91,98,90,96,85,90,95,80,84,88,92,96,75,78,81,84,87,90,93,96,99,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,900
mov $1,$0
add $0,1
seq $1,97326 ; Largest integer m such that m*n has the same decimal digit length as n.
mul $0,$1
|
.include "pm_libs/pm_init.s"
pm_header "TestFramebuf", IRQ_KEY_POWER, 0
; Shutdown down when power key pressed
irq_key_power:
cint CINT_SHUTDOWN
main:
; Enable interrupts
enable_irqs IRQ_KEY_POWER | IRQ_PRC_COPY ; PRC_COPY declared to wake up HALT
enable_mirq
; Blank LCD
mov a, 0
cint CINT_TMP_CONTRAST
; Setup PRC
mov [n+PRC_MODE], PRC_ENABLE
mov [n+PRC_RATE], PRC_24FPS
; Copy image to VRAM
mov y, teampokeme
mov x, VRAM_BASE
mov hl, 768
: mov a, [y]
mov [x], a
inc x
inc y
dec hl
jnzb :b
; Fade in
mov a, 0
: push a
cint CINT_TMP_CONTRAST
pop a
halt
inc a
cmp a, $20
jnzb :b
; Wait for any key press
mov a, 0
: halt
mov a, [n+KEY_PAD]
cmp a, $FF
jzb :b
; Fade out
mov a, $20
: push a
cint CINT_TMP_CONTRAST
pop a
halt
dec a
jnzb :b
; Shutdown
cint CINT_SHUTDOWN
pm_align_tiles
teampokeme:
.incbin "teampokeme.bin"
pm_rominfo
|
BITS 32
metodi EQU 0
SECTION .text
EXTERN set_method
GLOBAL laske_ala:function
;vastaa: double laske_ala(double). ST0 = ympyrän pinta-ala
laske_ala: push ebp ;ABI: rekisterin tila säilytettävä
mov ebp, esp ;funktion pinokehys
fld qword [ebp + 8] ;st0 = säde
fmul st0, st0 ;st0 = säde ^ 2
fldpi ;st0 = pii, st1 = säde ^ 2
fmul st0, st1 ;st0 = pii * säde ^ 2
push metodi
call set_method ;kerrotaan main():iin laskentatapa
add esp, 4
leave
ret
|
;*******************************************************************************
; *
; Microchip licenses this software to you solely for use with Microchip *
; products. The software is owned by Microchip and/or its licensors, and is *
; protected under applicable copyright laws. All rights reserved. *
; *
; This software and any accompanying information is for suggestion only. *
; It shall not be deemed to modify Microchip?s standard warranty for its *
; products. It is your responsibility to ensure that this software meets *
; your requirements. *
; *
; SOFTWARE IS PROVIDED "AS IS". MICROCHIP AND ITS LICENSORS EXPRESSLY *
; DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING *
; BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS *
; FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL *
; MICROCHIP OR ITS LICENSORS BE LIABLE FOR ANY INCIDENTAL, SPECIAL, *
; INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO *
; YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR *
; SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY *
; DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER *
; SIMILAR COSTS. *
; *
; To the fullest extend allowed by law, Microchip and its licensors *
; liability shall not exceed the amount of fee, if any, that you have paid *
; directly to Microchip to use this software. *
; *
; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF *
; THESE TERMS. *
; *
;*******************************************************************************
; *
; Filename: *
; Date: *
; File Version: *
; Author: *
; Company: *
; Description: *
; *
;*******************************************************************************
; *
; Notes: In the MPLAB X Help, refer to the MPASM Assembler documentation *
; for information on assembly instructions. *
; *
;*******************************************************************************
; *
; Known Issues: This template is designed for relocatable code. As such, *
; build errors such as "Directive only allowed when generating an object *
; file" will result when the 'Build in Absolute Mode' checkbox is selected *
; in the project properties. Designing code in absolute mode is *
; antiquated - use relocatable mode. *
; *
;*******************************************************************************
; *
; Revision History: *
; *
;*******************************************************************************
;*******************************************************************************
; Processor Inclusion
;
; TODO Step #1 Open the task list under Window > Tasks. Include your
; device .inc file - e.g. #include <device_name>.inc. Available
; include files are in C:\Program Files\Microchip\MPLABX\mpasmx
; assuming the default installation path for MPLAB X. You may manually find
; the appropriate include file for your device here and include it, or
; simply copy the include generated by the configuration bits
; generator (see Step #2).
;
;*******************************************************************************
#include"p16f887.inc"
;*******************************************************************************
;
; TODO Step #2 - Configuration Word Setup
;
; The 'CONFIG' directive is used to embed the configuration word within the
; .asm file. MPLAB X requires users to embed their configuration words
; into source code. See the device datasheet for additional information
; on configuration word settings. Device configuration bits descriptions
; are in C:\Program Files\Microchip\MPLABX\mpasmx\P<device_name>.inc
; (may change depending on your MPLAB X installation directory).
;
; MPLAB X has a feature which generates configuration bits source code. Go to
; Window > PIC Memory Views > Configuration Bits. Configure each field as
; needed and select 'Generate Source Code to Output'. The resulting code which
; appears in the 'Output Window' > 'Config Bits Source' tab may be copied
; below.
;
;*******************************************************************************
#include "p16f887.inc"
; CONFIG1
; __config 0xFFD4
__CONFIG _CONFIG1, _FOSC_INTRC_NOCLKOUT & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_ON
; CONFIG2
; __config 0xFFFF
__CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF
;*******************************************************************************
;
; TODO Step #3 - Variable Definitions
;
; Refer to datasheet for available data memory (RAM) organization assuming
; relocatible code organization (which is an option in project
; properties > mpasm (Global Options)). Absolute mode generally should
; be used sparingly.
;
; Example of using GPR Uninitialized Data
;
; GPR_VAR UDATA
; MYVAR1 RES 1 ; User variable linker places
; MYVAR2 RES 1 ; User variable linker places
; MYVAR3 RES 1 ; User variable linker places
;
; ; Example of using Access Uninitialized Data Section (when available)
; ; The variables for the context saving in the device datasheet may need
; ; memory reserved here.
; INT_VAR UDATA_ACS
; W_TEMP RES 1 ; w register for context saving (ACCESS)
; STATUS_TEMP RES 1 ; status used for context saving
; BSR_TEMP RES 1 ; bank select used for ISR context saving
;
;*******************************************************************************
; TODO PLACE VARIABLE DEFINITIONS GO HERE
;*******************************************************************************
; Reset Vector
;*******************************************************************************
CBLOCK 0X20
CON1
CON2
CON3
ENDC
ORG 0X00
GOTO SETUP
ORG 0x04
RETURN
;*******************************************************************************
; TODO Step #4 - Interrupt Service Routines
;
; There are a few different ways to structure interrupt routines in the 8
; bit device families. On PIC18's the high priority and low priority
; interrupts are located at 0x0008 and 0x0018, respectively. On PIC16's and
; lower the interrupt is at 0x0004. Between device families there is subtle
; variation in the both the hardware supporting the ISR (for restoring
; interrupt context) as well as the software used to restore the context
; (without corrupting the STATUS bits).
;
; General formats are shown below in relocatible format.
;
;------------------------------PIC16's and below--------------------------------
;
; ISR CODE 0x0004 ; interrupt vector location
;
; <Search the device datasheet for 'context' and copy interrupt
; context saving code here. Older devices need context saving code,
; but newer devices like the 16F#### don't need context saving code.>
;
; RETFIE
;
;----------------------------------PIC18's--------------------------------------
;
; ISRHV CODE 0x0008
; GOTO HIGH_ISR
; ISRLV CODE 0x0018
; GOTO LOW_ISR
;
; ISRH CODE ; let linker place high ISR routine
; HIGH_ISR
; <Insert High Priority ISR Here - no SW context saving>
; RETFIE FAST
;
; ISRL CODE ; let linker place low ISR routine
; LOW_ISR
; <Search the device datasheet for 'context' and copy interrupt
; context saving code here>
; RETFIE
;
;*******************************************************************************
; TODO INSERT ISR HERE
;*******************************************************************************
; MAIN PROGRAM
;*******************************************************************************
SETUP:
BANKSEL ANSEL
CLRF ANSEL
BANKSEL PORTA
CLRF PORTA
BANKSEL TRISA
CLRF TRISA
MOVLW B'00000000'
BANKSEL PORTA
INICIO
MOVLW B'11111111'
MOVWF PORTA
CALL RETARDO
MOVLW B'00000000'
MOVWF PORTA
CALL RETARDO
GOTO INICIO
RETARDO
movlw 0x07
movwf CON1
movlw 0x2F
movwf CON2
movlw 0x03
movwf CON3
RETARDO_0
decfsz CON1, f
goto $+2
decfsz CON2, f
goto $+2
decfsz CON3, f
goto RETARDO_0
goto $+1
goto $+1
goto $+1
return
END |
; A186111: a(n) = -n if n odd, a(2n) = 3n if n odd, a(4n) = 2n.
; Submitted by Jon Maiga
; 1,-3,3,-2,5,-9,7,-4,9,-15,11,-6,13,-21,15,-8,17,-27,19,-10,21,-33,23,-12,25,-39,27,-14,29,-45,31,-16,33,-51,35,-18,37,-57,39,-20,41,-63,43,-22,45,-69,47,-24,49,-75,51,-26,53,-81,55,-28,57,-87,59,-30,61,-93,63,-32,65,-99,67,-34,69,-105,71,-36,73,-111,75,-38,77,-117,79,-40,81,-123,83,-42,85,-129,87,-44,89,-135,91,-46,93,-141,95,-48,97,-147,99,-50
add $0,1
lpb $0
add $2,$0
dif $0,2
sub $0,$1
mov $1,$0
lpe
sub $0,$2
|
; A077943: Expansion of 1/(1-2*x+2*x^2-2*x^3).
; 1,2,2,2,4,8,12,16,24,40,64,96,144,224,352,544,832,1280,1984,3072,4736,7296,11264,17408,26880,41472,64000,98816,152576,235520,363520,561152,866304,1337344,2064384,3186688,4919296,7593984,11722752,18096128,27934720,43122688
mov $1,2
mov $3,4
mov $4,2
lpb $0,1
sub $0,1
add $2,$4
sub $2,1
mov $4,$3
sub $4,$3
add $4,$1
add $1,$2
mul $3,2
trn $4,$3
mov $3,$2
lpe
sub $1,1
|
; A137234: Expansion of g.f. 1/((1-x)^2*(1 - 3*x + 2*x^2 - x^3)).
; 1,5,16,43,107,257,607,1422,3318,7727,17978,41810,97214,226014,525439,1221519,2839710,6601549,15346765,35676927,82938821,192809396,448227496,1042002541,2422362052,5631308596,13091204252,30433357644,70748973053,164471408153,382349636028,888855064863,2066337330719,4803651498493,11167134898939,25960439030586,60350698792410,140298353215035,326154101090910,758216295635110,1762639037938586,4097638623636490,9525854090667451,22144924062668003,51480702630305642,119678113856248417,278217860370802017
lpb $0
mov $2,$0
sub $0,1
seq $2,137229 ; Expansion of g.f. x/((1-x)*(1-3*x+2*x^2-x^3)).
add $1,$2
lpe
add $1,1
mov $0,$1
|
;
;==================================================================================================
; ZETA STANDARD CONFIGURATION
;==================================================================================================
;
#include "cfg_zeta.asm"
;
PPIDEENABLE .SET FALSE ; TRUE FOR PPIDE DEVICE SUPPORT
;
SDENABLE .SET FALSE ; TRUE FOR SD DEVICE SUPPORT
;
PPPENABLE .SET TRUE ; TRUE FOR PROPIO BOARD SUPPORT (VIDEO, KBD, & SD CARD)
;
CRTACT .SET TRUE ; TRUE TO ACTIVATE CRT AT STARTUP (BOOT ON CRT)
|
; A042779: Denominators of continued fraction convergents to sqrt(920).
; Submitted by Jon Maiga
; 1,3,181,546,32941,99369,5995081,18084612,1091071801,3291300015,198569072701,598998518118,36138480159781,109014438997461,6577004820007441,19840028899019784,1196978738761194481,3610776245182603227,217843553449717388101,657141436594334767530,39646329749109803439901,119596130683923745087233,7215414170784534508673881,21765838643037527271108876,1313165732753036170775206441,3961263036902146039596728199,238988947946881798546578898381,720928106877547541679333423342,43494675360599734299306584298901
seq $0,41429 ; Denominators of continued fraction convergents to sqrt(230).
dif $0,2
|
; float log1p(float x) __z88dk_fastcall
SECTION code_fp_math48
PUBLIC cm48_sdcciy_log1p_fastcall
EXTERN cm48_sdcciyp_dx2m48, am48_log1p, cm48_sdcciyp_m482d
cm48_sdcciy_log1p_fastcall:
call cm48_sdcciyp_dx2m48
call am48_log1p
jp cm48_sdcciyp_m482d
|
.byte $00 ; Unknown purpose
.byte OBJ_AUTOSCROLL, $04, $31
.byte OBJ_BOO, $0C, $11
.byte OBJ_BOO, $1E, $11
.byte $FF ; Terminator
|
; A190157: Decimal expansion of (1+sqrt(-1+2*sqrt(5)))/2.
; Submitted by Christian Krause
; 1,4,3,1,6,8,3,4,1,6,5,9,0,5,7,9,2,5,3,0,7,9,5,6,9,1,3,3,4,9,0,7,3,5,1,9,9,4,1,0,4,5,4,3,4,4,6,2,4,7,3,6,8,2,6,7,6,1,9,3,5,3,9,7,1,3,4,8,2,8,1,4,7,4,6,4,4,3,4,9,4,5,7,5,8,8,1,4,2,8,2,2,8,5,2,9,7,7,1,8
mov $1,1
mov $3,$0
mul $3,4
lpb $3
mod $5,$1
add $1,$6
add $1,5
add $2,$1
sub $3,1
add $5,$2
add $6,$5
lpe
mov $2,$6
mov $4,10
pow $4,$0
div $2,$4
cmp $7,0
add $2,$7
div $1,$2
mov $0,$1
mod $0,10
|
; Intel i8254x-series Network Driver for xOS
; Heavily based on BareMetal i8254x driver, by Ian Seyler
; https://github.com/ReturnInfinity/BareMetal-OS
use32
; Register list
I8254X_REG_CTRL = 0x0000 ; Control Register
I8254X_REG_STATUS = 0x0008 ; Device Status Register
I8254X_REG_CTRLEXT = 0x0018 ; Extended Control Register
I8254X_REG_MDIC = 0x0020 ; MDI Control Register
I8254X_REG_FCAL = 0x0028 ; Flow Control Address Low
I8254X_REG_FCAH = 0x002C ; Flow Control Address High
I8254X_REG_FCT = 0x0030 ; Flow Control Type
I8254X_REG_VET = 0x0038 ; VLAN Ether Type
I8254X_REG_ICR = 0x00C0 ; Interrupt Cause Read
I8254X_REG_ITR = 0x00C4 ; Interrupt Throttling Register
I8254X_REG_ICS = 0x00C8 ; Interrupt Cause Set Register
I8254X_REG_IMS = 0x00D0 ; Interrupt Mask Set/Read Register
I8254X_REG_IMC = 0x00D8 ; Interrupt Mask Clear Register
I8254X_REG_RCTL = 0x0100 ; Receive Control Register
I8254X_REG_FCTTV = 0x0170 ; Flow Control Transmit Timer Value
I8254X_REG_TXCW = 0x0178 ; Transmit Configuration Word
I8254X_REG_RXCW = 0x0180 ; Receive Configuration Word
I8254X_REG_TCTL = 0x0400 ; Transmit Control Register
I8254X_REG_TIPG = 0x0410 ; Transmit Inter Packet Gap
I8254X_REG_LEDCTL = 0x0E00 ; LED Control
I8254X_REG_PBA = 0x1000 ; Packet Buffer Allocation
I8254X_REG_RDBAL = 0x2800 ; RX Descriptor Base Address Low
I8254X_REG_RDBAH = 0x2804 ; RX Descriptor Base Address High
I8254X_REG_RDLEN = 0x2808 ; RX Descriptor Length
I8254X_REG_RDH = 0x2810 ; RX Descriptor Head
I8254X_REG_RDT = 0x2818 ; RX Descriptor Tail
I8254X_REG_RDTR = 0x2820 ; RX Delay Timer Register
I8254X_REG_RXDCTL = 0x3828 ; RX Descriptor Control
I8254X_REG_RADV = 0x282C ; RX Int. Absolute Delay Timer
I8254X_REG_RSRPD = 0x2C00 ; RX Small Packet Detect Interrupt
I8254X_REG_TXDMAC = 0x3000 ; TX DMA Control
I8254X_REG_TDBAL = 0x3800 ; TX Descriptor Base Address Low
I8254X_REG_TDBAH = 0x3804 ; TX Descriptor Base Address High
I8254X_REG_TDLEN = 0x3808 ; TX Descriptor Length
I8254X_REG_TDH = 0x3810 ; TX Descriptor Head
I8254X_REG_TDT = 0x3818 ; TX Descriptor Tail
I8254X_REG_TIDV = 0x3820 ; TX Interrupt Delay Value
I8254X_REG_TXDCTL = 0x3828 ; TX Descriptor Control
I8254X_REG_TADV = 0x382C ; TX Absolute Interrupt Delay Value
I8254X_REG_TSPMT = 0x3830 ; TCP Segmentation Pad & Min Threshold
I8254X_REG_RXCSUM = 0x5000 ; RX Checksum Control
; CTRL - Control Register (0x0000)
I8254X_CTRL_FD = 0x00000001 ; Full Duplex
I8254X_CTRL_LRST = 0x00000008 ; Link Reset
I8254X_CTRL_ASDE = 0x00000020 ; Auto-speed detection
I8254X_CTRL_SLU = 0x00000040 ; Set Link Up
I8254X_CTRL_ILOS = 0x00000080 ; Invert Loss of Signal
I8254X_CTRL_SPEED_MASK = 0x00000300 ; Speed selection
I8254X_CTRL_SPEED_SHIFT = 8
I8254X_CTRL_FRCSPD = 0x00000800 ; Force Speed
I8254X_CTRL_FRCDPLX = 0x00001000 ; Force Duplex
I8254X_CTRL_SDP0_DATA = 0x00040000 ; SDP0 data
I8254X_CTRL_SDP1_DATA = 0x00080000 ; SDP1 data
I8254X_CTRL_SDP0_IODIR = 0x00400000 ; SDP0 direction
I8254X_CTRL_SDP1_IODIR = 0x00800000 ; SDP1 direction
I8254X_CTRL_RST = 0x04000000 ; Device Reset
I8254X_CTRL_RFCE = 0x08000000 ; RX Flow Ctrl Enable
I8254X_CTRL_TFCE = 0x10000000 ; TX Flow Ctrl Enable
I8254X_CTRL_VME = 0x40000000 ; VLAN Mode Enable
I8254X_CTRL_PHY_RST = 0x80000000 ; PHY reset
; STATUS - Device Status Register (0x0008)
I8254X_STATUS_FD = 0x00000001 ; Full Duplex
I8254X_STATUS_LU = 0x00000002 ; Link Up
I8254X_STATUS_TXOFF = 0x00000010 ; Transmit paused
I8254X_STATUS_TBIMODE = 0x00000020 ; TBI Mode
I8254X_STATUS_SPEED_MASK = 0x000000C0 ; Link Speed setting
I8254X_STATUS_SPEED_SHIFT = 6
I8254X_STATUS_ASDV_MASK = 0x00000300 ; Auto Speed Detection
I8254X_STATUS_ASDV_SHIFT = 8
I8254X_STATUS_PCI66 = 0x00000800 ; PCI bus speed
I8254X_STATUS_BUS64 = 0x00001000 ; PCI bus width
I8254X_STATUS_PCIX_MODE = 0x00002000 ; PCI-X mode
I8254X_STATUS_PCIXSPD_MASK = 0x0000C000 ; PCI-X speed
I8254X_STATUS_PCIXSPD_SHIFT = 14
; CTRL_EXT - Extended Device Control Register (0x0018)
I8254X_CTRLEXT_PHY_INT = 0x00000020 ; PHY interrupt
I8254X_CTRLEXT_SDP6_DATA = 0x00000040 ; SDP6 data
I8254X_CTRLEXT_SDP7_DATA = 0x00000080 ; SDP7 data
I8254X_CTRLEXT_SDP6_IODIR = 0x00000400 ; SDP6 direction
I8254X_CTRLEXT_SDP7_IODIR = 0x00000800 ; SDP7 direction
I8254X_CTRLEXT_ASDCHK = 0x00001000 ; Auto-Speed Detect Chk
I8254X_CTRLEXT_EE_RST = 0x00002000 ; EEPROM reset
I8254X_CTRLEXT_SPD_BYPS = 0x00008000 ; Speed Select Bypass
I8254X_CTRLEXT_RO_DIS = 0x00020000 ; Relaxed Ordering Dis.
I8254X_CTRLEXT_LNKMOD_MASK = 0x00C00000 ; Link Mode
I8254X_CTRLEXT_LNKMOD_SHIFT = 22
; MDIC - MDI Control Register (0x0020)
I8254X_MDIC_DATA_MASK = 0x0000FFFF ; Data
I8254X_MDIC_REG_MASK = 0x001F0000 ; PHY Register
I8254X_MDIC_REG_SHIFT = 16
I8254X_MDIC_PHY_MASK = 0x03E00000 ; PHY Address
I8254X_MDIC_PHY_SHIFT = 21
I8254X_MDIC_OP_MASK = 0x0C000000 ; Opcode
I8254X_MDIC_OP_SHIFT = 26
I8254X_MDIC_R = 0x10000000 ; Ready
I8254X_MDIC_I = 0x20000000 ; Interrupt Enable
I8254X_MDIC_E = 0x40000000 ; Error
; ICR - Interrupt Cause Read (0x00c0)
I8254X_ICR_TXDW = 0x00000001 ; TX Desc Written back
I8254X_ICR_TXQE = 0x00000002 ; TX Queue Empty
I8254X_ICR_LSC = 0x00000004 ; Link Status Change
I8254X_ICR_RXSEQ = 0x00000008 ; RX S=ence Error
I8254X_ICR_RXDMT0 = 0x00000010 ; RX Desc min threshold reached
I8254X_ICR_RXO = 0x00000040 ; RX Overrun
I8254X_ICR_RXT0 = 0x00000080 ; RX Timer Interrupt
I8254X_ICR_MDAC = 0x00000200 ; MDIO Access Complete
I8254X_ICR_RXCFG = 0x00000400
I8254X_ICR_PHY_INT = 0x00001000 ; PHY Interrupt
I8254X_ICR_GPI_SDP6 = 0x00002000 ; GPI on SDP6
I8254X_ICR_GPI_SDP7 = 0x00004000 ; GPI on SDP7
I8254X_ICR_TXD_LOW = 0x00008000 ; TX Desc low threshold hit
I8254X_ICR_SRPD = 0x00010000 ; Small RX packet detected
; RCTL - Receive Control Register (0x0100)
I8254X_RCTL_EN = 0x00000002 ; Receiver Enable
I8254X_RCTL_SBP = 0x00000004 ; Store Bad Packets
I8254X_RCTL_UPE = 0x00000008 ; Unicast Promiscuous Enabled
I8254X_RCTL_MPE = 0x00000010 ; Xcast Promiscuous Enabled
I8254X_RCTL_LPE = 0x00000020 ; Long Packet Reception Enable
I8254X_RCTL_LBM_MASK = 0x000000C0 ; Loopback Mode
I8254X_RCTL_LBM_SHIFT = 6
I8254X_RCTL_RDMTS_MASK = 0x00000300 ; RX Desc Min Threshold Size
I8254X_RCTL_RDMTS_SHIFT = 8
I8254X_RCTL_MO_MASK = 0x00003000 ; Multicast Offset
I8254X_RCTL_MO_SHIFT = 12
I8254X_RCTL_BAM = 0x00008000 ; Broadcast Accept Mode
I8254X_RCTL_BSIZE_MASK = 0x00030000 ; RX Buffer Size
I8254X_RCTL_BSIZE_SHIFT = 16
I8254X_RCTL_VFE = 0x00040000 ; VLAN Filter Enable
I8254X_RCTL_CFIEN = 0x00080000 ; CFI Enable
I8254X_RCTL_CFI = 0x00100000 ; Canonical Form Indicator Bit
I8254X_RCTL_DPF = 0x00400000 ; Discard Pause Frames
I8254X_RCTL_PMCF = 0x00800000 ; Pass MAC Control Frames
I8254X_RCTL_BSEX = 0x02000000 ; Buffer Size Extension
I8254X_RCTL_SECRC = 0x04000000 ; Strip Ethernet CRC
; TCTL - Transmit Control Register (0x0400)
I8254X_TCTL_EN = 0x00000002 ; Transmit Enable
I8254X_TCTL_PSP = 0x00000008 ; Pad short packets
I8254X_TCTL_SWXOFF = 0x00400000 ; Software XOFF Transmission
; PBA - Packet Buffer Allocation (0x1000)
I8254X_PBA_RXA_MASK = 0x0000FFFF ; RX Packet Buffer
I8254X_PBA_RXA_SHIFT = 0
I8254X_PBA_TXA_MASK = 0xFFFF0000 ; TX Packet Buffer
I8254X_PBA_TXA_SHIFT = 16
; Flow Control Type
I8254X_FCT_TYPE_DEFAULT = 0x8808
; === TX Descriptor fields ===
; TX Packet Length (word 2)
I8254X_TXDESC_LEN_MASK = 0x0000ffff
; TX Descriptor CMD field (word 2)
I8254X_TXDESC_IDE = 0x80000000 ; Interrupt Delay Enable
I8254X_TXDESC_VLE = 0x40000000 ; VLAN Packet Enable
I8254X_TXDESC_DEXT = 0x20000000 ; Extension
I8254X_TXDESC_RPS = 0x10000000 ; Report Packet Sent
I8254X_TXDESC_RS = 0x08000000 ; Report Status
I8254X_TXDESC_IC = 0x04000000 ; Insert Checksum
I8254X_TXDESC_IFCS = 0x02000000 ; Insert FCS
I8254X_TXDESC_EOP = 0x01000000 ; End Of Packet
; TX Descriptor STA field (word 3)
I8254X_TXDESC_TU = 0x00000008 ; Transmit Underrun
I8254X_TXDESC_LC = 0x00000004 ; Late Collision
I8254X_TXDESC_EC = 0x00000002 ; Excess Collisions
I8254X_TXDESC_DD = 0x00000001 ; Descriptor Done
; === RX Descriptor fields ===
; RX Packet Length (word 2)
I8254X_RXDESC_LEN_MASK = 0x0000ffff
; RX Descriptor STA field (word 3)
I8254X_RXDESC_PIF = 0x00000080 ; Passed In-exact Filter
I8254X_RXDESC_IPCS = 0x00000040 ; IP cksum calculated
I8254X_RXDESC_TCPCS = 0x00000020 ; TCP cksum calculated
I8254X_RXDESC_VP = 0x00000008 ; Packet is 802.1Q
I8254X_RXDESC_IXSM = 0x00000004 ; Ignore cksum indication
I8254X_RXDESC_EOP = 0x00000002 ; End Of Packet
I8254X_RXDESC_DD = 0x00000001 ; Descriptor Done
|
;VRAM
;0000-03FF BG0 1KWORD
;1000-1FFF CHR 4KWORD 0-255CHR
;2000-2FFF SP 4KWORD 0-64CHR
;3000-3100 SATB
;4000-7BFF CHRBG0 16KWORD 32*32CHR(256*256) 7C00-7FFF 1KWORD(not using)
chardatBank .equ 2
spdatBank .equ 3
muldatBank .equ 4
mapdatBank .equ 20
VDC_0 .equ $0000
VDC_1 .equ $0001
VDC_2 .equ $0002
VDC_3 .equ $0003
VDC1_0 .equ VDC_0
VDC1_1 .equ VDC_1
VDC1_2 .equ VDC_2
VDC1_3 .equ VDC_3
VDC2_0 .equ $0010
VDC2_1 .equ $0011
VDC2_2 .equ $0012
VDC2_3 .equ $0013
VPC_0 .equ $0008
VPC_1 .equ $0009
VPC_2 .equ $000A
VPC_3 .equ $000B
VPC_4 .equ $000C
VPC_5 .equ $000D
VPC_6 .equ $000E
VPC_7 .equ $000F
VCE_0 .equ $0400
VCE_1 .equ $0401
VCE_2 .equ $0402
VCE_3 .equ $0403
VCE_4 .equ $0404
VCE_5 .equ $0405
VCE_6 .equ $0406
VCE_7 .equ $0407
INT_DIS_REG .equ $1402
IO_PAD .equ $1000
;----------------------------
jcc .macro
bcs .jp\@
jmp \1
.jp\@
.endm
;----------------------------
jcs .macro
bcc .jp\@
jmp \1
.jp\@
.endm
;----------------------------
jeq .macro
bne .jp\@
jmp \1
.jp\@
.endm
;----------------------------
jne .macro
beq .jp\@
jmp \1
.jp\@
.endm
;----------------------------
jpl .macro
bmi .jp\@
jmp \1
.jp\@
.endm
;----------------------------
jmi .macro
bpl .jp\@
jmp \1
.jp\@
.endm
;----------------------------
add .macro
;\1 = \2 + \3
;\1 = \1 + \2
.if (\# = 3)
clc
lda \2
adc \3
sta \1
.else
.if (\# = 2)
clc
lda \1
adc \2
sta \1
.else
clc
adc \1
.endif
.endif
.endm
;----------------------------
sub .macro
;\1 = \2 - \3
;\1 = \1 - \2
.if (\# = 3)
sec
lda \2
sbc \3
sta \1
.else
.if (\# = 2)
sec
lda \1
sbc \2
sta \1
.else
sec
sbc \1
.endif
.endif
.endm
;----------------------------
addw .macro
;\1 = \2 + \3
;\1 = \1 + \2
.if (\# = 3)
.if (\?3 = 2);Immediate
clc
lda \2
adc #LOW(\3)
sta \1
lda \2+1
adc #HIGH(\3)
sta \1+1
.else
clc
lda \2
adc \3
sta \1
lda \2+1
adc \3+1
sta \1+1
.endif
.else
.if (\?2 = 2);Immediate
clc
lda \1
adc #LOW(\2)
sta \1
lda \1+1
adc #HIGH(\2)
sta \1+1
.else
clc
lda \1
adc \2
sta \1
lda \1+1
adc \2+1
sta \1+1
.endif
.endif
.endm
;----------------------------
subw .macro
;\1 = \2 - \3
;\1 = \1 - \2
.if (\# = 3)
.if (\?3 = 2);Immediate
sec
lda \2
sbc #LOW(\3)
sta \1
lda \2+1
sbc #HIGH(\3)
sta \1+1
.else
.if (\?2 = 2);Immediate
sec
lda #LOW(\2)
sbc \3
sta \1
lda #HIGH(\2)
sbc \3+1
sta \1+1
.else
sec
lda \2
sbc \3
sta \1
lda \2+1
sbc \3+1
sta \1+1
.endif
.endif
.else
.if (\?2 = 2);Immediate
sec
lda \1
sbc #LOW(\2)
sta \1
lda \1+1
sbc #HIGH(\2)
sta \1+1
.else
sec
lda \1
sbc \2
sta \1
lda \1+1
sbc \2+1
sta \1+1
.endif
.endif
.endm
;----------------------------
addq .macro
;\1 = \2 + \3
;\1 = \1 + \2
;\1 = \2 + \3:\4(Immediate)
.if (\# = 4)
clc
lda \2
adc #LOW(\4)
sta \1
lda \2+1
adc #HIGH(\4)
sta \1+1
lda \2+2
adc #LOW(\3)
sta \1+2
lda \2+3
adc #HIGH(\3)
sta \1+3
.else
.if (\# = 3)
clc
lda \2
adc \3
sta \1
lda \2+1
adc \3+1
sta \1+1
lda \2+2
adc \3+2
sta \1+2
lda \2+3
adc \3+3
sta \1+3
.else
clc
lda \1
adc \2
sta \1
lda \1+1
adc \2+1
sta \1+1
lda \1+2
adc \2+2
sta \1+2
lda \1+3
adc \2+3
sta \1+3
.endif
.endif
.endm
;----------------------------
subq .macro
;\1 = \2 - \3
;\1 = \1 - \2
.if (\# = 3)
sec
lda \2
sbc \3
sta \1
lda \2+1
sbc \3+1
sta \1+1
lda \2+2
sbc \3+2
sta \1+2
lda \2+3
sbc \3+3
sta \1+3
.else
sec
lda \1
sbc \2
sta \1
lda \1+1
sbc \2+1
sta \1+1
lda \1+2
sbc \2+2
sta \1+2
lda \1+3
sbc \2+3
sta \1+3
.endif
.endm
;----------------------------
neg .macro
lda \1
eor #$FF
inc a
sta \1
.endm
;----------------------------
negw .macro
sec
lda \1
eor #$FF
adc #0
sta \1
lda \1+1
eor #$FF
adc #0
sta \1+1
.endm
;----------------------------
negq .macro
sec
lda \1
eor #$FF
adc #0
sta \1
lda \1+1
eor #$FF
adc #0
sta \1+1
lda \1+2
eor #$FF
adc #0
sta \1+2
lda \1+3
eor #$FF
adc #0
sta \1+3
.endm
;----------------------------
mov .macro
;\1 = \2
lda \2
sta \1
.endm
;----------------------------
movw .macro
;\1 = \2
.if (\?2 = 2);Immediate
lda #LOW(\2)
sta \1
lda #HIGH(\2)
sta \1+1
.else
lda \2
sta \1
lda \2+1
sta \1+1
.endif
.endm
;----------------------------
movq .macro
;\1 = \2
;\1 = \2:\3
.if (\?2 = 2);Immediate
lda #LOW(\3)
sta \1
lda #HIGH(\3)
sta \1+1
lda #LOW(\2)
sta \1+2
lda #HIGH(\2)
sta \1+3
.else
lda \2
sta \1
lda \2+1
sta \1+1
lda \2+2
sta \1+2
lda \2+3
sta \1+3
.endif
.endm
;----------------------------
stzw .macro
;\1 = 0
stz \1
stz \1+1
.endm
;----------------------------
stzq .macro
;\1 = 0
stz \1
stz \1+1
stz \1+2
stz \1+3
.endm
;----------------------------
cmpw .macro
;\1 - \2
.if (\?2 = 2);Immediate
sec
lda \1
sbc #LOW(\2)
lda \1+1
sbc #HIGH(\2)
.else
sec
lda \1
sbc \2
lda \1+1
sbc \2+1
.endif
.endm
;----------------------------
cmpq .macro
;\1 - \2
;\1 - \2:\3
.if (\?2 = 2);Immediate
sec
lda \1
sbc #LOW(\3)
lda \1+1
sbc #HIGH(\3)
lda \1+2
sbc #LOW(\2)
lda \1+3
sbc #HIGH(\2)
.else
sec
lda \1
sbc \2
lda \1+1
sbc \2+1
lda \1+2
sbc \2+2
lda \1+3
sbc \2+3
.endif
.endm
;//////////////////////////////////
.zp
;**********************************
.org $2000
;++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++
lineAddr .ds 2
lineBgAddr .ds 2
lineBgAddrWork .ds 2
lineDataX .ds 4
lineDataY .ds 4
lineDataXX .ds 4
lineDataXY .ds 4
lineDataYX .ds 4
lineDataYY .ds 4
lineX0 .ds 4
lineY0 .ds 4
lineX1 .ds 4
lineY1 .ds 4
lineX2 .ds 4
lineY2 .ds 4
lineX3 .ds 4
lineY3 .ds 4
lineLoopX .ds 1
lineLoopY .ds 1
lineLoopXWork .ds 1
lineBgData .ds 32
lineDataWork .ds 1
;++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++
;---------------------
mul16a
div16a .ds 2
mul16b
div16b .ds 2
mul16c
div16c .ds 2
mul16d
div16d .ds 2
mul48work
div16ans .ds 2
div16work .ds 2
.ds 4
mulbank .ds 1
muladdr .ds 2
;---------------------
;LDRU SsBA
padlast .ds 1
padnow .ds 1
padstate .ds 1
;---------------------
rotationAngle .ds 1
bgMultiply .ds 2
multmp .ds 6
.bss
;**********************************
.org $2100
;**********************************
.org $2200
;---------------------
shipX .ds 2
shipY .ds 2
;---------------------
clearBGWork .ds 2
;---------------------
paramMultiply .ds 2
paramBgAddr .ds 2
paramX0 .ds 2
paramY0 .ds 2
paramCountX .ds 1
paramCountY .ds 1
;---------------------
clearChar .ds 32
;---------------------
spriteWork .ds 8 * 64
;**********************************
.org $3600
rotationProc .ds 1
;//////////////////////////////////
.code
.bank 0
;**********************************
.org $E000
main:
;Initialize VDP
jsr initializeVdp
;On Screen
jsr onScreen
;set proc bank
lda #1
tam #$06
;set rotation routine
tii procData, rotationProc, $0A00
;clearBG
jsr clearBG
;clear Sprite Work
jsr clearSpriteWork
;initialize Rotation Proc
jsr initRotationProc
;set paramMultiply $8000
movw paramMultiply, #$8000
movw shipX, #128-32
movw shipY, #144
stz <rotationAngle
.rotationLoop:
jsr getPramIndex
lda paramBgAddrDataLow, x
sta paramBgAddr
lda paramBgAddrDataHigh, x
sta paramBgAddr+1
lda paramX0Data, x
sta paramX0
mov paramX0+1, #$FF
lda paramY0Data, x
sta paramY0
mov paramY0+1, #$FF
lda paramCountXData, x
sta paramCountX
lda paramCountYData, x
sta paramCountY
;x = xcosA - ysinA
;xcosA
lda rotationAngle
add #64
tax
lda sinData0,x
sta <mul16c
lda sinData1,x
sta <mul16c+1
lda sinData2,x
sta <mul16d
lda sinData3,x
sta <mul16d+1
movw <mul16a, paramX0
jsr smul48
lda <mul16b
sta <multmp
lda <mul16b+1
sta <multmp+1
lda <mul16c
sta <multmp+2
lda <mul16c+1
sta <multmp+3
lda <mul16d
sta <multmp+4
lda <mul16d+1
sta <multmp+5
;ysinA
ldx rotationAngle
lda sinData0,x
sta <mul16c
lda sinData1,x
sta <mul16c+1
lda sinData2,x
sta <mul16d
lda sinData3,x
sta <mul16d+1
movw <mul16a, paramY0
jsr smul48
;x = xcosA - ysinA
subq <lineDataX, <multmp, <mul16b
movq <mul16c, <lineDataX
movw <mul16a, paramMultiply
jsr smul48
movq <lineDataX, <mul16b+1
addq <lineDataX, <lineDataX, #$0080, #$0000
;y = xsinA + ycosA
;xsinA
ldx rotationAngle
lda sinData0,x
sta <mul16c
lda sinData1,x
sta <mul16c+1
lda sinData2,x
sta <mul16d
lda sinData3,x
sta <mul16d+1
movw <mul16a, paramX0
jsr smul48
lda <mul16b
sta <multmp
lda <mul16b+1
sta <multmp+1
lda <mul16c
sta <multmp+2
lda <mul16c+1
sta <multmp+3
lda <mul16d
sta <multmp+4
lda <mul16d+1
sta <multmp+5
;ycosA
lda rotationAngle
add #64
tax
lda sinData0,x
sta <mul16c
lda sinData1,x
sta <mul16c+1
lda sinData2,x
sta <mul16d
lda sinData3,x
sta <mul16d+1
movw <mul16a, #$FFC4;-60
movw <mul16a, paramY0
jsr smul48
;y = xsinA + ycosA
addq <lineDataY, <multmp, <mul16b
movq <mul16c, <lineDataY
movw <mul16a, paramMultiply
jsr smul48
movq <lineDataY, <mul16b+1
addq <lineDataY, <lineDataY, #$0080, #$0000
;set line data
ldx rotationAngle
movw <mul16a, paramMultiply
jsr getMultiplySin
lda <mul16b+1
sta <lineDataXY
lda <mul16c
sta <lineDataXY+1
lda <mul16c+1
sta <lineDataXY+2
lda <mul16d
sta <lineDataXY+3
txa
add #64
tax
jsr getMultiplySin
lda <mul16b+1
sta <lineDataXX
lda <mul16c
sta <lineDataXX+1
lda <mul16c+1
sta <lineDataXX+2
lda <mul16d
sta <lineDataXX+3
lda <mul16b+1
sta <lineDataYY
lda <mul16c
sta <lineDataYY+1
lda <mul16c+1
sta <lineDataYY+2
lda <mul16d
sta <lineDataYY+3
txa
add #64
tax
jsr getMultiplySin
lda <mul16b+1
sta <lineDataYX
lda <mul16c
sta <lineDataYX+1
lda <mul16c+1
sta <lineDataYX+2
lda <mul16d
sta <lineDataYX+3
movw <lineBgAddr, paramBgAddr
mov <lineLoopX, paramCountX
mov <lineLoopY, paramCountY
jsr setMap
jsr rotationProc
inc <rotationAngle
subw paramMultiply, #16
lda paramMultiply
ora paramMultiply+1
bne .mainJump01
jsr clearCHAR
movw paramMultiply, #$8000
.mainJump01:
jmp .rotationLoop
;----------------------------
sdiv32:
;div16d:div16c / div16a = div16a div16b
;push x
; phx
;d sign
lda <div16d+1
pha
;d eor a sign
eor <div16a+1
pha
;d sign
bbr7 <div16d+1, .sdiv16jp00
;d neg
sec
lda <mul16c
eor #$FF
adc #0
sta <mul16c
lda <mul16c+1
eor #$FF
adc #0
sta <mul16c+1
lda <mul16d
eor #$FF
adc #0
sta <mul16d
lda <mul16d+1
eor #$FF
adc #0
sta <mul16d+1
.sdiv16jp00:
;a sign
bbr7 <div16a+1, .sdiv16jp01
;a neg
sec
lda <mul16a
eor #$FF
adc #0
sta <mul16a
lda <mul16a+1
eor #$FF
adc #0
sta <mul16a+1
.sdiv16jp01:
jsr udiv32
;anser sign
pla
bpl .sdiv16jp02
;anser neg
sec
lda <mul16a
eor #$FF
adc #0
sta <mul16a
lda <mul16a+1
eor #$FF
adc #0
sta <mul16a+1
.sdiv16jp02:
;remainder sign
pla
bpl .sdiv16jp03
;remainder neg
sec
lda <mul16b
eor #$FF
adc #0
sta <mul16b
lda <mul16b+1
eor #$FF
adc #0
sta <mul16b+1
.sdiv16jp03:
;pull x
; plx
rts
;----------------------------
udiv32:
;div16d:div16c / div16a = div16a div16b
;push x y
phx
phy
;div16a to div16b
lda <div16a
sta <div16b
lda <div16a+1
sta <div16b+1
;set zero div16a
stz <div16a
stz <div16a+1
;set zero div16ans
stz <div16ans
stz <div16ans+1
;set count
ldx #16
.udivloop:
;right shift div16b:div16a
lsr <div16b+1
ror <div16b
ror <div16a+1
ror <div16a
;div16d:div16c - div16b:div16a = a:y:div16work
sec
lda <div16c
sbc <div16a
sta <div16work
lda <div16c+1
sbc <div16a+1
sta <div16work+1
lda <div16d
sbc <div16b
tay
lda <div16d+1
sbc <div16b+1
;check div16d:div16c >= div16b:div16a
bcc .udivjump
rol <div16ans
rol <div16ans+1
;div16d:div16c = a:y:div16work
sty <div16d
sta <div16d+1
lda <div16work
sta <div16c
lda <div16work+1
sta <div16c+1
dex
bne .udivloop
bra .udivjump01
.udivjump:
rol <div16ans
rol <div16ans+1
;decrement x
dex
bne .udivloop
.udivjump01:
;div16ans to div16a
lda <div16ans
sta <div16a
lda <div16ans+1
sta <div16a+1
;div16c to div16b
lda <div16c
sta <div16b
lda <div16c+1
sta <div16b+1
;pull y x
ply
plx
rts
;----------------------------
smul16:
;mul16d:mul16c = mul16a * mul16b
;push x
;phx
;a eor b sign
lda <mul16a+1
eor <mul16b+1
pha
;a sign
bbr7 <mul16a+1, .smul16jp00
;a neg
sec
lda <mul16a
eor #$FF
adc #0
sta <mul16a
lda <mul16a+1
eor #$FF
adc #0
sta <mul16a+1
.smul16jp00:
;b sign
bbr7 <mul16b+1, .smul16jp01
;b neg
sec
lda <mul16b
eor #$FF
adc #0
sta <mul16b
lda <mul16b+1
eor #$FF
adc #0
sta <mul16b+1
.smul16jp01:
jsr umul16
;anser sign
pla
bpl .smul16jp02
;anser neg
sec
lda <mul16c
eor #$FF
adc #0
sta <mul16c
lda <mul16c+1
eor #$FF
adc #0
sta <mul16c+1
lda <mul16d
eor #$FF
adc #0
sta <mul16d
lda <mul16d+1
eor #$FF
adc #0
sta <mul16d+1
.smul16jp02:
;pull x
;plx
rts
;----------------------------
umul16:
;mul16d:mul16c = mul16a * mul16b
;push x y
phx
phy
lda <mul16b
lsr a
lsr a
lsr a
lsr a
lsr a
clc
adc #muldatBank
sta <mulbank
tam #$02
lda <mul16b
and #$1F
ora #$40
stz <muladdr
sta <muladdr+1
ldy <mul16a
lda [muladdr],y
sta <mul16c
ldy <mul16a+1
lda [muladdr],y
sta <mul16c+1
lda <mulbank
clc
adc #8
tam #$02
clc
ldy <mul16a
lda [muladdr],y
adc <mul16c+1
sta <mul16c+1
ldy <mul16a+1
lda [muladdr],y
adc #0
sta <mul16d
lda <mul16b+1
lsr a
lsr a
lsr a
lsr a
lsr a
clc
adc #muldatBank
sta <mulbank
tam #$02
lda <mul16b+1
and #$1F
ora #$40
stz <muladdr
sta <muladdr+1
clc
ldy <mul16a
lda [muladdr],y
adc <mul16c+1
sta <mul16c+1
ldy <mul16a+1
lda [muladdr],y
adc <mul16d
sta <mul16d
cla
adc #0
sta <mul16d+1
lda <mulbank
clc
adc #8
tam #$02
clc
ldy <mul16a
lda [muladdr],y
adc <mul16d
sta <mul16d
ldy <mul16a+1
lda [muladdr],y
adc <mul16d+1
sta <mul16d+1
;pull y x
.end000:
ply
plx
rts
;----------------------------
getPadData:
;
lda <padnow
sta <padlast
lda #$01
sta IO_PAD
lda #$03
sta IO_PAD
lda #$01
sta IO_PAD
lda IO_PAD
asl a
asl a
asl a
asl a
sta <padnow
lda #$00
sta IO_PAD
lda IO_PAD
and #$0F
ora <padnow
eor #$FF
sta <padnow
lda <padlast
eor #$FF
and <padnow
sta <padstate
rts
;----------------------------
initializeVdp:
;
;reset wait
cly
.resetWaitloop0:
clx
.resetWaitloop1:
dex
bne .resetWaitloop1
dey
bne .resetWaitloop0
;set vdp
vdpdataloop: lda vdpdata, y
cmp #$FF
beq vdpdataend
sta VDC_0
iny
lda vdpdata, y
sta VDC_2
iny
lda vdpdata, y
sta VDC_3
iny
bra vdpdataloop
vdpdataend:
;disable interrupts TIQD IRQ2D
lda #$05
sta INT_DIS_REG
;262Line VCE Clock 5MHz
lda #$04
sta VCE_0
stz VCE_1
;CHAR set palette
stz VCE_2
stz VCE_3
tia palettedata, VCE_4, $20
;CHAR set to vram
lda #chardatBank
tam #$06
;vram address $1000
st0 #$00
st1 #$00
st2 #$10
st0 #$02
tia $C000, VDC_2, $1000
;SP set palette
stz VCE_2
lda #$01
sta VCE_3
tia palettedata, VCE_4, $20
;SP set to vram
lda #spdatBank
tam #$06
;vram address $1000
st0 #$00
st1 #$00
st2 #$20
st0 #$02
tia $C000, VDC_2, $1000
;clear zeropage
stz $2000
tii $2000, $2001, $00FF
rts
;----------------------------
onScreen:
;on screen
;bg sp vsync
;+1
st0 #$05
st1 #$C8
st2 #$00
rts
;----------------------------
_irq1:
;IRQ1 interrupt process
pha
phx
phy
;ACK interrupt
lda VDC_0
jsr getPadData
bbr7 <padnow, .padJump0 ;LEFT
subw shipX, #2
.padJump0:
bbr5 <padnow, .padJump1 ;RIGHT
addw shipX, #2
.padJump1:
bbr4 <padnow, .padJump2 ;UP
subw shipY, #2
.padJump2:
bbr6 <padnow, .padJump3 ;DOWN
addw shipY, #2
.padJump3:
;ship sprite locate
addw spriteWork, shipY, #64
addw spriteWork+2, shipX, #32
movw spriteWork+4, #$0100
movw spriteWork+6, #$1180
addw spriteWork+8, shipY, #64
addw spriteWork+10, shipX, #32+32
movw spriteWork+12, #$0108
movw spriteWork+14, #$1180
;set sprite
st0 #$00
st1 #$00
st2 #$30
st0 #$02
tia spriteWork, VDC_2, 8 * 64
;SATB DMA set
st0 #$13
st1 #$00
st2 #$30
ply
plx
pla
rti
;----------------------------
_reset:
;reset process
;disable interrupts
sei
;select the 7.16 MHz clock
csh
;clear the decimal flag
cld
;initialize the stack pointer
ldx #$FF
txs
;I/O page0
lda #$FF
tam #$00
;RAM page1
lda #$F8
tam #$01
;jump main
jmp main
;----------------------------
_irq2:
_timer:
_nmi:
;IRQ2 TIMER NMI interrupt process
rti
;----------------------------
vdpdata:
.db $05, $00, $00 ;screen off +1
.db $0A, $02, $02 ;HSW $02 HDS $02
.db $0B, $1F, $04 ;HDW $1F HDE $04
.db $0C, $02, $0D ;VSW $02 VDS $0D
.db $0D, $EF, $00 ;VDW $00EF
.db $0E, $03, $00 ;VCR $03
.db $0F, $00, $00 ;DMA INC INC
.db $07, $00, $00 ;scrollx 0
.db $08, $00, $00 ;scrolly 0
.db $09, $00, $00 ;32x32
.db $FF ;end
;----------------------------
palettedata:
.dw $0007, $0020, $0100, $0120, $0004, $0024, $0104, $0124,\
$01B6, $0038, $01C0, $01F8, $0007, $003F, $01C7, $01FF
;----------------------------
;interrupt vectors
.org $FFF6
.dw _irq2
.dw _irq1
.dw _timer
.dw _nmi
.dw _reset
;////////////////////////////
.bank 1
.org $C000
;----------------------------
clearCHAR:
movw clearBGWork, #$4000
ldy #30
.loopY:
ldx #32
.loopX:
sei
st0 #$00
movw VDC_2, clearBGWork
st0 #$02
tia clearChar, VDC_2, 32
cli
addw clearBGWork, #16
dex
bne .loopX
dey
bne .loopY
rts
;----------------------------
clearSpriteWork:
stz spriteWork
tii spriteWork, spriteWork+1, 8 * 64 - 1
rts
;----------------------------
clearBG:
;clear BG0 BAT
movw clearBGWork, #$0400
st0 #$00
st1 #$00
st2 #$00
st0 #$02
ldy #32
.clearbatloop0:
ldx #32
.clearbatloop1:
movw VDC_2, clearBGWork
addw clearBGWork, #1
dex
bne .clearbatloop1
dey
bne .clearbatloop0
rts
;----------------------------
initRotationProc:
stz <lineBgData+16
tii lineBgData+16, lineBgData+17, 15
stz clearChar
tii clearChar, clearChar+1, 31
rts
;----------------------------
setMap:
lda #mapdatBank
tam #$02
inc a
tam #$03
inc a
tam #$04
inc a
tam #$05
rts
;----------------------------
getMultiplySin
;reg x angle
;mul16a multiplier
lda sinData0, x
sta <mul16c
lda sinData1, x
sta <mul16c+1
lda sinData2, x
sta <mul16d
lda sinData3, x
sta <mul16d+1
jsr smul48
rts
;----------------------------
smul48:
;mul16d:mul16c:mul16b = mul16d:mul16c * mul16a
;a eor d sign
lda <mul16a+1
eor <mul16d+1
pha
;a sign
bbr7 <mul16a+1, .smul48jp00
;a neg
sec
lda <mul16a
eor #$FF
adc #0
sta <mul16a
lda <mul16a+1
eor #$FF
adc #0
sta <mul16a+1
.smul48jp00:
;d sign
bbr7 <mul16d+1, .smul48jp01
;d neg
sec
lda <mul16c
eor #$FF
adc #0
sta <mul16c
lda <mul16c+1
eor #$FF
adc #0
sta <mul16c+1
lda <mul16d
eor #$FF
adc #0
sta <mul16d
lda <mul16d+1
eor #$FF
adc #0
sta <mul16d+1
.smul48jp01:
jsr umul48
;anser sign
pla
bpl .smul48jp02
;anser neg
sec
lda <mul16b
eor #$FF
adc #0
sta <mul16b
lda <mul16b+1
eor #$FF
adc #0
sta <mul16b+1
lda <mul16c
eor #$FF
adc #0
sta <mul16c
lda <mul16c+1
eor #$FF
adc #0
sta <mul16c+1
lda <mul16d
eor #$FF
adc #0
sta <mul16d
lda <mul16d+1
eor #$FF
adc #0
sta <mul16d+1
.smul48jp02:
rts
;----------------------------
umul48:
;mul16d:mul16c:mul16b = mul16d:mul16c * mul16a
;mul48work+6 = mul16d
movw <mul48work+6, <mul16d
;mul16c * mul16a
movw <mul16b, <mul16c
jsr umul16
;mul48work+2:mul48work = mul16d:mul16c
movq <mul48work, <mul16c
;mul16d * mul16a
movw <mul16b, <mul48work+6
jsr umul16
;mul48work+4:mul48work+2 + mul16d:mul16c
stzw <mul48work+4
addq <mul48work+2, <mul16c
;mul16d:mul16c:mul16b = mul48work+4:mul48work+2:mul48work
movq <mul16b, <mul48work
movw <mul16d, <mul48work+4
rts
;---------------------
getPramIndex:
lda paramMultiply+1
cmp #$17
bcc .j0 ;<$17
ldx #$0F
bra .end
.j0:
cmp #$0F
bcc .j1 ;<$0F
ldx #$0E
bra .end
.j1:
cmp #$04
bcc .j2 ;<$04
tax
dex
bra .end
.j2:
cmp #$03
bcc .j3 ;<$03
lda paramMultiply
cmp #$40
bcc .j3 ;<$40
ldx #$02
bra .end
.j3:
clx
.end:
rts
;---------------------
paramBgAddrDataLow
.db $00, $00, $20, $40, $60, $80, $80, $A0, $A0, $A0, $A0, $C0, $C0, $C0, $C0, $E0
;---------------------
paramBgAddrDataHigh
.db $40, $40, $42, $46, $4A, $4E, $4E, $52, $52, $52, $52, $56, $56, $56, $56, $5A
;---------------------
paramX0Data
.db $C0, $C0, $C8, $D0, $D8, $E0, $E0, $E8, $E8, $E8, $E8, $F0, $F0, $F0, $F0, $F8
;---------------------
paramY0Data
.db $C4, $C4, $C8, $D0, $D8, $E0, $E0, $E8, $E8, $E8, $E8, $F0, $F0, $F0, $F0, $F8
;---------------------
paramCountXData
.db 32, 32, 28, 24, 20, 16, 16, 12, 12, 12, 12, 8, 8, 8, 8, 4
;---------------------
paramCountYData
.db 30, 30, 28, 24, 20, 16, 16, 12, 12, 12, 12, 8, 8, 8, 8, 4
;---------------------
INCLUDE "proc.txt"
;---------------------
sinData3
.db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;---------------------
sinData2
.db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,\
$00, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,\
$FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
;---------------------
sinData1
.db $00, $06, $0C, $12, $19, $1F, $25, $2B, $31, $38, $3E, $44, $4A, $50, $56, $5C,\
$61, $67, $6D, $73, $78, $7E, $83, $88, $8E, $93, $98, $9D, $A2, $A7, $AB, $B0,\
$B5, $B9, $BD, $C1, $C5, $C9, $CD, $D1, $D4, $D8, $DB, $DE, $E1, $E4, $E7, $EA,\
$EC, $EE, $F1, $F3, $F4, $F6, $F8, $F9, $FB, $FC, $FD, $FE, $FE, $FF, $FF, $FF,\
$00, $FF, $FF, $FF, $FE, $FE, $FD, $FC, $FB, $F9, $F8, $F6, $F4, $F3, $F1, $EE,\
$EC, $EA, $E7, $E4, $E1, $DE, $DB, $D8, $D4, $D1, $CD, $C9, $C5, $C1, $BD, $B9,\
$B5, $B0, $AB, $A7, $A2, $9D, $98, $93, $8E, $88, $83, $7E, $78, $73, $6D, $67,\
$61, $5C, $56, $50, $4A, $44, $3E, $38, $31, $2B, $25, $1F, $19, $12, $0C, $06,\
$00, $F9, $F3, $ED, $E6, $E0, $DA, $D4, $CE, $C7, $C1, $BB, $B5, $AF, $A9, $A3,\
$9E, $98, $92, $8C, $87, $81, $7C, $77, $71, $6C, $67, $62, $5D, $58, $54, $4F,\
$4A, $46, $42, $3E, $3A, $36, $32, $2E, $2B, $27, $24, $21, $1E, $1B, $18, $15,\
$13, $11, $0E, $0C, $0B, $09, $07, $06, $04, $03, $02, $01, $01, $00, $00, $00,\
$00, $00, $00, $00, $01, $01, $02, $03, $04, $06, $07, $09, $0B, $0C, $0E, $11,\
$13, $15, $18, $1B, $1E, $21, $24, $27, $2B, $2E, $32, $36, $3A, $3E, $42, $46,\
$4A, $4F, $54, $58, $5D, $62, $67, $6C, $71, $77, $7C, $81, $87, $8C, $92, $98,\
$9E, $A3, $A9, $AF, $B5, $BB, $C1, $C7, $CE, $D4, $DA, $E0, $E6, $ED, $F3, $F9
;---------------------
sinData0
.db $00, $48, $90, $D5, $18, $56, $90, $C4, $F1, $17, $34, $47, $50, $4D, $3E, $22,\
$F8, $BE, $74, $1A, $AD, $2F, $9C, $F6, $3A, $68, $80, $80, $68, $36, $EB, $86,\
$05, $68, $AF, $D8, $E4, $D1, $9F, $4D, $DB, $48, $94, $BE, $C6, $AA, $6C, $0A,\
$83, $D9, $09, $14, $FA, $BA, $54, $C8, $15, $3B, $3B, $13, $C4, $4E, $B1, $EC,\
$00, $EC, $B1, $4E, $C4, $13, $3B, $3B, $15, $C8, $54, $BA, $FA, $14, $09, $D9,\
$83, $0A, $6C, $AA, $C6, $BE, $94, $48, $DB, $4D, $9F, $D1, $E4, $D8, $AF, $68,\
$05, $86, $EB, $36, $68, $80, $80, $68, $3A, $F6, $9C, $2F, $AD, $1A, $74, $BE,\
$F8, $22, $3E, $4D, $50, $47, $34, $17, $F1, $C4, $90, $56, $18, $D5, $90, $48,\
$00, $B8, $70, $2B, $E8, $AA, $70, $3C, $0F, $E9, $CC, $B9, $B0, $B3, $C2, $DE,\
$08, $42, $8C, $E6, $53, $D1, $64, $0A, $C6, $98, $80, $80, $98, $CA, $15, $7A,\
$FB, $98, $51, $28, $1C, $2F, $61, $B3, $25, $B8, $6C, $42, $3A, $56, $94, $F6,\
$7D, $27, $F7, $EC, $06, $46, $AC, $38, $EB, $C5, $C5, $ED, $3C, $B2, $4F, $14,\
$00, $14, $4F, $B2, $3C, $ED, $C5, $C5, $EB, $38, $AC, $46, $06, $EC, $F7, $27,\
$7D, $F6, $94, $56, $3A, $42, $6C, $B8, $25, $B3, $61, $2F, $1C, $28, $51, $98,\
$FB, $7A, $15, $CA, $98, $80, $80, $98, $C6, $0A, $64, $D1, $53, $E6, $8C, $42,\
$08, $DE, $C2, $B3, $B0, $B9, $CC, $E9, $0F, $3C, $70, $AA, $E8, $2B, $70, $B8
;++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++
.org $D700
;---------------------
bgDataAddr
.db $40, $40, $41, $41, $42, $42, $43, $43, $44, $44, $45, $45, $46, $46, $47, $47,\
$48, $48, $49, $49, $4A, $4A, $4B, $4B, $4C, $4C, $4D, $4D, $4E, $4E, $4F, $4F,\
$50, $50, $51, $51, $52, $52, $53, $53, $54, $54, $55, $55, $56, $56, $57, $57,\
$58, $58, $59, $59, $5A, $5A, $5B, $5B, $5C, $5C, $5D, $5D, $5E, $5E, $5F, $5F,\
$60, $60, $61, $61, $62, $62, $63, $63, $64, $64, $65, $65, $66, $66, $67, $67,\
$68, $68, $69, $69, $6A, $6A, $6B, $6B, $6C, $6C, $6D, $6D, $6E, $6E, $6F, $6F,\
$70, $70, $71, $71, $72, $72, $73, $73, $74, $74, $75, $75, $76, $76, $77, $77,\
$78, $78, $79, $79, $7A, $7A, $7B, $7B, $7C, $7C, $7D, $7D, $7E, $7E, $7F, $7F,\
$80, $80, $81, $81, $82, $82, $83, $83, $84, $84, $85, $85, $86, $86, $87, $87,\
$88, $88, $89, $89, $8A, $8A, $8B, $8B, $8C, $8C, $8D, $8D, $8E, $8E, $8F, $8F,\
$90, $90, $91, $91, $92, $92, $93, $93, $94, $94, $95, $95, $96, $96, $97, $97,\
$98, $98, $99, $99, $9A, $9A, $9B, $9B, $9C, $9C, $9D, $9D, $9E, $9E, $9F, $9F,\
$A0, $A0, $A1, $A1, $A2, $A2, $A3, $A3, $A4, $A4, $A5, $A5, $A6, $A6, $A7, $A7,\
$A8, $A8, $A9, $A9, $AA, $AA, $AB, $AB, $AC, $AC, $AD, $AD, $AE, $AE, $AF, $AF,\
$B0, $B0, $B1, $B1, $B2, $B2, $B3, $B3, $B4, $B4, $B5, $B5, $B6, $B6, $B7, $B7,\
$B8, $B8, $B9, $B9, $BA, $BA, $BB, $BB, $BC, $BC, $BD, $BD, $BE, $BE, $BF, $BF
;---------------------
bgDataLow0
.db $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F,\
$00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03, $00, $03,\
$0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F, $0C, $0F
;---------------------
bgDataLow1
.db $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03, $00, $00, $03, $03,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F,\
$0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F, $0C, $0C, $0F, $0F
;---------------------
bgDataLow2
.db $00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$00, $00, $00, $00, $03, $03, $03, $03, $00, $00, $00, $00, $03, $03, $03, $03,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F
;---------------------
bgDataLow3
.db $00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$00, $00, $00, $00, $00, $00, $00, $00, $03, $03, $03, $03, $03, $03, $03, $03,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F,\
$0C, $0C, $0C, $0C, $0C, $0C, $0C, $0C, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F
;---------------------
bgDataHigh0
.db $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0,\
$00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30, $00, $30,\
$C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0, $C0, $F0
;---------------------
bgDataHigh1
.db $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30, $00, $00, $30, $30,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0,\
$C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0, $C0, $C0, $F0, $F0
;---------------------
bgDataHigh2
.db $00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$00, $00, $00, $00, $30, $30, $30, $30, $00, $00, $00, $00, $30, $30, $30, $30,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0
;---------------------
bgDataHigh3
.db $00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$00, $00, $00, $00, $00, $00, $00, $00, $30, $30, $30, $30, $30, $30, $30, $30,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0,\
$C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0
;++++++++++++++++++++++++++++++++
;++++++++++++++++++++++++++++++++
;////////////////////////////
.bank 2
INCBIN "char.dat" ; 8K 2 $02
INCBIN "sp.dat" ; 8K 3 $03
INCBIN "mul.dat" ; 128K 4~19 $04~$13
INCBIN "map.dat" ; 32K 20~23 $14~$17
|
.thumb
.org 0x0
add r1,r1,r2
strb r1,[r4,#0x1D]
ldrb r2,[r0,#0x8]
ldrb r1,[r4,#0x1A]
add r2,r2,r1
strb r2,[r4,#0x1A]
mov r1,r4
add r1,#0x3A
ldrb r2,[r1]
ldrb r3,[r0,#0x9] @mag bonus
add r2,r2,r3
strb r2,[r1]
mov r0,r4
bx r14
|
; Buffering (get line with parity) utility V2.00 1989 Tony Tebby QJUMP
section iou
xdef iob_glpr
xref iob_gbpr
include 'dev8_keys_buf'
include 'dev8_keys_err'
include 'dev8_keys_k'
;+++
; This routine gets multiple bytes from an IO buffer. The transfer is
; terminated by a <NL> <EOF> or if the transfer is complete. If it needs a
; new buffer, the old buffer is added to the linked list of throwaways.
;
; If it is end of file, the buffer is thrown away and A2 is returned as
; either the next list of buffers or zero. The end of file flag is put in
; (A1), but neither D1 nor A1 is updated.
;
; When A2 is modified, the corresponding current output queue pointer is
; updated.
;
; This routine can be called from an interrupt server.
;
; This is a clean routine.
;
; d0 r status: 0, err.nc, err.prty, err.bffl or +1 for end of file
; d1 c u byte count
; d2 c p number of bytes to transfer
; d7 c p byte parity code
; a1 c u destination for bytes transferred
; a2 c u pointer to buffer header, updated if new buffer or eof
; a6 c p pointer to system variables
; all other registers preserved
;--
iob_glpr
moveq #0,d0
cmp.l d1,d2 ; number of bytes to read
ble.s ibgm_bffl
move.l d1,-(sp)
jsr iob_gbpr
bne.s ibgm_bad
move.b d1,(a1)
move.l (sp)+,d1
addq.l #1,d1
cmp.b #k.nl,(a1)+ ; newline at end
bne.s iob_glpr
bra.s ibgm_done
ibgm_bad
blt.s ibgm_rest
move.b d1,(a1)
ibgm_rest
move.l (sp)+,d1
ibgm_done
tst.l d0
rts
ibgm_bffl
moveq #err.bffl,d0
bra.s ibgm_done
end
|
; A297405: Binary "cubes"; numbers whose binary representation consists of three consecutive identical blocks.
; 7,42,63,292,365,438,511,2184,2457,2730,3003,3276,3549,3822,4095,16912,17969,19026,20083,21140,22197,23254,24311,25368,26425,27482,28539,29596,30653,31710,32767,133152,137313,141474,145635,149796,153957,158118,162279,166440,170601,174762,178923,183084,187245,191406,195567,199728,203889,208050,212211,216372,220533,224694,228855,233016,237177,241338,245499,249660,253821,257982,262143,1056832,1073345,1089858,1106371,1122884,1139397,1155910,1172423,1188936,1205449,1221962,1238475,1254988,1271501,1288014,1304527,1321040,1337553,1354066,1370579,1387092,1403605,1420118,1436631,1453144,1469657,1486170,1502683,1519196,1535709,1552222,1568735,1585248,1601761,1618274,1634787,1651300,1667813,1684326,1700839,1717352,1733865,1750378,1766891,1783404,1799917,1816430,1832943,1849456,1865969,1882482,1898995,1915508,1932021,1948534,1965047,1981560,1998073,2014586,2031099,2047612,2064125,2080638,2097151,8421504,8487297,8553090,8618883,8684676,8750469,8816262,8882055,8947848,9013641,9079434,9145227,9211020,9276813,9342606,9408399,9474192,9539985,9605778,9671571,9737364,9803157,9868950,9934743,10000536,10066329,10132122,10197915,10263708,10329501,10395294,10461087,10526880,10592673,10658466,10724259,10790052,10855845,10921638,10987431,11053224,11119017,11184810,11250603,11316396,11382189,11447982,11513775,11579568,11645361,11711154,11776947,11842740,11908533,11974326,12040119,12105912,12171705,12237498,12303291,12369084,12434877,12500670,12566463,12632256,12698049,12763842,12829635,12895428,12961221,13027014,13092807,13158600,13224393,13290186,13355979,13421772,13487565,13553358,13619151,13684944,13750737,13816530,13882323,13948116,14013909,14079702,14145495,14211288,14277081,14342874,14408667,14474460,14540253,14606046,14671839,14737632,14803425,14869218,14935011,15000804,15066597,15132390,15198183,15263976,15329769,15395562,15461355,15527148,15592941,15658734,15724527,15790320,15856113,15921906,15987699,16053492,16119285,16185078,16250871,16316664,16382457,16448250
mov $11,$0
mov $13,$0
add $13,1
lpb $13
mov $0,$11
sub $13,1
sub $0,$13
mov $7,$0
mov $9,2
lpb $9
clr $0,7
mov $0,$7
sub $9,1
add $0,$9
mov $2,2
add $6,$0
add $5,$6
lpb $0
div $0,$2
mul $5,2
mul $6,4
lpe
add $0,4
sub $1,2
mul $0,$1
sub $6,$2
add $5,$6
add $5,5
add $2,$5
mul $2,2
add $2,$0
mov $1,$2
mov $10,$9
lpb $10
mov $8,$1
sub $10,1
lpe
lpe
lpb $7
mov $7,0
sub $8,$1
lpe
mov $1,$8
sub $1,12
div $1,4
mul $1,2
add $1,7
add $12,$1
lpe
mov $1,$12
|
#ifndef SPROUT_RANGE_ADAPTOR_STEPS_HPP
#define SPROUT_RANGE_ADAPTOR_STEPS_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/step_iterator.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/lvalue_forward.hpp>
#include <sprout/type_traits/identity.hpp>
#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT
namespace sprout {
namespace adaptors {
//
// steps_range
//
template<typename Range>
class steps_range
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::step_iterator<typename sprout::container_traits<Range>::iterator>
>
{
public:
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::step_iterator<typename sprout::container_traits<Range>::iterator>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::difference_type difference_type;
public:
steps_range() = default;
steps_range(steps_range const&) = default;
explicit SPROUT_CONSTEXPR steps_range(range_type& range)
: base_type(
iterator(sprout::begin(range), 1, sprout::end(range)),
iterator(sprout::end(range), 1, sprout::end(range))
)
{}
SPROUT_CONSTEXPR steps_range(difference_type width, range_type& range)
: base_type(
iterator(sprout::begin(range), width, sprout::end(range)),
iterator(sprout::end(range), width, sprout::end(range))
)
{}
SPROUT_CONSTEXPR steps_range(difference_type width, difference_type init, range_type& range)
: base_type(
iterator(sprout::next(sprout::begin(range), NS_SSCRISK_CEL_OR_SPROUT::min(init, sprout::size(range))), width, sprout::end(range)),
iterator(sprout::end(range), width, sprout::end(range))
)
{}
};
//
// step_holder
//
template<typename Difference>
class step_holder {
public:
typedef Difference difference_type;
private:
difference_type width_;
difference_type init_;
public:
step_holder() = default;
step_holder(step_holder const&) = default;
explicit SPROUT_CONSTEXPR step_holder(difference_type width, difference_type init = 0)
: width_(width), init_(init)
{}
SPROUT_CONSTEXPR difference_type const& width() const {
return width_;
}
SPROUT_CONSTEXPR difference_type const& init() const {
return init_;
}
};
//
// steps_forwarder
//
class steps_forwarder {
public:
template<typename Difference>
SPROUT_CONSTEXPR sprout::adaptors::step_holder<Difference>
operator()(Difference width) const {
return sprout::adaptors::step_holder<Difference>(width);
}
template<typename Difference>
SPROUT_CONSTEXPR sprout::adaptors::step_holder<Difference>
operator()(Difference width, typename sprout::identity<Difference>::type init) const {
return sprout::adaptors::step_holder<Difference>(width, init);
}
};
//
// steps
//
namespace {
SPROUT_STATIC_CONSTEXPR sprout::adaptors::steps_forwarder steps = {};
} // anonymous-namespace
//
// operator|
//
template<typename Range, typename Difference>
inline SPROUT_CONSTEXPR sprout::adaptors::steps_range<
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>
operator|(Range&& lhs, sprout::adaptors::step_holder<Difference> const& rhs) {
return sprout::adaptors::steps_range<
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
>(
rhs.width(), rhs.init(),
sprout::lvalue_forward<Range>(lhs)
);
}
} // namespace adaptors
//
// container_construct_traits
//
template<typename Range>
struct container_construct_traits<sprout::adaptors::steps_range<Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::steps_range<Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_STEPS_HPP
|
// Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
// Including type: OVR.OpenVR.IVRSystem
#include "OVR/OpenVR/IVRSystem.hpp"
// Including type: System.IntPtr
#include "System/IntPtr.hpp"
// Including type: OVR.OpenVR.TrackedDevicePose_t
#include "OVR/OpenVR/TrackedDevicePose_t.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
#include "beatsaber-hook/shared/utils/typedefs-array.hpp"
#include "beatsaber-hook/shared/utils/typedefs-string.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: OVR::OpenVR
namespace OVR::OpenVR {
// Forward declaring type: HmdMatrix44_t
struct HmdMatrix44_t;
// Forward declaring type: EVREye
struct EVREye;
// Forward declaring type: DistortionCoordinates_t
struct DistortionCoordinates_t;
// Skipping declaration: HmdMatrix34_t because it is already included!
// Forward declaring type: ETextureType
struct ETextureType;
// Forward declaring type: ETrackingUniverseOrigin
struct ETrackingUniverseOrigin;
// Forward declaring type: ETrackedDeviceClass
struct ETrackedDeviceClass;
// Forward declaring type: EDeviceActivityLevel
struct EDeviceActivityLevel;
// Forward declaring type: ETrackedControllerRole
struct ETrackedControllerRole;
// Forward declaring type: ETrackedDeviceProperty
struct ETrackedDeviceProperty;
// Forward declaring type: ETrackedPropertyError
struct ETrackedPropertyError;
// Forward declaring type: VREvent_t
struct VREvent_t;
// Forward declaring type: EVREventType
struct EVREventType;
// Forward declaring type: HiddenAreaMesh_t
struct HiddenAreaMesh_t;
// Forward declaring type: EHiddenAreaMeshType
struct EHiddenAreaMeshType;
// Forward declaring type: VRControllerState_t
struct VRControllerState_t;
// Forward declaring type: EVRButtonId
struct EVRButtonId;
// Forward declaring type: EVRControllerAxisType
struct EVRControllerAxisType;
// Forward declaring type: EVRFirmwareError
struct EVRFirmwareError;
}
// Forward declaring namespace: System::Text
namespace System::Text {
// Forward declaring type: StringBuilder
class StringBuilder;
}
// Completed forward declares
// Type namespace: OVR.OpenVR
namespace OVR::OpenVR {
// Forward declaring type: CVRSystem
class CVRSystem;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
NEED_NO_BOX(::OVR::OpenVR::CVRSystem);
DEFINE_IL2CPP_ARG_TYPE(::OVR::OpenVR::CVRSystem*, "OVR.OpenVR", "CVRSystem");
// Type namespace: OVR.OpenVR
namespace OVR::OpenVR {
// Size: 0x188
#pragma pack(push, 1)
// Autogenerated type: OVR.OpenVR.CVRSystem
// [TokenAttribute] Offset: FFFFFFFF
class CVRSystem : public ::Il2CppObject {
public:
// Nested type: ::OVR::OpenVR::CVRSystem::_PollNextEventPacked
class _PollNextEventPacked;
// Nested type: ::OVR::OpenVR::CVRSystem::PollNextEventUnion
struct PollNextEventUnion;
// Nested type: ::OVR::OpenVR::CVRSystem::_GetControllerStatePacked
class _GetControllerStatePacked;
// Nested type: ::OVR::OpenVR::CVRSystem::GetControllerStateUnion
struct GetControllerStateUnion;
// Nested type: ::OVR::OpenVR::CVRSystem::_GetControllerStateWithPosePacked
class _GetControllerStateWithPosePacked;
// Nested type: ::OVR::OpenVR::CVRSystem::GetControllerStateWithPoseUnion
struct GetControllerStateWithPoseUnion;
public:
// private OVR.OpenVR.IVRSystem FnTable
// Size: 0x178
// Offset: 0x10
::OVR::OpenVR::IVRSystem FnTable;
// Field size check
static_assert(sizeof(::OVR::OpenVR::IVRSystem) == 0x178);
public:
// Creating conversion operator: operator ::OVR::OpenVR::IVRSystem
constexpr operator ::OVR::OpenVR::IVRSystem() const noexcept {
return FnTable;
}
// Get instance field reference: private OVR.OpenVR.IVRSystem FnTable
[[deprecated("Use field access instead!")]] ::OVR::OpenVR::IVRSystem& dyn_FnTable();
// System.Void .ctor(System.IntPtr pInterface)
// Offset: 0x9858E0
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static CVRSystem* New_ctor(::System::IntPtr pInterface) {
static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::CVRSystem::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<CVRSystem*, creationType>(pInterface)));
}
// public System.Void GetRecommendedRenderTargetSize(ref System.UInt32 pnWidth, ref System.UInt32 pnHeight)
// Offset: 0x985A08
void GetRecommendedRenderTargetSize(ByRef<uint> pnWidth, ByRef<uint> pnHeight);
// public OVR.OpenVR.HmdMatrix44_t GetProjectionMatrix(OVR.OpenVR.EVREye eEye, System.Single fNearZ, System.Single fFarZ)
// Offset: 0x985A2C
::OVR::OpenVR::HmdMatrix44_t GetProjectionMatrix(::OVR::OpenVR::EVREye eEye, float fNearZ, float fFarZ);
// public System.Void GetProjectionRaw(OVR.OpenVR.EVREye eEye, ref System.Single pfLeft, ref System.Single pfRight, ref System.Single pfTop, ref System.Single pfBottom)
// Offset: 0x985A78
void GetProjectionRaw(::OVR::OpenVR::EVREye eEye, ByRef<float> pfLeft, ByRef<float> pfRight, ByRef<float> pfTop, ByRef<float> pfBottom);
// public System.Boolean ComputeDistortion(OVR.OpenVR.EVREye eEye, System.Single fU, System.Single fV, ref OVR.OpenVR.DistortionCoordinates_t pDistortionCoordinates)
// Offset: 0x985AA4
bool ComputeDistortion(::OVR::OpenVR::EVREye eEye, float fU, float fV, ByRef<::OVR::OpenVR::DistortionCoordinates_t> pDistortionCoordinates);
// public OVR.OpenVR.HmdMatrix34_t GetEyeToHeadTransform(OVR.OpenVR.EVREye eEye)
// Offset: 0x985AC0
::OVR::OpenVR::HmdMatrix34_t GetEyeToHeadTransform(::OVR::OpenVR::EVREye eEye);
// public System.Boolean GetTimeSinceLastVsync(ref System.Single pfSecondsSinceLastVsync, ref System.UInt64 pulFrameCounter)
// Offset: 0x985B0C
bool GetTimeSinceLastVsync(ByRef<float> pfSecondsSinceLastVsync, ByRef<uint64_t> pulFrameCounter);
// public System.Int32 GetD3D9AdapterIndex()
// Offset: 0x985B30
int GetD3D9AdapterIndex();
// public System.Void GetDXGIOutputInfo(ref System.Int32 pnAdapterIndex)
// Offset: 0x985B4C
void GetDXGIOutputInfo(ByRef<int> pnAdapterIndex);
// public System.Void GetOutputDevice(ref System.UInt64 pnDevice, OVR.OpenVR.ETextureType textureType, System.IntPtr pInstance)
// Offset: 0x985B6C
void GetOutputDevice(ByRef<uint64_t> pnDevice, ::OVR::OpenVR::ETextureType textureType, ::System::IntPtr pInstance);
// public System.Boolean IsDisplayOnDesktop()
// Offset: 0x985B8C
bool IsDisplayOnDesktop();
// public System.Boolean SetDisplayVisibility(System.Boolean bIsVisibleOnDesktop)
// Offset: 0x985BA8
bool SetDisplayVisibility(bool bIsVisibleOnDesktop);
// public System.Void GetDeviceToAbsoluteTrackingPose(OVR.OpenVR.ETrackingUniverseOrigin eOrigin, System.Single fPredictedSecondsToPhotonsFromNow, OVR.OpenVR.TrackedDevicePose_t[] pTrackedDevicePoseArray)
// Offset: 0x985BC8
void GetDeviceToAbsoluteTrackingPose(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, ::ArrayW<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePoseArray);
// public System.Void ResetSeatedZeroPose()
// Offset: 0x985BF0
void ResetSeatedZeroPose();
// public OVR.OpenVR.HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose()
// Offset: 0x985C0C
::OVR::OpenVR::HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose();
// public OVR.OpenVR.HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose()
// Offset: 0x985C58
::OVR::OpenVR::HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose();
// public System.UInt32 GetSortedTrackedDeviceIndicesOfClass(OVR.OpenVR.ETrackedDeviceClass eTrackedDeviceClass, System.UInt32[] punTrackedDeviceIndexArray, System.UInt32 unRelativeToTrackedDeviceIndex)
// Offset: 0x985CA4
uint GetSortedTrackedDeviceIndicesOfClass(::OVR::OpenVR::ETrackedDeviceClass eTrackedDeviceClass, ::ArrayW<uint> punTrackedDeviceIndexArray, uint unRelativeToTrackedDeviceIndex);
// public OVR.OpenVR.EDeviceActivityLevel GetTrackedDeviceActivityLevel(System.UInt32 unDeviceId)
// Offset: 0x985CD0
::OVR::OpenVR::EDeviceActivityLevel GetTrackedDeviceActivityLevel(uint unDeviceId);
// public System.Void ApplyTransform(ref OVR.OpenVR.TrackedDevicePose_t pOutputPose, ref OVR.OpenVR.TrackedDevicePose_t pTrackedDevicePose, ref OVR.OpenVR.HmdMatrix34_t pTransform)
// Offset: 0x985CEC
void ApplyTransform(ByRef<::OVR::OpenVR::TrackedDevicePose_t> pOutputPose, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose, ByRef<::OVR::OpenVR::HmdMatrix34_t> pTransform);
// public System.UInt32 GetTrackedDeviceIndexForControllerRole(OVR.OpenVR.ETrackedControllerRole unDeviceType)
// Offset: 0x985D08
uint GetTrackedDeviceIndexForControllerRole(::OVR::OpenVR::ETrackedControllerRole unDeviceType);
// public OVR.OpenVR.ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex(System.UInt32 unDeviceIndex)
// Offset: 0x985D24
::OVR::OpenVR::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex(uint unDeviceIndex);
// public OVR.OpenVR.ETrackedDeviceClass GetTrackedDeviceClass(System.UInt32 unDeviceIndex)
// Offset: 0x985D40
::OVR::OpenVR::ETrackedDeviceClass GetTrackedDeviceClass(uint unDeviceIndex);
// public System.Boolean IsTrackedDeviceConnected(System.UInt32 unDeviceIndex)
// Offset: 0x985D5C
bool IsTrackedDeviceConnected(uint unDeviceIndex);
// public System.Boolean GetBoolTrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985D78
bool GetBoolTrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.Single GetFloatTrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985D94
float GetFloatTrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.Int32 GetInt32TrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985DB0
int GetInt32TrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.UInt64 GetUint64TrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985DCC
uint64_t GetUint64TrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public OVR.OpenVR.HmdMatrix34_t GetMatrix34TrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985DE8
::OVR::OpenVR::HmdMatrix34_t GetMatrix34TrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.UInt32 GetArrayTrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, System.UInt32 propType, System.IntPtr pBuffer, System.UInt32 unBufferSize, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985E34
uint GetArrayTrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, uint propType, ::System::IntPtr pBuffer, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.UInt32 GetStringTrackedDeviceProperty(System.UInt32 unDeviceIndex, OVR.OpenVR.ETrackedDeviceProperty prop, System.Text.StringBuilder pchValue, System.UInt32 unBufferSize, ref OVR.OpenVR.ETrackedPropertyError pError)
// Offset: 0x985E50
uint GetStringTrackedDeviceProperty(uint unDeviceIndex, ::OVR::OpenVR::ETrackedDeviceProperty prop, ::System::Text::StringBuilder* pchValue, uint unBufferSize, ByRef<::OVR::OpenVR::ETrackedPropertyError> pError);
// public System.String GetPropErrorNameFromEnum(OVR.OpenVR.ETrackedPropertyError error)
// Offset: 0x985E6C
::StringW GetPropErrorNameFromEnum(::OVR::OpenVR::ETrackedPropertyError error);
// public System.Boolean PollNextEvent(ref OVR.OpenVR.VREvent_t pEvent, System.UInt32 uncbVREvent)
// Offset: 0x985EFC
bool PollNextEvent(ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent);
// public System.Boolean PollNextEventWithPose(OVR.OpenVR.ETrackingUniverseOrigin eOrigin, ref OVR.OpenVR.VREvent_t pEvent, System.UInt32 uncbVREvent, ref OVR.OpenVR.TrackedDevicePose_t pTrackedDevicePose)
// Offset: 0x98607C
bool PollNextEventWithPose(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, ByRef<::OVR::OpenVR::VREvent_t> pEvent, uint uncbVREvent, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose);
// public System.String GetEventTypeNameFromEnum(OVR.OpenVR.EVREventType eType)
// Offset: 0x986098
::StringW GetEventTypeNameFromEnum(::OVR::OpenVR::EVREventType eType);
// public OVR.OpenVR.HiddenAreaMesh_t GetHiddenAreaMesh(OVR.OpenVR.EVREye eEye, OVR.OpenVR.EHiddenAreaMeshType type)
// Offset: 0x986128
::OVR::OpenVR::HiddenAreaMesh_t GetHiddenAreaMesh(::OVR::OpenVR::EVREye eEye, ::OVR::OpenVR::EHiddenAreaMeshType type);
// public System.Boolean GetControllerState(System.UInt32 unControllerDeviceIndex, ref OVR.OpenVR.VRControllerState_t pControllerState, System.UInt32 unControllerStateSize)
// Offset: 0x986144
bool GetControllerState(uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize);
// public System.Boolean GetControllerStateWithPose(OVR.OpenVR.ETrackingUniverseOrigin eOrigin, System.UInt32 unControllerDeviceIndex, ref OVR.OpenVR.VRControllerState_t pControllerState, System.UInt32 unControllerStateSize, ref OVR.OpenVR.TrackedDevicePose_t pTrackedDevicePose)
// Offset: 0x9862EC
bool GetControllerStateWithPose(::OVR::OpenVR::ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ByRef<::OVR::OpenVR::VRControllerState_t> pControllerState, uint unControllerStateSize, ByRef<::OVR::OpenVR::TrackedDevicePose_t> pTrackedDevicePose);
// public System.Void TriggerHapticPulse(System.UInt32 unControllerDeviceIndex, System.UInt32 unAxisId, System.UInt16 usDurationMicroSec)
// Offset: 0x9864B4
void TriggerHapticPulse(uint unControllerDeviceIndex, uint unAxisId, uint16_t usDurationMicroSec);
// public System.String GetButtonIdNameFromEnum(OVR.OpenVR.EVRButtonId eButtonId)
// Offset: 0x9864D0
::StringW GetButtonIdNameFromEnum(::OVR::OpenVR::EVRButtonId eButtonId);
// public System.String GetControllerAxisTypeNameFromEnum(OVR.OpenVR.EVRControllerAxisType eAxisType)
// Offset: 0x986560
::StringW GetControllerAxisTypeNameFromEnum(::OVR::OpenVR::EVRControllerAxisType eAxisType);
// public System.Boolean IsInputAvailable()
// Offset: 0x9865F0
bool IsInputAvailable();
// public System.Boolean IsSteamVRDrawingControllers()
// Offset: 0x98660C
bool IsSteamVRDrawingControllers();
// public System.Boolean ShouldApplicationPause()
// Offset: 0x986628
bool ShouldApplicationPause();
// public System.Boolean ShouldApplicationReduceRenderingWork()
// Offset: 0x986644
bool ShouldApplicationReduceRenderingWork();
// public System.UInt32 DriverDebugRequest(System.UInt32 unDeviceIndex, System.String pchRequest, System.Text.StringBuilder pchResponseBuffer, System.UInt32 unResponseBufferSize)
// Offset: 0x986660
uint DriverDebugRequest(uint unDeviceIndex, ::StringW pchRequest, ::System::Text::StringBuilder* pchResponseBuffer, uint unResponseBufferSize);
// public OVR.OpenVR.EVRFirmwareError PerformFirmwareUpdate(System.UInt32 unDeviceIndex)
// Offset: 0x98667C
::OVR::OpenVR::EVRFirmwareError PerformFirmwareUpdate(uint unDeviceIndex);
// public System.Void AcknowledgeQuit_Exiting()
// Offset: 0x986698
void AcknowledgeQuit_Exiting();
// public System.Void AcknowledgeQuit_UserPrompt()
// Offset: 0x9866B4
void AcknowledgeQuit_UserPrompt();
}; // OVR.OpenVR.CVRSystem
#pragma pack(pop)
static check_size<sizeof(CVRSystem), 16 + sizeof(::OVR::OpenVR::IVRSystem)> __OVR_OpenVR_CVRSystemSizeCheck;
static_assert(sizeof(CVRSystem) == 0x188);
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetRecommendedRenderTargetSize
// Il2CppName: GetRecommendedRenderTargetSize
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(ByRef<uint>, ByRef<uint>)>(&OVR::OpenVR::CVRSystem::GetRecommendedRenderTargetSize)> {
static const MethodInfo* get() {
static auto* pnWidth = &::il2cpp_utils::GetClassFromName("System", "UInt32")->this_arg;
static auto* pnHeight = &::il2cpp_utils::GetClassFromName("System", "UInt32")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetRecommendedRenderTargetSize", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pnWidth, pnHeight});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetProjectionMatrix
// Il2CppName: GetProjectionMatrix
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HmdMatrix44_t (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREye, float, float)>(&OVR::OpenVR::CVRSystem::GetProjectionMatrix)> {
static const MethodInfo* get() {
static auto* eEye = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREye")->byval_arg;
static auto* fNearZ = &::il2cpp_utils::GetClassFromName("System", "Single")->byval_arg;
static auto* fFarZ = &::il2cpp_utils::GetClassFromName("System", "Single")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetProjectionMatrix", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eEye, fNearZ, fFarZ});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetProjectionRaw
// Il2CppName: GetProjectionRaw
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREye, ByRef<float>, ByRef<float>, ByRef<float>, ByRef<float>)>(&OVR::OpenVR::CVRSystem::GetProjectionRaw)> {
static const MethodInfo* get() {
static auto* eEye = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREye")->byval_arg;
static auto* pfLeft = &::il2cpp_utils::GetClassFromName("System", "Single")->this_arg;
static auto* pfRight = &::il2cpp_utils::GetClassFromName("System", "Single")->this_arg;
static auto* pfTop = &::il2cpp_utils::GetClassFromName("System", "Single")->this_arg;
static auto* pfBottom = &::il2cpp_utils::GetClassFromName("System", "Single")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetProjectionRaw", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eEye, pfLeft, pfRight, pfTop, pfBottom});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::ComputeDistortion
// Il2CppName: ComputeDistortion
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREye, float, float, ByRef<::OVR::OpenVR::DistortionCoordinates_t>)>(&OVR::OpenVR::CVRSystem::ComputeDistortion)> {
static const MethodInfo* get() {
static auto* eEye = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREye")->byval_arg;
static auto* fU = &::il2cpp_utils::GetClassFromName("System", "Single")->byval_arg;
static auto* fV = &::il2cpp_utils::GetClassFromName("System", "Single")->byval_arg;
static auto* pDistortionCoordinates = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "DistortionCoordinates_t")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "ComputeDistortion", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eEye, fU, fV, pDistortionCoordinates});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetEyeToHeadTransform
// Il2CppName: GetEyeToHeadTransform
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HmdMatrix34_t (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREye)>(&OVR::OpenVR::CVRSystem::GetEyeToHeadTransform)> {
static const MethodInfo* get() {
static auto* eEye = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREye")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetEyeToHeadTransform", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eEye});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetTimeSinceLastVsync
// Il2CppName: GetTimeSinceLastVsync
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(ByRef<float>, ByRef<uint64_t>)>(&OVR::OpenVR::CVRSystem::GetTimeSinceLastVsync)> {
static const MethodInfo* get() {
static auto* pfSecondsSinceLastVsync = &::il2cpp_utils::GetClassFromName("System", "Single")->this_arg;
static auto* pulFrameCounter = &::il2cpp_utils::GetClassFromName("System", "UInt64")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetTimeSinceLastVsync", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pfSecondsSinceLastVsync, pulFrameCounter});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetD3D9AdapterIndex
// Il2CppName: GetD3D9AdapterIndex
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<int (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::GetD3D9AdapterIndex)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetD3D9AdapterIndex", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetDXGIOutputInfo
// Il2CppName: GetDXGIOutputInfo
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(ByRef<int>)>(&OVR::OpenVR::CVRSystem::GetDXGIOutputInfo)> {
static const MethodInfo* get() {
static auto* pnAdapterIndex = &::il2cpp_utils::GetClassFromName("System", "Int32")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetDXGIOutputInfo", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pnAdapterIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetOutputDevice
// Il2CppName: GetOutputDevice
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(ByRef<uint64_t>, ::OVR::OpenVR::ETextureType, ::System::IntPtr)>(&OVR::OpenVR::CVRSystem::GetOutputDevice)> {
static const MethodInfo* get() {
static auto* pnDevice = &::il2cpp_utils::GetClassFromName("System", "UInt64")->this_arg;
static auto* textureType = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETextureType")->byval_arg;
static auto* pInstance = &::il2cpp_utils::GetClassFromName("System", "IntPtr")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetOutputDevice", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pnDevice, textureType, pInstance});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::IsDisplayOnDesktop
// Il2CppName: IsDisplayOnDesktop
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::IsDisplayOnDesktop)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "IsDisplayOnDesktop", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::SetDisplayVisibility
// Il2CppName: SetDisplayVisibility
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(bool)>(&OVR::OpenVR::CVRSystem::SetDisplayVisibility)> {
static const MethodInfo* get() {
static auto* bIsVisibleOnDesktop = &::il2cpp_utils::GetClassFromName("System", "Boolean")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "SetDisplayVisibility", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{bIsVisibleOnDesktop});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetDeviceToAbsoluteTrackingPose
// Il2CppName: GetDeviceToAbsoluteTrackingPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackingUniverseOrigin, float, ::ArrayW<::OVR::OpenVR::TrackedDevicePose_t>)>(&OVR::OpenVR::CVRSystem::GetDeviceToAbsoluteTrackingPose)> {
static const MethodInfo* get() {
static auto* eOrigin = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackingUniverseOrigin")->byval_arg;
static auto* fPredictedSecondsToPhotonsFromNow = &::il2cpp_utils::GetClassFromName("System", "Single")->byval_arg;
static auto* pTrackedDevicePoseArray = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("OVR.OpenVR", "TrackedDevicePose_t"), 1)->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetDeviceToAbsoluteTrackingPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eOrigin, fPredictedSecondsToPhotonsFromNow, pTrackedDevicePoseArray});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::ResetSeatedZeroPose
// Il2CppName: ResetSeatedZeroPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::ResetSeatedZeroPose)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "ResetSeatedZeroPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetSeatedZeroPoseToStandingAbsoluteTrackingPose
// Il2CppName: GetSeatedZeroPoseToStandingAbsoluteTrackingPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HmdMatrix34_t (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::GetSeatedZeroPoseToStandingAbsoluteTrackingPose)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetSeatedZeroPoseToStandingAbsoluteTrackingPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetRawZeroPoseToStandingAbsoluteTrackingPose
// Il2CppName: GetRawZeroPoseToStandingAbsoluteTrackingPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HmdMatrix34_t (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::GetRawZeroPoseToStandingAbsoluteTrackingPose)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetRawZeroPoseToStandingAbsoluteTrackingPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetSortedTrackedDeviceIndicesOfClass
// Il2CppName: GetSortedTrackedDeviceIndicesOfClass
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackedDeviceClass, ::ArrayW<uint>, uint)>(&OVR::OpenVR::CVRSystem::GetSortedTrackedDeviceIndicesOfClass)> {
static const MethodInfo* get() {
static auto* eTrackedDeviceClass = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceClass")->byval_arg;
static auto* punTrackedDeviceIndexArray = &il2cpp_functions::array_class_get(::il2cpp_utils::GetClassFromName("System", "UInt32"), 1)->byval_arg;
static auto* unRelativeToTrackedDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetSortedTrackedDeviceIndicesOfClass", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eTrackedDeviceClass, punTrackedDeviceIndexArray, unRelativeToTrackedDeviceIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetTrackedDeviceActivityLevel
// Il2CppName: GetTrackedDeviceActivityLevel
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::EDeviceActivityLevel (OVR::OpenVR::CVRSystem::*)(uint)>(&OVR::OpenVR::CVRSystem::GetTrackedDeviceActivityLevel)> {
static const MethodInfo* get() {
static auto* unDeviceId = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetTrackedDeviceActivityLevel", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceId});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::ApplyTransform
// Il2CppName: ApplyTransform
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(ByRef<::OVR::OpenVR::TrackedDevicePose_t>, ByRef<::OVR::OpenVR::TrackedDevicePose_t>, ByRef<::OVR::OpenVR::HmdMatrix34_t>)>(&OVR::OpenVR::CVRSystem::ApplyTransform)> {
static const MethodInfo* get() {
static auto* pOutputPose = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "TrackedDevicePose_t")->this_arg;
static auto* pTrackedDevicePose = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "TrackedDevicePose_t")->this_arg;
static auto* pTransform = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "HmdMatrix34_t")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "ApplyTransform", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pOutputPose, pTrackedDevicePose, pTransform});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetTrackedDeviceIndexForControllerRole
// Il2CppName: GetTrackedDeviceIndexForControllerRole
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackedControllerRole)>(&OVR::OpenVR::CVRSystem::GetTrackedDeviceIndexForControllerRole)> {
static const MethodInfo* get() {
static auto* unDeviceType = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedControllerRole")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetTrackedDeviceIndexForControllerRole", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceType});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetControllerRoleForTrackedDeviceIndex
// Il2CppName: GetControllerRoleForTrackedDeviceIndex
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::ETrackedControllerRole (OVR::OpenVR::CVRSystem::*)(uint)>(&OVR::OpenVR::CVRSystem::GetControllerRoleForTrackedDeviceIndex)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetControllerRoleForTrackedDeviceIndex", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetTrackedDeviceClass
// Il2CppName: GetTrackedDeviceClass
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::ETrackedDeviceClass (OVR::OpenVR::CVRSystem::*)(uint)>(&OVR::OpenVR::CVRSystem::GetTrackedDeviceClass)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetTrackedDeviceClass", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::IsTrackedDeviceConnected
// Il2CppName: IsTrackedDeviceConnected
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(uint)>(&OVR::OpenVR::CVRSystem::IsTrackedDeviceConnected)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "IsTrackedDeviceConnected", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetBoolTrackedDeviceProperty
// Il2CppName: GetBoolTrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetBoolTrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetBoolTrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetFloatTrackedDeviceProperty
// Il2CppName: GetFloatTrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<float (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetFloatTrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetFloatTrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetInt32TrackedDeviceProperty
// Il2CppName: GetInt32TrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<int (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetInt32TrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetInt32TrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetUint64TrackedDeviceProperty
// Il2CppName: GetUint64TrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint64_t (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetUint64TrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetUint64TrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetMatrix34TrackedDeviceProperty
// Il2CppName: GetMatrix34TrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HmdMatrix34_t (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetMatrix34TrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetMatrix34TrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetArrayTrackedDeviceProperty
// Il2CppName: GetArrayTrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, uint, ::System::IntPtr, uint, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetArrayTrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* propType = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pBuffer = &::il2cpp_utils::GetClassFromName("System", "IntPtr")->byval_arg;
static auto* unBufferSize = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetArrayTrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, propType, pBuffer, unBufferSize, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetStringTrackedDeviceProperty
// Il2CppName: GetStringTrackedDeviceProperty
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (OVR::OpenVR::CVRSystem::*)(uint, ::OVR::OpenVR::ETrackedDeviceProperty, ::System::Text::StringBuilder*, uint, ByRef<::OVR::OpenVR::ETrackedPropertyError>)>(&OVR::OpenVR::CVRSystem::GetStringTrackedDeviceProperty)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* prop = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedDeviceProperty")->byval_arg;
static auto* pchValue = &::il2cpp_utils::GetClassFromName("System.Text", "StringBuilder")->byval_arg;
static auto* unBufferSize = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pError = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetStringTrackedDeviceProperty", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, prop, pchValue, unBufferSize, pError});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetPropErrorNameFromEnum
// Il2CppName: GetPropErrorNameFromEnum
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackedPropertyError)>(&OVR::OpenVR::CVRSystem::GetPropErrorNameFromEnum)> {
static const MethodInfo* get() {
static auto* error = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackedPropertyError")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetPropErrorNameFromEnum", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{error});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::PollNextEvent
// Il2CppName: PollNextEvent
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(ByRef<::OVR::OpenVR::VREvent_t>, uint)>(&OVR::OpenVR::CVRSystem::PollNextEvent)> {
static const MethodInfo* get() {
static auto* pEvent = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "VREvent_t")->this_arg;
static auto* uncbVREvent = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "PollNextEvent", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{pEvent, uncbVREvent});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::PollNextEventWithPose
// Il2CppName: PollNextEventWithPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackingUniverseOrigin, ByRef<::OVR::OpenVR::VREvent_t>, uint, ByRef<::OVR::OpenVR::TrackedDevicePose_t>)>(&OVR::OpenVR::CVRSystem::PollNextEventWithPose)> {
static const MethodInfo* get() {
static auto* eOrigin = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackingUniverseOrigin")->byval_arg;
static auto* pEvent = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "VREvent_t")->this_arg;
static auto* uncbVREvent = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pTrackedDevicePose = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "TrackedDevicePose_t")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "PollNextEventWithPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eOrigin, pEvent, uncbVREvent, pTrackedDevicePose});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetEventTypeNameFromEnum
// Il2CppName: GetEventTypeNameFromEnum
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREventType)>(&OVR::OpenVR::CVRSystem::GetEventTypeNameFromEnum)> {
static const MethodInfo* get() {
static auto* eType = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREventType")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetEventTypeNameFromEnum", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eType});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetHiddenAreaMesh
// Il2CppName: GetHiddenAreaMesh
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::HiddenAreaMesh_t (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVREye, ::OVR::OpenVR::EHiddenAreaMeshType)>(&OVR::OpenVR::CVRSystem::GetHiddenAreaMesh)> {
static const MethodInfo* get() {
static auto* eEye = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVREye")->byval_arg;
static auto* type = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EHiddenAreaMeshType")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetHiddenAreaMesh", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eEye, type});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetControllerState
// Il2CppName: GetControllerState
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(uint, ByRef<::OVR::OpenVR::VRControllerState_t>, uint)>(&OVR::OpenVR::CVRSystem::GetControllerState)> {
static const MethodInfo* get() {
static auto* unControllerDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pControllerState = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "VRControllerState_t")->this_arg;
static auto* unControllerStateSize = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetControllerState", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unControllerDeviceIndex, pControllerState, unControllerStateSize});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetControllerStateWithPose
// Il2CppName: GetControllerStateWithPose
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::ETrackingUniverseOrigin, uint, ByRef<::OVR::OpenVR::VRControllerState_t>, uint, ByRef<::OVR::OpenVR::TrackedDevicePose_t>)>(&OVR::OpenVR::CVRSystem::GetControllerStateWithPose)> {
static const MethodInfo* get() {
static auto* eOrigin = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "ETrackingUniverseOrigin")->byval_arg;
static auto* unControllerDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pControllerState = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "VRControllerState_t")->this_arg;
static auto* unControllerStateSize = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pTrackedDevicePose = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "TrackedDevicePose_t")->this_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetControllerStateWithPose", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eOrigin, unControllerDeviceIndex, pControllerState, unControllerStateSize, pTrackedDevicePose});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::TriggerHapticPulse
// Il2CppName: TriggerHapticPulse
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)(uint, uint, uint16_t)>(&OVR::OpenVR::CVRSystem::TriggerHapticPulse)> {
static const MethodInfo* get() {
static auto* unControllerDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* unAxisId = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* usDurationMicroSec = &::il2cpp_utils::GetClassFromName("System", "UInt16")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "TriggerHapticPulse", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unControllerDeviceIndex, unAxisId, usDurationMicroSec});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetButtonIdNameFromEnum
// Il2CppName: GetButtonIdNameFromEnum
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVRButtonId)>(&OVR::OpenVR::CVRSystem::GetButtonIdNameFromEnum)> {
static const MethodInfo* get() {
static auto* eButtonId = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVRButtonId")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetButtonIdNameFromEnum", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eButtonId});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::GetControllerAxisTypeNameFromEnum
// Il2CppName: GetControllerAxisTypeNameFromEnum
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::StringW (OVR::OpenVR::CVRSystem::*)(::OVR::OpenVR::EVRControllerAxisType)>(&OVR::OpenVR::CVRSystem::GetControllerAxisTypeNameFromEnum)> {
static const MethodInfo* get() {
static auto* eAxisType = &::il2cpp_utils::GetClassFromName("OVR.OpenVR", "EVRControllerAxisType")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "GetControllerAxisTypeNameFromEnum", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eAxisType});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::IsInputAvailable
// Il2CppName: IsInputAvailable
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::IsInputAvailable)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "IsInputAvailable", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::IsSteamVRDrawingControllers
// Il2CppName: IsSteamVRDrawingControllers
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::IsSteamVRDrawingControllers)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "IsSteamVRDrawingControllers", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::ShouldApplicationPause
// Il2CppName: ShouldApplicationPause
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::ShouldApplicationPause)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "ShouldApplicationPause", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::ShouldApplicationReduceRenderingWork
// Il2CppName: ShouldApplicationReduceRenderingWork
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<bool (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::ShouldApplicationReduceRenderingWork)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "ShouldApplicationReduceRenderingWork", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::DriverDebugRequest
// Il2CppName: DriverDebugRequest
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<uint (OVR::OpenVR::CVRSystem::*)(uint, ::StringW, ::System::Text::StringBuilder*, uint)>(&OVR::OpenVR::CVRSystem::DriverDebugRequest)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
static auto* pchRequest = &::il2cpp_utils::GetClassFromName("System", "String")->byval_arg;
static auto* pchResponseBuffer = &::il2cpp_utils::GetClassFromName("System.Text", "StringBuilder")->byval_arg;
static auto* unResponseBufferSize = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "DriverDebugRequest", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex, pchRequest, pchResponseBuffer, unResponseBufferSize});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::PerformFirmwareUpdate
// Il2CppName: PerformFirmwareUpdate
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::OVR::OpenVR::EVRFirmwareError (OVR::OpenVR::CVRSystem::*)(uint)>(&OVR::OpenVR::CVRSystem::PerformFirmwareUpdate)> {
static const MethodInfo* get() {
static auto* unDeviceIndex = &::il2cpp_utils::GetClassFromName("System", "UInt32")->byval_arg;
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "PerformFirmwareUpdate", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{unDeviceIndex});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::AcknowledgeQuit_Exiting
// Il2CppName: AcknowledgeQuit_Exiting
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::AcknowledgeQuit_Exiting)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "AcknowledgeQuit_Exiting", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
// Writing MetadataGetter for method: OVR::OpenVR::CVRSystem::AcknowledgeQuit_UserPrompt
// Il2CppName: AcknowledgeQuit_UserPrompt
template<>
struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::CVRSystem::*)()>(&OVR::OpenVR::CVRSystem::AcknowledgeQuit_UserPrompt)> {
static const MethodInfo* get() {
return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::CVRSystem*), "AcknowledgeQuit_UserPrompt", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{});
}
};
|
; A131520: Number of partitions of the graph G_n (defined below) into "strokes".
; 2,6,12,22,40,74,140,270,528,1042,2068,4118,8216,16410,32796,65566,131104,262178,524324,1048614,2097192,4194346,8388652,16777262,33554480,67108914,134217780,268435510,536870968,1073741882,2147483708,4294967358,8589934656,17179869250,34359738436,68719476806,137438953544,274877907018,549755813964,1099511627854,2199023255632,4398046511186,8796093022292,17592186044502,35184372088920,70368744177754,140737488355420,281474976710750,562949953421408,1125899906842722,2251799813685348,4503599627370598,9007199254741096
mov $1,2
pow $1,$0
add $1,$0
mul $1,2
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 00
ldff(ff), a
ld a, 30
ldff(00), a
ld a, 01
ldff(4d), a
stop, 00
ld a, ff
ldff(45), a
ld b, 91
call lwaitly_b
ld hl, fe00
ld d, 10
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 0e
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 14
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 28
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 2e
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 34
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 48
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 4e
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 54
ld(hl++), a
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
xor a, a
ldff(0f), a
ei
ld a, 01
ldff(45), a
ld c, 41
ld a, 93
ldff(40), a
ld a, 06
ldff(43), a
.text@1000
lstatint:
nop
.text@1097
ldff a, (c)
and a, 03
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
|
db 0 ; species ID placeholder
db 60, 40, 80, 40, 60, 45
; hp atk def spd sat sdf
db GRASS, PSYCHIC ; type
db 90 ; catch rate
db 98 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/exeggcute/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm CURSE, ROLLOUT, TOXIC, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, PSYCHIC_M, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, DREAM_EATER, REST, ATTRACT, THIEF, NIGHTMARE, STRENGTH, FLASH
; end
|
object_const_def ; object_event constants
const LAKEOFRAGE_LANCE
const LAKEOFRAGE_GRAMPS
const LAKEOFRAGE_SUPER_NERD1
const LAKEOFRAGE_COOLTRAINER_F1
const LAKEOFRAGE_FISHER1
const LAKEOFRAGE_FISHER2
const LAKEOFRAGE_COOLTRAINER_M
const LAKEOFRAGE_COOLTRAINER_F2
const LAKEOFRAGE_GYARADOS
const LAKEOFRAGE_WESLEY
const LAKEOFRAGE_POKE_BALL1
const LAKEOFRAGE_POKE_BALL2
LakeOfRage_MapScripts:
db 2 ; scene scripts
scene_script .DummyScene0 ; unusable
scene_script .DummyScene1 ; unusable
db 2 ; callbacks
callback MAPCALLBACK_NEWMAP, .FlyPoint
callback MAPCALLBACK_OBJECTS, .Wesley
.DummyScene0:
end
.DummyScene1:
end
.FlyPoint:
setflag ENGINE_FLYPOINT_LAKE_OF_RAGE
return
.Wesley:
readvar VAR_WEEKDAY
ifequal WEDNESDAY, .WesleyAppears
disappear LAKEOFRAGE_WESLEY
return
.WesleyAppears:
appear LAKEOFRAGE_WESLEY
return
LakeOfRageLanceScript:
checkevent EVENT_REFUSED_TO_HELP_LANCE_AT_LAKE_OF_RAGE
iftrue .AskAgainForHelp
opentext
writetext UnknownText_0x70157
buttonsound
faceplayer
writetext UnknownText_0x701b4
yesorno
iffalse .RefusedToHelp
.AgreedToHelp:
writetext UnknownText_0x702c6
waitbutton
closetext
playsound SFX_WARP_TO
applymovement LAKEOFRAGE_LANCE, MovementData_0x70155
disappear LAKEOFRAGE_LANCE
clearevent EVENT_MAHOGANY_MART_LANCE_AND_DRAGONITE
setevent EVENT_DECIDED_TO_HELP_LANCE
setmapscene MAHOGANY_MART_1F, SCENE_MAHOGANYMART1F_LANCE_UNCOVERS_STAIRS
end
.RefusedToHelp:
writetext UnknownText_0x70371
waitbutton
closetext
setevent EVENT_REFUSED_TO_HELP_LANCE_AT_LAKE_OF_RAGE
end
.AskAgainForHelp:
faceplayer
opentext
writetext UnknownText_0x703a5
yesorno
iffalse .RefusedToHelp
sjump .AgreedToHelp
RedGyarados:
opentext
writetext UnknownText_0x703cb
pause 15
cry GYARADOS
closetext
loadwildmon GYARADOS, 30
loadvar VAR_BATTLETYPE, BATTLETYPE_SHINY
startbattle
ifequal LOSE, .NotBeaten
disappear LAKEOFRAGE_GYARADOS
.NotBeaten:
reloadmapafterbattle
opentext
giveitem RED_SCALE
waitsfx
writetext UnknownText_0x703df
playsound SFX_ITEM
waitsfx
itemnotify
closetext
setscene 0 ; Lake of Rage does not have a scene variable
appear LAKEOFRAGE_LANCE
end
LakeOfRageGrampsScript:
faceplayer
opentext
checkevent EVENT_CLEARED_ROCKET_HIDEOUT
iftrue .ClearedRocketHideout
writetext LakeOfRageGrampsText
waitbutton
closetext
end
.ClearedRocketHideout:
writetext LakeOfRageGrampsText_ClearedRocketHideout
waitbutton
closetext
end
LakeOfRageSuperNerdScript:
jumptextfaceplayer LakeOfRageSuperNerdText
LakeOfRageCooltrainerFScript:
jumptextfaceplayer LakeOfRageCooltrainerFText
LakeOfRageSign:
jumptext LakeOfRageSignText
MagikarpHouseSignScript:
opentext
writetext FishingGurusHouseSignText
checkevent EVENT_CLEARED_ROCKET_HIDEOUT
iftrue .MagikarpLengthRecord
waitbutton
closetext
end
.MagikarpLengthRecord:
buttonsound
special MagikarpHouseSign
closetext
end
TrainerFisherAndre:
trainer FISHER, ANDRE, EVENT_BEAT_FISHER_ANDRE, FisherAndreSeenText, FisherAndreBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext FisherAndreAfterBattleText
waitbutton
closetext
end
TrainerFisherRaymond:
trainer FISHER, RAYMOND, EVENT_BEAT_FISHER_RAYMOND, FisherRaymondSeenText, FisherRaymondBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext FisherRaymondAfterBattleText
waitbutton
closetext
end
TrainerCooltrainermAaron:
trainer COOLTRAINERM, AARON, EVENT_BEAT_COOLTRAINERM_AARON, CooltrainermAaronSeenText, CooltrainermAaronBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext CooltrainermAaronAfterBattleText
waitbutton
closetext
end
TrainerCooltrainerfLois:
trainer COOLTRAINERF, LOIS, EVENT_BEAT_COOLTRAINERF_LOIS, CooltrainerfLoisSeenText, CooltrainerfLoisBeatenText, 0, .Script
.Script:
endifjustbattled
opentext
writetext CooltrainerfLoisAfterBattleText
waitbutton
closetext
end
WesleyScript:
faceplayer
opentext
checkevent EVENT_GOT_BLACKBELT_FROM_WESLEY
iftrue WesleyWednesdayScript
readvar VAR_WEEKDAY
ifnotequal WEDNESDAY, WesleyNotWednesdayScript
checkevent EVENT_MET_WESLEY_OF_WEDNESDAY
iftrue .MetWesley
writetext MeetWesleyText
buttonsound
setevent EVENT_MET_WESLEY_OF_WEDNESDAY
.MetWesley:
writetext WesleyGivesGiftText
buttonsound
verbosegiveitem BLACKBELT
iffalse WesleyDoneScript
setevent EVENT_GOT_BLACKBELT_FROM_WESLEY
writetext WesleyGaveGiftText
waitbutton
closetext
end
WesleyWednesdayScript:
writetext WesleyWednesdayText
waitbutton
WesleyDoneScript:
closetext
end
WesleyNotWednesdayScript:
writetext WesleyNotWednesdayText
waitbutton
closetext
end
LakeOfRageElixer:
itemball ELIXER
LakeOfRageTMDetect:
tmhmball TM_DETECT
LakeOfRageHiddenFullRestore:
hiddenitem FULL_RESTORE, EVENT_LAKE_OF_RAGE_HIDDEN_FULL_RESTORE
LakeOfRageHiddenRareCandy:
hiddenitem RARE_CANDY, EVENT_LAKE_OF_RAGE_HIDDEN_RARE_CANDY
LakeOfRageHiddenMaxPotion:
hiddenitem MAX_POTION, EVENT_LAKE_OF_RAGE_HIDDEN_MAX_POTION
MovementData_0x70155:
teleport_from
step_end
UnknownText_0x70157:
text "This lake is full"
line "of GYARADOS but"
cont "nothing else…"
para "So the MAGIKARP"
line "are being forced"
cont "to evolve…"
done
UnknownText_0x701b4:
text "Did you come here"
line "because of the"
cont "rumors?"
para "You're <PLAYER>?"
line "I'm LANCE, a"
cont "trainer like you."
para "I heard some ru-"
line "mors, so I came to"
cont "investigate…"
para "I saw the way you"
line "battled earlier,"
cont "<PLAY_G>."
para "I can tell that"
line "you're a trainer"
para "with considerable"
line "skill."
para "If you don't mind,"
line "could you help me"
cont "investigate?"
done
UnknownText_0x702c6:
text "LANCE: Excellent!"
para "It seems that the"
line "LAKE's MAGIKARP"
para "are being forced"
line "to evolve."
para "A mysterious radio"
line "broadcast coming"
para "from MAHOGANY is"
line "the cause."
para "I'll be waiting"
line "for you, <PLAY_G>."
done
UnknownText_0x70371:
text "Oh… Well, if you"
line "change your mind,"
cont "please help me."
done
UnknownText_0x703a5:
text "LANCE: Hm? Are you"
line "going to help me?"
done
UnknownText_0x703cb:
text "GYARADOS: Gyashaa!"
done
UnknownText_0x703df:
text "<PLAYER> obtained a"
line "RED SCALE."
done
LakeOfRageGrampsText:
text "The GYARADOS are"
line "angry!"
para "It's a bad omen!"
done
LakeOfRageGrampsText_ClearedRocketHideout:
text "Hahah! The MAGI-"
line "KARP are biting!"
done
LakeOfRageSuperNerdText:
text "I heard this lake"
line "was made by ram-"
cont "paging GYARADOS."
para "I wonder if there"
line "is any connection"
para "to their mass out-"
line "break now?"
done
LakeOfRageCooltrainerFText:
text "Did my eyes de-"
line "ceive me? I saw a"
para "red GYARADOS in"
line "the LAKE…"
para "But I thought"
line "GYARADOS were"
cont "usually blue?"
done
FisherAndreSeenText:
text "Let me battle with"
line "the #MON I just"
cont "caught!"
done
FisherAndreBeatenText:
text "I might be an ex-"
line "pert angler, but"
para "I stink as a #-"
line "MON trainer…"
done
FisherAndreAfterBattleText:
text "I won't lose as an"
line "angler! I catch"
cont "#MON all day."
done
FisherRaymondSeenText:
text "No matter what I"
line "do, all I catch"
para "are the same #-"
line "MON…"
done
FisherRaymondBeatenText:
text "My line's all"
line "tangled up…"
done
FisherRaymondAfterBattleText:
text "Why can't I catch"
line "any good #MON?"
done
CooltrainermAaronSeenText:
text "If a trainer spots"
line "another trainer,"
para "he has to make a"
line "challenge."
para "That is our"
line "destiny."
done
CooltrainermAaronBeatenText:
text "Whew…"
line "Good battle."
done
CooltrainermAaronAfterBattleText:
text "#MON and their"
line "trainer become"
para "powerful through"
line "constant battling."
done
CooltrainerfLoisSeenText:
text "What happened to"
line "the red GYARADOS?"
para "It's gone?"
para "Oh, darn. I came"
line "here for nothing?"
para "I know--let's"
line "battle!"
done
CooltrainerfLoisBeatenText:
text "Good going!"
done
CooltrainerfLoisAfterBattleText:
text "Come to think of"
line "it, I've seen a"
cont "pink BUTTERFREE."
done
MeetWesleyText:
text "WESLEY: Well, how"
line "do you do?"
para "Seeing as how it's"
line "Wednesday today,"
para "I'm WESLEY of"
line "Wednesday."
done
WesleyGivesGiftText:
text "Pleased to meet"
line "you. Please take a"
cont "souvenir."
done
WesleyGaveGiftText:
text "WESLEY: BLACKBELT"
line "beefs up the power"
cont "of fighting moves."
done
WesleyWednesdayText:
text "WESLEY: Since you"
line "found me, you must"
para "have met my broth-"
line "ers and sisters."
para "Or did you just"
line "get lucky?"
done
WesleyNotWednesdayText:
text "WESLEY: Today's"
line "not Wednesday."
cont "That's too bad."
done
LakeOfRageSignText:
text "LAKE OF RAGE,"
line "also known as"
cont "GYARADOS LAKE."
done
FishingGurusHouseSignText:
text "FISHING GURU'S"
line "HOUSE"
done
LakeOfRage_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 7, 3, LAKE_OF_RAGE_HIDDEN_POWER_HOUSE, 1
warp_event 27, 31, LAKE_OF_RAGE_MAGIKARP_HOUSE, 1
db 0 ; coord events
db 5 ; bg events
bg_event 21, 27, BGEVENT_READ, LakeOfRageSign
bg_event 25, 31, BGEVENT_READ, MagikarpHouseSignScript
bg_event 11, 28, BGEVENT_ITEM, LakeOfRageHiddenFullRestore
bg_event 4, 4, BGEVENT_ITEM, LakeOfRageHiddenRareCandy
bg_event 35, 5, BGEVENT_ITEM, LakeOfRageHiddenMaxPotion
db 12 ; object events
object_event 21, 28, SPRITE_LANCE, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, LakeOfRageLanceScript, EVENT_LAKE_OF_RAGE_LANCE
object_event 20, 26, SPRITE_GRAMPS, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, LakeOfRageGrampsScript, -1
object_event 36, 13, SPRITE_SUPER_NERD, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, LakeOfRageSuperNerdScript, -1
object_event 25, 29, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, LakeOfRageCooltrainerFScript, -1
object_event 30, 23, SPRITE_FISHER, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, TrainerFisherAndre, EVENT_LAKE_OF_RAGE_CIVILIANS
object_event 24, 26, SPRITE_FISHER, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_TRAINER, 1, TrainerFisherRaymond, EVENT_LAKE_OF_RAGE_CIVILIANS
object_event 4, 15, SPRITE_COOLTRAINER_M, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_TRAINER, 1, TrainerCooltrainermAaron, EVENT_LAKE_OF_RAGE_CIVILIANS
object_event 36, 7, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_TRAINER, 0, TrainerCooltrainerfLois, EVENT_LAKE_OF_RAGE_CIVILIANS
object_event 18, 22, SPRITE_GYARADOS, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, RedGyarados, EVENT_LAKE_OF_RAGE_RED_GYARADOS
object_event 4, 4, SPRITE_SUPER_NERD, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, WesleyScript, EVENT_LAKE_OF_RAGE_WESLEY_OF_WEDNESDAY
object_event 7, 10, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, LakeOfRageElixer, EVENT_LAKE_OF_RAGE_ELIXER
object_event 35, 2, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_TMHMBALL, 0, LakeOfRageTMDetect, EVENT_LAKE_OF_RAGE_TM_DETECT
|
.export _lvl2
_lvl2:
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 66, 66, 66, 66, 66, 66, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107
.byte 66, 66, 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 5, 5
; Sprites
.byte 55, 4, 91, 4, 150, 4, 153, 1, 156, 4, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 66, 66, 105, 134, 134, 134, 134, 134, 135, 134, 134, 134, 134, 134, 5, 5
.byte 66, 66, 105, 134, 134, 134, 134, 134, 143, 134, 134, 134, 134, 134, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
; Sprites
.byte 69, 3, 75, 3, 104, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 66, 66, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 66, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 1, 1, 134, 134, 1, 1, 1, 134, 134, 1, 1, 5, 5
.byte 66, 66, 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
.byte 66, 66, 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 104, 106
.byte 66, 66, 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 104, 66
; Sprites
.byte 40, 4, 72, 0, 120, 4, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.include "levels/position_overrides/lvl2_2_4.asm"
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 66, 66, 66, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
; Sprites
.byte 51, 3, 105, 3, 115, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 5, 5, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 93, 93, 93
.byte 5, 5, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
; Sprites
.byte 67, 2, 137, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 104, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 106, 66, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 106, 106, 66, 66, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 1, 106, 66, 66, 107, 107, 66, 66
.byte 5, 5, 1, 1, 1, 1, 1, 1, 106, 66, 66, 107, 1, 1, 104, 66
.byte 5, 5, 1, 1, 1, 1, 1, 106, 66, 66, 107, 1, 1, 1, 104, 66
.byte 5, 5, 106, 106, 106, 106, 106, 66, 66, 105, 1, 1, 1, 1, 104, 66
.byte 5, 5, 104, 66, 66, 66, 66, 66, 66, 105, 1, 1, 1, 1, 104, 66
.byte 106, 106, 66, 66, 66, 66, 66, 66, 66, 66, 106, 106, 106, 106, 66, 66
.byte 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66
; Sprites
.byte 41, 2, 100, 2, 140, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.byte 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
; Sprites
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
.byte 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
; End sprite data
;Overrides
.byte $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0, $f0
.byte 0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0,0, 0, 0, 0
; No last room because rom space |
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.16.27026.1
TITLE Z:\Sources\Lunor\Repos\rougemeilland\Palmtree.Math.Core.Implements\Palmtree.Math.Core.Implements\TEST_op_BitwiseAnd.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES
msvcjmc SEGMENT
__7B7A869E_ctype@h DB 01H
__457DD326_basetsd@h DB 01H
__4384A2D9_corecrt_memcpy_s@h DB 01H
__4E51A221_corecrt_wstring@h DB 01H
__2140C079_string@h DB 01H
__1887E595_winnt@h DB 01H
__9FC7C64B_processthreadsapi@h DB 01H
__FA470AEC_memoryapi@h DB 01H
__F37DAFF1_winerror@h DB 01H
__7A450CCC_winbase@h DB 01H
__B4B40122_winioctl@h DB 01H
__86261D59_stralign@h DB 01H
__1C66ECB2_pmc_debug@h DB 01H
__753CF642_test_op_bitwiseand@c DB 01H
msvcjmc ENDS
PUBLIC _TEST_PMC_BitwiseAnd_I_X
PUBLIC _TEST_PMC_BitwiseAnd_L_X
PUBLIC _TEST_PMC_BitwiseAnd_X_I
PUBLIC _TEST_PMC_BitwiseAnd_X_L
PUBLIC _TEST_PMC_BitwiseAnd_X_X
PUBLIC __JustMyCode_Default
EXTRN _TEST_Assert:PROC
EXTRN _FormatTestLabel:PROC
EXTRN _FormatTestMesssage:PROC
EXTRN @_RTC_CheckStackVars@8:PROC
EXTRN @__CheckForDebuggerJustMyCode@4:PROC
EXTRN @__security_check_cookie@4:PROC
EXTRN __RTC_CheckEsp:PROC
EXTRN __RTC_InitBase:PROC
EXTRN __RTC_Shutdown:PROC
EXTRN ___security_cookie:DWORD
; COMDAT rtc$TMZ
rtc$TMZ SEGMENT
__RTC_Shutdown.rtc$TMZ DD FLAT:__RTC_Shutdown
rtc$TMZ ENDS
; COMDAT rtc$IMZ
rtc$IMZ SEGMENT
__RTC_InitBase.rtc$IMZ DD FLAT:__RTC_InitBase
rtc$IMZ ENDS
_DATA SEGMENT
$SG94545 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94546 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'I', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94547 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'I', 00H, '_', 00H, 'X', 00H, 'n0', 0a9H
DB '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH
DB 090H, 08aH, '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H
DB 00H
$SG94548 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'I', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94549 DB 0c7H, '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H
DB 'N', 0f4H, 081H, 'W0j0D0', 00H, 00H
ORG $+2
$SG94550 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'I', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94571 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94572 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'L', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94573 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'L', 00H, '_', 00H, 'X', 00H, 'n0', 0a9H
DB '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH
DB 090H, 08aH, '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H
DB 00H
$SG94574 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'L', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94575 DB 0c7H, '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H
DB 'N', 0f4H, 081H, 'W0j0D0', 00H, 00H
ORG $+2
$SG94576 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'L', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94597 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94598 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94599 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, 'n0', 0a9H
DB '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH
DB 090H, 08aH, '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H
DB 00H
$SG94600 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94601 DB 0c7H, '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H
DB 'N', 0f4H, 081H, 'W0j0D0', 00H, 00H
ORG $+2
$SG94602 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'I', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94623 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94624 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'L', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94625 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'L', 00H, 'n0', 0a9H
DB '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH
DB 090H, 08aH, '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H
DB 00H
$SG94626 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'L', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94627 DB 0c7H, '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H
DB 'N', 0f4H, 081H, 'W0j0D0', 00H, 00H
ORG $+2
$SG94628 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'L', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94658 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94659 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94660 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'F', 00H, 'r', 00H
DB 'o', 00H, 'm', 00H, 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A'
DB 00H, 'r', 00H, 'r', 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H
DB '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH
DB '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94661 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94662 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, 'n0', 0a9H
DB '_0^', 0b3H, '0', 0fcH, '0', 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH
DB 090H, 08aH, '0g0o0j0D0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H
DB 00H
$SG94663 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+6
$SG94664 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'T', 00H, 'o', 00H
DB 'B', 00H, 'y', 00H, 't', 00H, 'e', 00H, 'A', 00H, 'r', 00H, 'r'
DB 00H, 'a', 00H, 'y', 00H, 'n0', 0a9H, '_0^', 0b3H, '0', 0fcH, '0'
DB 0c9H, '0L0', 01fH, 'g', 085H, '_', 01aH, 090H, 08aH, '0g0o0j0D'
DB '0(', 00H, '%', 00H, 'd', 00H, ')', 00H, 00H, 00H
ORG $+2
$SG94665 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
ORG $+2
$SG94666 DB 0c7H, '0', 0fcH, '0', 0bfH, '0n0', 085H, 'Q', 0b9H, '[L0', 00H
DB 'N', 0f4H, 081H, 'W0j0D0', 00H, 00H
ORG $+2
$SG94667 DB 'P', 00H, 'M', 00H, 'C', 00H, '_', 00H, 'B', 00H, 'i', 00H
DB 't', 00H, 'w', 00H, 'i', 00H, 's', 00H, 'e', 00H, 'A', 00H, 'n'
DB 00H, 'd', 00H, '_', 00H, 'X', 00H, '_', 00H, 'X', 00H, ' ', 00H
DB '(', 00H, '%', 00H, 'd', 00H, '.', 00H, '%', 00H, 'd', 00H, ')'
DB 00H, 00H, 00H
_DATA ENDS
; Function compile flags: /Odt
; COMDAT __JustMyCode_Default
_TEXT SEGMENT
__JustMyCode_Default PROC ; COMDAT
push ebp
mov ebp, esp
pop ebp
ret 0
__JustMyCode_Default ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_debug.h
_TEXT SEGMENT
_buffer1$ = 8 ; size = 4
_count1$ = 12 ; size = 4
_buffer2$ = 16 ; size = 4
_count2$ = 20 ; size = 4
__EQUALS_MEMORY PROC
; 155 : {
push ebp
mov ebp, esp
mov ecx, OFFSET __1C66ECB2_pmc_debug@h
call @__CheckForDebuggerJustMyCode@4
; 156 : if (count1 != count2)
mov eax, DWORD PTR _count1$[ebp]
cmp eax, DWORD PTR _count2$[ebp]
je SHORT $LN2@EQUALS_MEM
; 157 : return (-1);
or eax, -1
jmp SHORT $LN1@EQUALS_MEM
$LN2@EQUALS_MEM:
; 158 : while (count1 > 0)
cmp DWORD PTR _count1$[ebp], 0
jbe SHORT $LN3@EQUALS_MEM
; 159 : {
; 160 : if (*buffer1 != *buffer2)
mov ecx, DWORD PTR _buffer1$[ebp]
movzx edx, BYTE PTR [ecx]
mov eax, DWORD PTR _buffer2$[ebp]
movzx ecx, BYTE PTR [eax]
cmp edx, ecx
je SHORT $LN5@EQUALS_MEM
; 161 : return (-1);
or eax, -1
jmp SHORT $LN1@EQUALS_MEM
$LN5@EQUALS_MEM:
; 162 : ++buffer1;
mov edx, DWORD PTR _buffer1$[ebp]
add edx, 1
mov DWORD PTR _buffer1$[ebp], edx
; 163 : ++buffer2;
mov eax, DWORD PTR _buffer2$[ebp]
add eax, 1
mov DWORD PTR _buffer2$[ebp], eax
; 164 : --count1;
mov ecx, DWORD PTR _count1$[ebp]
sub ecx, 1
mov DWORD PTR _count1$[ebp], ecx
; 165 : }
jmp SHORT $LN2@EQUALS_MEM
$LN3@EQUALS_MEM:
; 166 : return (0);
xor eax, eax
$LN1@EQUALS_MEM:
; 167 : }
cmp ebp, esp
call __RTC_CheckEsp
pop ebp
ret 0
__EQUALS_MEMORY ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_bitwiseand.c
_TEXT SEGMENT
tv176 = -352 ; size = 4
tv161 = -348 ; size = 4
tv142 = -344 ; size = 4
tv92 = -340 ; size = 4
tv74 = -336 ; size = 4
_w_result$ = -332 ; size = 4
_v_result$ = -328 ; size = 4
_u_result$ = -324 ; size = 4
_result$ = -320 ; size = 4
_actual_w_buf_size$ = -312 ; size = 4
_actual_w_buf$ = -300 ; size = 256
_w$ = -36 ; size = 4
_v$ = -24 ; size = 4
_u$ = -12 ; size = 4
__$ArrayPad$ = -4 ; size = 4
_env$ = 8 ; size = 4
_ep$ = 12 ; size = 4
_no$ = 16 ; size = 4
_u_buf$ = 20 ; size = 4
_u_buf_size$ = 24 ; size = 4
_v_buf$ = 28 ; size = 4
_v_buf_size$ = 32 ; size = 4
_desired_w_buf$ = 36 ; size = 4
_desired_w_buf_size$ = 40 ; size = 4
_TEST_PMC_BitwiseAnd_X_X PROC
; 92 : {
push ebp
mov ebp, esp
sub esp, 352 ; 00000160H
push esi
push edi
lea edi, DWORD PTR [ebp-352]
mov ecx, 88 ; 00000058H
mov eax, -858993460 ; ccccccccH
rep stosd
mov eax, DWORD PTR ___security_cookie
xor eax, ebp
mov DWORD PTR __$ArrayPad$[ebp], eax
mov ecx, OFFSET __753CF642_test_op_bitwiseand@c
call @__CheckForDebuggerJustMyCode@4
; 93 : HANDLE u;
; 94 : HANDLE v;
; 95 : HANDLE w;
; 96 : unsigned char actual_w_buf[256];
; 97 : size_t actual_w_buf_size;
; 98 : PMC_STATUS_CODE result;
; 99 : PMC_STATUS_CODE u_result;
; 100 : PMC_STATUS_CODE v_result;
; 101 : PMC_STATUS_CODE w_result;
; 102 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_X (%d.%d)", no, 1), (u_result = ep->PMC_FromByteArray(u_buf, u_buf_size, &u)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", u_result));
mov esi, esp
lea eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _u_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _u_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _u_result$[ebp], eax
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN6@TEST_PMC_B
mov DWORD PTR tv74[ebp], 1
jmp SHORT $LN7@TEST_PMC_B
$LN6@TEST_PMC_B:
mov DWORD PTR tv74[ebp], 0
$LN7@TEST_PMC_B:
mov edx, DWORD PTR _u_result$[ebp]
push edx
push OFFSET $SG94658
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv74[ebp]
push eax
push 1
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94659
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 103 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_X (%d.%d)", no, 2), (v_result = ep->PMC_FromByteArray(v_buf, v_buf_size, &v)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", v_result));
mov esi, esp
lea eax, DWORD PTR _v$[ebp]
push eax
mov ecx, DWORD PTR _v_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _v_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _v_result$[ebp], eax
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN8@TEST_PMC_B
mov DWORD PTR tv92[ebp], 1
jmp SHORT $LN9@TEST_PMC_B
$LN8@TEST_PMC_B:
mov DWORD PTR tv92[ebp], 0
$LN9@TEST_PMC_B:
mov edx, DWORD PTR _v_result$[ebp]
push edx
push OFFSET $SG94660
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv92[ebp]
push eax
push 2
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94661
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 104 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_X (%d.%d)", no, 3), (w_result = ep->PMC_BitwiseAnd_X_X(u, v, &w)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_BitwiseAnd_X_Xの復帰コードが期待通りではない(%d)", w_result));
mov esi, esp
lea eax, DWORD PTR _w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+164]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _w_result$[ebp], eax
cmp DWORD PTR _w_result$[ebp], 0
jne SHORT $LN10@TEST_PMC_B
mov DWORD PTR tv142[ebp], 1
jmp SHORT $LN11@TEST_PMC_B
$LN10@TEST_PMC_B:
mov DWORD PTR tv142[ebp], 0
$LN11@TEST_PMC_B:
mov edx, DWORD PTR _w_result$[ebp]
push edx
push OFFSET $SG94662
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv142[ebp]
push eax
push 3
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94663
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 105 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_X (%d.%d)", no, 4), (result = ep->PMC_ToByteArray(w, actual_w_buf, sizeof(actual_w_buf), &actual_w_buf_size)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_ToByteArrayの復帰コードが期待通りではない(%d)", result));
mov esi, esp
lea eax, DWORD PTR _actual_w_buf_size$[ebp]
push eax
push 256 ; 00000100H
lea ecx, DWORD PTR _actual_w_buf$[ebp]
push ecx
mov edx, DWORD PTR _w$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+28]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
jne SHORT $LN12@TEST_PMC_B
mov DWORD PTR tv161[ebp], 1
jmp SHORT $LN13@TEST_PMC_B
$LN12@TEST_PMC_B:
mov DWORD PTR tv161[ebp], 0
$LN13@TEST_PMC_B:
mov edx, DWORD PTR _result$[ebp]
push edx
push OFFSET $SG94664
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv161[ebp]
push eax
push 4
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94665
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 106 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_X (%d.%d)", no, 5), _EQUALS_MEMORY(actual_w_buf, actual_w_buf_size, desired_w_buf, desired_w_buf_size) == 0, L"データの内容が一致しない");
mov eax, DWORD PTR _desired_w_buf_size$[ebp]
push eax
mov ecx, DWORD PTR _desired_w_buf$[ebp]
push ecx
mov edx, DWORD PTR _actual_w_buf_size$[ebp]
push edx
lea eax, DWORD PTR _actual_w_buf$[ebp]
push eax
call __EQUALS_MEMORY
add esp, 16 ; 00000010H
test eax, eax
jne SHORT $LN14@TEST_PMC_B
mov DWORD PTR tv176[ebp], 1
jmp SHORT $LN15@TEST_PMC_B
$LN14@TEST_PMC_B:
mov DWORD PTR tv176[ebp], 0
$LN15@TEST_PMC_B:
push OFFSET $SG94666
mov ecx, DWORD PTR tv176[ebp]
push ecx
push 5
mov edx, DWORD PTR _no$[ebp]
push edx
push OFFSET $SG94667
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov eax, DWORD PTR _env$[ebp]
push eax
call _TEST_Assert
add esp, 16 ; 00000010H
; 107 : if (w_result == PMC_STATUS_OK)
cmp DWORD PTR _w_result$[ebp], 0
jne SHORT $LN2@TEST_PMC_B
; 108 : ep->PMC_Dispose(w);
mov esi, esp
mov ecx, DWORD PTR _w$[ebp]
push ecx
mov edx, DWORD PTR _ep$[ebp]
mov eax, DWORD PTR [edx+16]
call eax
cmp esi, esp
call __RTC_CheckEsp
$LN2@TEST_PMC_B:
; 109 : if (v_result == PMC_STATUS_OK)
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN3@TEST_PMC_B
; 110 : ep->PMC_Dispose(v);
mov esi, esp
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _ep$[ebp]
mov eax, DWORD PTR [edx+16]
call eax
cmp esi, esp
call __RTC_CheckEsp
$LN3@TEST_PMC_B:
; 111 : if (u_result == PMC_STATUS_OK)
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN1@TEST_PMC_B
; 112 : ep->PMC_Dispose(u);
mov esi, esp
mov ecx, DWORD PTR _u$[ebp]
push ecx
mov edx, DWORD PTR _ep$[ebp]
mov eax, DWORD PTR [edx+16]
call eax
cmp esi, esp
call __RTC_CheckEsp
$LN1@TEST_PMC_B:
; 113 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN22@TEST_PMC_B
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
mov ecx, DWORD PTR __$ArrayPad$[ebp]
xor ecx, ebp
call @__security_check_cookie@4
add esp, 352 ; 00000160H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 1
$LN22@TEST_PMC_B:
DD 5
DD $LN21@TEST_PMC_B
$LN21@TEST_PMC_B:
DD -12 ; fffffff4H
DD 4
DD $LN16@TEST_PMC_B
DD -24 ; ffffffe8H
DD 4
DD $LN17@TEST_PMC_B
DD -36 ; ffffffdcH
DD 4
DD $LN18@TEST_PMC_B
DD -300 ; fffffed4H
DD 256 ; 00000100H
DD $LN19@TEST_PMC_B
DD -312 ; fffffec8H
DD 4
DD $LN20@TEST_PMC_B
$LN20@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 98 ; 00000062H
DB 117 ; 00000075H
DB 102 ; 00000066H
DB 95 ; 0000005fH
DB 115 ; 00000073H
DB 105 ; 00000069H
DB 122 ; 0000007aH
DB 101 ; 00000065H
DB 0
$LN19@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 95 ; 0000005fH
DB 98 ; 00000062H
DB 117 ; 00000075H
DB 102 ; 00000066H
DB 0
$LN18@TEST_PMC_B:
DB 119 ; 00000077H
DB 0
$LN17@TEST_PMC_B:
DB 118 ; 00000076H
DB 0
$LN16@TEST_PMC_B:
DB 117 ; 00000075H
DB 0
_TEST_PMC_BitwiseAnd_X_X ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_bitwiseand.c
_TEXT SEGMENT
tv134 = -48 ; size = 4
tv92 = -44 ; size = 4
tv74 = -40 ; size = 4
_u_result$ = -36 ; size = 4
_result$ = -32 ; size = 4
_actual_w$ = -24 ; size = 8
_u$ = -8 ; size = 4
_env$ = 8 ; size = 4
_ep$ = 12 ; size = 4
_no$ = 16 ; size = 4
_u_buf$ = 20 ; size = 4
_u_buf_size$ = 24 ; size = 4
_v$ = 28 ; size = 8
_desired_w$ = 36 ; size = 8
_TEST_PMC_BitwiseAnd_X_L PROC
; 79 : {
push ebp
mov ebp, esp
sub esp, 48 ; 00000030H
push esi
push edi
lea edi, DWORD PTR [ebp-48]
mov ecx, 12 ; 0000000cH
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __753CF642_test_op_bitwiseand@c
call @__CheckForDebuggerJustMyCode@4
; 80 : HANDLE u;
; 81 : unsigned __int64 actual_w;
; 82 : PMC_STATUS_CODE result;
; 83 : PMC_STATUS_CODE u_result;
; 84 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_L (%d.%d)", no, 1), (u_result = ep->PMC_FromByteArray(u_buf, u_buf_size, &u)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", u_result));
mov esi, esp
lea eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _u_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _u_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _u_result$[ebp], eax
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN4@TEST_PMC_B
mov DWORD PTR tv74[ebp], 1
jmp SHORT $LN5@TEST_PMC_B
$LN4@TEST_PMC_B:
mov DWORD PTR tv74[ebp], 0
$LN5@TEST_PMC_B:
mov edx, DWORD PTR _u_result$[ebp]
push edx
push OFFSET $SG94623
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv74[ebp]
push eax
push 1
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94624
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 85 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_L (%d.%d)", no, 2), (result = ep->PMC_BitwiseAnd_X_L(u, v, &actual_w)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_BitwiseAnd_X_Lの復帰コードが期待通りではない(%d)", result));
mov esi, esp
lea eax, DWORD PTR _actual_w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp+4]
push ecx
mov edx, DWORD PTR _v$[ebp]
push edx
mov eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _ep$[ebp]
mov edx, DWORD PTR [ecx+160]
call edx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
jne SHORT $LN6@TEST_PMC_B
mov DWORD PTR tv92[ebp], 1
jmp SHORT $LN7@TEST_PMC_B
$LN6@TEST_PMC_B:
mov DWORD PTR tv92[ebp], 0
$LN7@TEST_PMC_B:
mov eax, DWORD PTR _result$[ebp]
push eax
push OFFSET $SG94625
call _FormatTestMesssage
add esp, 8
push eax
mov ecx, DWORD PTR tv92[ebp]
push ecx
push 2
mov edx, DWORD PTR _no$[ebp]
push edx
push OFFSET $SG94626
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov eax, DWORD PTR _env$[ebp]
push eax
call _TEST_Assert
add esp, 16 ; 00000010H
; 86 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_L (%d.%d)", no, 3), actual_w == desired_w, L"データの内容が一致しない");
mov ecx, DWORD PTR _actual_w$[ebp]
cmp ecx, DWORD PTR _desired_w$[ebp]
jne SHORT $LN8@TEST_PMC_B
mov edx, DWORD PTR _actual_w$[ebp+4]
cmp edx, DWORD PTR _desired_w$[ebp+4]
jne SHORT $LN8@TEST_PMC_B
mov DWORD PTR tv134[ebp], 1
jmp SHORT $LN9@TEST_PMC_B
$LN8@TEST_PMC_B:
mov DWORD PTR tv134[ebp], 0
$LN9@TEST_PMC_B:
push OFFSET $SG94627
mov eax, DWORD PTR tv134[ebp]
push eax
push 3
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94628
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 87 : if (u_result == PMC_STATUS_OK)
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN1@TEST_PMC_B
; 88 : ep->PMC_Dispose(u);
mov esi, esp
mov eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _ep$[ebp]
mov edx, DWORD PTR [ecx+16]
call edx
cmp esi, esp
call __RTC_CheckEsp
$LN1@TEST_PMC_B:
; 89 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN13@TEST_PMC_B
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
add esp, 48 ; 00000030H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 3
$LN13@TEST_PMC_B:
DD 2
DD $LN12@TEST_PMC_B
$LN12@TEST_PMC_B:
DD -8 ; fffffff8H
DD 4
DD $LN10@TEST_PMC_B
DD -24 ; ffffffe8H
DD 8
DD $LN11@TEST_PMC_B
$LN11@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 0
$LN10@TEST_PMC_B:
DB 117 ; 00000075H
DB 0
_TEST_PMC_BitwiseAnd_X_L ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_bitwiseand.c
_TEXT SEGMENT
tv134 = -44 ; size = 4
tv92 = -40 ; size = 4
tv74 = -36 ; size = 4
_u_result$ = -32 ; size = 4
_result$ = -28 ; size = 4
_actual_w$ = -20 ; size = 4
_u$ = -8 ; size = 4
_env$ = 8 ; size = 4
_ep$ = 12 ; size = 4
_no$ = 16 ; size = 4
_u_buf$ = 20 ; size = 4
_u_buf_size$ = 24 ; size = 4
_v$ = 28 ; size = 4
_desired_w$ = 32 ; size = 4
_TEST_PMC_BitwiseAnd_X_I PROC
; 66 : {
push ebp
mov ebp, esp
sub esp, 44 ; 0000002cH
push esi
push edi
lea edi, DWORD PTR [ebp-44]
mov ecx, 11 ; 0000000bH
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __753CF642_test_op_bitwiseand@c
call @__CheckForDebuggerJustMyCode@4
; 67 : HANDLE u;
; 68 : unsigned __int32 actual_w;
; 69 : PMC_STATUS_CODE result;
; 70 : PMC_STATUS_CODE u_result;
; 71 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_I (%d.%d)", no, 1), (u_result = ep->PMC_FromByteArray(u_buf, u_buf_size, &u)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", u_result));
mov esi, esp
lea eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _u_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _u_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _u_result$[ebp], eax
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN4@TEST_PMC_B
mov DWORD PTR tv74[ebp], 1
jmp SHORT $LN5@TEST_PMC_B
$LN4@TEST_PMC_B:
mov DWORD PTR tv74[ebp], 0
$LN5@TEST_PMC_B:
mov edx, DWORD PTR _u_result$[ebp]
push edx
push OFFSET $SG94597
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv74[ebp]
push eax
push 1
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94598
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 72 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_I (%d.%d)", no, 2), (result = ep->PMC_BitwiseAnd_X_I(u, v, &actual_w)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_BitwiseAnd_X_Iの復帰コードが期待通りではない(%d)", result));
mov esi, esp
lea eax, DWORD PTR _actual_w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+156]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
jne SHORT $LN6@TEST_PMC_B
mov DWORD PTR tv92[ebp], 1
jmp SHORT $LN7@TEST_PMC_B
$LN6@TEST_PMC_B:
mov DWORD PTR tv92[ebp], 0
$LN7@TEST_PMC_B:
mov edx, DWORD PTR _result$[ebp]
push edx
push OFFSET $SG94599
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv92[ebp]
push eax
push 2
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94600
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 73 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_X_I (%d.%d)", no, 3), actual_w == desired_w, L"データの内容が一致しない");
mov eax, DWORD PTR _actual_w$[ebp]
cmp eax, DWORD PTR _desired_w$[ebp]
jne SHORT $LN8@TEST_PMC_B
mov DWORD PTR tv134[ebp], 1
jmp SHORT $LN9@TEST_PMC_B
$LN8@TEST_PMC_B:
mov DWORD PTR tv134[ebp], 0
$LN9@TEST_PMC_B:
push OFFSET $SG94601
mov ecx, DWORD PTR tv134[ebp]
push ecx
push 3
mov edx, DWORD PTR _no$[ebp]
push edx
push OFFSET $SG94602
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov eax, DWORD PTR _env$[ebp]
push eax
call _TEST_Assert
add esp, 16 ; 00000010H
; 74 : if (u_result == PMC_STATUS_OK)
cmp DWORD PTR _u_result$[ebp], 0
jne SHORT $LN1@TEST_PMC_B
; 75 : ep->PMC_Dispose(u);
mov esi, esp
mov ecx, DWORD PTR _u$[ebp]
push ecx
mov edx, DWORD PTR _ep$[ebp]
mov eax, DWORD PTR [edx+16]
call eax
cmp esi, esp
call __RTC_CheckEsp
$LN1@TEST_PMC_B:
; 76 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN13@TEST_PMC_B
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
add esp, 44 ; 0000002cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 3
$LN13@TEST_PMC_B:
DD 2
DD $LN12@TEST_PMC_B
$LN12@TEST_PMC_B:
DD -8 ; fffffff8H
DD 4
DD $LN10@TEST_PMC_B
DD -20 ; ffffffecH
DD 4
DD $LN11@TEST_PMC_B
$LN11@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 0
$LN10@TEST_PMC_B:
DB 117 ; 00000075H
DB 0
_TEST_PMC_BitwiseAnd_X_I ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_bitwiseand.c
_TEXT SEGMENT
tv134 = -48 ; size = 4
tv92 = -44 ; size = 4
tv74 = -40 ; size = 4
_v_result$ = -36 ; size = 4
_result$ = -32 ; size = 4
_actual_w$ = -24 ; size = 8
_v$ = -8 ; size = 4
_env$ = 8 ; size = 4
_ep$ = 12 ; size = 4
_no$ = 16 ; size = 4
_u$ = 20 ; size = 8
_v_buf$ = 28 ; size = 4
_v_buf_size$ = 32 ; size = 4
_desired_w$ = 36 ; size = 8
_TEST_PMC_BitwiseAnd_L_X PROC
; 53 : {
push ebp
mov ebp, esp
sub esp, 48 ; 00000030H
push esi
push edi
lea edi, DWORD PTR [ebp-48]
mov ecx, 12 ; 0000000cH
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __753CF642_test_op_bitwiseand@c
call @__CheckForDebuggerJustMyCode@4
; 54 : HANDLE v;
; 55 : unsigned __int64 actual_w;
; 56 : PMC_STATUS_CODE result;
; 57 : PMC_STATUS_CODE v_result;
; 58 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_L_X (%d.%d)", no, 1), (v_result = ep->PMC_FromByteArray(v_buf, v_buf_size, &v)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", v_result));
mov esi, esp
lea eax, DWORD PTR _v$[ebp]
push eax
mov ecx, DWORD PTR _v_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _v_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _v_result$[ebp], eax
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN4@TEST_PMC_B
mov DWORD PTR tv74[ebp], 1
jmp SHORT $LN5@TEST_PMC_B
$LN4@TEST_PMC_B:
mov DWORD PTR tv74[ebp], 0
$LN5@TEST_PMC_B:
mov edx, DWORD PTR _v_result$[ebp]
push edx
push OFFSET $SG94571
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv74[ebp]
push eax
push 1
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94572
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 59 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_L_X (%d.%d)", no, 2), (result = ep->PMC_BitwiseAnd_L_X(u, v, &actual_w)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_BitwiseAnd_L_Xの復帰コードが期待通りではない(%d)", result));
mov esi, esp
lea eax, DWORD PTR _actual_w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp+4]
push edx
mov eax, DWORD PTR _u$[ebp]
push eax
mov ecx, DWORD PTR _ep$[ebp]
mov edx, DWORD PTR [ecx+152]
call edx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
jne SHORT $LN6@TEST_PMC_B
mov DWORD PTR tv92[ebp], 1
jmp SHORT $LN7@TEST_PMC_B
$LN6@TEST_PMC_B:
mov DWORD PTR tv92[ebp], 0
$LN7@TEST_PMC_B:
mov eax, DWORD PTR _result$[ebp]
push eax
push OFFSET $SG94573
call _FormatTestMesssage
add esp, 8
push eax
mov ecx, DWORD PTR tv92[ebp]
push ecx
push 2
mov edx, DWORD PTR _no$[ebp]
push edx
push OFFSET $SG94574
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov eax, DWORD PTR _env$[ebp]
push eax
call _TEST_Assert
add esp, 16 ; 00000010H
; 60 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_L_X (%d.%d)", no, 3), actual_w == desired_w, L"データの内容が一致しない");
mov ecx, DWORD PTR _actual_w$[ebp]
cmp ecx, DWORD PTR _desired_w$[ebp]
jne SHORT $LN8@TEST_PMC_B
mov edx, DWORD PTR _actual_w$[ebp+4]
cmp edx, DWORD PTR _desired_w$[ebp+4]
jne SHORT $LN8@TEST_PMC_B
mov DWORD PTR tv134[ebp], 1
jmp SHORT $LN9@TEST_PMC_B
$LN8@TEST_PMC_B:
mov DWORD PTR tv134[ebp], 0
$LN9@TEST_PMC_B:
push OFFSET $SG94575
mov eax, DWORD PTR tv134[ebp]
push eax
push 3
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94576
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 61 : if (v_result == PMC_STATUS_OK)
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN1@TEST_PMC_B
; 62 : ep->PMC_Dispose(v);
mov esi, esp
mov eax, DWORD PTR _v$[ebp]
push eax
mov ecx, DWORD PTR _ep$[ebp]
mov edx, DWORD PTR [ecx+16]
call edx
cmp esi, esp
call __RTC_CheckEsp
$LN1@TEST_PMC_B:
; 63 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN13@TEST_PMC_B
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
add esp, 48 ; 00000030H
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 3
$LN13@TEST_PMC_B:
DD 2
DD $LN12@TEST_PMC_B
$LN12@TEST_PMC_B:
DD -8 ; fffffff8H
DD 4
DD $LN10@TEST_PMC_B
DD -24 ; ffffffe8H
DD 8
DD $LN11@TEST_PMC_B
$LN11@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 0
$LN10@TEST_PMC_B:
DB 118 ; 00000076H
DB 0
_TEST_PMC_BitwiseAnd_L_X ENDP
_TEXT ENDS
; Function compile flags: /Odtp /RTCsu
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\test_op_bitwiseand.c
_TEXT SEGMENT
tv134 = -44 ; size = 4
tv92 = -40 ; size = 4
tv74 = -36 ; size = 4
_v_result$ = -32 ; size = 4
_result$ = -28 ; size = 4
_actual_w$ = -20 ; size = 4
_v$ = -8 ; size = 4
_env$ = 8 ; size = 4
_ep$ = 12 ; size = 4
_no$ = 16 ; size = 4
_u$ = 20 ; size = 4
_v_buf$ = 24 ; size = 4
_v_buf_size$ = 28 ; size = 4
_desired_w$ = 32 ; size = 4
_TEST_PMC_BitwiseAnd_I_X PROC
; 40 : {
push ebp
mov ebp, esp
sub esp, 44 ; 0000002cH
push esi
push edi
lea edi, DWORD PTR [ebp-44]
mov ecx, 11 ; 0000000bH
mov eax, -858993460 ; ccccccccH
rep stosd
mov ecx, OFFSET __753CF642_test_op_bitwiseand@c
call @__CheckForDebuggerJustMyCode@4
; 41 : HANDLE v;
; 42 : unsigned __int32 actual_w;
; 43 : PMC_STATUS_CODE result;
; 44 : PMC_STATUS_CODE v_result;
; 45 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_I_X (%d.%d)", no, 1), (v_result = ep->PMC_FromByteArray(v_buf, v_buf_size, &v)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_FromByteArrayの復帰コードが期待通りではない(%d)", v_result));
mov esi, esp
lea eax, DWORD PTR _v$[ebp]
push eax
mov ecx, DWORD PTR _v_buf_size$[ebp]
push ecx
mov edx, DWORD PTR _v_buf$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+24]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _v_result$[ebp], eax
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN4@TEST_PMC_B
mov DWORD PTR tv74[ebp], 1
jmp SHORT $LN5@TEST_PMC_B
$LN4@TEST_PMC_B:
mov DWORD PTR tv74[ebp], 0
$LN5@TEST_PMC_B:
mov edx, DWORD PTR _v_result$[ebp]
push edx
push OFFSET $SG94545
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv74[ebp]
push eax
push 1
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94546
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 46 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_I_X (%d.%d)", no, 2), (result = ep->PMC_BitwiseAnd_I_X(u, v, &actual_w)) == PMC_STATUS_OK, FormatTestMesssage(L"PMC_BitwiseAnd_I_Xの復帰コードが期待通りではない(%d)", result));
mov esi, esp
lea eax, DWORD PTR _actual_w$[ebp]
push eax
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _u$[ebp]
push edx
mov eax, DWORD PTR _ep$[ebp]
mov ecx, DWORD PTR [eax+148]
call ecx
cmp esi, esp
call __RTC_CheckEsp
mov DWORD PTR _result$[ebp], eax
cmp DWORD PTR _result$[ebp], 0
jne SHORT $LN6@TEST_PMC_B
mov DWORD PTR tv92[ebp], 1
jmp SHORT $LN7@TEST_PMC_B
$LN6@TEST_PMC_B:
mov DWORD PTR tv92[ebp], 0
$LN7@TEST_PMC_B:
mov edx, DWORD PTR _result$[ebp]
push edx
push OFFSET $SG94547
call _FormatTestMesssage
add esp, 8
push eax
mov eax, DWORD PTR tv92[ebp]
push eax
push 2
mov ecx, DWORD PTR _no$[ebp]
push ecx
push OFFSET $SG94548
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov edx, DWORD PTR _env$[ebp]
push edx
call _TEST_Assert
add esp, 16 ; 00000010H
; 47 : TEST_Assert(env, FormatTestLabel(L"PMC_BitwiseAnd_I_X (%d.%d)", no, 3), actual_w == desired_w, L"データの内容が一致しない");
mov eax, DWORD PTR _actual_w$[ebp]
cmp eax, DWORD PTR _desired_w$[ebp]
jne SHORT $LN8@TEST_PMC_B
mov DWORD PTR tv134[ebp], 1
jmp SHORT $LN9@TEST_PMC_B
$LN8@TEST_PMC_B:
mov DWORD PTR tv134[ebp], 0
$LN9@TEST_PMC_B:
push OFFSET $SG94549
mov ecx, DWORD PTR tv134[ebp]
push ecx
push 3
mov edx, DWORD PTR _no$[ebp]
push edx
push OFFSET $SG94550
call _FormatTestLabel
add esp, 12 ; 0000000cH
push eax
mov eax, DWORD PTR _env$[ebp]
push eax
call _TEST_Assert
add esp, 16 ; 00000010H
; 48 : if (v_result == PMC_STATUS_OK)
cmp DWORD PTR _v_result$[ebp], 0
jne SHORT $LN1@TEST_PMC_B
; 49 : ep->PMC_Dispose(v);
mov esi, esp
mov ecx, DWORD PTR _v$[ebp]
push ecx
mov edx, DWORD PTR _ep$[ebp]
mov eax, DWORD PTR [edx+16]
call eax
cmp esi, esp
call __RTC_CheckEsp
$LN1@TEST_PMC_B:
; 50 : }
push edx
mov ecx, ebp
push eax
lea edx, DWORD PTR $LN13@TEST_PMC_B
call @_RTC_CheckStackVars@8
pop eax
pop edx
pop edi
pop esi
add esp, 44 ; 0000002cH
cmp ebp, esp
call __RTC_CheckEsp
mov esp, ebp
pop ebp
ret 0
npad 3
$LN13@TEST_PMC_B:
DD 2
DD $LN12@TEST_PMC_B
$LN12@TEST_PMC_B:
DD -8 ; fffffff8H
DD 4
DD $LN10@TEST_PMC_B
DD -20 ; ffffffecH
DD 4
DD $LN11@TEST_PMC_B
$LN11@TEST_PMC_B:
DB 97 ; 00000061H
DB 99 ; 00000063H
DB 116 ; 00000074H
DB 117 ; 00000075H
DB 97 ; 00000061H
DB 108 ; 0000006cH
DB 95 ; 0000005fH
DB 119 ; 00000077H
DB 0
$LN10@TEST_PMC_B:
DB 118 ; 00000076H
DB 0
_TEST_PMC_BitwiseAnd_I_X ENDP
_TEXT ENDS
END
|
; A021365: Decimal expansion of 1/361.
; 0,0,2,7,7,0,0,8,3,1,0,2,4,9,3,0,7,4,7,9,2,2,4,3,7,6,7,3,1,3,0,1,9,3,9,0,5,8,1,7,1,7,4,5,1,5,2,3,5,4,5,7,0,6,3,7,1,1,9,1,1,3,5,7,3,4,0,7,2,0,2,2,1,6,0,6,6,4,8,1,9,9,4,4,5,9,8,3,3,7,9,5,0,1,3,8,5,0,4
seq $0,173833 ; 10^n - 3.
div $0,361
mod $0,10
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.