text stringlengths 1 1.05M |
|---|
AskName:
call SaveScreenTilesToBuffer1
call GetPredefRegisters
push hl
ld a, [wIsInBattle]
dec a
coord hl, 0, 0
lb bc, 4, 11
call z, ClearScreenArea ; only if in wild battle
ld a, [wcf91]
ld [wd11e], a
call GetMonName
ld hl, DoYouWantToNicknameText
call PrintText
coord hl, 14, 7
lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID
pop hl
ld a, [wCurrentMenuItem]
and a
jr nz, .declinedNickname
ld a, [wUpdateSpritesEnabled]
push af
xor a
ld [wUpdateSpritesEnabled], a
push hl
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
ld a, [wIsInBattle]
and a
jr nz, .inBattle
call ReloadMapSpriteTilePatterns
.inBattle
call LoadScreenTilesFromBuffer1
pop hl
pop af
ld [wUpdateSpritesEnabled], a
ld a, [wcf4b]
cp "@"
ret nz
.declinedNickname
ld d, h
ld e, l
ld hl, wcd6d
ld bc, NAME_LENGTH
jp CopyData
DoYouWantToNicknameText:
TX_FAR _DoYouWantToNicknameText
db "@"
DisplayNameRaterScreen:
ld hl, wBuffer
xor a
ld [wUpdateSpritesEnabled], a
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
call LoadGBPal
ld a, [wcf4b]
cp "@"
jr z, .playerCancelled
ld hl, wPartyMonNicks
ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld e, l
ld d, h
ld hl, wBuffer
ld bc, NAME_LENGTH
call CopyData
and a
ret
.playerCancelled
scf
ret
DisplayNamingScreen:
push hl
ld hl, wd730
set 6, [hl]
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
ld b, SET_PAL_GENERIC
call RunPaletteCommand
call LoadHpBarAndStatusTilePatterns
call LoadEDTile
callba LoadMonPartySpriteGfx
coord hl, 0, 4
lb bc, 9, 18
call TextBoxBorder
call PrintNamingText
ld a, 3
ld [wTopMenuItemY], a
ld a, 1
ld [wTopMenuItemX], a
ld [wLastMenuItem], a
ld [wCurrentMenuItem], a
ld a, $ff
ld [wMenuWatchedKeys], a
ld a, 7
ld [wMaxMenuItem], a
ld a, "@"
ld [wcf4b], a
xor a
ld hl, wNamingScreenSubmitName
ld [hli], a
ld [hli], a
ld [wAnimCounter], a
.selectReturnPoint
call PrintAlphabet
call GBPalNormal
.ABStartReturnPoint
ld a, [wNamingScreenSubmitName]
and a
jr nz, .submitNickname
call PrintNicknameAndUnderscores
.dPadReturnPoint
call PlaceMenuCursor
.inputLoop
ld a, [wCurrentMenuItem]
push af
callba AnimatePartyMon_ForceSpeed1
pop af
ld [wCurrentMenuItem], a
call JoypadLowSensitivity
ld a, [hJoyPressed]
and a
jr z, .inputLoop
ld hl, .namingScreenButtonFunctions
.checkForPressedButton
sla a
jr c, .foundPressedButton
inc hl
inc hl
inc hl
inc hl
jr .checkForPressedButton
.foundPressedButton
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld h, [hl]
ld l, a
push de
jp hl
.submitNickname
pop de
ld hl, wcf4b
ld bc, NAME_LENGTH
call CopyData
call GBPalWhiteOutWithDelay3
call ClearScreen
call ClearSprites
call RunDefaultPaletteCommand
call GBPalNormal
xor a
ld [wAnimCounter], a
ld hl, wd730
res 6, [hl]
ld a, [wIsInBattle]
and a
jp z, LoadTextBoxTilePatterns
jpab LoadHudTilePatterns
.namingScreenButtonFunctions
dw .dPadReturnPoint
dw .pressedDown
dw .dPadReturnPoint
dw .pressedUp
dw .dPadReturnPoint
dw .pressedLeft
dw .dPadReturnPoint
dw .pressedRight
dw .ABStartReturnPoint
dw .pressedStart
dw .selectReturnPoint
dw .pressedSelect
dw .ABStartReturnPoint
dw .pressedB
dw .ABStartReturnPoint
dw .pressedA
.pressedA_changedCase
pop de
ld de, .selectReturnPoint
push de
.pressedSelect
ld a, [wAlphabetCase]
xor $1
ld [wAlphabetCase], a
ret
.pressedStart
ld a, 1
ld [wNamingScreenSubmitName], a
ret
.pressedA
ld a, [wCurrentMenuItem]
cp $5 ; "ED" row
jr nz, .didNotPressED
ld a, [wTopMenuItemX]
cp $11 ; "ED" column
jr z, .pressedStart
.didNotPressED
ld a, [wCurrentMenuItem]
cp $6 ; case switch row
jr nz, .didNotPressCaseSwtich
ld a, [wTopMenuItemX]
cp $1 ; case switch column
jr z, .pressedA_changedCase
.didNotPressCaseSwtich
ld hl, wMenuCursorLocation
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
ld a, [hl]
ld [wNamingScreenLetter], a
call CalcStringLength
ld a, [wNamingScreenLetter]
cp $e5
ld de, Dakutens
jr z, .dakutensAndHandakutens
cp $e4
ld de, Handakutens
jr z, .dakutensAndHandakutens
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
ld a, [wNamingScreenNameLength]
cp $7 ; max length of player/rival names
jr .checkNameLength
.checkMonNameLength
ld a, [wNamingScreenNameLength]
cp $a ; max length of pokemon nicknames
.checkNameLength
jr c, .addLetter
ret
.dakutensAndHandakutens
push hl
call DakutensAndHandakutens
pop hl
ret nc
dec hl
.addLetter
ld a, [wNamingScreenLetter]
ld [hli], a
ld [hl], "@"
ld a, SFX_PRESS_AB
call PlaySound
ret
.pressedB
ld a, [wNamingScreenNameLength]
and a
ret z
call CalcStringLength
dec hl
ld [hl], "@"
ret
.pressedRight
ld a, [wCurrentMenuItem]
cp $6
ret z ; can't scroll right on bottom row
ld a, [wTopMenuItemX]
cp $11 ; max
jp z, .wrapToFirstColumn
inc a
inc a
jr .done
.wrapToFirstColumn
ld a, $1
jr .done
.pressedLeft
ld a, [wCurrentMenuItem]
cp $6
ret z ; can't scroll right on bottom row
ld a, [wTopMenuItemX]
dec a
jp z, .wrapToLastColumn
dec a
jr .done
.wrapToLastColumn
ld a, $11 ; max
jr .done
.pressedUp
ld a, [wCurrentMenuItem]
dec a
ld [wCurrentMenuItem], a
and a
ret nz
ld a, $6 ; wrap to bottom row
ld [wCurrentMenuItem], a
ld a, $1 ; force left column
jr .done
.pressedDown
ld a, [wCurrentMenuItem]
inc a
ld [wCurrentMenuItem], a
cp $7
jr nz, .wrapToTopRow
ld a, $1
ld [wCurrentMenuItem], a
jr .done
.wrapToTopRow
cp $6
ret nz
ld a, $1
.done
ld [wTopMenuItemX], a
jp EraseMenuCursor
LoadEDTile:
; In Red/Blue, the bank for the ED_tile was defined incorrectly as bank0
; Luckily, the MBC3 treats loading $0 into $2000-$2fff range as loading bank1 into $4000-$7fff range
; Because Yellow uses the MBC5, loading $0 into $2000 - $2fff range will load bank0 instead of bank1 and thus incorrectly load the tile
; Instead of defining the correct bank, GameFreak decided to simply copy the ED_Tile in the function during HBlank
ld de, ED_Tile
ld hl, vFont + $700
ld c, $4 ; number of copies needed
.waitForHBlankLoop
ld a, [rSTAT]
and %10 ; in HBlank?
jr nz, .waitForHBlankLoop
ld a, [de]
ld [hli], a
ld [hli], a
inc de
ld a, [de]
ld [hli], a
ld [hli], a
inc de
dec c
jr nz, .waitForHBlankLoop
ret
ED_Tile:
INCBIN "gfx/ED_tile.1bpp"
ED_TileEnd:
PrintAlphabet:
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld a, [wAlphabetCase]
and a
ld de, LowerCaseAlphabet
jr nz, .lowercase
ld de, UpperCaseAlphabet
.lowercase
coord hl, 2, 5
lb bc, 5, 9 ; 5 rows, 9 columns
.outerLoop
push bc
.innerLoop
ld a, [de]
ld [hli], a
inc hl
inc de
dec c
jr nz, .innerLoop
ld bc, SCREEN_WIDTH + 2
add hl, bc
pop bc
dec b
jr nz, .outerLoop
call PlaceString
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
LowerCaseAlphabet:
db "abcdefghijklmnopqrstuvwxyz ×():;[]",$e1,$e2,"-?!♂♀/",$f2,",¥UPPER CASE@"
UpperCaseAlphabet:
db "ABCDEFGHIJKLMNOPQRSTUVWXYZ ×():;[]",$e1,$e2,"-?!♂♀/",$f2,",¥lower case@"
PrintNicknameAndUnderscores:
call CalcStringLength
ld a, c
ld [wNamingScreenNameLength], a
coord hl, 10, 2
lb bc, 1, 10
call ClearScreenArea
coord hl, 10, 2
ld de, wcf4b
call PlaceString
coord hl, 10, 3
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .pokemon1
ld b, 7 ; player or rival max name length
jr .playerOrRival1
.pokemon1
ld b, 10 ; pokemon max name length
.playerOrRival1
ld a, $76 ; underscore tile id
.placeUnderscoreLoop
ld [hli], a
dec b
jr nz, .placeUnderscoreLoop
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
ld a, [wNamingScreenNameLength]
jr nc, .pokemon2
cp 7 ; player or rival max name length
jr .playerOrRival2
.pokemon2
cp 10 ; pokemon max name length
.playerOrRival2
jr nz, .emptySpacesRemaining
; when all spaces are filled, force the cursor onto the ED tile
call EraseMenuCursor
ld a, $11 ; "ED" x coord
ld [wTopMenuItemX], a
ld a, $5 ; "ED" y corrd
ld [wCurrentMenuItem], a
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
ld a, 9 ; keep the last underscore raised
jr nc, .pokemon3
ld a, 6 ; keep the last underscore raised
.pokemon3
.emptySpacesRemaining
ld c, a
ld b, $0
coord hl, 10, 3
add hl, bc
ld [hl], $77 ; raised underscore tile id
ret
DakutensAndHandakutens:
push de
call CalcStringLength
dec hl
ld a, [hl]
pop hl
ld de, $2
call IsInArray
ret nc
inc hl
ld a, [hl]
ld [wNamingScreenLetter], a
ret
Dakutens:
db "かが", "きぎ", "くぐ", "けげ", "こご"
db "さざ", "しじ", "すず", "せぜ", "そぞ"
db "ただ", "ちぢ", "つづ", "てで", "とど"
db "はば", "ひび", "ふぶ", "へべ", "ほぼ"
db "カガ", "キギ", "クグ", "ケゲ", "コゴ"
db "サザ", "シジ", "スズ", "セゼ", "ソゾ"
db "タダ", "チヂ", "ツヅ", "テデ", "トド"
db "ハバ", "ヒビ", "フブ", "へべ", "ホボ"
db $ff
Handakutens:
db "はぱ", "ひぴ", "ふぷ", "へぺ", "ほぽ"
db "ハパ", "ヒピ", "フプ", "へぺ", "ホポ"
db $ff
; calculates the length of the string at wcf4b and stores it in c
CalcStringLength:
ld hl, wcf4b
ld c, $0
.loop
ld a, [hl]
cp "@"
ret z
inc hl
inc c
jr .loop
PrintNamingText:
coord hl, 0, 1
ld a, [wNamingScreenType]
ld de, YourTextString
and a
jr z, .notNickname
ld de, RivalsTextString
dec a
jr z, .notNickname
ld a, [wcf91]
ld [wMonPartySpriteSpecies], a
push af
callba WriteMonPartySpriteOAMBySpecies
pop af
ld [wd11e], a
call GetMonName
coord hl, 4, 1
call PlaceString
ld hl, $1
add hl, bc
ld [hl], $c9
coord hl, 1, 3
ld de, NicknameTextString
jr .placeString
.notNickname
call PlaceString
ld l, c
ld h, b
ld de, NameTextString
.placeString
jp PlaceString
YourTextString:
db "YOUR @"
RivalsTextString:
db "RIVAL's @"
NameTextString:
db "NAME?@"
NicknameTextString:
db "NICKNAME?@"
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
%>
<%docstring>link(from, to) -> str
Invokes the syscall link.
See 'man 2 link' for more information.
Arguments:
from(char*): from
to(char*): to
Returns:
int
</%docstring>
<%page args="from=0, to=0"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = ['from', 'to']
can_pushstr_array = []
argument_names = ['from', 'to']
argument_values = [from, to]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%r' % (name, arg))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, str):
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_link']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* link(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=('\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)} |
; Copyright 2019 IBM 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.
[BITS 64]
%include "common.inc"
%include "pmc.inc"
section .data
warmup_cnt: db 1
fill: times 63 db 0
warmup_cnt_fake: dw 4096
fill2: times 62 db 0
dev_file: db '/dev/cpu/',VICTIM_PROCESS_STR,'/msr',0
fd: dq 0
val: dq 0
len: equ $-val
lea_array: times 40 db 0
junk: db 1
;##### DATA STARTS HERE ########
;##### DATA ENDS HERE ########
section .text
global perf_test_entry:function
global snippet:function
perf_test_entry:
push rbp
mov rbp, rsp
sub rsp, len
check_pinning VICTIM_PROCESS
msr_open
msr_seek
.data:
mov eax, 0
cpuid
lfence
reset_counter
start_counter
mov ax, 2
mul DWORD[warmup_cnt_fake]
cmp eax, 4
je .else
;##### SNIPPET STARTS HERE ######
;##### SNIPPET ENDS HERE ######
;lea rax, [lea_array+rax*2]
.else:
lfence
stop_counter
mov eax, DWORD[warmup_cnt_fake]
mov ecx, 2
xor edx, edx
div ecx
mov DWORD[warmup_cnt_fake], eax
inc DWORD[warmup_cnt]
cmp DWORD[warmup_cnt], 13
jl .data
msr_close
exit 0
|
; w_vector_t *w_vector_init(void *p, size_t capacity, size_t max_size)
SECTION code_clib
SECTION code_adt_w_vector
PUBLIC w_vector_init
EXTERN asm_w_vector_init
w_vector_init:
pop af
pop hl
pop bc
pop de
push de
push bc
push hl
push af
jp asm_w_vector_init
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _w_vector_init
defc _w_vector_init = w_vector_init
ENDIF
|
; QLSD Initilaise an SHDC card (via bit-banging) 1.00 (C) W. Lenerz 2017
;
; 2018-06-11 1.01 Take the QLSD hardware lock before initialising card (MK)
section procs
xdef inicrd
include 'dev8_dv3_qlsd_keys'
include 'dev8_keys_qlv'
include 'dev8_keys_err'
include 'dev8_keys_sys'
; algo :
; put into spi mode
; cmd0
; cmd8
; cmd58
; cmd55
; cmd58
inireg reg d1/d2/d3/d5/a2/a6
;+++
; This routine initialises an sdhc card
; *** read/write via bit bang
;
; d5 c p card number (1...3)
; a3 c p driver linkage block
;
; status return 0, ERR.MCHK or ERR.FDIU
;---
inicrd andi.w #3,d5
beq.s err_ipar
movem.l inireg,-(a7)
move.l qlsd_sysvars(a3),a6 ; so caller doesn't have to provide it
move.l hdl_1sec(a3),d0 ; something like one second timeout
lock_wait
bset #7,sys_qlsd(a6) ; prevent poll from accessing device
beq.s lock_ok ; got the lock, proceed
subq.l #3,d0
bgt.s lock_wait
movem.l (a7)+,inireg
moveq #err.fdiu,d0 ; still in use, give up
rts
err_ipar
moveq #err.ipar,d0
rts
lock_ok
move.w #SPI_SELECT0,d3
add.w d5,d3
move.l #IF_BASE,a2 ; point to card physical addresses
; set interface to a known state
tst.b IF_RESET(a2) ; reset the IF
tst.b IF_ENABLE(a2) ; enable it
tst.b SPI_SELECT0(a2) ; deselect all
tst.b SPI_XFER_OFF(a2) ; use bitbang protocol
move.w sr,d0
trap #0
move.w d0,-(a7)
; now put I/F into SPI mode ; pretend to send many bytes, toggles clock
moveq #10,d2
inilp1 moveq #-1,d0
bsr sendbyte
dbf d2,inilp1
tst.b (a2,d3.w) ; select the card
; send cmd0 101 times or until correct response
moveq #100,d2 ; nbr of loop iterations +1
inilp2 move.l #$40000000,d0
move.w #$95,d1
bsr snd_cmd ; send command 0 - put to idle
bne.s lp2dbf ; command sending went wrong ->
subq.b #1,d1 ; sent OK, but correct response?
beq.s reply1 ; ... yes ->
lp2dbf dbf d2,inilp2 ; ... no, try again
bra ini_err ; if we get here, no correct answer from card
; here I got a valid reply , so cmd0 was successful
; now try to send command8
reply1
move.l #$48000001,d0 ; prepare cmd8
move.w #$aa87,d1
bsr snd_cmd ; send command 8, return 1 + 4 more bytes
bne ini_err ; ooos
cmp.b #1,d1 ; correct response?
bne ini_err ; no
bsr readbyte ; 2
bsr readbyte ; 3
bsr readbyte ; 4
move.b d0,d2 ; keep 4th response byte
bsr readbyte ; 5
cmp.b #1,d2 ; 4th response byte must be 1
bne ini_err ; but it isn't
cmp.b #$aa,d0 ; 5th response byte must be $aa
bne.s ini_err ; but is isn't
; here I got a correct reply from command8, now do command58
move.l #$7a000000,d0
move.w #$87,d1
bsr snd_cmd ; send command 58, 1 + 4 more bytes
bne.s ini_err ; oops on send command
bsr.s readbyte ; 2
bsr.s readbyte ; 3
bsr.s readbyte ; 4
bsr.s readbyte ; 5
; now do cmd55 followed by acmd41
move.w #$9fff,d2 ; should be enough on a slow machine
inilp3 move.l #$77000000,d0 ; send command55 (special command to follow)
move.w #$87,d1
bsr.s snd_cmd
bne.s ini_err ; pb on send command
move.l #$69400000,d0 ; send acmd41 (sd_send_op_cond)
move.w #$87,d1
bsr.s snd_cmd ; reply will be 0 if success
bne.s ini_err
tst.b d1 ; check for correct reply from card
beq.s reply2 ; got correct reply
dbf d2,inilp3 ; didn't, so try again
bra.s ini_err ; if we get here, reply never was 0
reply2
move.l #$7a000000,d0 ; send command58 -read ocr
move.w #$87,d1
bsr.s snd_cmd ;
bne.s ini_err
bsr.s readbyte ; 1 get 4 more response bytes
move.b d0,d2 ; keep response 1
bsr.s readbyte ; 2
bsr.s readbyte ; 3
bsr.s readbyte ; 4
andi.b #$40,d2 ; is this an SDHC card?
beq.s ini_err ; no! -->
tst.b SPI_XFER_FAST(a2) ; yes, all good, set fast commo mode
moveq #0,d0
ini_out move.w (a7)+,sr
tst.b SPI_SELECT0(a2) ; deselect all
ini_rts bclr #7,sys_qlsd(a6) ; release device
movem.l (a7)+,inireg
tst.l d0
rts
ini_err moveq #err.mchk,d0
bra.s ini_out
;+++
; This routine reads a byte from an sdhc card through bit-banging.
; A byte is read bit by bit, the MSB comes first.
;
; d0 r byte read
; d1 s
; a2 c p pointer to interface base for the selected card
;
; no error return
;+++
readbyte
tst.b SPI_SET_MOSI(a2) ; output high
moveq #7,d1 ; dbf for 8 bits
moveq #0,d0 ; d0 will contain result
rblp tst.b SPI_CLR_SCLK(a2) ; set clock low
nop ; wait
tst.b SPI_READ(a2) ; got a bit ?
beq.s nextbit ; no
bset d1,d0 ; ... yes, show it
nextbit
tst.b SPI_SET_SCLK(a2) ; set clock high
dbf d1,rblp
rts
;+++
; This routine sends a command to an sdhc card. The command is 6 bytes long.
; Bytes are sent via bitbang.
; On entry d0 contains the first 4 bytes and d1.w the last two.
;
; d0 cr first 4 command bytes / error code
; d1 cr .W : 2 last command bytes / return byte
; d3 s
; a2 c p pointer to interface base
;
; status return 0 or ERR.MCHK (card didn't reply)
;---
; I could loop this, but it's just a few bytes anyway
snd_cmd
move.w d1,-(a7) ; sendbyte destroys d1
move.l d0,d3
moveq #-1,d0
bsr.s sendbyte ; (pretend to) send a byte (sends 8 clock pulses)
move.l d3,d0
rol.l #8,d0
bsr.s sendbyte ; send first byte
rol.l #8,d0
bsr.s sendbyte ; send next byte
rol.l #8,d0
bsr.s sendbyte ; send 3rd byte
rol.l #8,d0
bsr.s sendbyte ; send 4th byte
move.w (a7)+,d3
move.w d3,d0
ror.w #8,d0
bsr.s sendbyte ; penultimate byte
move.b d3,d0
bsr.s sendbyte ; last byte
; now wait for response
move.w #99,d3
waitlp bsr.s readbyte ; get response byte, myst be <>-1 if success
cmp.b #-1,d0 ; was reply -1 (=bad)?
bne.s got_rply ; ... no, so we're done ok
dbf d3,waitlp ; ... yes, command not finished yet
moveq #err.mchk,d0 ; if we get here, card didn't reply in time
rts
got_rply
move.b d0,d1 ; return byte
moveq #0,d0 ; all OK
rts
;+++++++++++++++++++++++
; This routine sends a byte to an sdhc card through bit-banging.
; A byte is sent bit by bit, the MSb comes first.
;
; d0 c p byte to send
; d1 s
; a2 c p pointer to interface base
;
; no error return
;+++++++++++++++++++++++
sendbyte
moveq #7,d1 ; dbf for 8 bits
sb_lp
btst d1,d0 ; is this bit set?
beq.s not_set ; ... no
bit_set tst.b SPI_SET_MOSI(a2) ; output high
bra.s common
not_set tst.b SPI_CLR_MOSI(a2) ; output low
common tst.b SPI_CLR_SCLK(a2) ; clock low
nop ; wait
tst.b SPI_SET_SCLK(a2) ; clock high
dbf d1,sb_lp ; do for all bits
rts
end
|
; ---------------------------------------------------------------------------
; Object 88 - chaos emeralds on the ending sequence
; ---------------------------------------------------------------------------
EndChaos:
moveq #0,d0
move.b obRoutine(a0),d0
move.w ECha_Index(pc,d0.w),d1
jsr ECha_Index(pc,d1.w)
jmp (DisplaySprite).l
; ===========================================================================
ECha_Index: dc.w ECha_Main-ECha_Index
dc.w ECha_Move-ECha_Index
echa_origX: equ $38 ; x-axis centre of emerald circle (2 bytes)
echa_origY: equ $3A ; y-axis centre of emerald circle (2 bytes)
echa_radius: equ $3C ; radius (2 bytes)
echa_angle: equ $3E ; angle for rotation (2 bytes)
; ===========================================================================
ECha_Main: ; Routine 0
cmpi.b #2,(v_player+obFrame).w ; this isn't `fr_Wait1`: `v_player` is Object 88, which has its own frames
beq.s ECha_CreateEms
addq.l #4,sp
rts
; ===========================================================================
ECha_CreateEms:
move.w (v_player+obX).w,obX(a0) ; match X position with Sonic
move.w (v_player+obY).w,obY(a0) ; match Y position with Sonic
movea.l a0,a1
moveq #0,d3
moveq #1,d2
moveq #5,d1
ECha_LoadLoop:
move.b #id_EndChaos,(a1) ; load chaos emerald object
addq.b #2,obRoutine(a1)
move.l #Map_ECha,obMap(a1)
move.w #$3C5,obGfx(a1)
move.b #4,obRender(a1)
move.b #1,obPriority(a1)
move.w obX(a0),echa_origX(a1)
move.w obY(a0),echa_origY(a1)
move.b d2,obAnim(a1)
move.b d2,obFrame(a1)
addq.b #1,d2
move.b d3,obAngle(a1)
addi.b #$100/6,d3 ; angle between each emerald
lea $40(a1),a1
dbf d1,ECha_LoadLoop ; repeat 5 more times
ECha_Move: ; Routine 2
move.w echa_angle(a0),d0
add.w d0,obAngle(a0)
move.b obAngle(a0),d0
jsr (CalcSine).l
moveq #0,d4
move.b echa_radius(a0),d4
muls.w d4,d1
asr.l #8,d1
muls.w d4,d0
asr.l #8,d0
add.w echa_origX(a0),d1
add.w echa_origY(a0),d0
move.w d1,obX(a0)
move.w d0,obY(a0)
ECha_Expand:
cmpi.w #$2000,echa_radius(a0)
beq.s ECha_Rotate
addi.w #$20,echa_radius(a0) ; expand circle of emeralds
ECha_Rotate:
cmpi.w #$2000,echa_angle(a0)
beq.s ECha_Rise
addi.w #$20,echa_angle(a0) ; move emeralds around the centre
ECha_Rise:
cmpi.w #$140,echa_origY(a0)
beq.s ECha_End
subq.w #1,echa_origY(a0) ; make circle rise
ECha_End:
rts
|
#include "up16_core.asm"
nop
start:
lli r4, #0x71
; replace second nop with lli r3 #0xff for task 1
lli r3, #0xff
lli r1, #1
lli r2, #2
lui r4, r4, #0xf9
add r2, r1
mov r5, r3
addi r3, r1, #1
addi r6, r4, #5
jmp proc3
proc2:
nop
add r4, r1
or r2, r4
nop
proc3:
sw r4, r1, #0
sw r5, r1, #1
nop
lw r6, r1, #0
add r1, r6
lw r7, r1, #1
add r3, r1
add r5, r3
nop
lli r3, #0
sub r6, r2
bne r3, r0, end
nop
add r1, r2
nand r2, r1
nop
nop
nop
end:
not r1, r4
jmp start
|
100: LD SP, #4000
108: LD R1, #10
116: ST a, R1
124: LD R2, #2
132: ST b, R2
function block
1000: SUB R3, R1, R2
1008: BLEZ R3, #1048
1016: AND R4, #true, #false
1024: LD R0, R4
1032: BR *0(SP)
1040: BR #1064
1048: LD R0, #false
1056: BR *0(SP)
function main
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "PropertiesDialog.h"
#include <AK/StringBuilder.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/CheckBox.h>
#include <LibGUI/FilePicker.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/TabWidget.h>
#include <grp.h>
#include <limits.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, bool disable_rename, Window* parent_window)
: Dialog(parent_window)
, m_model(model)
{
auto file_path = FileSystemPath(path);
ASSERT(file_path.is_valid());
auto& main_widget = set_main_widget<GUI::Widget>();
main_widget.set_layout<GUI::VerticalBoxLayout>();
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
main_widget.set_fill_with_background_color(true);
set_rect({ 0, 0, 360, 420 });
set_resizable(false);
auto& tab_widget = main_widget.add<GUI::TabWidget>();
auto& general_tab = tab_widget.add_tab<GUI::Widget>("General");
general_tab.set_layout<GUI::VerticalBoxLayout>();
general_tab.layout()->set_margins({ 12, 8, 12, 8 });
general_tab.layout()->set_spacing(10);
general_tab.layout()->add_spacer();
auto& file_container = general_tab.add<GUI::Widget>();
file_container.set_layout<GUI::HorizontalBoxLayout>();
file_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
file_container.layout()->set_spacing(20);
file_container.set_preferred_size(0, 34);
m_icon = file_container.add<GUI::Label>();
m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
m_icon->set_preferred_size(32, 32);
m_name = file_path.basename();
m_path = file_path.string();
m_name_box = file_container.add<GUI::TextBox>();
m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
m_name_box->set_preferred_size({ 0, 22 });
m_name_box->set_text(m_name);
m_name_box->set_enabled(!disable_rename);
m_name_box->on_change = [&]() {
m_name_dirty = m_name != m_name_box->text();
m_apply_button->set_enabled(true);
};
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"));
make_divider(general_tab);
struct stat st;
if (lstat(path.characters(), &st)) {
perror("stat");
return;
}
String owner_name;
String group_name;
if (auto* pw = getpwuid(st.st_uid)) {
owner_name = pw->pw_name;
} else {
owner_name = "n/a";
}
if (auto* gr = getgrgid(st.st_gid)) {
group_name = gr->gr_name;
} else {
group_name = "n/a";
}
m_mode = st.st_mode;
auto properties = Vector<PropertyValuePair>();
properties.append({ "Type:", get_description(m_mode) });
properties.append({ "Location:", path });
if (S_ISLNK(m_mode)) {
char link_destination[PATH_MAX];
ssize_t len = readlink(path.characters(), link_destination, sizeof(link_destination));
if (len < 0) {
perror("readlink");
} else {
properties.append({ "Link target:", String(link_destination, len) });
}
}
properties.append({ "Size:", String::format("%zu bytes", st.st_size) });
properties.append({ "Owner:", String::format("%s (%lu)", owner_name.characters(), st.st_uid) });
properties.append({ "Group:", String::format("%s (%lu)", group_name.characters(), st.st_gid) });
properties.append({ "Created at:", GUI::FileSystemModel::timestamp_string(st.st_ctime) });
properties.append({ "Last modified:", GUI::FileSystemModel::timestamp_string(st.st_mtime) });
make_property_value_pairs(properties, general_tab);
make_divider(general_tab);
make_permission_checkboxes(general_tab, { S_IRUSR, S_IWUSR, S_IXUSR }, "Owner:", m_mode);
make_permission_checkboxes(general_tab, { S_IRGRP, S_IWGRP, S_IXGRP }, "Group:", m_mode);
make_permission_checkboxes(general_tab, { S_IROTH, S_IWOTH, S_IXOTH }, "Others:", m_mode);
general_tab.layout()->add_spacer();
auto& button_widget = main_widget.add<GUI::Widget>();
button_widget.set_layout<GUI::HorizontalBoxLayout>();
button_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
button_widget.set_preferred_size(0, 24);
button_widget.layout()->set_spacing(5);
button_widget.layout()->add_spacer();
make_button("OK", button_widget).on_click = [this](auto) {
if (apply_changes())
close();
};
make_button("Cancel", button_widget).on_click = [this](auto) {
close();
};
m_apply_button = make_button("Apply", button_widget);
m_apply_button->on_click = [this](auto) { apply_changes(); };
m_apply_button->set_enabled(false);
update();
}
PropertiesDialog::~PropertiesDialog() {}
void PropertiesDialog::update()
{
m_icon->set_icon(const_cast<Gfx::Bitmap*>(m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32)));
set_title(String::format("%s - Properties", m_name.characters()));
}
void PropertiesDialog::permission_changed(mode_t mask, bool set)
{
if (set) {
m_mode |= mask;
} else {
m_mode &= ~mask;
}
m_permissions_dirty = true;
m_apply_button->set_enabled(true);
}
String PropertiesDialog::make_full_path(String name)
{
return String::format("%s/%s", m_model.root_path().characters(), name.characters());
}
bool PropertiesDialog::apply_changes()
{
if (m_name_dirty) {
String new_name = m_name_box->text();
String new_file = make_full_path(new_name).characters();
if (GUI::FilePicker::file_exists(new_file)) {
GUI::MessageBox::show(String::format("A file \"%s\" already exists!", new_name.characters()), "Error", GUI::MessageBox::Type::Error);
return false;
}
if (rename(make_full_path(m_name).characters(), new_file.characters())) {
GUI::MessageBox::show(String::format("Could not rename file: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error);
return false;
}
m_name = new_name;
m_name_dirty = false;
update();
}
if (m_permissions_dirty) {
if (chmod(make_full_path(m_name).characters(), m_mode)) {
GUI::MessageBox::show(String::format("Could not update permissions: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error);
return false;
}
m_permissions_dirty = false;
}
update();
m_apply_button->set_enabled(false);
return true;
}
void PropertiesDialog::make_permission_checkboxes(GUI::Widget& parent, PermissionMasks masks, String label_string, mode_t mode)
{
auto& widget = parent.add<GUI::Widget>();
widget.set_layout<GUI::HorizontalBoxLayout>();
widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
widget.set_preferred_size(0, 16);
widget.layout()->set_spacing(10);
auto& label = widget.add<GUI::Label>(label_string);
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
struct stat st;
if (lstat(m_path.characters(), &st)) {
perror("stat");
return;
}
auto can_edit_checkboxes = st.st_uid == getuid();
auto& box_read = widget.add<GUI::CheckBox>("Read");
box_read.set_checked(mode & masks.read);
box_read.on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); };
box_read.set_enabled(can_edit_checkboxes);
auto& box_write = widget.add<GUI::CheckBox>("Write");
box_write.set_checked(mode & masks.write);
box_write.on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); };
box_write.set_enabled(can_edit_checkboxes);
auto& box_execute = widget.add<GUI::CheckBox>("Execute");
box_execute.set_checked(mode & masks.execute);
box_execute.on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); };
box_execute.set_enabled(can_edit_checkboxes);
}
void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>& pairs, GUI::Widget& parent)
{
int max_width = 0;
Vector<NonnullRefPtr<GUI::Label>> property_labels;
property_labels.ensure_capacity(pairs.size());
for (auto pair : pairs) {
auto& label_container = parent.add<GUI::Widget>();
label_container.set_layout<GUI::HorizontalBoxLayout>();
label_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
label_container.set_preferred_size(0, 14);
label_container.layout()->set_spacing(12);
auto& label_property = label_container.add<GUI::Label>(pair.property);
label_property.set_text_alignment(Gfx::TextAlignment::CenterLeft);
label_property.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
label_container.add<GUI::Label>(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft);
max_width = max(max_width, label_property.font().width(pair.property));
property_labels.append(label_property);
}
for (auto label : property_labels)
label->set_preferred_size({ max_width, 0 });
}
GUI::Button& PropertiesDialog::make_button(String text, GUI::Widget& parent)
{
auto& button = parent.add<GUI::Button>(text);
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
button.set_preferred_size(70, 22);
return button;
}
void PropertiesDialog::make_divider(GUI::Widget& parent)
{
parent.layout()->add_spacer();
auto& divider = parent.add<GUI::Frame>();
divider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
divider.set_preferred_size({ 0, 2 });
parent.layout()->add_spacer();
}
|
; A066534: Total number of walks with length > 0 in the Hasse diagram of a Boolean algebra of order n.
; 0,1,6,30,152,840,5232,37072,297600,2680704,26812160,294945024,3539364864,46011796480,644165265408,9662479226880,154599668154368,2628194359738368
lpb $0,1
add $2,1
lpb $0,1
mul $2,$0
mul $1,2
add $1,$2
sub $0,1
lpe
lpe
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2020 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include "datastruct.asm"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Define SM3 Out Of Order Data Structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; LANE_DATA
;;; name size align
FIELD _job_in_lane, 8, 8 ; pointer to job object
END_FIELDS
%assign _LANE_DATA_size _FIELD_OFFSET
%assign _LANE_DATA_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; SM3_ARGS_X16
;;; name size align
FIELD _digest, 4*8*16, 4 ; transposed digest
FIELD _data_ptr, 8*16, 8 ; array of pointers to data
END_FIELDS
%assign _SM3_ARGS_X4_size _FIELD_OFFSET
%assign _SM3_ARGS_X4_align _STRUCT_ALIGN
%assign _SM3_ARGS_X8_size _FIELD_OFFSET
%assign _SM3_ARGS_X8_align _STRUCT_ALIGN
%assign _SM3_ARGS_X16_size _FIELD_OFFSET
%assign _SM3_ARGS_X16_align _STRUCT_ALIGN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
START_FIELDS ; MB_MGR
;;; name size align
FIELD _args, _SM3_ARGS_X4_size, _SM3_ARGS_X4_align
FIELD _lens, 4*16, 8
FIELD _unused_lanes, 8, 8
FIELD _ldata, _LANE_DATA_size*16, _LANE_DATA_align
FIELD _num_lanes_inuse, 4, 4
END_FIELDS
%assign _MB_MGR_size _FIELD_OFFSET
%assign _MB_MGR_align _STRUCT_ALIGN
_args_digest equ _args + _digest
_args_data_ptr equ _args + _data_ptr
|
#include "common.hh"
#include <algorithm>
#include <iostream>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include "args.hh"
#include "cgi.hh"
#include "config.hh"
#include "db.hh"
#include "event.hh"
#include "event_utils.hh"
#include "http.hh"
#include "sender_client.hh"
/*
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
*/
using namespace stuff;
namespace {
std::unique_ptr<Config> g_cfg;
std::unique_ptr<SenderClient> g_sender;
bool parse(const std::string& text, std::vector<std::string>* args) {
if (Args::parse(text, args)) return true;
Http::response(200, "Invalid parameter format");
return false;
}
bool parse_time(const std::string& value, time_t* date) {
struct tm _t, _tmp;
time_t now = time(NULL);
localtime_r(&now, &_t);
_tmp = _t;
auto ptr = strptime(value.c_str(), "%H:%M", &_tmp);
if (ptr && !*ptr) goto done;
_tmp = _t;
ptr = strptime(value.c_str(), "%A %H:%M", &_tmp);
if (ptr && !*ptr) {
// Given the weekday, figure out distance to "now"
int days = _tmp.tm_wday - _t.tm_wday;
if (days <= 0) {
days += 7;
}
time_t tmp = mktime(&_tmp) + days * EventUtils::ONE_DAY_IN_SEC;
localtime_r(&tmp, &_tmp);
goto done;
}
_tmp = _t;
ptr = strptime(value.c_str(), "%d/%m %H:%M", &_tmp);
if (ptr && !*ptr) goto done;
_tmp = _t;
ptr = strptime(value.c_str(), "%A %d/%m %H:%M", &_tmp);
if (ptr && !*ptr) goto done;
_tmp = _t;
ptr = strptime(value.c_str(), "%Y-%m-%d %H:%M", &_tmp);
if (ptr && !*ptr) goto done;
return false;
done:
*date = mktime(&_tmp);
return true;
}
bool create(EventUtils* utils,
std::map<std::string, std::string>& data,
std::vector<std::string>& args) {
if (args.size() < 2) {
Http::response(200, "Usage: create NAME START [TEXT]");
return true;
}
std::string name, text;
time_t start;
name = args.front();
args.erase(args.begin());
text = args.front();
args.erase(args.begin());
while (true) {
if (parse_time(text, &start)) break;
if (args.empty()) {
Http::response(200, "Couldn't figure out when to start the event, try [DAY|DATE] HH:MM");
return true;
}
text.push_back(' ');
text.append(args.front());
args.erase(args.begin());
}
auto event = utils->create(name, start);
if (!utils->good()) return true;
if (!event) {
Http::response(200, "Unable to create event");
return true;
}
if (!args.empty()) {
std::string text(args.front());
args.erase(args.begin());
for (const auto& arg : args) {
text.push_back(' ');
text.append(arg);
}
event->set_text(text);
}
if (!event->store()) {
Http::response(200, "Unable to store event");
return true;
}
Http::response(200, "Event created");
utils->created(event.get());
return true;
}
template<typename Iterator>
bool append_indexes(Iterator begin, Iterator end,
std::vector<unsigned long>* out) {
for (auto it = begin; it != end; ++it) {
char* end = nullptr;
errno = 0;
auto tmp = strtoul(it->c_str(), &end, 10);
if (errno || !end || *end) {
Http::response(200, "Bad index: " + *it);
return false;
}
out->push_back(tmp);
}
return true;
}
bool cancel(EventUtils* utils,
std::map<std::string, std::string>& data,
std::vector<std::string>& args) {
std::vector<unsigned long> indexes;
if (args.empty()) {
indexes.push_back(0);
} else {
if (!append_indexes(args.begin(), args.end(), &indexes)) {
return true;
}
std::sort(indexes.begin(), indexes.end(),
std::greater<unsigned long>());
std::unique(indexes.begin(), indexes.end());
}
auto events = utils->all();
if (!utils->good()) return true;
if (indexes.front() >= events.size()) {
if (events.empty()) {
Http::response(200, "There are no events");
} else if (events.size() == 1) {
Http::response(200, "There is only one event");
} else {
std::ostringstream ss;
ss << "There are only " << events.size() << " events";
Http::response(200, ss.str());
}
return true;
}
for (const auto& index : indexes) {
utils->cancel(events[index].get(), index);
}
if (indexes.size() > 1) {
Http::response(200, "Events removed");
} else {
Http::response(200, "Event removed");
}
return true;
}
bool update(EventUtils* utils,
std::map<std::string, std::string>& data,
std::vector<std::string>& args) {
std::set<std::string> update;
update.insert("name");
update.insert("start");
update.insert("text");
if (args.empty()) {
Http::response(200, "Usage: update [INDEX] [name NAME] [start START] [text TEXT]");
return true;
}
std::unique_ptr<Event> event;
int64_t first_event;
auto it = args.begin();
if (update.count(*it) == 0) {
std::vector<unsigned long> indexes;
if (!append_indexes(args.begin(), ++it, &indexes)) {
return true;
}
auto events = utils->all();
if (!utils->good()) return true;
if (indexes.front() >= events.size()) {
std::ostringstream ss;
ss << "No such event: " << indexes.front() << std::endl;
Http::response(200, ss.str());
return true;
}
first_event = events.front()->id();
event.swap(events[indexes.front()]);
} else {
event = utils->next();
if (!utils->good()) return true;
if (!event) {
Http::response(200, "No event to update");
return true;
}
first_event = event->id();
}
while (it != args.end()) {
if (*it == "name") {
if (++it == args.end()) {
Http::response(200, "Missing argument to name");
return true;
}
event->set_name(*it);
++it;
} else if (*it == "start") {
if (++it == args.end()) {
Http::response(200, "Missing argument to start");
return true;
}
std::string text(*it);
for (++it; it != args.end() && update.count(*it) == 0; ++it) {
text.push_back(' ');
text.append(*it);
}
time_t time;
if (!parse_time(text, &time)) {
Http::response(200, "Bad argument to start: " + text);
return true;
}
event->set_start(time);
} else if (*it == "text") {
if (++it == args.end()) {
event->set_text("");
} else {
std::string text(*it);
for (++it; it != args.end() && update.count(*it) == 0; ++it) {
text.push_back(' ');
text.append(*it);
}
event->set_text(text);
}
} else {
Http::response(200, "Expected name/start/text, not: " + *it);
return true;
}
}
if (event->store()) {
Http::response(200, "Event updated");
utils->updated(event.get(), first_event);
} else {
Http::response(200, "Update failed");
}
return true;
}
bool show(EventUtils* utils,
std::map<std::string, std::string>& data,
std::vector<std::string>& args) {
std::vector<unsigned long> indexes;
if (args.empty()) {
indexes.push_back(0);
} else {
if (!append_indexes(args.begin(), args.end(), &indexes)) {
return true;
}
}
auto events = utils->all();
if (!utils->good()) return true;
std::ostringstream ss;
for (const auto& index : indexes) {
if (indexes.size() > 1) {
ss << '(' << index << ") ";
}
if (index >= events.size()) {
if (events.empty()) {
ss << "There are no events" << std::endl;
} else {
ss << "No such event: " << index << std::endl;
}
} else {
ss << events[index]->name() << " @ "
<< EventUtils::format_date(events[index]->start()) << std::endl;
const auto& text = events[index]->text();
if (!text.empty()) {
ss << text << std::endl;
}
std::vector<Event::Going> going;
events[index]->going(&going);
auto it = going.begin();
for (; it != going.end(); ++it) {
if (!it->is_going) break;
ss << it->name;
if (!it->note.empty()) {
ss << ": " << it->note;
}
ss << std::endl;
}
if (it != going.end()) ss << std::endl;
for (; it != going.end(); ++it) {
ss << it->name << ": not going";
if (!it->note.empty()) {
ss << ", " << it->note;
}
ss << std::endl;
}
}
}
Http::response(200, ss.str());
return true;
}
bool going(EventUtils* utils,
std::map<std::string, std::string>& data,
std::vector<std::string>& args,
bool going) {
const auto& user_name = data["user_name"];
if (user_name.empty()) {
Http::response(500, "No user_name");
return true;
}
std::unique_ptr<Event> event;
std::vector<unsigned long> indexes;
std::string note, user = user_name;
if (!args.empty() && args.front() == "user") {
if (args.size() == 1) {
Http::response(200, "Expected username after 'user'");
return true;
}
user = args[1];
args.erase(args.begin(), args.begin() + 2);
}
if (args.empty()) {
event = utils->next();
if (!utils->good()) return true;
} else {
if (args.size() == 1) {
char* end = nullptr;
errno = 0;
auto tmp = strtoul(args.front().c_str(), &end, 10);
if (errno == 0 && end && !*end) {
indexes.push_back(tmp);
}
if (indexes.empty()) {
event = utils->next();
if (!utils->good()) return true;
note = args.front();
}
} else {
auto it = args.begin() + 1;
if (!append_indexes(args.begin(), it, &indexes)) {
return true;
}
note = *it;
for (++it; it != args.end(); ++it) {
note.push_back(' ');
note.append(*it);
}
}
}
if (!event) {
auto events = utils->all();
if (!utils->good()) return true;
if (events.empty()) {
Http::response(200, "There are no events to attend");
return true;
}
if (indexes.front() >= events.size()) {
std::ostringstream ss;
ss << "There are no such event to attend: " << indexes.front();
Http::response(200, ss.str());
return true;
}
event.swap(events[indexes.front()]);
}
event->update_going(user, going, note);
if (event->store()) {
Http::response(200, "Your wish have been recorded, if not granted");
utils->going(event.get(), going, user, user_name);
} else {
Http::response(200, "Event store failed");
}
return true;
}
bool help(std::vector<std::string>& args) {
std::ostringstream ss;
if (args.empty()) {
ss << "Usage: help COMMAND" << std::endl;
ss << "Known commands: create, update, cancel, show, going, !going, join, part";
} else if (args.front() == "create") {
ss << "Usage: create NAME START [TEXT]" << std::endl;
ss << "Create a new event with the name NAME starting at START with"
<< " an optional description TEXT." << std::endl;
ss << "START can be of the format: [DATE|DAY] HH:MM";
} else if (args.front() == "update") {
ss << "Usage: update [INDEX] [name NAME] [start START] [text TEXT]"
<< std::endl;
ss << "Update an event, specified by index (default is next event)"
<< std::endl;
ss << "See help for create for description of NAME, START and TEXT.";
} else if (args.front() == "cancel") {
ss << "Usage: cancel [INDEX...]" << std::endl;
ss << "Cancel one or more events given by index"
<< " (default is next event)";
} else if (args.front() == "show") {
ss << "Usage: show [INDEX...]" << std::endl;
ss << "Show one or more events given by index"
<< " (default is next event)";
} else if (args.front() == "going" || args.front() == "join") {
ss << "Usage: going [user USER] [INDEX] [NOTE]" << std::endl;
ss << "Join an event specified by index (default is next event)"
<< " and add an optional NOTE" << std::endl;
ss << "If USER is specified, you're saying that USER is joining"
<< " instead of yourself - use with caution" << std::endl;
ss << "join is an alias for going";
} else if (args.front() == "!going" || args.front() == "part") {
ss << "Usage: !going [user USER] [INDEX] [NOTE]" << std::endl;
ss << "Un-join an event specified by index (default is next event)"
<< " and add an optional NOTE" << std::endl;
ss << "If USER is specified, you're saying that USER is not going"
<< " instead of yourself - use with caution" << std::endl;
ss << "part is an alias for !going";
} else {
ss << "Unknown command: " << args.front();
}
Http::response(200, ss.str());
return true;
}
void error_response(const std::string& message) {
Http::response(200, message);
}
bool handle_request(CGI* cgi) {
switch (cgi->request_type()) {
case CGI::GET:
case CGI::POST:
break;
default:
Http::response(500, "Unsupported request");
return true;
}
std::map<std::string, std::string> data;
cgi->get_data(&data);
const auto& token = data["token"];
if (token != g_cfg->get("token", "")) {
Http::response(500, "Bad token");
return true;
}
const auto& channel = data["channel_name"];
if (channel.empty()) {
Http::response(500, "No channel");;
return true;
}
std::vector<std::string> args;
if (!parse(data["text"], &args)) return true;
if (args.empty()) {
std::ostringstream ss;
ss << "Usage: [COMMAND] [ARGUMENTS]" << std::endl
<< "For more help about a command, use " << data["command"]
<< " help COMMAND";
Http::response(200, ss.str());
return true;
}
auto command = args.front();
args.erase(args.begin());
auto utils = EventUtils::create(channel, error_response, g_cfg.get(),
g_sender.get());
if (command == "create") {
return create(utils.get(), data, args);
}
if (command == "cancel") {
return cancel(utils.get(), data, args);
}
if (command == "update") {
return update(utils.get(), data, args);
}
if (command == "show") {
return show(utils.get(), data, args);
}
if (command == "going" || command == "join") {
return going(utils.get(), data, args, true);
}
if (command == "!going" || command == "part") {
return going(utils.get(), data, args, false);
}
if (command == "help") {
return help(args);
}
Http::response(200, "Unknown command: " + command);
return true;
}
} // namespace
int main() {
g_cfg = Config::create();
if (!g_cfg->load("./event.config")) {
g_cfg->load(SYSCONFDIR "/event.config");
}
g_sender = SenderClient::create(g_cfg.get());
int ret = CGI::run(handle_request);
g_sender.reset();
g_cfg.reset();
return ret;
}
|
UFO_SPAWN_BASE_TIME = 15
UFO_START_FRAME = 6
UFO_SHOT_TIME = 30
UFO_FRAMES = 4
.segment "BSS"
ufo_y: .res 1
ufo_x: .res 1
ufo_move_horizontal: .res 1
ufo_shot_wait: .res 1
ufo_shot_countdown: .res 1
ufo_active: .res 1
ufo_spawn_wait: .res 1
ufo_spawn_countdown: .res 1
ufo_frame: .res 1
ufo_temp: .res 1
ufo_reg_x: .res 1
ufo_reg_y: .res 1
.segment "CODE"
; at the beginning of the level set a timer to launch the ufo
.proc init_ufo_level_timer
lda #UFO_SPAWN_BASE_TIME
sec
sbc level
abs_a
sta ufo_spawn_wait
sta ufo_spawn_countdown
set ufo_shot_wait, #UFO_SHOT_TIME
rts
.endproc
; clobber the y register
.proc create_ufo
lda frame_counter
bne end ; if frame counter is not 0, we can not create a ufo
dec ufo_spawn_countdown
lda ufo_spawn_countdown
bne end ; if spawn countdown is not 0 we can not create a ufo
lda ufo_spawn_wait
sta ufo_spawn_countdown
lda ufo_active ; check to see if ufo is active
bne end ; if the ufo is currently active don't create a ufo
get_random_a
asl ; multiply random numbers by x2
bmi vertical
horizontal:
sta ufo_x
lda #0
sta ufo_y
lda #1
sta ufo_move_horizontal
jmp dir_end
vertical:
sta ufo_y
lda #0
sta ufo_x
sta ufo_move_horizontal
dir_end:
set ufo_active, #1
end:
rts
.endproc
; move the ufo position inside the game loop
.proc move_ufo
lda ufo_active
beq end
lda ufo_move_horizontal
beq vertical
horizontal:
inc ufo_y
lda ufo_y
bne dir_end
sta ufo_active ; ufo is no longer active
;set ufo_spawn_countdown, ufo_spawn_wait
jmp end
vertical:
inc ufo_x
lda ufo_x
bne dir_end
sta ufo_active ; ufo is no longer active
;set ufo_spawn_countdown, ufo_spawn_wait
jmp end
dir_end:
inc ufo_frame
lda ufo_frame
and #%00000011
sta ufo_frame
clc
adc #UFO_START_FRAME
sta ufo_temp
render_sprite ufo_y, ufo_x, ufo_temp, #PLAYER_PALETTE
dec ufo_shot_countdown
lda ufo_shot_countdown
bne no_shot
set ufo_shot_countdown, ufo_shot_wait
jsr ufo_shoot
no_shot:
end:
rts
.endproc
; destroy the ufo
.proc kill_ufo
lda ufo_active
bne ufo_alive
rts ; can't be killed if already dead
ufo_alive:
lda #0
sta ufo_active ; kill off ufo
create_explosion ufo_y, ufo_x
stx ufo_reg_x
sty ufo_reg_y
lda #50
jsr add_score_base10
ldx ufo_reg_x
ldy ufo_reg_y
rts
.endproc |
; A186316: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) before g(j) when f(i)=g(j), where f and g are the squares and hexagonal numbers. Complement of A186315.
; 2,4,6,9,11,14,16,18,21,23,26,28,31,33,35,38,40,43,45,47,50,52,55,57,60,62,64,67,69,72,74,76,79,81,84,86,88,91,93,96,98,101,103,105,108,110,113,115,117,120,122,125,127,130,132,134,137,139,142,144,146,149,151,154,156,158,161,163,166,168,171,173,175,178,180,183,185,187,190,192,195,197,200,202,204,207,209,212,214,216,219,221,224,226,228,231,233,236,238,241
add $0,5
mul $0,70
div $0,29
sub $0,10
|
; A165826: Totally multiplicative sequence with a(p) = 5.
; 1,5,5,25,5,25,5,125,25,25,5,125,5,25,25,625,5,125,5,125,25,25,5,625,25,25,125,125,5,125,5,3125,25,25,25,625,5,25,25,625,5,125,5,125,125,25,5,3125,25,125,25,125,5,625,25,625,25,25,5,625,5,25,125,15625,25,125,5,125,25,125,5,3125,5,25,125,125,25,125,5,3125,625,25,5,625,25,25,25,625,5,625,25,125,25,25,25,15625,5,125,125,625,5,125,5,625,125,25,5,3125,5,125,25,3125,5,125,25,125,125,25,25,3125,25,25,25,125,125,625,5,78125,25,125,5,625,25,25,625,625,5,125,5,625,25,25,25,15625,25,25,125,125,5,625,5,625,125,125,25,625,5,25,25,15625,25,3125,5,125,125,25,5,3125,25,125,125,125,5,125,125,3125,25,25,5,3125,5,125,25,625,25,125,25,125,625,125,5,78125,5,25,125,625,5,625,5,3125,25,25,25,625,25,25,125,3125,25,625,5,125,25,25,25,15625,25,25,25,625,25,125,5,15625,625,25,5,625,5,125,125,625,5,625,25,125,25,125,5,15625,5,125,3125,125,125,125,25,625,25,625
cal $0,73093 ; Number of prime power divisors of n.
cal $0,170111 ; Number of reduced words of length n in Coxeter group on 6 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I.
mov $1,$0
mul $1,2916
div $1,23328
mul $1,2
div $1,6
mul $1,4
add $1,1
|
#!/usr/bin/sisa16_asm -run
//use a separately compiled libc.
//..include"libc_pre.hasm"
//..(2):
//..dinclude"libc_pre.bin"
//use the normal libc.
..include"libc.hasm"
..(5):
length_of_input_string:
bytes %/0%;
..main(3):
lrx0 %/what%
proc_krenel
halt;
what:
la '\n'; interrupt;
lrx0 %0xc%,%0%;
proc_gets
lrx0 %0xc%,%0%;
proc_prints
la '\n'; putchar; la '\r'; putchar;
lrx0 %0xc%,%0%;
proc_stringlen;
//we now have the length of the string stored, we have to get it into RX0.
rxincr;
farstrx0 %&length_of_input_string%;
rx2_0;
//The length of the string (plus one, for the null byte) is now in RX2, the src and dest arguments must be setup.
lrx0 %/0xd0000%
lrx1 %/0xc0000%
proc_memcpy;
lrx0 %0xd%,%0%;
proc_prints;
la '\n'; putchar; la '\r'; putchar;
//We would now like to write to disk.
lrx0 %/0x3001% //location in file.
llb %0xd00% //the source in memory.
proc_fwrite
lrx0 %/0x3001% //the source in file.
llb %0xe00% //the destination in memory.
proc_fread
lrx0 %/0xe0000%
proc_atoi_dec
proc_rxsqrt
lrx1 %/0xc0000%;
proc_itoa_dec
lrx0 %0xc%,%0%;
proc_prints
la '\n'; putchar;
la '\r'; putchar;
lrx0 %/0x1000%;
proc_alloc;
rx2_0
la '\n'; putchar; la '\r'; putchar;
//print the number!
rx0_2;arx0;apush;
lb8; rx1b;rxrsh;arx0;apush;
rx0_2;lb16;rx1b;rxrsh;arx0;apush;
rx0_2;lb24;rx1b;rxrsh;arx0;apush;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
rx0_2;
//lrx1 %/256%;rxadd;
proc_free;
la '\n'; putchar;
la '\r'; putchar;
lrx0 %/0xF00%;
proc_alloc;
rx2_0
//print the number!
rx0_2;arx0;apush;
lb8; rx1b;rxrsh;arx0;apush;
rx0_2;lb16;rx1b;rxrsh;arx0;apush;
rx0_2;lb24;rx1b;rxrsh;arx0;apush;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
la '\n'; putchar;
la '\r'; putchar;
lrx0 %/0xBAFF00%;
proc_alloc;
rx2_0
//print the number!
rx0_2;arx0;apush;
lb8; rx1b;rxrsh;arx0;apush;
rx0_2;lb16;rx1b;rxrsh;arx0;apush;
rx0_2;lb24;rx1b;rxrsh;arx0;apush;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
proc_printbytelchex;
apop;
la '\n'; interrupt;
halt;
|
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// +build
#include <algorithm>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if !GOOS_windows
#include <unistd.h>
#endif
#include "defs.h"
#if defined(__GNUC__)
#define SYSCALLAPI
#define NORETURN __attribute__((noreturn))
#define ALIGNED(N) __attribute__((aligned(N)))
#define PRINTF(fmt, args) __attribute__((format(printf, fmt, args)))
#define INPUT_DATA_ALIGNMENT 64 << 10
#else
// Assuming windows/cl.
#define SYSCALLAPI WINAPI
#define NORETURN __declspec(noreturn)
#define INPUT_DATA_ALIGNMENT 4 << 10
#define ALIGNED(N) __declspec(align(N)) // here we are not aligning the value because of msvc reporting the value as an illegal value
#define PRINTF(fmt, args)
#define __thread __declspec(thread)
#endif
#ifndef GIT_REVISION
#define GIT_REVISION "unknown"
#endif
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
// uint64 is impossible to printf without using the clumsy and verbose "%" PRId64.
// So we define and use uint64. Note: pkg/csource does s/uint64/uint64/.
// Also define uint32/16/8 for consistency.
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
// exit/_exit do not necessary work (e.g. if fuzzer sets seccomp filter that prohibits exit_group).
// Use doexit instead. We must redefine exit to something that exists in stdlib,
// because some standard libraries contain "using ::exit;", but has different signature.
#define exit vsnprintf
// Dynamic memory allocation reduces test reproducibility across different libc versions and kernels.
// malloc will cause unspecified number of additional mmap's at unspecified locations.
// For small objects prefer stack allocations, for larger -- either global objects (this may have
// issues with concurrency), or controlled mmaps, or make the fuzzer allocate memory.
#define malloc do_not_use_malloc
#define calloc do_not_use_calloc
// Note: zircon max fd is 256.
// Some common_OS.h files know about this constant for RLIMIT_NOFILE.
const int kMaxFd = 250;
const int kMaxThreads = 32;
const int kInPipeFd = kMaxFd - 1; // remapped from stdin
const int kOutPipeFd = kMaxFd - 2; // remapped from stdout
const int kCoverFd = kOutPipeFd - kMaxThreads;
const int kExtraCoverFd = kCoverFd - 1;
const int kMaxArgs = 9;
const int kCoverSize = 256 << 10;
const int kFailStatus = 67;
// Two approaches of dealing with kcov memory.
const int kCoverOptimizedCount = 12; // the number of kcov instances to be opened inside main()
const int kCoverOptimizedPreMmap = 3; // this many will be mmapped inside main(), others - when needed.
const int kCoverDefaultCount = 6; // otherwise we only init kcov instances inside main()
// Logical error (e.g. invalid input program), use as an assert() alternative.
// If such error happens 10+ times in a row, it will be detected as a bug by syz-fuzzer.
// syz-fuzzer will fail and syz-manager will create a bug for this.
// Note: err is used for bug deduplication, thus distinction between err (constant message)
// and msg (varying part).
static NORETURN void fail(const char* err);
static NORETURN PRINTF(2, 3) void failmsg(const char* err, const char* msg, ...);
// Just exit (e.g. due to temporal ENOMEM error).
static NORETURN PRINTF(1, 2) void exitf(const char* msg, ...);
static NORETURN void doexit(int status);
static NORETURN void doexit_thread(int status);
// Print debug output that is visible when running syz-manager/execprog with -debug flag.
// Debug output is supposed to be relatively high-level (syscalls executed, return values, timing, etc)
// and is intended mostly for end users. If you need to debug lower-level details, use debug_verbose
// function and temporary enable it in your build by changing #if 0 below.
// This function does not add \n at the end of msg as opposed to the previous functions.
static PRINTF(1, 2) void debug(const char* msg, ...);
void debug_dump_data(const char* data, int length);
#if 0
#define debug_verbose(...) debug(__VA_ARGS__)
#else
#define debug_verbose(...) (void)0
#endif
static void receive_execute();
static void reply_execute(int status);
#if GOOS_akaros
static void resend_execute(int fd);
#endif
#if SYZ_EXECUTOR_USES_FORK_SERVER
static void receive_handshake();
static void reply_handshake();
#endif
#if SYZ_EXECUTOR_USES_SHMEM
// The output region is the only thing in executor process for which consistency matters.
// If it is corrupted ipc package will fail to parse its contents and panic.
// But fuzzer constantly invents new ways of how to currupt the region,
// so we map the region at a (hopefully) hard to guess address with random offset,
// surrounded by unmapped pages.
// The address chosen must also work on 32-bit kernels with 1GB user address space.
const uint64 kOutputBase = 0x1b2bc20000ull;
#if SYZ_EXECUTOR_USES_FORK_SERVER
// Allocating (and forking) virtual memory for each executed process is expensive, so we only mmap
// the amount we might possibly need for the specific received prog.
const int kMaxOutputComparisons = 14 << 20; // executions with comparsions enabled are usually < 1% of all executions
const int kMaxOutputCoverage = 6 << 20; // coverage is needed in ~ up to 1/3 of all executions (depending on corpus rotation)
const int kMaxOutputSignal = 4 << 20;
const int kMinOutput = 256 << 10; // if we don't need to send signal, the output is rather short.
const int kInitialOutput = kMinOutput; // the minimal size to be allocated in the parent process
#else
// We don't fork and allocate the memory only once, so prepare for the worst case.
const int kInitialOutput = 14 << 20;
#endif
// TODO: allocate a smaller amount of memory in the parent once we merge the patches that enable
// prog execution with neither signal nor coverage. Likely 64kb will be enough in that case.
const int kInFd = 3;
const int kOutFd = 4;
static uint32* output_data;
static uint32* output_pos;
static int output_size;
static void mmap_output(int size);
static uint32* write_output(uint32 v);
static uint32* write_output_64(uint64 v);
static void write_completed(uint32 completed);
static uint32 hash(uint32 a);
static bool dedup(uint32 sig);
#endif
uint64 start_time_ms = 0;
static bool flag_debug;
static bool flag_coverage;
static bool flag_sandbox_none;
static bool flag_sandbox_setuid;
static bool flag_sandbox_namespace;
static bool flag_sandbox_android;
static bool flag_extra_coverage;
static bool flag_net_injection;
static bool flag_net_devices;
static bool flag_net_reset;
static bool flag_cgroups;
static bool flag_close_fds;
static bool flag_devlink_pci;
static bool flag_vhci_injection;
static bool flag_wifi;
static bool flag_delay_kcov_mmap;
static bool flag_collect_cover;
static bool flag_collect_signal;
static bool flag_dedup_cover;
static bool flag_threaded;
static bool flag_coverage_filter;
// If true, then executor should write the comparisons data to fuzzer.
static bool flag_comparisons;
// Tunable timeouts, received with execute_req.
static uint64 syscall_timeout_ms;
static uint64 program_timeout_ms;
static uint64 slowdown_scale;
#define SYZ_EXECUTOR 1
#include "common.h"
const int kMaxInput = 4 << 20; // keep in sync with prog.ExecBufferSize
const int kMaxCommands = 1000; // prog package knows about this constant (prog.execMaxCommands)
const uint64 instr_eof = -1;
const uint64 instr_copyin = -2;
const uint64 instr_copyout = -3;
const uint64 instr_setprops = -4;
const uint64 arg_const = 0;
const uint64 arg_result = 1;
const uint64 arg_data = 2;
const uint64 arg_csum = 3;
const uint64 binary_format_native = 0;
const uint64 binary_format_bigendian = 1;
const uint64 binary_format_strdec = 2;
const uint64 binary_format_strhex = 3;
const uint64 binary_format_stroct = 4;
const uint64 no_copyout = -1;
static int running;
uint32 completed;
bool is_kernel_64_bit = true;
ALIGNED(INPUT_DATA_ALIGNMENT)
static char input_data[kMaxInput];
// Checksum kinds.
static const uint64 arg_csum_inet = 0;
// Checksum chunk kinds.
static const uint64 arg_csum_chunk_data = 0;
static const uint64 arg_csum_chunk_const = 1;
typedef intptr_t(SYSCALLAPI* syscall_t)(intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t);
struct call_t {
const char* name;
int sys_nr;
call_attrs_t attrs;
syscall_t call;
};
struct cover_t {
int fd;
uint32 size;
uint32 mmap_alloc_size;
char* data;
char* data_end;
// Note: On everything but darwin the first value in data is the count of
// recorded PCs, followed by the PCs. We therefore set data_offset to the
// size of one PC.
// On darwin data points to an instance of the ksancov_trace struct. Here we
// set data_offset to the offset between data and the structs 'pcs' member,
// which contains the PCs.
intptr_t data_offset;
// Note: On everything but darwin this is 0, as the PCs contained in data
// are already correct. XNUs KSANCOV API, however, chose to always squeeze
// PCs into 32 bit. To make the recorded PC fit, KSANCOV substracts a fixed
// offset (VM_MIN_KERNEL_ADDRESS for AMD64) and then truncates the result to
// uint32_t. We get this from the 'offset' member in ksancov_trace.
intptr_t pc_offset;
};
struct thread_t {
int id;
bool created;
event_t ready;
event_t done;
uint64* copyout_pos;
uint64 copyout_index;
bool executing;
int call_index;
int call_num;
int num_args;
intptr_t args[kMaxArgs];
call_props_t call_props;
intptr_t res;
uint32 reserrno;
bool fault_injected;
cover_t cov;
bool soft_fail_state;
};
static thread_t threads[kMaxThreads];
static thread_t* last_scheduled;
// Threads use this variable to access information about themselves.
static __thread struct thread_t* current_thread;
static cover_t extra_cov;
struct res_t {
bool executed;
uint64 val;
};
static res_t results[kMaxCommands];
const uint64 kInMagic = 0xbadc0ffeebadface;
const uint32 kOutMagic = 0xbadf00d;
struct handshake_req {
uint64 magic;
uint64 flags; // env flags
uint64 pid;
};
struct handshake_reply {
uint32 magic;
};
struct execute_req {
uint64 magic;
uint64 env_flags;
uint64 exec_flags;
uint64 pid;
uint64 syscall_timeout_ms;
uint64 program_timeout_ms;
uint64 slowdown_scale;
uint64 prog_size;
};
struct execute_reply {
uint32 magic;
uint32 done;
uint32 status;
};
// call_reply.flags
const uint32 call_flag_executed = 1 << 0;
const uint32 call_flag_finished = 1 << 1;
const uint32 call_flag_blocked = 1 << 2;
const uint32 call_flag_fault_injected = 1 << 3;
struct call_reply {
execute_reply header;
uint32 magic;
uint32 call_index;
uint32 call_num;
uint32 reserrno;
uint32 flags;
uint32 signal_size;
uint32 cover_size;
uint32 comps_size;
// signal/cover/comps follow
};
enum {
KCOV_CMP_CONST = 1,
KCOV_CMP_SIZE1 = 0,
KCOV_CMP_SIZE2 = 2,
KCOV_CMP_SIZE4 = 4,
KCOV_CMP_SIZE8 = 6,
KCOV_CMP_SIZE_MASK = 6,
};
struct kcov_comparison_t {
// Note: comparisons are always 64-bits regardless of kernel bitness.
uint64 type;
uint64 arg1;
uint64 arg2;
uint64 pc;
bool ignore() const;
void write();
bool operator==(const struct kcov_comparison_t& other) const;
bool operator<(const struct kcov_comparison_t& other) const;
};
typedef char kcov_comparison_size[sizeof(kcov_comparison_t) == 4 * sizeof(uint64) ? 1 : -1];
struct feature_t {
const char* name;
void (*setup)();
};
static thread_t* schedule_call(int call_index, int call_num, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos, call_props_t call_props);
static void handle_completion(thread_t* th);
static void copyout_call_results(thread_t* th);
static void write_call_output(thread_t* th, bool finished);
static void write_extra_output();
static void execute_call(thread_t* th);
static void thread_create(thread_t* th, int id, bool need_coverage);
static void thread_mmap_cover(thread_t* th);
static void* worker_thread(void* arg);
static uint64 read_input(uint64** input_posp, bool peek = false);
static uint64 read_arg(uint64** input_posp);
static uint64 read_const_arg(uint64** input_posp, uint64* size_p, uint64* bf, uint64* bf_off_p, uint64* bf_len_p);
static uint64 read_result(uint64** input_posp);
static uint64 swap(uint64 v, uint64 size, uint64 bf);
static void copyin(char* addr, uint64 val, uint64 size, uint64 bf, uint64 bf_off, uint64 bf_len);
static bool copyout(char* addr, uint64 size, uint64* res);
static void setup_control_pipes();
static void setup_features(char** enable, int n);
#include "syscalls.h"
#if GOOS_linux
#include "executor_linux.h"
#elif GOOS_fuchsia
#include "executor_fuchsia.h"
#elif GOOS_akaros
#include "executor_akaros.h"
#elif GOOS_freebsd || GOOS_netbsd || GOOS_openbsd
#include "executor_bsd.h"
#elif GOOS_darwin
#include "executor_darwin.h"
#elif GOOS_windows
#include "executor_windows.h"
#elif GOOS_test
#include "executor_test.h"
#else
#error "unknown OS"
#endif
#include "cov_filter.h"
#include "test.h"
int main(int argc, char** argv)
{
if (argc == 2 && strcmp(argv[1], "version") == 0) {
puts(GOOS " " GOARCH " " SYZ_REVISION " " GIT_REVISION);
return 0;
}
if (argc >= 2 && strcmp(argv[1], "setup") == 0) {
setup_features(argv + 2, argc - 2);
return 0;
}
if (argc >= 2 && strcmp(argv[1], "leak") == 0) {
#if SYZ_HAVE_LEAK_CHECK
check_leaks(argv + 2, argc - 2);
#else
fail("leak checking is not implemented");
#endif
return 0;
}
if (argc >= 2 && strcmp(argv[1], "setup_kcsan_filterlist") == 0) {
#if SYZ_HAVE_KCSAN
setup_kcsan_filterlist(argv + 2, argc - 2, true);
#else
fail("KCSAN is not implemented");
#endif
return 0;
}
if (argc == 2 && strcmp(argv[1], "test") == 0)
return run_tests();
if (argc < 2 || strcmp(argv[1], "exec") != 0) {
fprintf(stderr, "unknown command");
return 1;
}
start_time_ms = current_time_ms();
os_init(argc, argv, (char*)SYZ_DATA_OFFSET, SYZ_NUM_PAGES * SYZ_PAGE_SIZE);
current_thread = &threads[0];
#if SYZ_EXECUTOR_USES_SHMEM
if (mmap(&input_data[0], kMaxInput, PROT_READ, MAP_PRIVATE | MAP_FIXED, kInFd, 0) != &input_data[0])
fail("mmap of input file failed");
mmap_output(kInitialOutput);
// Prevent test programs to mess with these fds.
// Due to races in collider mode, a program can e.g. ftruncate one of these fds,
// which will cause fuzzer to crash.
close(kInFd);
#if !SYZ_EXECUTOR_USES_FORK_SERVER
close(kOutFd);
#endif
// For SYZ_EXECUTOR_USES_FORK_SERVER, close(kOutFd) is invoked in the forked child,
// after the program has been received.
#endif
use_temporary_dir();
install_segv_handler();
setup_control_pipes();
#if SYZ_EXECUTOR_USES_FORK_SERVER
receive_handshake();
#else
receive_execute();
#endif
if (flag_coverage) {
int create_count = kCoverDefaultCount, mmap_count = create_count;
if (flag_delay_kcov_mmap) {
create_count = kCoverOptimizedCount;
mmap_count = kCoverOptimizedPreMmap;
}
if (create_count > kMaxThreads)
create_count = kMaxThreads;
for (int i = 0; i < create_count; i++) {
threads[i].cov.fd = kCoverFd + i;
cover_open(&threads[i].cov, false);
if (i < mmap_count) {
// Pre-mmap coverage collection for some threads. This should be enough for almost
// all programs, for the remaning few ones coverage will be set up when it's needed.
thread_mmap_cover(&threads[i]);
}
}
extra_cov.fd = kExtraCoverFd;
cover_open(&extra_cov, true);
cover_mmap(&extra_cov);
cover_protect(&extra_cov);
if (flag_extra_coverage) {
// Don't enable comps because we don't use them in the fuzzer yet.
cover_enable(&extra_cov, false, true);
}
char sep = '/';
#if GOOS_windows
sep = '\\';
#endif
char filename[1024] = {0};
char* end = strrchr(argv[0], sep);
size_t len = end - argv[0];
strncpy(filename, argv[0], len + 1);
strncat(filename, "syz-cover-bitmap", 17);
filename[sizeof(filename) - 1] = '\0';
init_coverage_filter(filename);
}
int status = 0;
if (flag_sandbox_none)
status = do_sandbox_none();
#if SYZ_HAVE_SANDBOX_SETUID
else if (flag_sandbox_setuid)
status = do_sandbox_setuid();
#endif
#if SYZ_HAVE_SANDBOX_NAMESPACE
else if (flag_sandbox_namespace)
status = do_sandbox_namespace();
#endif
#if SYZ_HAVE_SANDBOX_ANDROID
else if (flag_sandbox_android)
status = do_sandbox_android();
#endif
else
fail("unknown sandbox type");
#if SYZ_EXECUTOR_USES_FORK_SERVER
fprintf(stderr, "loop exited with status %d\n", status);
// Other statuses happen when fuzzer processes manages to kill loop, e.g. with:
// ptrace(PTRACE_SEIZE, 1, 0, 0x100040)
if (status != kFailStatus)
status = 0;
// If an external sandbox process wraps executor, the out pipe will be closed
// before the sandbox process exits this will make ipc package kill the sandbox.
// As the result sandbox process will exit with exit status 9 instead of the executor
// exit status (notably kFailStatus). So we duplicate the exit status on the pipe.
reply_execute(status);
doexit(status);
// Unreachable.
return 1;
#else
reply_execute(status);
return status;
#endif
}
#if SYZ_EXECUTOR_USES_SHMEM
// This method can be invoked as many times as one likes - MMAP_FIXED can overwrite the previous
// mapping without any problems. The only precondition - kOutFd must not be closed.
static void mmap_output(int size)
{
if (size <= output_size)
return;
if (size % SYZ_PAGE_SIZE != 0)
failmsg("trying to mmap output area that is not divisible by page size", "page=%d,area=%d", SYZ_PAGE_SIZE, size);
uint32* mmap_at = NULL;
if (output_data == NULL) {
// It's the first time we map output region - generate its location.
output_data = mmap_at = (uint32*)(kOutputBase + (1 << 20) * (getpid() % 128));
} else {
// We are expanding the mmapped region. Adjust the parameters to avoid mmapping already
// mmapped area as much as possible.
// There exists a mremap call that could have helped, but it's purely Linux-specific.
mmap_at = (uint32*)((char*)(output_data) + output_size);
}
void* result = mmap(mmap_at, size - output_size,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, kOutFd, output_size);
if (result != mmap_at)
fail("mmap of output file failed");
output_size = size;
}
#endif
void setup_control_pipes()
{
if (dup2(0, kInPipeFd) < 0)
fail("dup2(0, kInPipeFd) failed");
if (dup2(1, kOutPipeFd) < 0)
fail("dup2(1, kOutPipeFd) failed");
if (dup2(2, 1) < 0)
fail("dup2(2, 1) failed");
// We used to close(0), but now we dup stderr to stdin to keep fd numbers
// stable across executor and C programs generated by pkg/csource.
if (dup2(2, 0) < 0)
fail("dup2(2, 0) failed");
}
void parse_env_flags(uint64 flags)
{
// Note: Values correspond to ordering in pkg/ipc/ipc.go, e.g. FlagSandboxNamespace
flag_debug = flags & (1 << 0);
flag_coverage = flags & (1 << 1);
if (flags & (1 << 2))
flag_sandbox_setuid = true;
else if (flags & (1 << 3))
flag_sandbox_namespace = true;
else if (flags & (1 << 4))
flag_sandbox_android = true;
else
flag_sandbox_none = true;
flag_extra_coverage = flags & (1 << 5);
flag_net_injection = flags & (1 << 6);
flag_net_devices = flags & (1 << 7);
flag_net_reset = flags & (1 << 8);
flag_cgroups = flags & (1 << 9);
flag_close_fds = flags & (1 << 10);
flag_devlink_pci = flags & (1 << 11);
flag_vhci_injection = flags & (1 << 12);
flag_wifi = flags & (1 << 13);
flag_delay_kcov_mmap = flags & (1 << 14);
}
#if SYZ_EXECUTOR_USES_FORK_SERVER
void receive_handshake()
{
handshake_req req = {};
int n = read(kInPipeFd, &req, sizeof(req));
if (n != sizeof(req))
failmsg("handshake read failed", "read=%d", n);
if (req.magic != kInMagic)
failmsg("bad handshake magic", "magic=0x%llx", req.magic);
parse_env_flags(req.flags);
procid = req.pid;
}
void reply_handshake()
{
handshake_reply reply = {};
reply.magic = kOutMagic;
if (write(kOutPipeFd, &reply, sizeof(reply)) != sizeof(reply))
fail("control pipe write failed");
}
#endif
static execute_req last_execute_req;
void receive_execute()
{
execute_req& req = last_execute_req;
if (read(kInPipeFd, &req, sizeof(req)) != (ssize_t)sizeof(req))
fail("control pipe read failed");
if (req.magic != kInMagic)
failmsg("bad execute request magic", "magic=0x%llx", req.magic);
if (req.prog_size > kMaxInput)
failmsg("bad execute prog size", "size=0x%llx", req.prog_size);
parse_env_flags(req.env_flags);
procid = req.pid;
syscall_timeout_ms = req.syscall_timeout_ms;
program_timeout_ms = req.program_timeout_ms;
slowdown_scale = req.slowdown_scale;
flag_collect_signal = req.exec_flags & (1 << 0);
flag_collect_cover = req.exec_flags & (1 << 1);
flag_dedup_cover = req.exec_flags & (1 << 2);
flag_comparisons = req.exec_flags & (1 << 3);
flag_threaded = req.exec_flags & (1 << 4);
flag_coverage_filter = req.exec_flags & (1 << 5);
debug("[%llums] exec opts: procid=%llu threaded=%d cover=%d comps=%d dedup=%d signal=%d"
" timeouts=%llu/%llu/%llu prog=%llu filter=%d\n",
current_time_ms() - start_time_ms, procid, flag_threaded, flag_collect_cover,
flag_comparisons, flag_dedup_cover, flag_collect_signal, syscall_timeout_ms,
program_timeout_ms, slowdown_scale, req.prog_size, flag_coverage_filter);
if (syscall_timeout_ms == 0 || program_timeout_ms <= syscall_timeout_ms || slowdown_scale == 0)
failmsg("bad timeouts", "syscall=%llu, program=%llu, scale=%llu",
syscall_timeout_ms, program_timeout_ms, slowdown_scale);
if (SYZ_EXECUTOR_USES_SHMEM) {
if (req.prog_size)
fail("need_prog: no program");
return;
}
if (req.prog_size == 0)
fail("need_prog: no program");
uint64 pos = 0;
for (;;) {
ssize_t rv = read(kInPipeFd, input_data + pos, sizeof(input_data) - pos);
if (rv < 0)
fail("read failed");
pos += rv;
if (rv == 0 || pos >= req.prog_size)
break;
}
if (pos != req.prog_size)
failmsg("bad input size", "size=%lld, want=%lld", pos, req.prog_size);
}
bool cover_collection_required()
{
return flag_coverage && (flag_collect_signal || flag_collect_cover || flag_comparisons);
}
#if GOOS_akaros
void resend_execute(int fd)
{
execute_req& req = last_execute_req;
if (write(fd, &req, sizeof(req)) != sizeof(req))
fail("child pipe header write failed");
if (write(fd, input_data, req.prog_size) != (ssize_t)req.prog_size)
fail("child pipe program write failed");
}
#endif
void reply_execute(int status)
{
execute_reply reply = {};
reply.magic = kOutMagic;
reply.done = true;
reply.status = status;
if (write(kOutPipeFd, &reply, sizeof(reply)) != sizeof(reply))
fail("control pipe write failed");
}
#if SYZ_EXECUTOR_USES_SHMEM
void realloc_output_data()
{
#if SYZ_EXECUTOR_USES_FORK_SERVER
if (flag_comparisons)
mmap_output(kMaxOutputComparisons);
else if (flag_collect_cover)
mmap_output(kMaxOutputCoverage);
else if (flag_collect_signal)
mmap_output(kMaxOutputSignal);
if (close(kOutFd) < 0)
fail("failed to close kOutFd");
#endif
}
#endif
// execute_one executes program stored in input_data.
void execute_one()
{
#if SYZ_EXECUTOR_USES_SHMEM
realloc_output_data();
output_pos = output_data;
write_output(0); // Number of executed syscalls (updated later).
#endif
uint64 start = current_time_ms();
uint64* input_pos = (uint64*)input_data;
if (cover_collection_required()) {
if (!flag_threaded)
cover_enable(&threads[0].cov, flag_comparisons, false);
if (flag_extra_coverage)
cover_reset(&extra_cov);
}
int call_index = 0;
uint64 prog_extra_timeout = 0;
uint64 prog_extra_cover_timeout = 0;
call_props_t call_props;
memset(&call_props, 0, sizeof(call_props));
for (;;) {
uint64 call_num = read_input(&input_pos);
if (call_num == instr_eof)
break;
if (call_num == instr_copyin) {
char* addr = (char*)read_input(&input_pos);
uint64 typ = read_input(&input_pos);
switch (typ) {
case arg_const: {
uint64 size, bf, bf_off, bf_len;
uint64 arg = read_const_arg(&input_pos, &size, &bf, &bf_off, &bf_len);
copyin(addr, arg, size, bf, bf_off, bf_len);
break;
}
case arg_result: {
uint64 meta = read_input(&input_pos);
uint64 size = meta & 0xff;
uint64 bf = meta >> 8;
uint64 val = read_result(&input_pos);
copyin(addr, val, size, bf, 0, 0);
break;
}
case arg_data: {
uint64 size = read_input(&input_pos);
size &= ~(1ull << 63); // readable flag
NONFAILING(memcpy(addr, input_pos, size));
// Read out the data.
for (uint64 i = 0; i < (size + 7) / 8; i++)
read_input(&input_pos);
break;
}
case arg_csum: {
debug_verbose("checksum found at %p\n", addr);
uint64 size = read_input(&input_pos);
char* csum_addr = addr;
uint64 csum_kind = read_input(&input_pos);
switch (csum_kind) {
case arg_csum_inet: {
if (size != 2)
failmsg("bag inet checksum size", "size=%llu", size);
debug_verbose("calculating checksum for %p\n", csum_addr);
struct csum_inet csum;
csum_inet_init(&csum);
uint64 chunks_num = read_input(&input_pos);
uint64 chunk;
for (chunk = 0; chunk < chunks_num; chunk++) {
uint64 chunk_kind = read_input(&input_pos);
uint64 chunk_value = read_input(&input_pos);
uint64 chunk_size = read_input(&input_pos);
switch (chunk_kind) {
case arg_csum_chunk_data:
debug_verbose("#%lld: data chunk, addr: %llx, size: %llu\n",
chunk, chunk_value, chunk_size);
NONFAILING(csum_inet_update(&csum, (const uint8*)chunk_value, chunk_size));
break;
case arg_csum_chunk_const:
if (chunk_size != 2 && chunk_size != 4 && chunk_size != 8)
failmsg("bad checksum const chunk size", "size=%lld", chunk_size);
// Here we assume that const values come to us big endian.
debug_verbose("#%lld: const chunk, value: %llx, size: %llu\n",
chunk, chunk_value, chunk_size);
csum_inet_update(&csum, (const uint8*)&chunk_value, chunk_size);
break;
default:
failmsg("bad checksum chunk kind", "kind=%llu", chunk_kind);
}
}
uint16 csum_value = csum_inet_digest(&csum);
debug_verbose("writing inet checksum %hx to %p\n", csum_value, csum_addr);
copyin(csum_addr, csum_value, 2, binary_format_native, 0, 0);
break;
}
default:
failmsg("bad checksum kind", "kind=%llu", csum_kind);
}
break;
}
default:
failmsg("bad argument type", "type=%llu", typ);
}
continue;
}
if (call_num == instr_copyout) {
read_input(&input_pos); // index
read_input(&input_pos); // addr
read_input(&input_pos); // size
// The copyout will happen when/if the call completes.
continue;
}
if (call_num == instr_setprops) {
read_call_props_t(call_props, read_input(&input_pos, false));
continue;
}
// Normal syscall.
if (call_num >= ARRAY_SIZE(syscalls))
failmsg("invalid syscall number", "call_num=%llu", call_num);
const call_t* call = &syscalls[call_num];
if (call->attrs.disabled)
failmsg("executing disabled syscall", "syscall=%s", call->name);
if (prog_extra_timeout < call->attrs.prog_timeout)
prog_extra_timeout = call->attrs.prog_timeout * slowdown_scale;
if (strncmp(syscalls[call_num].name, "syz_usb", strlen("syz_usb")) == 0)
prog_extra_cover_timeout = std::max(prog_extra_cover_timeout, 500 * slowdown_scale);
if (strncmp(syscalls[call_num].name, "syz_80211_inject_frame", strlen("syz_80211_inject_frame")) == 0)
prog_extra_cover_timeout = std::max(prog_extra_cover_timeout, 300 * slowdown_scale);
uint64 copyout_index = read_input(&input_pos);
uint64 num_args = read_input(&input_pos);
if (num_args > kMaxArgs)
failmsg("command has bad number of arguments", "args=%llu", num_args);
uint64 args[kMaxArgs] = {};
for (uint64 i = 0; i < num_args; i++)
args[i] = read_arg(&input_pos);
for (uint64 i = num_args; i < kMaxArgs; i++)
args[i] = 0;
thread_t* th = schedule_call(call_index++, call_num, copyout_index,
num_args, args, input_pos, call_props);
if (call_props.async && flag_threaded) {
// Don't wait for an async call to finish. We'll wait at the end.
// If we're not in the threaded mode, just ignore the async flag - during repro simplification syzkaller
// will anyway try to make it non-threaded.
} else if (flag_threaded) {
// Wait for call completion.
uint64 timeout_ms = syscall_timeout_ms + call->attrs.timeout * slowdown_scale;
// This is because of printing pre/post call. Ideally we print everything in the main thread
// and then remove this (would also avoid intermixed output).
if (flag_debug && timeout_ms < 1000)
timeout_ms = 1000;
if (event_timedwait(&th->done, timeout_ms))
handle_completion(th);
// Check if any of previous calls have completed.
for (int i = 0; i < kMaxThreads; i++) {
th = &threads[i];
if (th->executing && event_isset(&th->done))
handle_completion(th);
}
} else {
// Execute directly.
if (th != &threads[0])
fail("using non-main thread in non-thread mode");
event_reset(&th->ready);
execute_call(th);
event_set(&th->done);
handle_completion(th);
}
memset(&call_props, 0, sizeof(call_props));
}
if (running > 0) {
// Give unfinished syscalls some additional time.
last_scheduled = 0;
uint64 wait_start = current_time_ms();
uint64 wait_end = wait_start + 2 * syscall_timeout_ms;
wait_end = std::max(wait_end, start + program_timeout_ms / 6);
wait_end = std::max(wait_end, wait_start + prog_extra_timeout);
while (running > 0 && current_time_ms() <= wait_end) {
sleep_ms(1 * slowdown_scale);
for (int i = 0; i < kMaxThreads; i++) {
thread_t* th = &threads[i];
if (th->executing && event_isset(&th->done))
handle_completion(th);
}
}
// Write output coverage for unfinished calls.
if (running > 0) {
for (int i = 0; i < kMaxThreads; i++) {
thread_t* th = &threads[i];
if (th->executing) {
if (cover_collection_required())
cover_collect(&th->cov);
write_call_output(th, false);
}
}
}
}
#if SYZ_HAVE_CLOSE_FDS
close_fds();
#endif
write_extra_output();
// Check for new extra coverage in small intervals to avoid situation
// that we were killed on timeout before we write any.
// Check for extra coverage is very cheap, effectively a memory load.
const uint64 kSleepMs = 100;
for (uint64 i = 0; i < prog_extra_cover_timeout / kSleepMs; i++) {
sleep_ms(kSleepMs);
write_extra_output();
}
}
thread_t* schedule_call(int call_index, int call_num, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos, call_props_t call_props)
{
// Find a spare thread to execute the call.
int i = 0;
for (; i < kMaxThreads; i++) {
thread_t* th = &threads[i];
if (!th->created)
thread_create(th, i, cover_collection_required());
if (event_isset(&th->done)) {
if (th->executing)
handle_completion(th);
break;
}
}
if (i == kMaxThreads)
exitf("out of threads");
thread_t* th = &threads[i];
if (event_isset(&th->ready) || !event_isset(&th->done) || th->executing)
failmsg("bad thread state in schedule", "ready=%d done=%d executing=%d",
event_isset(&th->ready), event_isset(&th->done), th->executing);
last_scheduled = th;
th->copyout_pos = pos;
th->copyout_index = copyout_index;
event_reset(&th->done);
th->executing = true;
th->call_index = call_index;
th->call_num = call_num;
th->num_args = num_args;
th->call_props = call_props;
for (int i = 0; i < kMaxArgs; i++)
th->args[i] = args[i];
event_set(&th->ready);
running++;
return th;
}
#if SYZ_EXECUTOR_USES_SHMEM
template <typename cover_data_t>
void write_coverage_signal(cover_t* cov, uint32* signal_count_pos, uint32* cover_count_pos)
{
// Write out feedback signals.
// Currently it is code edges computed as xor of two subsequent basic block PCs.
cover_data_t* cover_data = (cover_data_t*)(cov->data + cov->data_offset);
if (flag_collect_signal) {
uint32 nsig = 0;
cover_data_t prev_pc = 0;
bool prev_filter = true;
for (uint32 i = 0; i < cov->size; i++) {
cover_data_t pc = cover_data[i] + cov->pc_offset;
uint32 sig = pc;
if (use_cover_edges(pc))
sig ^= hash(prev_pc);
bool filter = coverage_filter(pc);
// Ignore the edge only if both current and previous PCs are filtered out
// to capture all incoming and outcoming edges into the interesting code.
bool ignore = !filter && !prev_filter;
prev_pc = pc;
prev_filter = filter;
if (ignore || dedup(sig))
continue;
write_output(sig);
nsig++;
}
// Write out number of signals.
*signal_count_pos = nsig;
}
if (flag_collect_cover) {
// Write out real coverage (basic block PCs).
uint32 cover_size = cov->size;
if (flag_dedup_cover) {
cover_data_t* end = cover_data + cover_size;
cover_unprotect(cov);
std::sort(cover_data, end);
cover_size = std::unique(cover_data, end) - cover_data;
cover_protect(cov);
}
// Truncate PCs to uint32 assuming that they fit into 32-bits.
// True for x86_64 and arm64 without KASLR.
for (uint32 i = 0; i < cover_size; i++)
write_output(cover_data[i] + cov->pc_offset);
*cover_count_pos = cover_size;
}
}
#endif
void handle_completion(thread_t* th)
{
if (event_isset(&th->ready) || !event_isset(&th->done) || !th->executing)
failmsg("bad thread state in completion", "ready=%d done=%d executing=%d",
event_isset(&th->ready), event_isset(&th->done), th->executing);
if (th->res != (intptr_t)-1)
copyout_call_results(th);
write_call_output(th, true);
write_extra_output();
th->executing = false;
running--;
if (running < 0) {
// This fires periodically for the past 2 years (see issue #502).
fprintf(stderr, "running=%d completed=%d flag_threaded=%d current=%d\n",
running, completed, flag_threaded, th->id);
for (int i = 0; i < kMaxThreads; i++) {
thread_t* th1 = &threads[i];
fprintf(stderr, "th #%2d: created=%d executing=%d"
" ready=%d done=%d call_index=%d res=%lld reserrno=%d\n",
i, th1->created, th1->executing,
event_isset(&th1->ready), event_isset(&th1->done),
th1->call_index, (uint64)th1->res, th1->reserrno);
}
exitf("negative running");
}
}
void copyout_call_results(thread_t* th)
{
if (th->copyout_index != no_copyout) {
if (th->copyout_index >= kMaxCommands)
failmsg("result overflows kMaxCommands", "index=%lld", th->copyout_index);
results[th->copyout_index].executed = true;
results[th->copyout_index].val = th->res;
}
for (bool done = false; !done;) {
uint64 instr = read_input(&th->copyout_pos);
switch (instr) {
case instr_copyout: {
uint64 index = read_input(&th->copyout_pos);
if (index >= kMaxCommands)
failmsg("result overflows kMaxCommands", "index=%lld", index);
char* addr = (char*)read_input(&th->copyout_pos);
uint64 size = read_input(&th->copyout_pos);
uint64 val = 0;
if (copyout(addr, size, &val)) {
results[index].executed = true;
results[index].val = val;
}
debug_verbose("copyout 0x%llx from %p\n", val, addr);
break;
}
default:
done = true;
break;
}
}
}
void write_call_output(thread_t* th, bool finished)
{
uint32 reserrno = 999;
const bool blocked = finished && th != last_scheduled;
uint32 call_flags = call_flag_executed | (blocked ? call_flag_blocked : 0);
if (finished) {
reserrno = th->res != -1 ? 0 : th->reserrno;
call_flags |= call_flag_finished |
(th->fault_injected ? call_flag_fault_injected : 0);
}
#if SYZ_EXECUTOR_USES_SHMEM
write_output(kOutMagic);
write_output(th->call_index);
write_output(th->call_num);
write_output(reserrno);
write_output(call_flags);
uint32* signal_count_pos = write_output(0); // filled in later
uint32* cover_count_pos = write_output(0); // filled in later
uint32* comps_count_pos = write_output(0); // filled in later
if (flag_comparisons) {
// Collect only the comparisons
uint32 ncomps = th->cov.size;
kcov_comparison_t* start = (kcov_comparison_t*)(th->cov.data + sizeof(uint64));
kcov_comparison_t* end = start + ncomps;
if ((char*)end > th->cov.data_end)
failmsg("too many comparisons", "ncomps=%u", ncomps);
cover_unprotect(&th->cov);
std::sort(start, end);
ncomps = std::unique(start, end) - start;
cover_protect(&th->cov);
uint32 comps_size = 0;
for (uint32 i = 0; i < ncomps; ++i) {
if (start[i].ignore())
continue;
comps_size++;
start[i].write();
}
// Write out number of comparisons.
*comps_count_pos = comps_size;
} else if (flag_collect_signal || flag_collect_cover) {
if (is_kernel_64_bit)
write_coverage_signal<uint64>(&th->cov, signal_count_pos, cover_count_pos);
else
write_coverage_signal<uint32>(&th->cov, signal_count_pos, cover_count_pos);
}
debug_verbose("out #%u: index=%u num=%u errno=%d finished=%d blocked=%d sig=%u cover=%u comps=%u\n",
completed, th->call_index, th->call_num, reserrno, finished, blocked,
*signal_count_pos, *cover_count_pos, *comps_count_pos);
completed++;
write_completed(completed);
#else
call_reply reply;
reply.header.magic = kOutMagic;
reply.header.done = 0;
reply.header.status = 0;
reply.magic = kOutMagic;
reply.call_index = th->call_index;
reply.call_num = th->call_num;
reply.reserrno = reserrno;
reply.flags = call_flags;
reply.signal_size = 0;
reply.cover_size = 0;
reply.comps_size = 0;
if (write(kOutPipeFd, &reply, sizeof(reply)) != sizeof(reply))
fail("control pipe call write failed");
debug_verbose("out: index=%u num=%u errno=%d finished=%d blocked=%d\n",
th->call_index, th->call_num, reserrno, finished, blocked);
#endif
}
void write_extra_output()
{
#if SYZ_EXECUTOR_USES_SHMEM
if (!cover_collection_required() || !flag_extra_coverage || flag_comparisons)
return;
cover_collect(&extra_cov);
if (!extra_cov.size)
return;
write_output(kOutMagic);
write_output(-1); // call index
write_output(-1); // call num
write_output(999); // errno
write_output(0); // call flags
uint32* signal_count_pos = write_output(0); // filled in later
uint32* cover_count_pos = write_output(0); // filled in later
write_output(0); // comps_count_pos
if (is_kernel_64_bit)
write_coverage_signal<uint64>(&extra_cov, signal_count_pos, cover_count_pos);
else
write_coverage_signal<uint32>(&extra_cov, signal_count_pos, cover_count_pos);
cover_reset(&extra_cov);
debug_verbose("extra: sig=%u cover=%u\n", *signal_count_pos, *cover_count_pos);
completed++;
write_completed(completed);
#endif
}
void thread_create(thread_t* th, int id, bool need_coverage)
{
th->created = true;
th->id = id;
th->executing = false;
// Lazily set up coverage collection.
// It is assumed that actually it's already initialized - with a few rare exceptions.
if (need_coverage) {
if (!th->cov.fd)
exitf("out of opened kcov threads");
thread_mmap_cover(th);
}
event_init(&th->ready);
event_init(&th->done);
event_set(&th->done);
if (flag_threaded)
thread_start(worker_thread, th);
}
void thread_mmap_cover(thread_t* th)
{
if (th->cov.data != NULL)
return;
cover_mmap(&th->cov);
cover_protect(&th->cov);
}
void* worker_thread(void* arg)
{
thread_t* th = (thread_t*)arg;
current_thread = th;
if (cover_collection_required())
cover_enable(&th->cov, flag_comparisons, false);
for (;;) {
event_wait(&th->ready);
event_reset(&th->ready);
execute_call(th);
event_set(&th->done);
}
return 0;
}
void execute_call(thread_t* th)
{
const call_t* call = &syscalls[th->call_num];
debug("#%d [%llums] -> %s(",
th->id, current_time_ms() - start_time_ms, call->name);
for (int i = 0; i < th->num_args; i++) {
if (i != 0)
debug(", ");
debug("0x%llx", (uint64)th->args[i]);
}
debug(")\n");
int fail_fd = -1;
th->soft_fail_state = false;
if (th->call_props.fail_nth > 0) {
if (th->call_props.rerun > 0)
fail("both fault injection and rerun are enabled for the same call");
fail_fd = inject_fault(th->call_props.fail_nth);
th->soft_fail_state = true;
}
if (flag_coverage)
cover_reset(&th->cov);
// For pseudo-syscalls and user-space functions NONFAILING can abort before assigning to th->res.
// Arrange for res = -1 and errno = EFAULT result for such case.
th->res = -1;
errno = EFAULT;
NONFAILING(th->res = execute_syscall(call, th->args));
th->reserrno = errno;
// Our pseudo-syscalls may misbehave.
if ((th->res == -1 && th->reserrno == 0) || call->attrs.ignore_return)
th->reserrno = EINVAL;
// Reset the flag before the first possible fail().
th->soft_fail_state = false;
if (flag_coverage) {
cover_collect(&th->cov);
if (th->cov.size >= kCoverSize)
failmsg("too much cover", "thr=%d, cov=%u", th->id, th->cov.size);
}
th->fault_injected = false;
if (th->call_props.fail_nth > 0)
th->fault_injected = fault_injected(fail_fd);
// If required, run the syscall some more times.
// But let's still return res, errno and coverage from the first execution.
for (int i = 0; i < th->call_props.rerun; i++)
NONFAILING(execute_syscall(call, th->args));
debug("#%d [%llums] <- %s=0x%llx",
th->id, current_time_ms() - start_time_ms, call->name, (uint64)th->res);
if (th->res == (intptr_t)-1)
debug(" errno=%d", th->reserrno);
if (flag_coverage)
debug(" cover=%u", th->cov.size);
if (th->call_props.fail_nth > 0)
debug(" fault=%d", th->fault_injected);
if (th->call_props.rerun > 0)
debug(" rerun=%d", th->call_props.rerun);
debug("\n");
}
#if SYZ_EXECUTOR_USES_SHMEM
static uint32 hash(uint32 a)
{
a = (a ^ 61) ^ (a >> 16);
a = a + (a << 3);
a = a ^ (a >> 4);
a = a * 0x27d4eb2d;
a = a ^ (a >> 15);
return a;
}
const uint32 dedup_table_size = 8 << 10;
uint32 dedup_table[dedup_table_size];
// Poorman's best-effort hashmap-based deduplication.
// The hashmap is global which means that we deduplicate across different calls.
// This is OK because we are interested only in new signals.
static bool dedup(uint32 sig)
{
for (uint32 i = 0; i < 4; i++) {
uint32 pos = (sig + i) % dedup_table_size;
if (dedup_table[pos] == sig)
return true;
if (dedup_table[pos] == 0) {
dedup_table[pos] = sig;
return false;
}
}
dedup_table[sig % dedup_table_size] = sig;
return false;
}
#endif
template <typename T>
void copyin_int(char* addr, uint64 val, uint64 bf, uint64 bf_off, uint64 bf_len)
{
if (bf_off == 0 && bf_len == 0) {
*(T*)addr = swap(val, sizeof(T), bf);
return;
}
T x = swap(*(T*)addr, sizeof(T), bf);
debug_verbose("copyin_int<%zu>: old x=0x%llx\n", sizeof(T), (uint64)x);
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
const uint64 shift = sizeof(T) * CHAR_BIT - bf_off - bf_len;
#else
const uint64 shift = bf_off;
#endif
x = (x & ~BITMASK(shift, bf_len)) | ((val << shift) & BITMASK(shift, bf_len));
debug_verbose("copyin_int<%zu>: new x=0x%llx\n", sizeof(T), (uint64)x);
*(T*)addr = swap(x, sizeof(T), bf);
}
void copyin(char* addr, uint64 val, uint64 size, uint64 bf, uint64 bf_off, uint64 bf_len)
{
debug_verbose("copyin: addr=%p val=0x%llx size=%llu bf=%llu bf_off=%llu bf_len=%llu\n",
addr, val, size, bf, bf_off, bf_len);
if (bf != binary_format_native && bf != binary_format_bigendian && (bf_off != 0 || bf_len != 0))
failmsg("bitmask for string format", "off=%llu, len=%llu", bf_off, bf_len);
switch (bf) {
case binary_format_native:
case binary_format_bigendian:
NONFAILING(switch (size) {
case 1:
copyin_int<uint8>(addr, val, bf, bf_off, bf_len);
break;
case 2:
copyin_int<uint16>(addr, val, bf, bf_off, bf_len);
break;
case 4:
copyin_int<uint32>(addr, val, bf, bf_off, bf_len);
break;
case 8:
copyin_int<uint64>(addr, val, bf, bf_off, bf_len);
break;
default:
failmsg("copyin: bad argument size", "size=%llu", size);
});
break;
case binary_format_strdec:
if (size != 20)
failmsg("bad strdec size", "size=%llu", size);
NONFAILING(sprintf((char*)addr, "%020llu", val));
break;
case binary_format_strhex:
if (size != 18)
failmsg("bad strhex size", "size=%llu", size);
NONFAILING(sprintf((char*)addr, "0x%016llx", val));
break;
case binary_format_stroct:
if (size != 23)
failmsg("bad stroct size", "size=%llu", size);
NONFAILING(sprintf((char*)addr, "%023llo", val));
break;
default:
failmsg("unknown binary format", "format=%llu", bf);
}
}
bool copyout(char* addr, uint64 size, uint64* res)
{
return NONFAILING(
switch (size) {
case 1:
*res = *(uint8*)addr;
break;
case 2:
*res = *(uint16*)addr;
break;
case 4:
*res = *(uint32*)addr;
break;
case 8:
*res = *(uint64*)addr;
break;
default:
failmsg("copyout: bad argument size", "size=%llu", size);
});
}
uint64 read_arg(uint64** input_posp)
{
uint64 typ = read_input(input_posp);
switch (typ) {
case arg_const: {
uint64 size, bf, bf_off, bf_len;
uint64 val = read_const_arg(input_posp, &size, &bf, &bf_off, &bf_len);
if (bf != binary_format_native && bf != binary_format_bigendian)
failmsg("bad argument binary format", "format=%llu", bf);
if (bf_off != 0 || bf_len != 0)
failmsg("bad argument bitfield", "off=%llu, len=%llu", bf_off, bf_len);
return swap(val, size, bf);
}
case arg_result: {
uint64 meta = read_input(input_posp);
uint64 bf = meta >> 8;
if (bf != binary_format_native)
failmsg("bad result argument format", "format=%llu", bf);
return read_result(input_posp);
}
default:
failmsg("bad argument type", "type=%llu", typ);
}
}
uint64 swap(uint64 v, uint64 size, uint64 bf)
{
if (bf == binary_format_native)
return v;
if (bf != binary_format_bigendian)
failmsg("bad binary format in swap", "format=%llu", bf);
switch (size) {
case 2:
return htobe16(v);
case 4:
return htobe32(v);
case 8:
return htobe64(v);
default:
failmsg("bad big-endian int size", "size=%llu", size);
}
}
uint64 read_const_arg(uint64** input_posp, uint64* size_p, uint64* bf_p, uint64* bf_off_p, uint64* bf_len_p)
{
uint64 meta = read_input(input_posp);
uint64 val = read_input(input_posp);
*size_p = meta & 0xff;
uint64 bf = (meta >> 8) & 0xff;
*bf_off_p = (meta >> 16) & 0xff;
*bf_len_p = (meta >> 24) & 0xff;
uint64 pid_stride = meta >> 32;
val += pid_stride * procid;
*bf_p = bf;
return val;
}
uint64 read_result(uint64** input_posp)
{
uint64 idx = read_input(input_posp);
uint64 op_div = read_input(input_posp);
uint64 op_add = read_input(input_posp);
uint64 arg = read_input(input_posp);
if (idx >= kMaxCommands)
failmsg("command refers to bad result", "result=%lld", idx);
if (results[idx].executed) {
arg = results[idx].val;
if (op_div != 0)
arg = arg / op_div;
arg += op_add;
}
return arg;
}
uint64 read_input(uint64** input_posp, bool peek)
{
uint64* input_pos = *input_posp;
if ((char*)input_pos >= input_data + kMaxInput)
failmsg("input command overflows input", "pos=%p: [%p:%p)", input_pos, input_data, input_data + kMaxInput);
if (!peek)
*input_posp = input_pos + 1;
return *input_pos;
}
#if SYZ_EXECUTOR_USES_SHMEM
uint32* write_output(uint32 v)
{
if (output_pos < output_data || (char*)output_pos >= (char*)output_data + output_size)
failmsg("output overflow", "pos=%p region=[%p:%p]",
output_pos, output_data, (char*)output_data + output_size);
*output_pos = v;
return output_pos++;
}
uint32* write_output_64(uint64 v)
{
if (output_pos < output_data || (char*)(output_pos + 1) >= (char*)output_data + output_size)
failmsg("output overflow", "pos=%p region=[%p:%p]",
output_pos, output_data, (char*)output_data + output_size);
*(uint64*)output_pos = v;
output_pos += 2;
return output_pos;
}
void write_completed(uint32 completed)
{
__atomic_store_n(output_data, completed, __ATOMIC_RELEASE);
}
#endif
#if SYZ_EXECUTOR_USES_SHMEM
void kcov_comparison_t::write()
{
if (type > (KCOV_CMP_CONST | KCOV_CMP_SIZE_MASK))
failmsg("invalid kcov comp type", "type=%llx", type);
// Write order: type arg1 arg2 pc.
write_output((uint32)type);
// KCOV converts all arguments of size x first to uintx_t and then to
// uint64. We want to properly extend signed values, e.g we want
// int8 c = 0xfe to be represented as 0xfffffffffffffffe.
// Note that uint8 c = 0xfe will be represented the same way.
// This is ok because during hints processing we will anyways try
// the value 0x00000000000000fe.
switch (type & KCOV_CMP_SIZE_MASK) {
case KCOV_CMP_SIZE1:
arg1 = (uint64)(long long)(signed char)arg1;
arg2 = (uint64)(long long)(signed char)arg2;
break;
case KCOV_CMP_SIZE2:
arg1 = (uint64)(long long)(short)arg1;
arg2 = (uint64)(long long)(short)arg2;
break;
case KCOV_CMP_SIZE4:
arg1 = (uint64)(long long)(int)arg1;
arg2 = (uint64)(long long)(int)arg2;
break;
}
bool is_size_8 = (type & KCOV_CMP_SIZE_MASK) == KCOV_CMP_SIZE8;
if (!is_size_8) {
write_output((uint32)arg1);
write_output((uint32)arg2);
} else {
write_output_64(arg1);
write_output_64(arg2);
}
}
bool kcov_comparison_t::ignore() const
{
// Comparisons with 0 are not interesting, fuzzer should be able to guess 0's without help.
if (arg1 == 0 && (arg2 == 0 || (type & KCOV_CMP_CONST)))
return true;
if ((type & KCOV_CMP_SIZE_MASK) == KCOV_CMP_SIZE8) {
// This can be a pointer (assuming 64-bit kernel).
// First of all, we want avert fuzzer from our output region.
// Without this fuzzer manages to discover and corrupt it.
uint64 out_start = (uint64)output_data;
uint64 out_end = out_start + output_size;
if (arg1 >= out_start && arg1 <= out_end)
return true;
if (arg2 >= out_start && arg2 <= out_end)
return true;
#if defined(GOOS_linux)
// Filter out kernel physical memory addresses.
// These are internal kernel comparisons and should not be interesting.
// The range covers first 1TB of physical mapping.
uint64 kmem_start = (uint64)0xffff880000000000ull;
uint64 kmem_end = (uint64)0xffff890000000000ull;
bool kptr1 = arg1 >= kmem_start && arg1 <= kmem_end;
bool kptr2 = arg2 >= kmem_start && arg2 <= kmem_end;
if (kptr1 && kptr2)
return true;
if (kptr1 && arg2 == 0)
return true;
if (kptr2 && arg1 == 0)
return true;
#endif
}
return !coverage_filter(pc);
}
bool kcov_comparison_t::operator==(const struct kcov_comparison_t& other) const
{
// We don't check for PC equality now, because it is not used.
return type == other.type && arg1 == other.arg1 && arg2 == other.arg2;
}
bool kcov_comparison_t::operator<(const struct kcov_comparison_t& other) const
{
if (type != other.type)
return type < other.type;
if (arg1 != other.arg1)
return arg1 < other.arg1;
// We don't check for PC equality now, because it is not used.
return arg2 < other.arg2;
}
#endif
void setup_features(char** enable, int n)
{
// This does any one-time setup for the requested features on the machine.
// Note: this can be called multiple times and must be idempotent.
flag_debug = true;
#if SYZ_HAVE_SETUP_EXT
// This can be defined in common_ext.h.
setup_ext();
#endif
#if SYZ_HAVE_FEATURES
setup_sysctl();
setup_cgroups();
#endif
for (int i = 0; i < n; i++) {
bool found = false;
#if SYZ_HAVE_FEATURES
for (unsigned f = 0; f < sizeof(features) / sizeof(features[0]); f++) {
if (strcmp(enable[i], features[f].name) == 0) {
features[f].setup();
found = true;
break;
}
}
#endif
if (!found)
failmsg("setup features: unknown feature", "feature=%s", enable[i]);
}
}
void failmsg(const char* err, const char* msg, ...)
{
int e = errno;
fprintf(stderr, "SYZFAIL: %s\n", err);
if (msg) {
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
}
fprintf(stderr, " (errno %d: %s)\n", e, strerror(e));
// fail()'s are often used during the validation of kernel reactions to queries
// that were issued by pseudo syscalls implementations. As fault injection may
// cause the kernel not to succeed in handling these queries (e.g. socket writes
// or reads may fail), this could ultimately lead to unwanted "lost connection to
// test machine" crashes.
// In order to avoid this and, on the other hand, to still have the ability to
// signal a disastrous situation, the exit code of this function depends on the
// current context.
// All fail() invocations during system call execution with enabled fault injection
// lead to termination with zero exit code. In all other cases, the exit code is
// kFailStatus.
if (current_thread && current_thread->soft_fail_state)
doexit(0);
doexit(kFailStatus);
}
void fail(const char* err)
{
failmsg(err, 0);
}
void exitf(const char* msg, ...)
{
int e = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit(0);
}
void debug(const char* msg, ...)
{
if (!flag_debug)
return;
int err = errno;
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fflush(stderr);
errno = err;
}
void debug_dump_data(const char* data, int length)
{
if (!flag_debug)
return;
int i = 0;
for (; i < length; i++) {
debug("%02x ", data[i] & 0xff);
if (i % 16 == 15)
debug("\n");
}
if (i % 16 != 0)
debug("\n");
}
|
; A083036: Partial sums of A083035.
; 1,1,1,2,3,3,4,5,5,5,6,6,6,7,8,8,8,9,9,9,10,11,11,12,13,13,13,14,15,15,16,17,17,17,18,18,18,19,20,20,21,22,22,22,23,24,24,25,26,26,26,27,27,27,28,29,29,29,30,30,30,31,32,32,33,34,34,34,35,35,35,36,37,37,37,38
mov $2,$0
add $2,1
mov $4,$0
lpb $2,1
mov $0,$4
sub $2,1
sub $0,$2
add $0,1
pow $0,2
sub $3,$3
lpb $0,1
add $3,1
sub $0,$3
lpe
mod $3,2
add $1,$3
lpe
|
// utilUmpire.cpp
// This file is generated by Shroud 0.11.0. Do not edit.
// Copyright (c) 2016-20, Lawrence Livermore National Security, LLC and Umpire
// project contributors. See the COPYRIGHT file for details.
//
// SPDX-License-Identifier: (MIT)
#include "typesUmpire.h"
#include <cstddef>
#include <cstring>
#ifdef __cplusplus
extern "C" {
#endif
// helper copy_string
// Copy the char* or std::string in context into c_var.
// Called by Fortran to deal with allocatable character.
void umpire_ShroudCopyStringAndFree(umpire_SHROUD_array *data, char *c_var, size_t c_var_len) {
const char *cxx_var = data->addr.ccharp;
size_t n = c_var_len;
if (data->elem_len < n) n = data->elem_len;
std::strncpy(c_var, cxx_var, n);
umpire_SHROUD_memory_destructor(&data->cxx); // delete data->cxx.addr
}
#ifdef __cplusplus
}
#endif
|
_main:
;EEPROM.c,18 :: void main() {
;EEPROM.c,19 :: unsigned short a=0, b=0, c=0, d=0;
CLRF main_a_L0+0
CLRF main_b_L0+0
CLRF main_c_L0+0
CLRF main_d_L0+0
;EEPROM.c,22 :: TRISD=1;
MOVLW 1
MOVWF TRISD+0
;EEPROM.c,23 :: PORTD=0;
CLRF PORTD+0
;EEPROM.c,26 :: Lcd_Init(); // Initialize LCD
CALL _Lcd_Init+0
;EEPROM.c,27 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,28 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,29 :: Lcd_Out(1,1,"HELLO EveryVoter");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr1_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,30 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main2:
DECFSZ R13+0, 1
GOTO L_main2
DECFSZ R12+0, 1
GOTO L_main2
DECFSZ R11+0, 1
GOTO L_main2
NOP
;EEPROM.c,31 :: if (PORTD.F0==1) // start
BTFSS PORTD+0, 0
GOTO L_main3
;EEPROM.c,34 :: }
L_main3:
;EEPROM.c,35 :: while (PORTD==0)
L_main4:
MOVF PORTD+0, 0
XORLW 0
BTFSS STATUS+0, 2
GOTO L_main5
;EEPROM.c,37 :: }
GOTO L_main4
L_main5:
;EEPROM.c,38 :: while (e=1)
L_main6:
;EEPROM.c,40 :: if (PORTD.F0==1)
BTFSS PORTD+0, 0
GOTO L_main8
;EEPROM.c,42 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,43 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,44 :: Lcd_Out(1,5,"START VOTING");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 5
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr2_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,45 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main9:
DECFSZ R13+0, 1
GOTO L_main9
DECFSZ R12+0, 1
GOTO L_main9
DECFSZ R11+0, 1
GOTO L_main9
NOP
;EEPROM.c,46 :: }
L_main8:
;EEPROM.c,47 :: if (PORTD.F1==1) //voter1
BTFSS PORTD+0, 1
GOTO L_main10
;EEPROM.c,49 :: a++;
INCF main_a_L0+0, 1
;EEPROM.c,51 :: eeprom_write(0x12,a);
MOVLW 18
MOVWF FARG_EEPROM_Write_Address+0
MOVF main_a_L0+0, 0
MOVWF FARG_EEPROM_Write_data_+0
CALL _EEPROM_Write+0
;EEPROM.c,52 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,53 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,54 :: Lcd_Out(1,5,"success");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 5
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr3_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,55 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main11:
DECFSZ R13+0, 1
GOTO L_main11
DECFSZ R12+0, 1
GOTO L_main11
DECFSZ R11+0, 1
GOTO L_main11
NOP
;EEPROM.c,56 :: }
L_main10:
;EEPROM.c,57 :: if (PORTD.F2==1) //voter2
BTFSS PORTD+0, 2
GOTO L_main12
;EEPROM.c,59 :: b++;
INCF main_b_L0+0, 1
;EEPROM.c,61 :: eeprom_write(0x23,b);
MOVLW 35
MOVWF FARG_EEPROM_Write_Address+0
MOVF main_b_L0+0, 0
MOVWF FARG_EEPROM_Write_data_+0
CALL _EEPROM_Write+0
;EEPROM.c,62 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,63 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,64 :: Lcd_Out(1,5,"success2");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 5
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr4_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,65 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main13:
DECFSZ R13+0, 1
GOTO L_main13
DECFSZ R12+0, 1
GOTO L_main13
DECFSZ R11+0, 1
GOTO L_main13
NOP
;EEPROM.c,66 :: }
L_main12:
;EEPROM.c,67 :: if (PORTD.F3==1) //voter3
BTFSS PORTD+0, 3
GOTO L_main14
;EEPROM.c,69 :: c++;
INCF main_c_L0+0, 1
;EEPROM.c,71 :: eeprom_write(0x34,c);
MOVLW 52
MOVWF FARG_EEPROM_Write_Address+0
MOVF main_c_L0+0, 0
MOVWF FARG_EEPROM_Write_data_+0
CALL _EEPROM_Write+0
;EEPROM.c,72 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,73 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,74 :: Lcd_Out(1,5,"success");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 5
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr5_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,75 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main15:
DECFSZ R13+0, 1
GOTO L_main15
DECFSZ R12+0, 1
GOTO L_main15
DECFSZ R11+0, 1
GOTO L_main15
NOP
;EEPROM.c,76 :: }
L_main14:
;EEPROM.c,77 :: if (PORTD.F4 ==1) //voter4
BTFSS PORTD+0, 4
GOTO L_main16
;EEPROM.c,79 :: d++;
INCF main_d_L0+0, 1
;EEPROM.c,81 :: eeprom_write(0x45,d);
MOVLW 69
MOVWF FARG_EEPROM_Write_Address+0
MOVF main_d_L0+0, 0
MOVWF FARG_EEPROM_Write_data_+0
CALL _EEPROM_Write+0
;EEPROM.c,82 :: Lcd_Cmd(_LCD_CLEAR); // Clear display
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,83 :: Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
MOVLW 12
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,84 :: Lcd_Out(1,5,"success");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 5
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr6_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,85 :: Delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main17:
DECFSZ R13+0, 1
GOTO L_main17
DECFSZ R12+0, 1
GOTO L_main17
DECFSZ R11+0, 1
GOTO L_main17
NOP
;EEPROM.c,86 :: }
L_main16:
;EEPROM.c,87 :: if (PORTD.F5==1)
BTFSS PORTD+0, 5
GOTO L_main18
;EEPROM.c,89 :: a=eeprom_read(0x12);
MOVLW 18
MOVWF FARG_EEPROM_Read_Address+0
CALL _EEPROM_Read+0
MOVF R0+0, 0
MOVWF main_a_L0+0
;EEPROM.c,90 :: b=eeprom_read(0x23);
MOVLW 35
MOVWF FARG_EEPROM_Read_Address+0
CALL _EEPROM_Read+0
MOVF R0+0, 0
MOVWF main_b_L0+0
;EEPROM.c,91 :: c=eeprom_read(0x34);
MOVLW 52
MOVWF FARG_EEPROM_Read_Address+0
CALL _EEPROM_Read+0
MOVF R0+0, 0
MOVWF main_c_L0+0
;EEPROM.c,92 :: d=eeprom_read(0x45);
MOVLW 69
MOVWF FARG_EEPROM_Read_Address+0
CALL _EEPROM_Read+0
MOVF R0+0, 0
MOVWF main_d_L0+0
;EEPROM.c,93 :: Lcd_Cmd(_LCD_CLEAR);
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,94 :: inttostr(a,txt);
MOVF main_a_L0+0, 0
MOVWF FARG_IntToStr_input+0
CLRF FARG_IntToStr_input+1
MOVLW main_txt_L0+0
MOVWF FARG_IntToStr_output+0
CALL _IntToStr+0
;EEPROM.c,95 :: inttostr(b,txt1);
MOVF main_b_L0+0, 0
MOVWF FARG_IntToStr_input+0
CLRF FARG_IntToStr_input+1
MOVLW main_txt1_L0+0
MOVWF FARG_IntToStr_output+0
CALL _IntToStr+0
;EEPROM.c,96 :: inttostr(c,txt2);
MOVF main_c_L0+0, 0
MOVWF FARG_IntToStr_input+0
CLRF FARG_IntToStr_input+1
MOVLW main_txt2_L0+0
MOVWF FARG_IntToStr_output+0
CALL _IntToStr+0
;EEPROM.c,97 :: inttostr(d,txt3);
MOVF main_d_L0+0, 0
MOVWF FARG_IntToStr_input+0
CLRF FARG_IntToStr_input+1
MOVLW main_txt3_L0+0
MOVWF FARG_IntToStr_output+0
CALL _IntToStr+0
;EEPROM.c,98 :: delay_ms(500);
MOVLW 6
MOVWF R11+0
MOVLW 19
MOVWF R12+0
MOVLW 173
MOVWF R13+0
L_main19:
DECFSZ R13+0, 1
GOTO L_main19
DECFSZ R12+0, 1
GOTO L_main19
DECFSZ R11+0, 1
GOTO L_main19
NOP
NOP
;EEPROM.c,99 :: lcd_out(1,1,"1:");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr7_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,100 :: lcd_out(1,4,"txt");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 4
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr8_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,101 :: lcd_out(2,1,"2:");
MOVLW 2
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr9_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,102 :: lcd_out(2,4,"txt1");
MOVLW 2
MOVWF FARG_Lcd_Out_row+0
MOVLW 4
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr10_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,103 :: delay_ms(2000),
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main20:
DECFSZ R13+0, 1
GOTO L_main20
DECFSZ R12+0, 1
GOTO L_main20
DECFSZ R11+0, 1
GOTO L_main20
NOP
;EEPROM.c,104 :: lcd_Cmd(_LCD_CLEAR);
MOVLW 1
MOVWF FARG_Lcd_Cmd_out_char+0
CALL _Lcd_Cmd+0
;EEPROM.c,105 :: lcd_out(1,1,"3:");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr11_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,106 :: lcd_out(1,4,"txt2");
MOVLW 1
MOVWF FARG_Lcd_Out_row+0
MOVLW 4
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr12_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,107 :: lcd_out(2,1,"4:");
MOVLW 2
MOVWF FARG_Lcd_Out_row+0
MOVLW 1
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr13_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,108 :: lcd_out(2,4,"txt3");
MOVLW 2
MOVWF FARG_Lcd_Out_row+0
MOVLW 4
MOVWF FARG_Lcd_Out_column+0
MOVLW ?lstr14_EEPROM+0
MOVWF FARG_Lcd_Out_text+0
CALL _Lcd_Out+0
;EEPROM.c,109 :: delay_ms(2000);
MOVLW 21
MOVWF R11+0
MOVLW 75
MOVWF R12+0
MOVLW 190
MOVWF R13+0
L_main21:
DECFSZ R13+0, 1
GOTO L_main21
DECFSZ R12+0, 1
GOTO L_main21
DECFSZ R11+0, 1
GOTO L_main21
NOP
;EEPROM.c,110 :: }
L_main18:
;EEPROM.c,111 :: }
GOTO L_main6
;EEPROM.c,113 :: }
L_end_main:
GOTO $+0
; end of _main
|
include 'macros.inc'
.8086
.MODEL SMALL
.STACK 256
DATA SEGMENT
TABLE_LETTERS DB 16 DUP(?)
TABLE_NUMBERS DB 16 DUP(?)
TABLE DB 16 (?)
DATA ENDS
CODE SEGMENT
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
JMP BEGIN
START: NEW_LINE
BEGIN: MOV CL,0 ; total counter
MOV DX,0 ; initialize letters counter
MOV BX,0 ; initialize numbers counter
READ_LOOP: READ
CMP AL,0DH ; equal to enter
JE QUIT
CMP AL, 30H
JL READ_LOOP ; if less than 0 not valid
CMP AL, 39H
JNA VALID_N ; if given less or equal to 9 is valid
CMP AL, 41H
JL READ_LOOP ; if less than ascii of A is not valid
CMP AL, 5AH
JNA VALID_L ; if less or equal to ascii code of Z valid
JMP READ_LOOP ; else invalid
VALID_N: MOV DI,BX ; move BX to DI
MOV [TABLE_NUMBERS + DI],AL ; move valid number to numbers table
MOV CH,0
MOV DI,CX
MOV [TABLE + DI],AL ; place number to merged table too
INC BX ; increase numbers counter
INC CL ; increase total counter
CMP CL,16 ; if reached 16 all input is given
JE COMPLETED ; so move to completed tag
JMP READ_LOOP ; else jump to read_loop
VALID_L: MOV DI,DX ; move DX to DI
MOV [TABLE_LETTERS + DI],AL ; move valid letter to letters table
MOV CH,0
MOV DI,CX
MOV [TABLE + DI],AL ; place letter to merged table too
INC DX ; increase letters counter
INC CL ; increase total counter
CMP CL,16 ; if reached 16 all input is given
JE COMPLETED ; so move to completed tag
JMP READ_LOOP ; else jump to read_loop
COMPLETED: NEW_LINE
MOV DI,0 ; DI will be the index for printing
PRINT_MATRIX: MOV AL,[TABLE + DI] ; move the table element in AL to print it
PRINT AL ; print the element
INC DI ; increase index
CMP DI, 16 ; when it reaches 16
JE PRINT_SORTED ; go to sorted
JMP PRINT_MATRIX ; else loop
PRINT_SORTED: NEW_LINE
MOV DI,BX ; BX holds the number of numbers
CMP DI,0 ; if numbers are zero
JE L2 ; go to print letters
MOV DI,0 ; DI will be the index for printing numbers
L1: MOV AL,[TABLE_NUMBERS + DI] ; move the table_number element in AL to print it
PRINT AL ; print the element
INC DI ; increase index
CMP DI,BX ; when it reaches the number of numbers
JAE L2N ; go to print letters
JMP L1 ; else loop
L2N: MOV DI,DX ; DX holds the number of letters
CMP DI,0 ; if numbers are zero
JE START ; restart program
PRINT '-' ; '-' between numbers and letters
L2: MOV DI,0 ; DI will be the index for printing letters
CONT_L2N: MOV AL,[TABLE_LETTERS + DI] ; move the table_letter element in AL to print it
ADD AL,32
PRINT AL ; print the element
INC DI ; increase index
CMP DI,DX ; when it reaches the number of letters
JE START ; restart program
JMP CONT_L2N ; else loop
QUIT: EXIT
MAIN ENDP
CODE ENDS |
#include <iostream>
#include <string>
int main()
{
std::string str;
std::cout<<"Enter any string and press enter: ";
getline(std::cin, str);
std::cout<<"You just entered: "<<str<<std::endl;
return 0;
}
|
; A103220: a(n) = n*(n+1)*(3*n^2+n-1)/6.
; 0,1,13,58,170,395,791,1428,2388,3765,5665,8206,11518,15743,21035,27560,35496,45033,56373,69730,85330,103411,124223,148028,175100,205725,240201,278838,321958,369895,422995,481616,546128,616913,694365,778890,870906,970843,1079143,1196260,1322660,1458821,1605233,1762398,1930830,2111055,2303611,2509048,2727928,2960825,3208325,3471026,3749538,4044483,4356495,4686220,5034316,5401453,5788313,6195590,6623990,7074231,7547043,8043168,8563360,9108385,9679021,10276058,10900298,11552555,12233655,12944436,13685748,14458453,15263425,16101550,16973726,17880863,18823883,19803720,20821320,21877641,22973653,24110338,25288690,26509715,27774431,29083868,30439068,31841085,33290985,34789846,36338758,37938823,39591155,41296880,43057136,44873073,46745853,48676650,50666650,52717051,54829063,57003908,59242820,61547045,63917841,66356478,68864238,71442415,74092315,76815256,79612568,82485593,85435685,88464210,91572546,94762083,98034223,101390380,104831980,108360461,111977273,115683878,119481750,123372375,127357251,131437888,135615808,139892545,144269645,148748666,153331178,158018763,162813015,167715540,172727956,177851893,183088993,188440910,193909310,199495871,205202283,211030248,216981480,223057705,229260661,235592098,242053778,248647475,255374975,262238076,269238588,276378333,283659145,291082870,298651366,306366503,314230163,322244240,330410640,338731281,347208093,355843018,364638010,373595035,382716071,392003108,401458148,411083205,420880305,430851486,440998798,451324303,461830075,472518200,483390776,494449913,505697733,517136370,528767970,540594691,552618703,564842188,577267340,589896365,602731481,615774918,629028918,642495735,656177635,670076896,684195808,698536673,713101805,727893530,742914186,758166123,773651703,789373300,805333300,821534101,837978113,854667758,871605470,888793695,906234891,923931528,941886088,960101065,978578965,997322306,1016333618,1035615443,1055170335,1075000860,1095109596,1115499133,1136172073,1157131030,1178378630,1199917511,1221750323,1243879728,1266308400,1289039025,1312074301,1335416938,1359069658,1383035195,1407316295,1431915716,1456836228,1482080613,1507651665,1533552190,1559785006,1586352943,1613258843,1640505560,1668095960,1696032921,1724319333,1752958098,1781952130,1811304355,1841017711,1871095148,1901539628,1932354125
mov $3,2
mov $4,1
lpb $0,1
add $1,$0
add $3,$4
add $2,$3
sub $2,3
add $3,$0
sub $0,1
add $1,$2
add $3,$0
sub $3,1
add $2,$3
mov $4,3
lpe
|
Name: w-select.asm
Type: file
Size: 14878
Last-Modified: '1992-04-28T15:00:00Z'
SHA-1: 410AC308844A23550AF10833954B6AF690931807
Description: null
|
; A000204: Lucas numbers (beginning with 1): L(n) = L(n-1) + L(n-2) with L(1) = 1, L(2) = 3.
; 1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801
mov $1,1
mov $3,3
lpb $0
sub $0,1
add $3,$2
mov $2,$1
mov $1,$3
lpe
mov $0,$1
|
;=================================================================
;
; Copyright (c) 2014, Eric Blundell
;
; All rights reserved.
;
; libasm_io is distributed under the following BSD 3-Clause License
;
; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from
; this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
; ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
;==================================================================
;the following is defined when the library examples are being built with the library
%ifdef _LIBASM_IO_BUILDING_
;if the library build system is building the examples, then an option to NASM specifies the directory
;to find this include, so we can include it by its name only
%include "libasm_io.inc"
%else
;otherwise if this code is compiled against the already installed library
;it's header needs to be included from its installed location
%include "/usr/local/include/libasm_io.inc"
%endif
;main gets called by the c runtime library, so it needs to be global to let the linker find it
;the cglobal macro from the library will add an underscore to the 'main' symbol name in the global statement
;and define main as _main if the platform we are on uses underscores in front of its C symbols
cglobal main
section .data
message_1: db "this",0
message_2: db "is",0
message_3: db "how",0
message_4: db "to",0
message_5: db "use",0
message_6: db "the",0
message_7: db "stack",0
message_1a: db "this : ",0
message_2a: db "is : ",0
message_3a: db "how : ",0
message_4a: db "to : ",0
message_5a: db "use : ",0
message_6a: db "the : ",0
message_7a: db "stack : ",0
example_1: db "printing output from example 1:",0
example_2: db "printing output from example 2:",0
example_3: db "printing output from the 'fun_with_lea' function:",0
section .text
print_messages_example:
;set up a new stack frame
push rbp
mov rbp, rsp
;subtract RSP by 56+8 to make room for 7x 8-byte pointer values on the stack, 7*8=56
;the +8 is to align the stack pointer to 16 bytes, 56/16 = 3.5 and (56+8)/16=4.0
;to align to 16 bytes, the value has to be divisible by 16 evenly
;64 bit windows requires the stack pointer be aligned to 16 bytes.
;it also requires that the stack contain at least 32 bytes of space in all function calls that
;call other functions. The alignment here is for portability.
sub rsp, (56+8)
;================================
;the keyword QWORD stands for QUAD WORD, a WORD is 16 bits (or two bytes).
;so a QWORD has 64 bits, which is big enough to hold the 64bit pointer
;to a message string (or any other memory)
;we need to specify the size so mov knows how many bytes of data its going to move into a memory location.
;some possible sizes are :
;BYTE -> 8 bits
;WORD -> 16 bits
;DWORD -> 32 bits
;TWORD -> 48 bits (three words)
;QWORD -> 64 bits
;we want to count by 8's in our offset, because we are moving 64 bit values which are 8 bytes long
;and they should not overlap at all.
;we need to use lea or mov to put a 64 bit label address into a register before moving the address into memory.
;this is because you cannot move the address of a 64 bit immediate label into memory directly without it being
;turnicated to 32 bits. Having the address turnicated will possibly cause the linker to complain
;or worse, cause your program to crash unexpectedly; the latter being a difficult to find bug.
;move the label address into a register first with lea, then move the register
;contents into a memory location on the stack.
lea rax, [rel message_1]
mov QWORD [rsp], rax
;mov accomplishes the same thing here.
;except we have no option of doing arithmetic on the right hand operand like lea can,
;and we need to specify the label address as being a QWORD.
mov rax, QWORD message_2
mov QWORD [rsp+8], rax
lea rax, [rel message_3]
mov QWORD [rsp+16], rax
lea rax, [rel message_4]
mov QWORD [rsp+24], rax
lea rax, [rel message_5]
mov QWORD [rsp+32], rax
lea rax, [rel message_6]
mov QWORD [rsp+40], rax
lea rax, [rel message_7]
mov QWORD [rsp+48], rax
;================================
mov rdi, [rsp]
call print_string
call print_nl
mov rdi, [rsp+8]
call print_string
call print_nl
mov rdi, [rsp+16]
call print_string
call print_nl
mov rdi, [rsp+24]
call print_string
call print_nl
mov rdi, [rsp+32]
call print_string
call print_nl
mov rdi, [rsp+40]
call print_string
call print_nl
mov rdi, [rsp+48]
call print_string
call print_nl
;restore the previous stack frame.
;we just add to rsp and equal amount to what we subtracted when we entered the function
;then restore the stack base pointer rbp by popping it.
add rsp, (56+8)
pop rbp
ret
print_messages_example_v2:
;this sets up a new stack frame
push rbp
mov rbp, rsp
;subtract RSP by (56+8) to make room for 7x 8-byte pointer values on the stack 7*8=56.
;the +8 is to align it, because 56 is not aligned to 16 bytes.
;(we need a value that divides by 16 evenly)
sub rsp, (56+8)
;================================
; you can also use RBP with a negative offset to address stack values, we use subtract because we are storing values
; in the direction in memory that moves towards RSP, (RSP resides at a lower address than RBP).
; we need to start at an offset equal in size to the data we are moving to memory
;
; otherwise, if we use [RBP] as the first address, this will happen:
;
; -- (etc..)
; -- (contains another byte of pointer)
; -- (rbp) high pointer address (contains a byte of a pointer)
; -- ..
; -- ..
; -- (rsp) low pointer address
;
;
; we would write into the calling functions stack frame and make it mad at us,
; probably crashing the program
; x86_64 is a little-endian architecture, it lays out the bytes of integers from low address to high address
; starting with the least significant byte
;=================================
lea rax, [rel message_1a]
mov QWORD [rbp-8], rax
lea rax, [rel message_2a]
mov QWORD [rbp-16], rax
lea rax, [rel message_3a]
mov QWORD [rbp-24], rax
lea rax, [rel message_4a]
mov QWORD [rbp-32], rax
lea rax, [rel message_5a]
mov QWORD [rbp-40], rax
lea rax, [rel message_6a]
mov QWORD [rbp-48], rax
lea rax, [rel message_7a]
mov QWORD [rbp-56], rax
;================================
; it's safe to address [RSP] directly
; because all register values in x86_64 are in little-endian format.
; (they are laid out from low byte to high byte in memory and in registers)
;
; right now the stack is something like this (thinking in terms of individual bytes in memory):
;
;
; -- (rbp) high address
; -- ..
; -- (etc..)
; -- (third byte of pointer to message_7)
; -- (second byte of pointer to message_7)
; -- (rsp) low address (has the first byte of pointer to message_7)
;
;
; also, when we address RSP and move it into RDI, nasm knows we need to pull a quad word from memory (64 bits);
; that is because RDI is a 64bit register.
;
; if your moving a byte of memory into a byte register like AL, it works the same.
;
; you could just do:
;
; mov AL, [rsp]
;
; and nasm will figure out that you want a byte because AL is a byte long
;
;if we start at RSP now we will be printing in reverse order.
;we aligned our stack to 16 bytes using +8 though so we need to start at [RSP+8],
;which is equal to [RBP-56] at this point.
mov rdi, [rsp+8]
call print_string
;print RSP+8 as an unsigned 64 bit integer, so we see the address of the string that was just printed
lea rdi, [(rsp+8)]
call print_uint
call print_nl
;=========READ ABOUT LEA HERE===========
;we are adding 8 to the end of our effective address to keep up with the fact that RSP was aligned to 16 bytes using +8
mov rdi, [(rsp+8) +8]
call print_string
; lea stands for LOAD EFFECTIVE ADDRESS, and it means:
; 1. take the effective address calculation on the RIGHT and compute the actual pointer value from it.
; 2. put the calculated pointer value in the register on the LEFT.
lea rdi, [(rsp+8) +8]
;print the address in RDI, which is equal to [(RSP+8) +8]
call print_uint
call print_nl
;===================================
mov rdi, [(rsp+16) +8]
call print_string
lea rdi, [(rsp+16) +8]
call print_uint
call print_nl
mov rdi, [(rsp+24) +8]
call print_string
lea rdi, [(rsp+24) +8]
call print_uint
call print_nl
mov rdi, [(rsp+32) +8]
call print_string
lea rdi, [(rsp+32) +8]
call print_uint
call print_nl
mov rdi, [(rsp+40) +8]
call print_string
lea rdi, [(rsp+40) +8]
call print_uint
call print_nl
mov rdi, [(rsp+48) +8]
call print_string
lea rdi, [(rsp+48) +8]
call print_uint
call print_nl
;restore the previous stack frame, add an equal amount to what we subtracted before
add rsp, (56+8)
pop rbp
ret
fun_with_lea:
; I am using LEA here to show you some of the fancy expressions that can be used to address memory.
; there are some constraints to memory addressing, but nasm can occasionally factor your math down
; to meet these constraints.
;
; if your affective address for memory operations do not meet processor constraints
; you will get an 'invalid effective address' error from nasm.
;
; the constraints are a bit too long to describe here,
; but you can read about effective addresses in nasm at this link:
;
; http://www.nasm.us/doc/nasmdoc3.html#section-3.3
;
push rbp
mov rbp, rsp
sub rsp, 32
;calculate a bogus address and print the result.
;lea can be used for arithmetic on values that are not actually pointers,
;but that's sort of hacky and has limited usage due to constraints on effective addressing calculations
mov rdi, 5
lea rdi, [rdi+10*2-6]
call print_int
call print_nl
;here we add together two registers and multiply by 8
mov rsi, 8
mov rdi, 5
lea rdi, [rsi+rdi*8]
call print_int
call print_nl
mov rdi, 5
lea rdi, [rdi-10*8]
call print_int
call print_nl
add rsp, 32
pop rbp
ret
main:
;create a new stack frame
;we first save the 'stack base pointer' which is the high address of the stack.
;the stack is currently like this:
;
; -- (rbp) high pointer address
; -- ..probably local variable/parameter in stack memory from the function that called this one..
; -- ..maybe another local variable/function parameter from the calling function..
; -- (rsp) low pointer address
;
;save the 'stack base pointer'
push rbp
;we effectively slide the bottom of the stack down (RBP) to RSP and make it empty
;by setting the 'stack base pointer' to the 'stack pointer'
;
;it makes the stack like this:
;
; -- (rbp) high pointer address = (rsp) low pointer address
;
;slide the base of the stack down to RSP, so its empty
mov rbp, rsp
;On windows, we need a minimum of 32 bytes of stack space before calling
;any functions, RSP also always needs to be aligned to 16 bytes.
;32/16 = 2, 2 is a whole number which means 32 is indeed aligned to 16 bytes
;this is for compatibility, Linux and Mac can run programs with or without the stack pointer being aligned,
;but on Windows if the stack is not aligned the program will crash.
sub rsp, 32
;print a message describing what the following output is from
mov rdi, QWORD example_1
call print_string
call print_nl
call print_nl
;call the first example
call print_messages_example
;make some space with a new line
call print_nl
;print a message saying the following output is from example 2
mov rdi, QWORD example_2
call print_string
call print_nl
call print_nl
;call the second example
call print_messages_example_v2
;make some space with a new line
call print_nl
;print a message saying we are going to output the results of the fun_with_lea example
mov rdi, QWORD example_3
call print_string
call print_nl
call print_nl
call fun_with_lea
call print_nl
;restore the stack to its previous state.
;first add an equal amount to RSP as what we subtracted when we entered this function.
;this includes the sum of all additional subtractions made after the first subtraction (if there are any).
;then restore the base pointer (RBP) by popping it back into itself.
add rsp, 32
;once we do the addition, the value of RBP we pushed at the beginning of the function
;should be the only thing left on the stack.
pop rbp
ret
|
global _start
section .data
message: db 'hello, world!', 10
section .text
_start:
mov rax, 1 ; system call number should be stored in rax
mov rdi, 1 ; argument #1 in rdi: where to write?
mov rsi, message ; argument #2 in rsi: where does the string start?
mov rdx, 14 ; argument #3 in rdx: how many bytes to write?
syscall ; this instruction invokes a system call |
; A102731: Numbers k such that 11*k + 23 is prime.
; 0,4,6,16,28,30,34,36,40,54,58,60,64,76,78,84,88,90,100,114,118,126,130,144,160,168,180,186,190,196,204,208,210,214,216,228,240,244,246,258,264,268,274,286,288,294,298,300,306,310,316,328,334,336,348,354,364,366,370,376,394,400,418,420,448,450,456,468,474,478,480,484,490,496,498,520,534,544,546,550,568,574,576,586,588,606,610,634,636,646,648,660,666,670,676,678,684,688,700,706
seq $0,141849 ; Primes congruent to 1 mod 11.
sub $0,23
div $0,11
|
/* Copyright(c) 1998-2020, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
//*************************************************************************
// \class AliAnalysisTaskSEDstarPolarization
// \brief Analysis task to perform D*+ polarization analysis
// \authors:
// F. Grosa, fabrizio.grosa@cern.ch
// S. Kundu, sourav.kundu@cern.ch
/////////////////////////////////////////////////////////////
#include <TRandom3.h>
#include "AliAODRecoDecayHF2Prong.h"
#include "AliAODRecoCascadeHF.h"
#include "AliRDHFCutsDStartoKpipi.h"
#include "AliVertexingHFUtils.h"
#include "AliAnalysisUtils.h"
#include "AliAODHandler.h"
#include "AliAODExtension.h"
#include "AliAODMCParticle.h"
#include "AliAnalysisManager.h"
#include "AliMultSelection.h"
#include "AliAnalysisTaskSEDstarPolarization.h"
/// \cond CLASSIMP
ClassImp(AliAnalysisTaskSEDstarPolarization);
/// \endcond
//________________________________________________________________________
AliAnalysisTaskSEDstarPolarization::AliAnalysisTaskSEDstarPolarization() : AliAnalysisTaskSE()
{
/// Default constructor
}
//________________________________________________________________________
AliAnalysisTaskSEDstarPolarization::AliAnalysisTaskSEDstarPolarization(const char *name, AliRDHFCuts *analysisCuts) :
AliAnalysisTaskSE(name)
{
/// Standard constructor
SetAnalysisCuts(analysisCuts);
DefineOutput(1, TList::Class());
DefineOutput(2, TList::Class());
}
//________________________________________________________________________
AliAnalysisTaskSEDstarPolarization::~AliAnalysisTaskSEDstarPolarization()
{
// Destructor
delete fOutput;
delete fListCuts;
delete fRDCuts;
if(fApplyML && fMLResponse)
delete fMLResponse;
}
//________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::LocalInit()
{
// Initialization
AliRDHFCutsDStartoKpipi *copycut = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi *>(fRDCuts)));
PostData(2, copycut);
return;
}
//________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::UserCreateOutputObjects()
{
/// Create the output container
//
// Several histograms are more conveniently managed in a TList
fOutput = new TList();
fOutput->SetOwner();
fOutput->SetName("OutputHistos");
fHistNEvents = new TH1F("hNEvents", "number of events ", 16, -0.5, 15.5);
fHistNEvents->GetXaxis()->SetBinLabel(1, "nEventsRead");
fHistNEvents->GetXaxis()->SetBinLabel(2, "nEvents Matched dAOD");
fHistNEvents->GetXaxis()->SetBinLabel(3, "nEvents Mismatched dAOD");
fHistNEvents->GetXaxis()->SetBinLabel(4, "nEventsAnal");
fHistNEvents->GetXaxis()->SetBinLabel(5, "n. passing IsEvSelected");
fHistNEvents->GetXaxis()->SetBinLabel(6, "n. rejected due to trigger");
fHistNEvents->GetXaxis()->SetBinLabel(7, "n. rejected due to not reco vertex");
fHistNEvents->GetXaxis()->SetBinLabel(8, "n. rejected for contr vertex");
fHistNEvents->GetXaxis()->SetBinLabel(9, "n. rejected for vertex out of accept");
fHistNEvents->GetXaxis()->SetBinLabel(10, "n. rejected for pileup events");
fHistNEvents->GetXaxis()->SetBinLabel(11, "no. of out centrality events");
fHistNEvents->GetXaxis()->SetBinLabel(12, "no. of D candidates");
fHistNEvents->GetXaxis()->SetBinLabel(13, "no. of D after filtering cuts");
fHistNEvents->GetXaxis()->SetBinLabel(14, "no. of D after selection cuts");
fHistNEvents->GetXaxis()->SetBinLabel(15, "no. of not on-the-fly rec D");
fHistNEvents->GetXaxis()->SetBinLabel(16, "no. of D rejected by preselect");
fHistNEvents->GetXaxis()->SetNdivisions(1, false);
fHistNEvents->SetMinimum(0);
fOutput->Add(fHistNEvents);
// Sparses for efficiencies (only gen)
if(fReadMC)
CreateEffSparses();
//Loading of ML models
if(fApplyML)
{
fMLResponse = new AliHFMLResponseDstartoD0pi("DstartoD0piMLResponse", "DstartoD0piMLResponse", fConfigPath.data());
fMLResponse->MLResponseInit();
}
CreateRecoSparses();
PostData(1, fOutput);
return;
}
//________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::UserExec(Option_t * /*option*/)
{
fAOD = dynamic_cast<AliAODEvent *>(InputEvent());
fHistNEvents->Fill(0); // all events
if (fAODProtection >= 0)
{
// Protection against different number of events in the AOD and deltaAOD
// In case of discrepancy the event is rejected.
int matchingAODdeltaAODlevel = AliRDHFCuts::CheckMatchingAODdeltaAODevents();
if (matchingAODdeltaAODlevel < 0 || (matchingAODdeltaAODlevel == 0 && fAODProtection == 1))
{
// AOD/deltaAOD trees have different number of entries || TProcessID do not match while it was required
fHistNEvents->Fill(2);
PostData(1, fOutput);
return;
}
fHistNEvents->Fill(1);
}
TClonesArray *arrayCand = nullptr;
if (!fAOD && AODEvent() && IsStandardAOD())
{
// In case there is an AOD handler writing a standard AOD, use the AOD
// event in memory rather than the input (ESD) event.
fAOD = dynamic_cast<AliAODEvent *>(AODEvent());
// in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
// have to taken from the AOD event hold by the AliAODExtension
AliAODHandler *aodHandler = dynamic_cast<AliAODHandler *>((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
if (aodHandler->GetExtensions())
{
AliAODExtension *ext = dynamic_cast<AliAODExtension *>(aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root"));
AliAODEvent *aodFromExt = ext->GetAOD();
arrayCand = dynamic_cast<TClonesArray *>(aodFromExt->GetList()->FindObject("Dstar"));
}
}
else if (fAOD)
{
arrayCand = dynamic_cast<TClonesArray *>(fAOD->GetList()->FindObject("Dstar"));
}
if (!fAOD || !arrayCand)
{
AliWarning("Candidate branch not found!\n");
PostData(1, fOutput);
return;
}
// fix for temporary bug in ESDfilter
// the AODs with null vertex pointer didn't pass the PhysSel
if (!fAOD->GetPrimaryVertex() || TMath::Abs(fAOD->GetMagneticField()) < 0.001)
{
PostData(1, fOutput);
return;
}
fHistNEvents->Fill(3); // count event
bool isEvSel = fRDCuts->IsEventSelected(fAOD);
if (fRDCuts->IsEventRejectedDueToTrigger())
fHistNEvents->Fill(5);
if (fRDCuts->IsEventRejectedDueToNotRecoVertex())
fHistNEvents->Fill(6);
if (fRDCuts->IsEventRejectedDueToVertexContributors())
fHistNEvents->Fill(7);
if (fRDCuts->IsEventRejectedDueToZVertexOutsideFiducialRegion())
fHistNEvents->Fill(8);
if (fRDCuts->IsEventRejectedDueToPileup())
fHistNEvents->Fill(9);
if (fRDCuts->IsEventRejectedDueToCentrality())
fHistNEvents->Fill(10);
TClonesArray *arrayMC = nullptr;
AliAODMCHeader *mcHeader = nullptr;
double centrality = -999.;
AliMultSelection *multSelection = dynamic_cast<AliMultSelection*>(fAOD->FindListObject("MultSelection"));
if(multSelection)
centrality = multSelection->GetMultiplicityPercentile("V0M");
// load MC particles
if (fReadMC)
{
arrayMC = dynamic_cast<TClonesArray *>(fAOD->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
if (!arrayMC)
{
AliWarning("MC particles branch not found!");
PostData(1, fOutput);
return;
}
// load MC header
mcHeader = dynamic_cast<AliAODMCHeader *>(fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
if (!mcHeader)
{
AliWarning("MC header branch not found!");
PostData(1, fOutput);
return;
}
// fill MC acceptance histos
FillMCGenAccHistos(arrayMC, mcHeader, centrality);
}
if (!isEvSel)
{
PostData(1, fOutput);
return;
}
fHistNEvents->Fill(4); // accepted event
// vHF object is needed to call the method that refills the missing info of the candidates
// if they have been deleted in dAOD reconstruction phase
// in order to reduce the size of the file
AliAnalysisVertexingHF vHF = AliAnalysisVertexingHF();
for (int iCand = 0; iCand < arrayCand->GetEntriesFast(); iCand++)
{
AliAODRecoCascadeHF *dStar = dynamic_cast<AliAODRecoCascadeHF *>(arrayCand->UncheckedAt(iCand));
bool unsetVtx = false;
bool recVtx = false;
AliAODVertex *origOwnVtx = nullptr;
int isSelected = IsCandidateSelected(dStar, &vHF, unsetVtx, recVtx, origOwnVtx);
if (!isSelected)
{
if (unsetVtx)
dStar->UnsetOwnPrimaryVtx();
if (recVtx)
fRDCuts->CleanOwnPrimaryVtx(dStar, fAOD, origOwnVtx);
continue;
}
fHistNEvents->Fill(13); // candidate selected
// get MC truth
AliAODMCParticle *partD = nullptr;
int labD = -1;
int orig = 0;
int pdgD0Dau[2] = {321, 211};
int pdgDstarDau[2] = {421, 211};
if (fReadMC)
{
labD = dStar->MatchToMC(413, 421, pdgDstarDau, pdgD0Dau, arrayMC, false);
partD = dynamic_cast<AliAODMCParticle *>(arrayMC->At(labD));
if (partD)
orig = AliVertexingHFUtils::CheckOrigin(arrayMC, partD, true);
}
// actual analysis
double mass = dStar->DeltaInvMass();
double ptCand = dStar->Pt();
AliAODTrack* dauPi = dynamic_cast<AliAODTrack *>(dStar->GetBachelor());
AliAODRecoDecayHF2Prong* dauD0 = dynamic_cast<AliAODRecoDecayHF2Prong *>(dStar->Get2Prong());
fourVecPi = ROOT::Math::PxPyPzMVector(dauPi->Px(), dauPi->Py(), dauPi->Pz(), TDatabasePDG::Instance()->GetParticle(211)->Mass());
fourVecD0 = ROOT::Math::PxPyPzMVector(dauD0->Px(), dauD0->Py(), dauD0->Pz(), TDatabasePDG::Instance()->GetParticle(421)->Mass());
fourVecDstar = fourVecPi + fourVecD0;
ROOT::Math::Boost boostv12{fourVecDstar.BoostToCM()};
fourVecPiCM = boostv12(fourVecPi);
fourVecD0CM = boostv12(fourVecD0);
double cosThetaStar = std::abs(fourVecPiCM.Pz() / fourVecPiCM.P());
std::vector<double> var4nSparse = {mass, ptCand, cosThetaStar, centrality};
if(!fReadMC)
fnSparseReco[0]->Fill(var4nSparse.data());
else
{
if(labD > 0) {
if(orig == 4)
fnSparseReco[1]->Fill(var4nSparse.data());
else if(orig == 5)
fnSparseReco[2]->Fill(var4nSparse.data());
}
else
fnSparseReco[3]->Fill(var4nSparse.data());
}
if (unsetVtx)
dStar->UnsetOwnPrimaryVtx();
if (recVtx)
fRDCuts->CleanOwnPrimaryVtx(dStar, fAOD, origOwnVtx);
}
PostData(1, fOutput);
}
//________________________________________________________________________
int AliAnalysisTaskSEDstarPolarization::IsCandidateSelected(AliAODRecoCascadeHF *&dStar, AliAnalysisVertexingHF *vHF, bool &unsetVtx, bool &recVtx, AliAODVertex *&origOwnVtx)
{
if (!dStar || !vHF)
return 0;
fHistNEvents->Fill(11);
// Preselection to speed up task
TObjArray arrDauTracks(3);
int nDau = 3;
for (int iDau = 0; iDau < nDau; iDau++)
{
AliAODTrack *track = vHF->GetProng(fAOD, dStar, iDau);
arrDauTracks.AddAt(track, iDau);
}
if (!fRDCuts->PreSelect(arrDauTracks))
{
fHistNEvents->Fill(15);
return 0;
}
if (!vHF->FillRecoCasc(fAOD, dStar, false))
{
fHistNEvents->Fill(14);
return 0;
}
fHistNEvents->Fill(12);
unsetVtx = false;
if (!dStar->GetOwnPrimaryVtx())
{
dStar->SetOwnPrimaryVtx(dynamic_cast<AliAODVertex *>(fAOD->GetPrimaryVertex()));
unsetVtx = true;
// NOTE: the own primary vertex should be unset, otherwise there is a memory leak
// Pay attention if you use continue inside this loop!!!
}
double ptD = dStar->Pt();
double yD = dStar->Y(413);
int ptBin = fRDCuts->PtBin(ptD);
if (ptBin < 0)
{
if (unsetVtx)
dStar->UnsetOwnPrimaryVtx();
return 0;
}
bool isFidAcc = fRDCuts->IsInFiducialAcceptance(ptD, yD);
if (!isFidAcc)
{
if (unsetVtx)
dStar->UnsetOwnPrimaryVtx();
return 0;
}
int isSelected = fRDCuts->IsSelected(dStar, AliRDHFCuts::kAll, fAOD);
if (!isSelected)
{
if (unsetVtx)
dStar->UnsetOwnPrimaryVtx();
return 0;
}
recVtx = false;
origOwnVtx = nullptr;
if (fRDCuts->GetIsPrimaryWithoutDaughters())
{
if (dStar->GetOwnPrimaryVtx())
origOwnVtx = new AliAODVertex(*dStar->GetOwnPrimaryVtx());
if (fRDCuts->RecalcOwnPrimaryVtx(dStar, fAOD))
recVtx = true;
else
fRDCuts->CleanOwnPrimaryVtx(dStar, fAOD, origOwnVtx);
}
if(fApplyML)
{
//variables for ML application
std::vector<double> modelPred = {};
bool isMLsel = false;
AliAODPidHF *pidHF = fRDCuts->GetPidHF();
isMLsel = fMLResponse->IsSelectedMultiClass(modelPred, dStar, fAOD->GetMagneticField(), pidHF, 0);
if(isMLsel)
isSelected = 1;
}
return isSelected;
}
//________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::FillMCGenAccHistos(TClonesArray *arrayMC, AliAODMCHeader *mcHeader, double centrality)
{
/// Fill MC histos for cuts study
/// - at GenLimAccStep and AccStep (if fFillAcceptanceLevel=false)
/// - at AccStep (if fFillAcceptanceLevel=true)
double zMCVertex = mcHeader->GetVtxZ(); //vertex MC
if (TMath::Abs(zMCVertex) <= fRDCuts->GetMaxVtxZ())
{
for (int iPart = 0; iPart < arrayMC->GetEntriesFast(); iPart++)
{
AliAODMCParticle *mcPart = dynamic_cast<AliAODMCParticle *>(arrayMC->At(iPart));
if (TMath::Abs(mcPart->GetPdgCode()) == 413)
{
int orig = AliVertexingHFUtils::CheckOrigin(arrayMC, mcPart, true); //Prompt = 4, FeedDown = 5
bool isParticleFromOutOfBunchPileUpEvent = AliAnalysisUtils::IsParticleFromOutOfBunchPileupCollision(iPart, mcHeader, arrayMC);
int deca = 0;
bool isGoodDecay = false;
int labDau[3] = {-1, -1, -1};
bool isFidAcc = false;
bool isDaugInAcc = false;
int nDau = 3;
deca = AliVertexingHFUtils::CheckDstarDecay(arrayMC, mcPart, labDau);
if (labDau[0] == -1)
continue; //protection against unfilled array of labels
if (deca > 0)
isGoodDecay = true;
if (isGoodDecay)
{
double pt = mcPart->Pt();
double rapid = mcPart->Y();
isFidAcc = fRDCuts->IsInFiducialAcceptance(pt, rapid);
isDaugInAcc = CheckDaugAcc(arrayMC, nDau, labDau);
if ((fFillAcceptanceLevel && isFidAcc && isDaugInAcc) || (!fFillAcceptanceLevel && TMath::Abs(rapid) < 0.5))
{
int labDauFirst = mcPart->GetDaughterFirst();
AliAODMCParticle* dauFirst = dynamic_cast<AliAODMCParticle *>(arrayMC->At(labDauFirst));
fourVecDstar = ROOT::Math::PxPyPzMVector(mcPart->Px(), mcPart->Py(), mcPart->Pz(), mcPart->M());
fourVecPi = ROOT::Math::PxPyPzMVector(dauFirst->Px(), dauFirst->Py(), dauFirst->Pz(), dauFirst->M());
ROOT::Math::Boost boostv12{fourVecDstar.BoostToCM()};
fourVecPiCM = boostv12(fourVecPi);
double cosThetaStar = fourVecPiCM.Pz() / fourVecPiCM.P();
if (orig == 4 && !isParticleFromOutOfBunchPileUpEvent)
{
double var4nSparseAcc[knVarForSparseAcc] = {pt, rapid, cosThetaStar, centrality};
fnSparseMC[0]->Fill(var4nSparseAcc);
}
else if (orig == 5 && !isParticleFromOutOfBunchPileUpEvent)
{
double var4nSparseAcc[knVarForSparseAcc] = {pt, rapid, cosThetaStar, centrality};
fnSparseMC[1]->Fill(var4nSparseAcc);
}
}
}
}
}
}
}
//________________________________________________________________________
bool AliAnalysisTaskSEDstarPolarization::CheckDaugAcc(TClonesArray *arrayMC, int nProng, int *labDau)
{
/// check if the decay products are in the good eta and pt range
for (int iProng = 0; iProng < nProng; iProng++)
{
bool isSoftPion = false;
AliAODMCParticle *mcPartDaughter = dynamic_cast<AliAODMCParticle *>(arrayMC->At(labDau[iProng]));
if (!mcPartDaughter)
return false;
AliAODMCParticle *mother = dynamic_cast<AliAODMCParticle *>(arrayMC->At(mcPartDaughter->GetMother()));
if(TMath::Abs(mother->GetPdgCode()) == 413)
isSoftPion = true;
double eta = mcPartDaughter->Eta();
double pt = mcPartDaughter->Pt();
double minPt = (!isSoftPion) ? 0.1 : 0.06;
if (TMath::Abs(eta) > 0.9 || pt < minPt)
return false;
}
return true;
}
//_________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::CreateEffSparses()
{
/// use sparses to be able to add variables if needed (multiplicity, Zvtx, etc)
int nPtBinsCutObj = fRDCuts->GetNPtBins();
float *ptLims = fRDCuts->GetPtBinLimits();
int nPtBins = (int)ptLims[nPtBinsCutObj];
if (fUseFinPtBinsForSparse)
nPtBins = nPtBins * 10;
int nBinsAcc[knVarForSparseAcc] = {nPtBins, 20, 5, 100};
double xminAcc[knVarForSparseAcc] = {0., -1., 0., 0.};
double xmaxAcc[knVarForSparseAcc] = {ptLims[nPtBinsCutObj], 1., 1., 100.};
TString label[2] = {"fromC", "fromB"};
for (int iHist = 0; iHist < 2; iHist++)
{
TString titleSparse = Form("MC nSparse (%s)- %s", fFillAcceptanceLevel ? "Acc.Step" : "Gen.Acc.Step", label[iHist].Data());
fnSparseMC[iHist] = new THnSparseF(Form("fnSparseAcc_%s", label[iHist].Data()), titleSparse.Data(), knVarForSparseAcc, nBinsAcc, xminAcc, xmaxAcc);
fnSparseMC[iHist]->GetAxis(0)->SetTitle("#it{p}_{T} (GeV/c)");
fnSparseMC[iHist]->GetAxis(1)->SetTitle("#it{y}");
fnSparseMC[iHist]->GetAxis(2)->SetTitle("|cos(#theta*)|");
fnSparseMC[iHist]->GetAxis(3)->SetTitle("centrality");
fOutput->Add(fnSparseMC[iHist]);
}
}
//_________________________________________________________________________
void AliAnalysisTaskSEDstarPolarization::CreateRecoSparses()
{
int nPtBinsCutObj = fRDCuts->GetNPtBins();
float *ptLims = fRDCuts->GetPtBinLimits();
int nPtBins = (int)ptLims[nPtBinsCutObj];
if (fUseFinPtBinsForSparse)
nPtBins = nPtBins * 10;
int nMassBins = 500;
double massMin = 0.138, massMax = 0.160;
int nCosThetaBins = 5;
int nBinsReco[knVarForSparseReco] = {nMassBins, nPtBins, nCosThetaBins, 100};
double xminReco[knVarForSparseReco] = {massMin, 0., 0., 0.};
double xmaxReco[knVarForSparseReco] = {massMax, ptLims[nPtBinsCutObj], 1., 100.};
TString label[4] = {"all", "fromC", "fromB", "bkg"};
for (int iHist = 0; iHist < 4; iHist++)
{
TString titleSparse = Form("Reco nSparse - %s", label[iHist].Data());
fnSparseReco[iHist] = new THnSparseF(Form("fnSparseReco_%s", label[iHist].Data()), titleSparse.Data(), knVarForSparseReco, nBinsReco, xminReco, xmaxReco);
fnSparseReco[iHist]->GetAxis(0)->SetTitle("#it{M}(K#pi#pi) #minus #it{M}(K#pi) (GeV/#it{c})");
fnSparseReco[iHist]->GetAxis(1)->SetTitle("#it{p}_{T} (GeV/c)");
fnSparseReco[iHist]->GetAxis(2)->SetTitle("|cos(#theta*)|");
fnSparseReco[iHist]->GetAxis(3)->SetTitle("centrality %");
fOutput->Add(fnSparseReco[iHist]);
}
}
|
;
; (c)2019 Phillip Stevens All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer. Redistributions in binary
; form must reproduce the above copyright notice, this list of conditions
; and the following disclaimer in the documentation and/or other materials
; provided with the distribution. Neither the name of the copyright holders
; nor the names of contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
INCLUDE "config_private.inc"
SECTION code_driver
PUBLIC asm_clock_getres
; HL contains address of struct timespec
; struct timespec { time_t tv_sec; /* seconds */
; nseconds_t tv_nsec;} /* and nanoseconds */
;
; ROMWBW always has 50 ticks per second
.asm_clock_getres
xor a ; scz180 has 50 ticks per second
ld (hl),a ; tv_sec 0x 00 00 00 00
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a ; tv_nsec 0x 01 31 2D 00
inc hl
ld (hl),$2d
inc hl
ld (hl),$31
inc hl
ld (hl),$01
ld hl,0 ; return null
ret
|
OUTPUT "issue172_dup_zero.bin"
DUP 1
DB 'A'
EDUP
DUP 0
DB 'B'
EDUP
DUP 2
DB 'C'
EDUP
; check also error message for negative count
DUP -1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %rbp
push %rbx
push %rdx
push %rsi
lea addresses_A_ht+0xf5f, %rbx
nop
nop
nop
nop
nop
inc %rdx
mov (%rbx), %ebp
nop
nop
nop
nop
nop
and %rbp, %rbp
lea addresses_UC_ht+0x55a7, %r12
nop
nop
nop
and $21098, %r15
mov $0x6162636465666768, %rsi
movq %rsi, %xmm1
and $0xffffffffffffffc0, %r12
vmovntdq %ymm1, (%r12)
nop
nop
sub %r15, %r15
pop %rsi
pop %rdx
pop %rbx
pop %rbp
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r15
push %rax
push %rbp
push %rdi
push %rsi
// Faulty Load
lea addresses_RW+0x1f35f, %rbp
clflush (%rbp)
nop
add $12487, %r14
movb (%rbp), %r15b
lea oracles, %rsi
and $0xff, %r15
shlq $12, %r15
mov (%rsi,%r15,1), %r15
pop %rsi
pop %rdi
pop %rbp
pop %rax
pop %r15
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 2, 'same': True}}
{'32': 3405}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
//
// Copyright © 2020 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <neon/workloads/NeonWorkloadUtils.hpp>
#include <arm_compute/runtime/NEON/functions/NEElementwiseOperations.h>
namespace armnn
{
arm_compute::Status NeonDivisionWorkloadValidate(const TensorInfo& input0,
const TensorInfo& input1,
const TensorInfo& output,
const ActivationDescriptor* activationDescriptor = nullptr);
class NeonDivisionWorkload : public BaseWorkload<DivisionQueueDescriptor>
{
public:
NeonDivisionWorkload(const DivisionQueueDescriptor& descriptor, const WorkloadInfo& info);
virtual void Execute() const override;
private:
mutable arm_compute::NEElementwiseDivision m_DivLayer;
};
} //namespace armnn
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x10d3f, %r13
nop
nop
nop
nop
xor %r11, %r11
mov (%r13), %bx
nop
nop
nop
xor $54414, %r10
lea addresses_normal_ht+0x1042f, %rsi
lea addresses_WC_ht+0x1566f, %rdi
clflush (%rsi)
nop
nop
nop
and %r8, %r8
mov $16, %rcx
rep movsb
xor %rbx, %rbx
lea addresses_D_ht+0xbbc5, %rsi
nop
nop
cmp $52052, %rdi
movl $0x61626364, (%rsi)
add %r13, %r13
lea addresses_normal_ht+0x1af21, %rdi
nop
add $11205, %r11
mov $0x6162636465666768, %r8
movq %r8, %xmm5
movups %xmm5, (%rdi)
nop
nop
nop
nop
and $38242, %r13
lea addresses_A_ht+0x3c6f, %rbx
add $46674, %r8
mov $0x6162636465666768, %rcx
movq %rcx, %xmm1
movups %xmm1, (%rbx)
nop
nop
nop
nop
add %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r15
push %r8
push %rcx
push %rdi
// Store
lea addresses_UC+0x812f, %r13
nop
nop
nop
add %r15, %r15
movw $0x5152, (%r13)
nop
nop
nop
xor $58774, %rdi
// Load
lea addresses_D+0xf09f, %r15
nop
nop
nop
nop
dec %r12
mov (%r15), %cx
and %rcx, %rcx
// Load
lea addresses_WT+0x1586f, %rcx
nop
nop
nop
nop
add %r12, %r12
movb (%rcx), %r8b
inc %rcx
// Load
lea addresses_WC+0x16aef, %r15
nop
nop
nop
sub %rcx, %rcx
movb (%r15), %r12b
nop
nop
nop
and $43944, %rcx
// Store
lea addresses_D+0x1968f, %r14
nop
nop
nop
and $29692, %r12
movl $0x51525354, (%r14)
nop
cmp $30135, %r15
// Store
lea addresses_A+0x12e6f, %r15
clflush (%r15)
nop
nop
nop
nop
add %rcx, %rcx
mov $0x5152535455565758, %rdi
movq %rdi, %xmm2
vmovaps %ymm2, (%r15)
nop
cmp $31134, %rdi
// Store
lea addresses_A+0x9aef, %r12
nop
nop
nop
nop
nop
sub $46323, %r8
mov $0x5152535455565758, %r14
movq %r14, %xmm4
vmovups %ymm4, (%r12)
nop
cmp %rdi, %rdi
// Store
lea addresses_A+0x12e6f, %r14
sub $3131, %rcx
mov $0x5152535455565758, %r8
movq %r8, %xmm6
vmovups %ymm6, (%r14)
add $2372, %rcx
// Store
lea addresses_D+0x170ef, %rdi
nop
nop
nop
nop
nop
sub %rcx, %rcx
mov $0x5152535455565758, %r8
movq %r8, %xmm1
vmovups %ymm1, (%rdi)
nop
nop
and %rdi, %rdi
// Store
lea addresses_A+0x1b12f, %r13
nop
nop
sub $55841, %r15
movw $0x5152, (%r13)
and $11525, %r13
// Faulty Load
lea addresses_A+0x12e6f, %r12
nop
cmp $45914, %rcx
mov (%r12), %r13w
lea oracles, %r8
and $0xff, %r13
shlq $12, %r13
mov (%r8,%r13,1), %r13
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_A', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 6}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT', 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_WC', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': True, 'AVXalign': True, 'size': 32, 'type': 'addresses_A', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D', 'congruent': 3}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_A', 'congruent': 6}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_A', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC_ht', 'congruent': 3}}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 1}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 8}, 'OP': 'STOR'}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
; A203194: (n-1)-st elementary symmetric function of the first n terms of (1,2,6,20,70,252,...)=A000984.
; Submitted by Jon Maiga
; 1,3,20,412,29080,7344960,6790976640,23310543674880,300020122552550400,14587151144134593024000,2695072097623041659787264000,1901191652075515716657381408768000,5141119908014521906432306538772430848000
add $0,1
mov $2,1
lpb $0
mov $1,$0
add $1,$0
sub $0,1
sub $1,2
bin $1,$0
mul $3,$1
add $3,$2
mul $2,$1
lpe
mov $0,$3
|
.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, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 08
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 b, 03
ld a, b3
ldff(40), a
ld a, 08
ldff(4b), a
ld a, 05
ldff(43), a
.text@1000
lstatint:
nop
.text@1095
ldff a, (c)
and a, b
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
//USE32
.extern __arch_start
.extern __serial_print1
.global __multiboot_magic
.global __multiboot_addr
.global _start
.global __xsave_enabled
.global __avx_enabled
.set MB_MAGIC, 0x1BADB002
.set MB_FLAGS, 0x3 //;; ALIGN + MEMINFO
//;; stack base address at EBDA border
//;; NOTE: Multiboot can use 9d400 to 9ffff
.set STACK_LOCATION, 0x9D3F0
.extern _MULTIBOOT_START_
.extern _LOAD_START_
.extern _LOAD_END_
.extern _end
.extern fast_kernel_start
.align 4
.section .multiboot
dd MB_MAGIC
dd MB_FLAGS
dd -(MB_MAGIC + MB_FLAGS)
dd _MULTIBOOT_START_
dd _LOAD_START_
dd _LOAD_END_
dd _end
dd _start
// ;; used for faster live updates
dd 0xFEE1DEAD
dd fast_kernel_start
.set data_segment 0x10
.set code_segment 0x08
.section .data
__xsave_enabled:
dw 0x0
__avx_enabled:
dw 0x0
__multiboot_magic:
dd 0x0
__multiboot_addr:
dd 0x0
section .text
;; Multiboot places boot paramters on eax and ebx.
_start:
;; load simple GDT
lgdt [gdtr]
;; Reload all data segments to new GDT
jmp code_segment:rock_bottom
;; Set up stack and load segment registers
;; (e.g. this is the very bottom of the stack)
rock_bottom:
mov cx, data_segment
mov ss, cx
mov ds, cx
mov es, cx
mov fs, cx
mov cx, 0x18 ;; GS segment
mov gs, cx
;; 32-bit stack ptr
mov esp, STACK_LOCATION
mov ebp, esp
;; enable SSE before we enter C/C++ land
call enable_sse
;; Enable modern x87 FPU exception handling
call enable_fpu_native
;; try to enable XSAVE before checking AVX
call enable_xsave
;; enable AVX if xsave and avx supported on CPU
call enable_avx
;; Save multiboot params
mov DWORD [__multiboot_magic], eax
mov DWORD [__multiboot_addr], ebx
call __arch_start
jmp __start_panic
//TODO ARM
enable_fpu_native:
push eax
mov eax, cr0
or eax, 0x20
mov cr0, eax
pop eax
ret
//TODO ENABLE NEON
enable_sse:
push eax ;preserve eax for multiboot
mov eax, cr0
and ax, 0xFFFB ;clear coprocessor emulation CR0.EM
or ax, 0x2 ;set coprocessor monitoring CR0.MP
mov cr0, eax
mov eax, cr4
or ax, 3 << 9 ;set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
mov cr4, eax
pop eax
ret
enable_xsave:
push eax
push ebx
; check for XSAVE support
mov eax, 1
xor ecx, ecx
cpuid
; bit 26 ecx
and ecx, 0x04000000
cmp ecx, 0x04000000
jne xsave_not_supported
; enable XSAVE
mov eax, cr4
or eax, 0x40000
mov cr4, eax
mov WORD [__xsave_enabled], 0x1
xsave_not_supported:
pop ebx
pop eax
ret
enable_avx:
push eax
push ebx
;; assuming cpuid with eax=1 supported
mov eax, 1
xor ecx, ecx
cpuid
;; check bits 27, 28 (xsave, avx)
and ecx, 0x18000000
cmp ecx, 0x18000000
jne avx_not_supported
;; enable AVX support
xor ecx, ecx
xgetbv
or eax, 0x7
xsetbv
mov WORD [__avx_enabled], 0x1
avx_not_supported:
pop ebx
pop eax
ret
__start_panic:
sub esp, 4
and esp, -16
mov DWORD [esp], str.panic
call __serial_print1
cli
hlt
ALIGN 32
gdtr:
dw gdt32_end - gdt32 - 1
dd gdt32
ALIGN 32
gdt32:
;; Entry 0x0: Null descriptor
dq 0x0
;; Entry 0x8: Code segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf9a ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
;; Entry 0x10: Data segment
dw 0xffff ;Limit
dw 0x0000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0xcf92 ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
;; Entry 0x18: GS Data segment
dw 0x0100 ;Limit
dw 0x1000 ;Base 15:00
db 0x00 ;Base 23:16
dw 0x4092 ;Flags / Limit / Type [F,L,F,Type]
db 0x00 ;Base 32:24
gdt32_end:
str:
.panic:
db `Panic: OS returned to x86 start.asm. Halting\n`,0x0
|
; A344121: a(n) is the multiplicative inverse of 24 (mod 7^n).
; Submitted by Christian Krause
; 5,47,243,2301,11905,112747,583343,5524601,28583805,270705447,1400606443,13264566901,68629715705,649963778147,3362856069543,31848225129201,164779947407605,1560563031330847,8074217422972643,76467588535211501,395636653725659505,3746911838225363547,19386196032557315743
add $0,6
lpb $0
sub $0,1
sub $2,1
add $1,$2
add $1,1
mul $1,7
pow $2,$0
add $2,2
max $2,2
mod $2,4
lpe
mov $0,$1
div $0,117649
mul $0,14
add $0,5
|
; A033375: [ 55/n ].
; 55,27,18,13,11,9,7,6,6,5,5,4,4,3,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
add $0,1
mov $1,55
div $1,$0
|
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2020, The Regents of the University of California
// All rights reserved.
//
// BSD 3-Clause License
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////
#include <QAbstractItemView>
#include <QAction>
#include <QApplication>
#include <QDebug>
#include <QLineEdit>
#include <QKeyEvent>
#include <QMenu>
#include <QPushButton>
#include <QStandardItemModel>
#include <fstream>
#include <iostream>
#include <limits>
#include <string>
#include "db.h"
#include "dbShape.h"
#include "db_sta/dbNetwork.hh"
#include "db_sta/dbSta.hh"
#include "sta/ArcDelayCalc.hh"
#include "sta/Corner.hh"
#include "sta/DcalcAnalysisPt.hh"
#include "sta/ExceptionPath.hh"
#include "sta/Graph.hh"
#include "sta/GraphDelayCalc.hh"
#include "sta/Liberty.hh"
#include "sta/Network.hh"
#include "sta/PathAnalysisPt.hh"
#include "sta/PathEnd.hh"
#include "sta/PathExpanded.hh"
#include "sta/PathRef.hh"
#include "sta/PatternMatch.hh"
#include "sta/PortDirection.hh"
#include "sta/Sdc.hh"
#include "sta/Search.hh"
#include "sta/Sta.hh"
#include "sta/Units.hh"
#include "sta/VertexVisitor.hh"
#include "staGui.h"
Q_DECLARE_METATYPE(sta::Corner*);
namespace gui {
const Painter::Color TimingPathRenderer::inst_highlight_color_
= Painter::Color(gui::Painter::highlight, 100);
const Painter::Color TimingPathRenderer::path_inst_color_
= Painter::Color(gui::Painter::magenta, 100);
const Painter::Color TimingPathRenderer::term_color_ = Painter::Color(gui::Painter::blue, 100);
const Painter::Color TimingPathRenderer::signal_color_ = Painter::Color(gui::Painter::red, 100);
const Painter::Color TimingPathRenderer::clock_color_ = Painter::Color(gui::Painter::cyan, 100);
const Painter::Color TimingPathRenderer::capture_clock_color_ = Painter::Color(gui::Painter::green, 100);
static QString convertDelay(float time, sta::Unit* convert)
{
if (sta::delayInf(time)) {
const QString infinity = "\u221E";
if (time < 0) {
return "-" + infinity;
} else {
return infinity;
}
} else {
return convert->asString(time);
}
}
/////////
TimingPathsModel::TimingPathsModel(sta::dbSta* sta, QObject* parent)
: QAbstractTableModel(parent), sta_(sta)
{
}
TimingPath* TimingPathsModel::getPathAt(const QModelIndex& index) const
{
return timing_paths_[index.row()].get();
}
int TimingPathsModel::rowCount(const QModelIndex& parent) const
{
return timing_paths_.size();
}
int TimingPathsModel::columnCount(const QModelIndex& parent) const
{
return 6;
}
QVariant TimingPathsModel::data(const QModelIndex& index, int role) const
{
const Column col_index = static_cast<Column>(index.column());
if (role == Qt::TextAlignmentRole) {
switch (col_index) {
case Clock:
case Start:
case End:
return Qt::AlignLeft;
case Required:
case Arrival:
case Slack:
return Qt::AlignRight;
}
} else if (role == Qt::DisplayRole) {
auto time_units = sta_->search()->units()->timeUnit();
auto* timing_path = getPathAt(index);
switch (col_index) {
case Clock:
return QString::fromStdString(timing_path->getEndClock());
case Required:
return convertDelay(timing_path->getPathRequiredTime(), time_units);
case Arrival:
return convertDelay(timing_path->getPathArrivalTime(), time_units);
case Slack:
return convertDelay(timing_path->getSlack(), time_units);
case Start:
return QString::fromStdString(timing_path->getStartStageName());
case End:
return QString::fromStdString(timing_path->getEndStageName());
}
}
return QVariant();
}
QVariant TimingPathsModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (static_cast<Column>(section)) {
case Clock:
return "Capture Clock";
case Required:
return "Required";
case Arrival:
return "Arrival";
case Slack:
return "Slack";
case Start:
return "Start";
case End:
return "End";
}
}
return QVariant();
}
void TimingPathsModel::resetModel()
{
beginResetModel();
timing_paths_.clear();
endResetModel();
}
void TimingPathsModel::sort(int col_index, Qt::SortOrder sort_order)
{
std::function<bool(const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2)> sort_func;
if (col_index == Clock) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getEndClock() < path2->getEndClock();
};
} else if (col_index == Required) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getPathRequiredTime() < path2->getPathRequiredTime();
};
} else if (col_index == Arrival) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getPathArrivalTime() < path2->getPathArrivalTime();
};
} else if (col_index == Slack) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getSlack() < path2->getSlack();
};
} else if (col_index == Start) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getStartStageName() < path2->getStartStageName();
};
} else if (col_index == End) {
sort_func = [](const std::unique_ptr<TimingPath>& path1, const std::unique_ptr<TimingPath>& path2) {
return path1->getEndStageName() < path2->getEndStageName();
};
} else {
return;
}
beginResetModel();
if (sort_order == Qt::AscendingOrder) {
std::stable_sort(timing_paths_.begin(), timing_paths_.end(), sort_func);
} else {
std::stable_sort(timing_paths_.rbegin(), timing_paths_.rend(), sort_func);
}
endResetModel();
}
void TimingPathsModel::populateModel(bool setup_hold,
int path_count,
const std::set<sta::Pin*>& from,
const std::vector<std::set<sta::Pin*>>& thru,
const std::set<sta::Pin*>& to,
bool unconstrainted)
{
beginResetModel();
timing_paths_.clear();
populatePaths(setup_hold, path_count, from, thru, to, unconstrainted);
endResetModel();
}
bool TimingPathsModel::populatePaths(bool get_max,
int path_count,
const std::set<sta::Pin*>& from,
const std::vector<std::set<sta::Pin*>>& thru,
const std::set<sta::Pin*>& to,
bool unconstrainted)
{
// On lines of DataBaseHandler
QApplication::setOverrideCursor(Qt::WaitCursor);
TimingPath::buildPaths(sta_,
get_max,
unconstrainted, // unconstrained
path_count,
from, // from
thru, // through
to, // to
true,
timing_paths_);
QApplication::restoreOverrideCursor();
return true;
}
/////////
void TimingPath::buildPaths(sta::dbSta* sta,
bool get_max,
bool include_unconstrained,
int path_count,
const std::set<sta::Pin*>& from,
const std::vector<std::set<sta::Pin*>>& thrus,
const std::set<sta::Pin*>& to,
bool include_capture,
std::vector<std::unique_ptr<TimingPath>>& paths)
{
sta->ensureGraph();
sta->searchPreamble();
sta::ExceptionFrom* e_from = nullptr;
if (!from.empty()) {
sta::PinSet* pins = new sta::PinSet;
pins->insert(from.begin(), from.end());
e_from = sta->makeExceptionFrom(pins,
nullptr,
nullptr,
sta::RiseFallBoth::riseFall());
}
sta::ExceptionThruSeq* e_thrus = nullptr;
if (!thrus.empty()) {
for (const auto& thru_set : thrus) {
if (thru_set.empty()) {
continue;
}
if (e_thrus == nullptr) {
e_thrus = new sta::ExceptionThruSeq;
}
sta::PinSet* pins = new sta::PinSet;
pins->insert(thru_set.begin(), thru_set.end());
e_thrus->push_back(sta->makeExceptionThru(pins,
nullptr,
nullptr,
sta::RiseFallBoth::riseFall()));
}
}
sta::ExceptionTo* e_to = nullptr;
if (!to.empty()) {
sta::PinSet* pins = new sta::PinSet;
pins->insert(to.begin(), to.end());
e_to = sta->makeExceptionTo(pins,
nullptr,
nullptr,
sta::RiseFallBoth::riseFall(),
sta::RiseFallBoth::riseFall());
}
sta::PathEndSeq* path_ends
= sta->search()->findPathEnds( // from, thrus, to, unconstrained
e_from,
e_thrus,
e_to,
include_unconstrained,
// corner, min_max,
sta->cmdCorner(),
get_max ? sta::MinMaxAll::max() : sta::MinMaxAll::min(),
// group_count, endpoint_count, unique_pins
path_count,
path_count,
true,
-sta::INF,
sta::INF, // slack_min, slack_max,
true, // sort_by_slack
nullptr, // group_names
// setup, hold, recovery, removal,
get_max,
!get_max,
false,
false,
// clk_gating_setup, clk_gating_hold
false,
false);
for (auto& path_end : *path_ends) {
TimingPath* timing_path = new TimingPath();
auto* path = path_end->path();
sta::DcalcAnalysisPt* dcalc_ap
= path->pathAnalysisPt(sta)->dcalcAnalysisPt();
auto* start_clock_edge = path_end->sourceClkEdge(sta);
if (start_clock_edge != nullptr) {
timing_path->setStartClock(start_clock_edge->clock()->name());
} else {
timing_path->setStartClock("<No clock>");
}
auto* end_clock = path_end->targetClk(sta);
if (end_clock != nullptr) {
timing_path->setEndClock(end_clock->name());
} else {
timing_path->setEndClock("<No clock>");
}
auto* path_delay = path_end->pathDelay();
if (path_delay != nullptr) {
timing_path->setPathDelay(path_delay->delay());
} else {
timing_path->setPathDelay(0.0);
}
timing_path->setSlack(path_end->slack(sta));
timing_path->setPathArrivalTime(path_end->dataArrivalTime(sta));
timing_path->setPathRequiredTime(path_end->requiredTime(sta));
bool clock_propagated = false;
if (start_clock_edge != nullptr) {
clock_propagated = start_clock_edge->clock()->isPropagated();
}
const bool clock_expaneded = clock_propagated;
timing_path->populatePath(path,
sta,
dcalc_ap,
clock_expaneded);
if (include_capture) {
timing_path->populateCapturePath(path_end->targetClkPath(),
sta,
dcalc_ap,
path_end->targetClkOffset(sta),
clock_expaneded);
}
timing_path->computeClkEndIndex();
timing_path->setSlackOnPathNodes();
paths.push_back(std::unique_ptr<TimingPath>(timing_path));
}
delete path_ends;
}
void TimingPath::populateNodeList(sta::Path* path,
sta::dbSta* sta,
sta::DcalcAnalysisPt* dcalc_ap,
float offset,
bool clock_expanded,
TimingNodeList& list)
{
float arrival_prev_stage = 0;
float arrival_cur_stage = 0;
sta::PathExpanded expand(path, sta);
for (size_t i = 0; i < expand.size(); i++) {
const auto* ref = expand.path(i);
const auto pin = ref->vertex(sta)->pin();
const bool pin_is_clock = sta->isClock(pin);
const auto slew = ref->slew(sta);
const bool is_driver = sta->network()->isDriver(pin);
const auto is_rising = ref->transition(sta) == sta::RiseFall::rise();
const auto arrival = ref->arrival(sta);
float cap = 0.0;
if (is_driver
&& !(!clock_expanded && (sta->network()->isCheckClk(pin) || !i))) {
sta::ArcDelayCalc* arc_delay_calc = sta->arcDelayCalc();
sta::Parasitic* parasitic = arc_delay_calc->findParasitic(pin, ref->transition(sta), dcalc_ap);
sta::GraphDelayCalc* graph_delay_calc = sta->graphDelayCalc();
cap = graph_delay_calc->loadCap(pin, parasitic, ref->transition(sta), dcalc_ap);
}
odb::dbITerm* term;
odb::dbBTerm* port;
sta->getDbNetwork()->staToDb(pin, term, port);
odb::dbObject* pin_object = term;
if (term == nullptr) {
pin_object = port;
}
arrival_cur_stage = arrival;
list.push_back(std::make_unique<TimingPathNode>(pin_object,
pin_is_clock,
is_rising,
!is_driver,
true,
arrival + offset,
arrival_cur_stage - arrival_prev_stage,
slew,
cap));
arrival_prev_stage = arrival_cur_stage;
}
// populate list with source/sink nodes
for (int i = 0; i < list.size(); i++) {
auto* node = list[i].get();
if (node->isSource()) {
if (i < (list.size() - 1)) {
// get the next node
node->addPairedNode(list[i + 1].get());
}
} else {
// node is sink
node->addPairedNode(node);
}
}
// first find the first instance node
TimingPathNode* instance_node = nullptr;
for (auto& node : list) {
if (node->hasInstance()) {
instance_node = node.get();
break;
}
}
// populate with instance nodes
for (auto& node : list) {
if (node->hasInstance()) {
instance_node = node.get();
}
node->setInstanceNode(instance_node);
}
}
void TimingPath::populatePath(sta::Path* path,
sta::dbSta* sta,
sta::DcalcAnalysisPt* dcalc_ap,
bool clock_expanded)
{
populateNodeList(path, sta, dcalc_ap, 0, clock_expanded, path_nodes_);
}
void TimingPath::populateCapturePath(sta::Path* path,
sta::dbSta* sta,
sta::DcalcAnalysisPt* dcalc_ap,
float offset,
bool clock_expanded)
{
populateNodeList(path, sta, dcalc_ap, offset, clock_expanded, capture_nodes_);
}
std::string TimingPath::getStartStageName() const
{
const int start_idx = getClkPathEndIndex() + 1;
if (start_idx >= path_nodes_.size()) {
return path_nodes_[0]->getNodeName();
}
return path_nodes_[start_idx]->getNodeName();
}
std::string TimingPath::getEndStageName() const
{
return path_nodes_.back()->getNodeName();
}
void TimingPath::computeClkEndIndex(TimingNodeList& nodes, int& index)
{
for (int i = 0; i < nodes.size(); i++) {
if (!nodes[i]->isClock()) {
index = i - 1;
return;
}
}
index = nodes.size() - 1; // assume last index is the end of the clock path
}
void TimingPath::computeClkEndIndex()
{
computeClkEndIndex(path_nodes_, clk_path_end_index_);
computeClkEndIndex(capture_nodes_, clk_capture_end_index_);
}
void TimingPath::setSlackOnPathNodes()
{
for (const auto& node : path_nodes_) {
node->setPathSlack(slack_);
}
}
/////////////
std::string TimingPathNode::getNodeName(bool include_master) const
{
if (isPinITerm()) {
odb::dbITerm* db_iterm = getPinAsITerm();
return db_iterm->getInst()->getName() + "/"
+ db_iterm->getMTerm()->getName()
+ (include_master
? " (" + db_iterm->getInst()->getMaster()->getName() + ")"
: "");
}
return getNetName();
}
std::string TimingPathNode::getNetName() const
{
return getNet()->getName();
}
odb::dbNet* TimingPathNode::getNet() const
{
if (isPinITerm()) {
return getPinAsITerm()->getNet();
}
return getPinAsBTerm()->getNet();
}
odb::dbInst* TimingPathNode::getInstance() const
{
if (isPinITerm()) {
return getPinAsITerm()->getInst();
}
return nullptr;
}
odb::dbITerm* TimingPathNode::getPinAsITerm() const
{
if (isPinITerm()) {
return static_cast<odb::dbITerm*>(pin_);
}
return nullptr;
}
odb::dbBTerm* TimingPathNode::getPinAsBTerm() const
{
if (isPinBTerm()) {
return static_cast<odb::dbBTerm*>(pin_);
}
return nullptr;
}
void TimingPathNode::copyData(TimingPathNode* other) const
{
other->pin_ = pin_;
other->is_clock_ = is_clock_;
other->is_rising_ = is_rising_;
other->is_sink_ = is_sink_;
other->has_values_ = has_values_;
other->arrival_ = arrival_;
other->delay_ = delay_;
other->slew_ = slew_;
other->load_ = load_;
other->path_slack_ = path_slack_;
}
const odb::Rect TimingPathNode::getPinBBox() const
{
if (isPinITerm()) {
return getPinAsITerm()->getBBox();
} else {
return getPinAsBTerm()->getBBox();
}
}
const odb::Rect TimingPathNode::getPinLargestBox() const
{
if (isPinITerm()) {
auto* iterm = getPinAsITerm();
odb::dbTransform transform;
iterm->getInst()->getTransform(transform);
odb::Rect pin_rect;
auto* mterm = iterm->getMTerm();
for (auto* pin : mterm->getMPins()) {
for (auto* box : pin->getGeometry()) {
odb::Rect box_rect;
box->getBox(box_rect);
transform.apply(box_rect);
if (pin_rect.dx() < box_rect.dx()) {
pin_rect = box_rect;
}
}
}
return pin_rect;
} else {
auto* bterm = getPinAsBTerm();
odb::Rect pin_rect;
for (auto* pin : bterm->getBPins()) {
for (auto* box : pin->getBoxes()) {
odb::Rect box_rect;
box->getBox(box_rect);
if (pin_rect.dx() < box_rect.dx()) {
pin_rect = box_rect;
}
}
}
return pin_rect;
}
}
/////////
TimingPathDetailModel::TimingPathDetailModel(bool is_capture, sta::dbSta* sta, QObject* parent)
: QAbstractTableModel(parent),
sta_(sta),
is_capture_(is_capture),
expand_clock_(false),
path_(nullptr),
nodes_(nullptr)
{
}
int TimingPathDetailModel::rowCount(const QModelIndex& parent) const
{
if (path_ == nullptr || !hasNodes()) {
return 0;
}
return nodes_->size() + 1;
}
int TimingPathDetailModel::columnCount(const QModelIndex& parent) const
{
return 6;
}
const TimingPathNode* TimingPathDetailModel::getNodeAt(const QModelIndex& index) const
{
int node_idx = index.row();
if (node_idx > clock_summary_row_) {
// account for collapsed clock entry
node_idx--;
}
return nodes_->at(node_idx).get();
}
QVariant TimingPathDetailModel::data(const QModelIndex& index, int role) const
{
if (path_ == nullptr ||
nodes_ == nullptr ||
!hasNodes()) {
return QVariant();
}
const Column col_index = static_cast<Column>(index.column());
if (role == Qt::TextAlignmentRole) {
switch (col_index) {
case Pin:
return Qt::AlignLeft;
case Time:
case Delay:
case Slew:
case Load:
return Qt::AlignRight;
case RiseFall:
return Qt::AlignCenter;
}
} else if (role == Qt::DisplayRole) {
const auto time_units = sta_->search()->units()->timeUnit();
if (index.row() == clock_summary_row_) {
int start_idx = getClockEndIndex();
if (start_idx < 0) {
start_idx = 0;
}
const auto& node = nodes_->at(start_idx);
switch (col_index) {
case Pin:
return "clock network delay";
case Time:
return convertDelay(node->getArrival(), time_units);
case Delay:
return convertDelay(node->getArrival() - nodes_->at(0)->getArrival(), time_units);
default:
return QVariant();
}
} else {
const auto* node = getNodeAt(index);
switch (col_index) {
case Pin:
return QString::fromStdString(node->getNodeName(/* include_master */ true));
case RiseFall:
return node->isRisingEdge() ? up_arrow_ : down_arrow_;
case Time:
return convertDelay(node->getArrival(), time_units);
case Delay:
return convertDelay(node->getDelay(), time_units);
case Slew:
return convertDelay(node->getSlew(), time_units);
case Load: {
if (node->getLoad() == 0)
return "";
const auto cap_units = sta_->search()->units()->capacitanceUnit();
return cap_units->asString(node->getLoad());
}
}
}
}
return QVariant();
}
bool TimingPathDetailModel::shouldHide(const QModelIndex& index) const
{
const int row = index.row();
const int last_clock = getClockEndIndex() + 1; // accounting for clock_summary would +1
if (row == 0) {
return false;
}
if (row == clock_summary_row_) {
return expand_clock_;
}
if (row >= last_clock) {
return false;
} else {
return !expand_clock_;
}
return false;
}
Qt::ItemFlags TimingPathDetailModel::flags(const QModelIndex& index) const
{
auto flags = QAbstractTableModel::flags(index);
flags.setFlag(Qt::ItemIsEnabled, !shouldHide(index));
return flags;
}
QVariant TimingPathDetailModel::headerData(int section,
Qt::Orientation orientation,
int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (static_cast<Column>(section)) {
case Pin:
return "Pin";
case RiseFall:
return up_down_arrows_;
case Time:
return "Time";
case Delay:
return "Delay";
case Slew:
return "Slew";
case Load:
return "Load";
}
}
return QVariant();
}
void TimingPathDetailModel::populateModel(TimingPath* path, TimingPath::TimingNodeList* nodes)
{
beginResetModel();
path_ = path;
nodes_ = nodes;
endResetModel();
}
/////////
TimingPathRenderer::TimingPathRenderer() :
path_(nullptr),
highlight_stage_()
{
}
void TimingPathRenderer::highlight(TimingPath* path)
{
path_ = path;
highlight_stage_.clear();
redraw();
}
void TimingPathRenderer::highlightNode(const TimingPathNode* node)
{
if (node != nullptr) {
odb::dbNet* net = node->getNet();
odb::dbObject* sink = nullptr;
odb::dbInst* inst = nullptr;
auto* instance_node = node->getInstanceNode();
if (instance_node != nullptr) {
inst = instance_node->getInstance();
}
const TimingPathNode* sink_node = nullptr;
for (auto* pair_node : node->getPairedNodes()) {
sink_node = pair_node;
}
if (sink_node != nullptr) {
sink = sink_node->getPin();
}
if (net != nullptr || inst != nullptr) {
highlight_stage_.push_back(std::make_unique<HighlightStage>(HighlightStage{net, inst, sink}));
}
redraw();
}
}
void TimingPathRenderer::drawNodesList(TimingPath::TimingNodeList* nodes,
gui::Painter& painter,
const gui::Descriptor* net_descriptor,
const gui::Descriptor* inst_descriptor,
const gui::Descriptor* bterm_descriptor,
const Painter::Color& clock_color)
{
for (auto node_itr = nodes->rbegin(); node_itr != nodes->rend(); node_itr++) {
auto& node = *node_itr;
odb::dbInst* db_inst = node->getInstance();
if (db_inst != nullptr) {
painter.setPenAndBrush(TimingPathRenderer::path_inst_color_, true);
inst_descriptor->highlight(db_inst, painter);
}
if (node->isPinBTerm()) {
painter.setPenAndBrush(TimingPathRenderer::term_color_, true);
bterm_descriptor->highlight(node->getPinAsBTerm(), painter);
}
if (node->isSource()) {
for (auto* sink_node : node->getPairedNodes()) {
if (sink_node != nullptr) {
gui::Painter::Color wire_color = node->isClock() ? clock_color : TimingPathRenderer::signal_color_;
painter.setPenAndBrush(wire_color, true);
net_descriptor->highlight(node->getNet(), painter, sink_node->getPin());
}
}
}
}
}
void TimingPathRenderer::drawObjects(gui::Painter& painter)
{
if (path_ == nullptr) {
return;
}
auto* net_descriptor = Gui::get()->getDescriptor<odb::dbNet*>();
auto* inst_descriptor = Gui::get()->getDescriptor<odb::dbInst*>();
auto* bterm_descriptor = Gui::get()->getDescriptor<odb::dbBTerm*>();
drawNodesList(path_->getCaptureNodes(),
painter,
net_descriptor,
inst_descriptor,
bterm_descriptor,
capture_clock_color_);
drawNodesList(path_->getPathNodes(),
painter,
net_descriptor,
inst_descriptor,
bterm_descriptor,
clock_color_);
highlightStage(painter, net_descriptor, inst_descriptor);
}
void TimingPathRenderer::highlightStage(gui::Painter& painter,
const gui::Descriptor* net_descriptor,
const gui::Descriptor* inst_descriptor)
{
if (highlight_stage_.empty()) {
return;
}
painter.setPenAndBrush(TimingPathRenderer::inst_highlight_color_, true);
for (const auto& highlight : highlight_stage_) {
if (highlight->inst != nullptr) {
inst_descriptor->highlight(highlight->inst, painter);
}
}
for (const auto& highlight : highlight_stage_) {
if (highlight->net != nullptr) {
net_descriptor->highlight(highlight->net, painter, highlight->sink);
}
}
}
/////////
TimingConeRenderer::TimingConeRenderer() :
sta_(nullptr),
term_(nullptr),
fanin_(false),
fanout_(false),
map_(),
min_map_index_(0),
max_map_index_(0),
min_timing_(0.0),
max_timing_(0.0),
color_generator_(SpectrumGenerator(1.0))
{
}
void TimingConeRenderer::setITerm(odb::dbITerm* term, bool fanin, bool fanout)
{
if (sta_ == nullptr) {
return;
}
auto* network = sta_->getDbNetwork();
setPin(network->dbToSta(term), fanin, fanout);
}
void TimingConeRenderer::setBTerm(odb::dbBTerm* term, bool fanin, bool fanout)
{
if (sta_ == nullptr) {
return;
}
auto* network = sta_->getDbNetwork();
setPin(network->dbToSta(term), fanin, fanout);
}
void TimingConeRenderer::setPin(sta::Pin* pin, bool fanin, bool fanout)
{
if (sta_ == nullptr) {
return;
}
if (isSupplyPin(pin)) {
return;
}
if (pin != term_) {
term_ = pin;
fanin_ = fanin;
fanout_ = fanout;
} else {
// toggle options
if (fanin) {
fanin_ = !fanin_;
}
if (fanout) {
fanout_ = !fanout_;
}
}
if (pin == nullptr || (!fanin_ && !fanout_)) {
Gui::get()->unregisterRenderer(this);
return;
} else {
Gui::get()->registerRenderer(this);
}
QApplication::setOverrideCursor(Qt::WaitCursor);
sta_->ensureGraph();
map_.clear();
DepthMapSet depth_map;
if (fanin_) {
getFaninCone(pin, depth_map);
}
if (fanout_) {
getFanoutCone(pin, depth_map);
}
for (const auto& [level, pins] : depth_map) {
auto& map_level = map_[level];
for (auto* pin : pins) {
map_level.push_back(std::make_unique<TimingPathNode>(pin));
}
}
min_map_index_ = std::numeric_limits<int>::max();
max_map_index_ = std::numeric_limits<int>::min();
for (const auto& [level, pins_list] : map_) {
min_map_index_ = std::min(min_map_index_, level);
max_map_index_ = std::max(max_map_index_, level);
}
buildConnectivity();
annotateTiming(pin);
QApplication::restoreOverrideCursor();
redraw();
}
bool TimingConeRenderer::isSupplyPin(sta::Pin* pin) const
{
auto* network = sta_->getDbNetwork();
odb::dbITerm* iterm;
odb::dbBTerm* bterm;
network->staToDb(pin, iterm, bterm);
if (iterm != nullptr) {
if (iterm->getSigType().isSupply()) {
return true;
}
} else if (bterm != nullptr) {
if (bterm->getSigType().isSupply()) {
return true;
}
}
return false;
}
void TimingConeRenderer::drawObjects(gui::Painter& painter)
{
if (map_.empty()) {
return;
}
// draw timing connections
const double timing_range = max_timing_ - min_timing_;
const bool cone_unconstrained = max_timing_ < min_timing_;
std::function<double(const TimingPathNode* node)> timingToRatio;
if (timing_range == 0.0 || cone_unconstrained) {
timingToRatio = [](const TimingPathNode* node) {
return 0.5;
};
} else {
timingToRatio = [this, timing_range](const TimingPathNode* node) {
double value = 0.0;
if (node->hasValues()) {
value = 1.0 - (node->getPathSlack() - min_timing_) / timing_range;
}
return value;
};
}
// draw instances
std::map<odb::dbInst*, TimingPathNode*> instances;
for (const auto& [level, pins] : map_) {
for (const auto& pin : pins) {
if (pin->isPinITerm()) {
odb::dbInst* inst = pin->getPinAsITerm()->getInst();
if (inst != nullptr) {
if (instances.count(inst) == 0) {
instances[inst] = pin.get();
} else {
auto& worst_pin = instances[inst];
if (!worst_pin->hasValues()) {
worst_pin = pin.get();
} else if (pin->hasValues()) {
if (worst_pin->getPathSlack() > pin->getPathSlack()) {
worst_pin = pin.get();
}
}
}
}
}
}
}
auto* inst_descriptor = Gui::get()->getDescriptor<odb::dbInst*>();
for (const auto& [inst, slack_pin] : instances) {
const auto color = color_generator_.getColor(timingToRatio(slack_pin), 150);
painter.setPenAndBrush(color, true);
inst_descriptor->highlight(inst, painter);
}
const int line_width = 2; // 2 pixels
auto* iterm_descriptor = Gui::get()->getDescriptor<odb::dbITerm*>();
auto* bterm_descriptor = Gui::get()->getDescriptor<odb::dbBTerm*>();
for (const auto& [level, pins] : map_) {
for (const auto& pin : pins) {
const auto color = color_generator_.getColor(timingToRatio(pin.get()), 255);
painter.setPenAndBrush(color, true);
if (pin->isPinITerm()) {
iterm_descriptor->highlight(pin->getPinAsITerm(), painter);
} else {
bterm_descriptor->highlight(pin->getPinAsBTerm(), painter);
}
painter.setPen(color, true, line_width);
const odb::Rect sink_rect = pin->getPinLargestBox();
const odb::Point sink_pt(0.5 * (sink_rect.xMin() + sink_rect.xMax()),
0.5 * (sink_rect.yMin() + sink_rect.yMax()));
for (auto* source_node : pin->getPairedNodes()) {
const odb::Rect source_rect = source_node->getPinLargestBox();
const odb::Point source_pt(0.5 * (source_rect.xMin() + source_rect.xMax()),
0.5 * (source_rect.yMin() + source_rect.yMax()));
const auto source_color = color_generator_.getColor(timingToRatio(source_node), 255);
painter.setPen(source_color, true, line_width);
painter.drawLine(source_pt.x(), source_pt.y(), sink_pt.x(), sink_pt.y());
}
}
}
// annotate with depth
const auto text_anchor = gui::Painter::Anchor::CENTER;
const double text_margin = 2.0;
painter.setPen(gui::Painter::white, true);
for (const auto& [level, pins] : map_) {
for (const auto& pin : pins) {
const odb::Rect pin_rect = pin->getPinLargestBox();
const odb::Point pin_pt(0.5 * (pin_rect.xMin() + pin_rect.xMax()),
0.5 * (pin_rect.yMin() + pin_rect.yMax()));
const std::string text = std::to_string(level);
const odb::Rect text_bound = painter.stringBoundaries(pin_pt.x(), pin_pt.y(), text_anchor, text);
if (text_bound.dx() < text_margin * pin_rect.dx() && text_bound.dy() < text_margin * pin_rect.dy()) {
painter.drawString(pin_pt.x(), pin_pt.y(), text_anchor, text);
}
}
}
if (!cone_unconstrained) {
// draw legend, dont draw if cone is unonstrained
const int legend_keys = 5;
const int color_count = color_generator_.getColorCount();
auto* units = sta_->units()->timeUnit();
const std::string text_units = std::string(units->scaleAbreviation()) + units->suffix();
std::vector<std::pair<int, std::string>> legend;
for (int i = 0; i < legend_keys; i++) {
const double scale = static_cast<double>(i) / (legend_keys - 1);
const int color_index = color_count * scale;
const double slack = max_timing_ - timing_range * scale;
const std::string text = units->asString(slack) + text_units;
legend.push_back({color_index, text});
}
std::reverse(legend.begin(), legend.end());
color_generator_.drawLegend(painter, legend);
}
}
void TimingConeRenderer::getFaninCone(sta::Pin* source_pin, DepthMapSet& depth_map)
{
sta::PinSeq pins_to;
pins_to.push_back(source_pin);
auto* pins = sta_->findFaninPins(&pins_to,
true, // flat
false, // startpoints_only
0,
0,
true, // thru_disabled
true); // thru_constants
DepthMapSet depth_map_set;
getCone(source_pin, pins, depth_map_set, true);
for (auto& [level, pin_list] : depth_map_set) {
depth_map[-level].insert(pin_list.begin(), pin_list.end());
}
}
void TimingConeRenderer::getFanoutCone(sta::Pin* source_pin, DepthMapSet& depth_map)
{
sta::PinSeq pins_from;
pins_from.push_back(source_pin);
auto* pins = sta_->findFanoutPins(&pins_from,
true, // flat
false, // startpoints_only
0,
0,
true, // thru_disabled
true); // thru_constants
getCone(source_pin, pins, depth_map, false);
}
void TimingConeRenderer::getCone(sta::Pin* source_pin, sta::PinSet* pins, DepthMapSet& depth_map, bool is_fanin)
{
auto* network = sta_->getDbNetwork();
auto* graph = sta_->graph();
auto filter_pins = [network](sta::Pin* pin) {
return network->isRegClkPin(pin);
};
auto pin_to_object = [network](sta::Pin* pin) -> odb::dbObject* {
odb::dbITerm* iterm = nullptr;
odb::dbBTerm* bterm = nullptr;
network->staToDb(pin, iterm, bterm);
odb::dbObject* pin_term = nullptr;
if (iterm != nullptr) {
pin_term = iterm;
} else {
pin_term = bterm;
}
return pin_term;
};
pins->erase(source_pin);
int level = 0;
std::map<int, std::set<sta::Pin*>> mapped_pins;
mapped_pins[level].insert(source_pin);
int pins_size = -1;
while (!pins->empty() && pins_size != pins->size()) {
pins_size = pins->size();
int next_level = level + 1;
auto& source_pins = mapped_pins[level];
auto& next_pins = mapped_pins[next_level];
for (auto* pin : source_pins) {
auto* pin_vertex = graph->pinDrvrVertex(pin);
sta::VertexEdgeIterator* itr = nullptr;
if (is_fanin) {
itr = new sta::VertexInEdgeIterator(pin_vertex, graph);
} else {
itr = new sta::VertexOutEdgeIterator(pin_vertex, graph);
}
while (itr->hasNext()) {
auto* next_edge = itr->next();
sta::Vertex* next_vertex = next_edge->to(graph);
if (next_vertex == pin_vertex) {
next_vertex = next_edge->from(graph);
}
auto* next_pin = next_vertex->pin();
auto pin_find = pins->find(next_pin);
if (pin_find != pins->end()) {
if (!filter_pins(next_pin)) {
next_pins.insert(next_pin);
}
pins->erase(pin_find);
}
}
delete itr;
}
level = next_level;
}
delete pins;
for (const auto& [level, pin_list] : mapped_pins) {
auto& dmap = depth_map[level];
for (auto* pin : pin_list) {
dmap.insert(pin_to_object(pin));
}
}
}
void TimingConeRenderer::buildConnectivity()
{
auto* network = sta_->getDbNetwork();
auto* graph = sta_->graph();
// clear map pairs
for (const auto& [level, pin_list] : map_) {
for (const auto& pin : pin_list) {
pin->clearPairedNodes();
}
}
for (const auto& [level, pin_list] : map_) {
int next_level = level + 1;
if (map_.count(next_level) == 0) {
break;
}
std::map<sta::Vertex*, TimingPathNode*> next_pins;
for (const auto& pin : map_[next_level]) {
sta::Pin* sta_pin = nullptr;
if (pin->isPinITerm()) {
sta_pin = network->dbToSta(pin->getPinAsITerm());
} else {
sta_pin = network->dbToSta(pin->getPinAsBTerm());
}
next_pins[graph->pinDrvrVertex(sta_pin)] = pin.get();
next_pins[graph->pinLoadVertex(sta_pin)] = pin.get();
}
for (const auto& source_pin : pin_list) {
sta::Pin* sta_pin = nullptr;
if (source_pin->isPinITerm()) {
sta_pin = network->dbToSta(source_pin->getPinAsITerm());
} else {
sta_pin = network->dbToSta(source_pin->getPinAsBTerm());
}
sta::VertexOutEdgeIterator fanout_iter(graph->pinDrvrVertex(sta_pin), graph);
while (fanout_iter.hasNext()) {
sta::Edge* edge = fanout_iter.next();
sta::Vertex* fanout = edge->to(graph);
auto next_pins_find = next_pins.find(fanout);
if (next_pins_find != next_pins.end()) {
next_pins_find->second->addPairedNode(source_pin.get());
}
}
}
}
}
void TimingConeRenderer::annotateTiming(sta::Pin* source_pin)
{
// annotate critical path and work forwards/backwards until all pins have timing
std::vector<TimingPathNode*> pin_order;
for (int i = 0; i <= std::max(-min_map_index_, max_map_index_); i++) {
if (i <= -min_map_index_) {
for (const auto& pin : map_[-i]) {
pin_order.push_back(pin.get());
}
}
if (i <= max_map_index_) {
for (const auto& pin : map_[i]) {
pin_order.push_back(pin.get());
}
}
}
// populate with max number of unique paths, all other paths will appear as 0
const int path_count = 1000;
std::vector<std::unique_ptr<TimingPath>> paths;
TimingPath::buildPaths(sta_,
true, // max
true, // unconstrained
path_count, // paths
{}, // from
{{source_pin}}, // thru
{}, // to
false,
paths);
for (const auto& path : paths) {
for (const auto& node : *path->getPathNodes()) {
auto pin_find = std::find_if(pin_order.begin(), pin_order.end(), [&node](const TimingPathNode* other) {
return node->getPin() == other->getPin();
});
if (pin_find != pin_order.end()) {
TimingPathNode* pin_node = *pin_find;
if (pin_node->hasValues()) {
continue;
}
node->copyData(pin_node);
}
}
}
min_timing_ = std::numeric_limits<float>::max();
max_timing_ = std::numeric_limits<float>::lowest();
for (const auto& [level, pin_list] : map_) {
for (const auto& pin : pin_list) {
if (sta::delayInf(pin->getPathSlack()) || !pin->hasValues()) {
continue;
}
min_timing_ = std::min(min_timing_, pin->getPathSlack());
max_timing_ = std::max(max_timing_, pin->getPathSlack());
}
}
for (auto& [level, pin_list] : map_) {
std::sort(pin_list.begin(), pin_list.end(), [](const auto& l, const auto& r) {
return l->getPathSlack() > r->getPathSlack();
});
}
}
/////////
PinSetWidget::PinSetWidget(bool add_remove_button, QWidget* parent) :
QWidget(parent),
sta_(nullptr),
pins_({}),
box_(new QListWidget(this)),
find_pin_(new QLineEdit(this)),
clear_(new QPushButton(this)),
add_remove_(nullptr),
add_mode_(true)
{
const int min_characters = 25;
const auto font_metrics = fontMetrics();
const int min_width = min_characters * font_metrics.averageCharWidth();
find_pin_->setMinimumWidth(min_width);
box_->setSelectionMode(QAbstractItemView::ExtendedSelection);
const int max_rows = 5;
const int row_height = font_metrics.height();
box_->setFixedHeight(max_rows * row_height);
clear_->setIcon(QIcon(":/delete.png"));
clear_->setToolTip(tr("Clear pins"));
clear_->setAutoDefault(false);
clear_->setDefault(false);
connect(clear_,
SIGNAL(pressed()),
this,
SLOT(clearPins()));
connect(find_pin_,
SIGNAL(returnPressed()),
this,
SLOT(findPin()));
QVBoxLayout* layout = new QVBoxLayout;
QHBoxLayout* row_layout = new QHBoxLayout;
row_layout->addWidget(find_pin_);
row_layout->addWidget(clear_);
if (add_remove_button) {
add_remove_ = new QPushButton(this);
add_remove_->setToolTip(tr("Add/Remove rows"));
row_layout->addWidget(add_remove_);
add_remove_->setAutoDefault(false);
add_remove_->setDefault(false);
connect(add_remove_,
&QPushButton::pressed,
[this]() {
emit addRemoveTriggered(this);
});
setAddMode();
}
layout->addLayout(row_layout);
layout->addWidget(box_);
setLayout(layout);
box_->setContextMenuPolicy(Qt::CustomContextMenu);
connect(box_,
SIGNAL(customContextMenuRequested(const QPoint&)),
this,
SLOT(showMenu(const QPoint)));
}
void PinSetWidget::setAddMode()
{
if (add_remove_ == nullptr) {
return;
}
add_mode_ = true;
add_remove_->setIcon(QIcon(":/add.png"));
}
void PinSetWidget::setRemoveMode()
{
if (add_remove_ == nullptr) {
return;
}
add_mode_ = false;
add_remove_->setIcon(QIcon(":/remove.png"));
}
void PinSetWidget::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Delete && box_->hasFocus()) {
removeSelectedPins();
} else {
QWidget::keyPressEvent(event);
}
}
void PinSetWidget::updatePins()
{
box_->clear();
if (!pins_.empty()) {
auto* network = sta_->getDbNetwork();
for (const auto* pin : pins_) {
auto* item = new QListWidgetItem(network->name(pin));
item->setData(Qt::UserRole, QVariant::fromValue((void*)pin));
box_->addItem(item);
}
}
}
void PinSetWidget::setPins(const std::set<sta::Pin*>& pins)
{
pins_.clear();
pins_.insert(pins_.end(), pins.begin(), pins.end());
updatePins();
}
const std::set<sta::Pin*> PinSetWidget::getPins() const
{
std::set<sta::Pin*> pins(pins_.begin(), pins_.end());
return pins;
}
void PinSetWidget::addPin(sta::Pin* pin)
{
if (pin == nullptr) {
return;
}
if (std::find(pins_.begin(), pins_.end(), pin) != pins_.end()) {
return;
}
pins_.push_back(pin);
}
void PinSetWidget::removePin(sta::Pin* pin)
{
pins_.erase(std::find(pins_.begin(), pins_.end(), pin));
}
void PinSetWidget::removeSelectedPins()
{
for (auto* selection : box_->selectedItems()) {
void* pin_data = selection->data(Qt::UserRole).value<void*>();
removePin((sta::Pin*)pin_data);
}
updatePins();
}
void PinSetWidget::findPin()
{
const QString text = find_pin_->text();
if (text.isEmpty()) {
return;
}
auto* network = sta_->getDbNetwork();
auto* top_inst = network->topInstance();
for (QString pin_name : text.split(" ")) {
pin_name = pin_name.trimmed();
if (pin_name.isEmpty()) {
continue;
}
QByteArray name = pin_name.toLatin1();
sta::PatternMatch matcher(name.constData());
// search pins
sta::PinSeq found_pins;
network->findPinsHierMatching(top_inst, &matcher, &found_pins);
for (auto* pin : found_pins) {
addPin(pin);
}
// search ports
sta::PortSeq found_ports;
network->findPortsMatching(network->cell(top_inst), &matcher, &found_ports);
for (auto* port : found_ports) {
if (network->isBus(port) || network->isBundle(port)) {
sta::PortMemberIterator* member_iter = network->memberIterator(port);
while (member_iter->hasNext()) {
sta::Port* member = member_iter->next();
addPin(network->findPin(top_inst, member));
}
delete member_iter;
} else {
addPin(network->findPin(top_inst, port));
}
}
}
updatePins();
}
void PinSetWidget::showMenu(const QPoint& point)
{
// Handle global position
const QPoint global = box_->mapToGlobal(point);
auto* pin_item = box_->itemAt(box_->viewport()->mapFromGlobal(global));
if (pin_item == nullptr) {
return;
}
sta::Pin* pin = (sta::Pin*)pin_item->data(Qt::UserRole).value<void*>();
// Create menu and insert some actions
QMenu pin_menu;
QAction* remove = pin_menu.addAction("Remove");
connect(remove,
&QAction::triggered,
[this, pin]() {
removePin(pin);
updatePins();
});
QAction* remove_sel = pin_menu.addAction("Remove selected");
connect(remove_sel,
&QAction::triggered,
[this]() {
removeSelectedPins();
});
QAction* clear_all = pin_menu.addAction("Clear all");
connect(clear_all,
SIGNAL(triggered()),
this,
SLOT(clearPins()));
QAction* inspect_action = pin_menu.addAction("Inspect");
connect(inspect_action,
&QAction::triggered,
[this, pin]() {
auto* gui = Gui::get();
odb::dbITerm* iterm;
odb::dbBTerm* bterm;
sta_->getDbNetwork()->staToDb(pin, iterm, bterm);
if (iterm != nullptr) {
emit inspect(gui->makeSelected(iterm));
} else {
emit inspect(gui->makeSelected(bterm));
}
});
// Show context menu at handling position
pin_menu.exec(global);
}
/////////
TimingControlsDialog::TimingControlsDialog(QWidget* parent) :
QDialog(parent),
sta_(nullptr),
layout_(new QFormLayout),
path_count_spin_box_(new QSpinBox(this)),
corner_box_(new QComboBox(this)),
uncontrained_(new QCheckBox(this)),
expand_clk_(new QCheckBox(this)),
from_(new PinSetWidget(false, this)),
thru_({}),
to_(new PinSetWidget(false, this))
{
setWindowTitle("Timing Controls");
path_count_spin_box_->setRange(0, 10000);
path_count_spin_box_->setValue(100);
layout_->addRow("Paths:", path_count_spin_box_);
layout_->addRow("Expand clock:", expand_clk_);
layout_->addRow("Command corner:", corner_box_);
setupPinRow("From:", from_);
setThruPin({});
setupPinRow("To:", to_);
setUnconstrained(false);
layout_->addRow("Unconstrained:", uncontrained_);
setLayout(layout_);
connect(corner_box_,
QOverload<int>::of(&QComboBox::currentIndexChanged),
[this](int index) {
if (index < 0 || index >= corner_box_->count()) {
return;
}
auto* corner = corner_box_->itemData(index).value<sta::Corner*>();
sta_->setCmdCorner(corner);
});
connect(expand_clk_,
SIGNAL(toggled(bool)),
this,
SIGNAL(expandClock(bool)));
}
void TimingControlsDialog::setupPinRow(const QString& label, PinSetWidget* row, int row_index)
{
if (row_index < 0) {
layout_->addRow(label, row);
} else {
layout_->insertRow(row_index, label, row);
}
row->setSTA(sta_);
connect(row,
SIGNAL(inspect(const Selected&)),
this,
SIGNAL(inspect(const Selected&)));
}
void TimingControlsDialog::setSTA(sta::dbSta* sta)
{
sta_ = sta;
from_->setSTA(sta_);
for (auto* row : thru_) {
row->setSTA(sta_);
}
to_->setSTA(sta_);
}
void TimingControlsDialog::setUnconstrained(bool unconstrained)
{
uncontrained_->setCheckState(unconstrained ? Qt::Checked : Qt::Unchecked);
}
bool TimingControlsDialog::getUnconstrained() const
{
return uncontrained_->checkState() == Qt::Checked;
}
void TimingControlsDialog::setExpandClock(bool expand)
{
expand_clk_->setCheckState(expand ? Qt::Checked : Qt::Unchecked);
}
bool TimingControlsDialog::getExpandClock() const
{
return expand_clk_->checkState() == Qt::Checked;
}
void TimingControlsDialog::populate()
{
setPinSelections();
auto* current_corner = sta_->cmdCorner();
corner_box_->clear();
int selection = 0;
for (auto* corner : sta_->corners()->corners()) {
if (corner == current_corner) {
selection = corner_box_->count();
}
corner_box_->addItem(corner->name(), QVariant::fromValue(corner));
}
if (corner_box_->count() > 1) {
selection += 1;
corner_box_->insertItem(0, "All", QVariant::fromValue(static_cast<sta::Corner*>(nullptr)));
if (current_corner == nullptr) {
selection = 0;
}
}
corner_box_->setCurrentIndex(selection);
}
void TimingControlsDialog::setPinSelections()
{
from_->updatePins();
for (auto* row : thru_) {
row->updatePins();
}
to_->updatePins();
}
sta::Pin* TimingControlsDialog::convertTerm(Gui::odbTerm term) const
{
auto* network = sta_->getDbNetwork();
if (std::holds_alternative<odb::dbITerm*>(term)) {
return network->dbToSta(std::get<odb::dbITerm*>(term));
} else {
return network->dbToSta(std::get<odb::dbBTerm*>(term));
}
}
void TimingControlsDialog::setThruPin(const std::vector<std::set<sta::Pin*>>& pins)
{
for (size_t i = 0; i < thru_.size(); i++) {
layout_->removeRow(thru_start_row_);
}
thru_.clear();
adjustSize();
auto new_pins = pins;
if (pins.empty()) {
new_pins.push_back({}); // add one row
}
for (const auto& pin_set : new_pins) {
addThruRow(pin_set);
}
}
void TimingControlsDialog::addThruRow(const std::set<sta::Pin*>& pins)
{
auto* row = new PinSetWidget(true, this);
setupPinRow("Through:", row, thru_start_row_ + thru_.size());
row->setPins(pins);
connect(row,
SIGNAL(addRemoveTriggered(PinSetWidget*)),
this,
SLOT(addRemoveThru(PinSetWidget*)));
for (const auto& lower_row : thru_) {
lower_row->setRemoveMode();
}
thru_.push_back(row);
}
void TimingControlsDialog::addRemoveThru(PinSetWidget* row)
{
if (row->isAddMode()) {
addThruRow({});
} else {
auto find_row = std::find(thru_.begin(), thru_.end(), row);
const int row_index = std::distance(thru_.begin(), find_row);
layout_->removeRow(thru_start_row_ + row_index);
thru_.erase(thru_.begin() + row_index);
thru_.back()->setAddMode();
adjustSize();
}
}
const std::vector<std::set<sta::Pin*>> TimingControlsDialog::getThruPins() const
{
std::vector<std::set<sta::Pin*>> pins;
for (auto* row : thru_) {
pins.push_back(row->getPins());
}
return pins;
}
} // namespace gui
|
Map_3C906: dc.w word_3C7CE-Map_3C906
dc.w word_3C7D6-Map_3C906
dc.w word_3C916-Map_3C906
dc.w word_3C91E-Map_3C906
dc.w word_3C926-Map_3C906
dc.w word_3C92E-Map_3C906
dc.w word_3C936-Map_3C906
dc.w word_3C93E-Map_3C906
word_3C916: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F1
word_3C91E: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F2
word_3C926: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F3
word_3C92E: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F4
word_3C936: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F5
word_3C93E: dc.w 1
dc.b $FC, $C, 0, $22, $FF, $F6
|
; A038558: Smallest number with derivative n.
; Submitted by Stefano Spezia
; 0,2,4,5,8,9,11,10,16,17,19,18,23,22,20,21,32,33,35,34,39,38,36,37,47,46,44,45,40,41,43,42,64,65,67,66,71,70,68,69,79,78,76,77,72,73,75,74,95,94,92,93,88,89,91,90,80,81,83,82,87,86,84,85,128,129,131,130,135,134,132,133,143,142,140,141,136,137,139,138,159,158,156,157,152,153,155,154,144,145,147,146,151,150,148,149,191,190,188,189
mul $0,2
mov $1,2
mov $2,2
lpb $0
div $0,2
sub $2,$3
mul $2,2
add $3,$0
mod $3,2
mov $4,$2
add $2,$1
mul $3,$4
add $1,$3
lpe
mov $0,$2
div $0,4
|
/*
* This file is part of Nokia HEIF library
*
* Copyright (c) 2015-2018 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
*
* Contact: heif@nokia.com
*
* This software, including documentation, is protected by copyright controlled by Nokia Corporation and/ or its
* subsidiaries. All rights are reserved. Copying, including reproducing, storing, adapting or translating, any or all
* of this material requires the prior written consent of Nokia.
*
*
*/
#include <jni.h>
#include "Helpers.h"
#include "MimeItem.h"
#define CLASS_NAME MimeItem
extern "C"
{
JNI_METHOD(jobject, getItemDataNative)
{
NATIVE_SELF;
return env->NewDirectByteBuffer(const_cast<uint8_t*>(nativeSelf->getData()),
static_cast<jlong>(nativeSelf->getDataSize()));
}
JNI_METHOD_ARG(void, setItemDataNative, jbyteArray data)
{
NATIVE_SELF;
jbyte *nativeData = env->GetByteArrayElements(data, 0);
nativeSelf->setData((uint8_t *) nativeData, static_cast<uint64_t>(env->GetArrayLength(data)));
env->ReleaseByteArrayElements(data, nativeData, 0);
}
} |
; ===============================================================
; Apr 2014
; ===============================================================
;
; void in_wait_key(void)
;
; Busy wait until a key is pressed.
;
; ===============================================================
SECTION code_input
PUBLIC asm_in_wait_key
EXTERN asm_in_test_key
asm_in_wait_key:
; uses : af
call asm_in_test_key
jr z, asm_in_wait_key
ret
|
;
; Default format table for scanf family
MODULE __scanf_format_table
SECTION rodata_clib
PUBLIC __scanf_format_table
EXTERN __scanf_handle_d
EXTERN __scanf_handle_s
EXTERN __scanf_handle_c
EXTERN __scanf_handle_x
EXTERN __scanf_handle_o
EXTERN __scanf_handle_B
EXTERN __scanf_handle_i
__scanf_format_table:
defb 'd'
defw __scanf_handle_d
defb 's'
defw __scanf_handle_s
defb 'c'
defw __scanf_handle_c
defb 'u'
defw __scanf_handle_d
defb 'x'
defw __scanf_handle_x
defb 'o'
defw __scanf_handle_o
defb 'B'
defw __scanf_handle_B
defb 'i'
defw __scanf_handle_i
defb 0
|
; A090326: Number of rules of a context-free grammar in Chomsky normal form that generates all permutations of n symbols.
; 1,4,15,54,185,608,1939,6058,18669,57012,173063,523262,1577953,4750216,14283387,42915666,128878037,386896220,1161212911,3484687270,10456158921,31372671024,94126401635,282395982074,847221500605,2541731610628,7625329049559,22876255584078,68629303623089,205888984611032,617669101316683,1853011598917282,5559043386686373
mov $4,$0
lpb $0
sub $0,1
add $1,$5
mul $1,2
trn $1,4
add $1,2
mov $2,$5
sub $2,1
add $3,$2
trn $3,5
add $3,5
mov $5,$3
mul $3,2
lpe
add $1,10
lpb $4
add $1,1
sub $4,1
lpe
sub $1,9
|
.const_F DAT 0x1000
#include "asm_test_data_3.asm"
|
; ***************************************************************************************
; ***************************************************************************************
;
; Name : miscellany.asm
; Author : Paul Robson (paul@robsons.org.uk)
; Date : 31st October 2021
; Purpose : Miscellaneous words
;
; ***************************************************************************************
; ***************************************************************************************
;; [MACRO] ;
ret
;; [END]
; ***************************************************************************************
;; [CALL] string.inline
ex de,hl ; swap of DE & HL required by spec
pop hl ; start of string -> HL
push hl ; push start of string on stack.
_SILAdvance:
ld a,(hl) ; advance over string
inc hl
or a
jr nz,_SILAdvance
ex (sp),hl ; correct return address
ret
; [END]
; ***************************************************************************************
;; [CALL] copy
ld a,b ; exit if C = 0
or c
ret z
push bc ; BC count
push de ; DE target
push hl ; HL source
xor a ; Clear C
sbc hl,de ; check overlap ?
jr nc,__copy_gt_count ; if source after target
add hl,de ; undo subtract
add hl,bc ; add count to HL + DE
ex de,hl
add hl,bc
ex de,hl
dec de ; dec them, so now at the last byte to copy
dec hl
lddr ; do it backwards
jr __copy_exit
__copy_gt_count:
add hl,de ; undo subtract
ldir ; do the copy
__copy_exit:
pop hl ; restore registers
pop de
pop bc
ret
;; [END]
; ***************************************************************************************
;; [CALL] fill
ld a,b ; exit if C = 0
or c
ret z
push bc ; BC count
push de ; DE target, L byte
__fill_loop:
ld a,l ; copy a byte
ld (de),a
inc de ; bump pointer
dec bc ; dec counter and loop
ld a,b
or c
jr nz,__fill_loop
pop de ; restore
pop bc
ret
;; [END]
; ***************************************************************************************
;; [CALL] halt
__halt_loop:
halt
jr __halt_loop
;; [END]
; ***************************************************************************************
;; [MACRO] break
di
;; [END]
|
;
;
; ZX Maths Routines
;
; 9/12/02 - Stefano Bodrato
;
; $Id: floor.asm,v 1.5 2016-06-22 19:59:18 dom Exp $
;
;double floor(double)
;Number in FA..
IF FORts2068
INCLUDE "target/ts2068/def/ts2068fp.def"
ENDIF
IF FORzx
INCLUDE "target/zx/def/zxfp.def"
ENDIF
IF FORzx81
INCLUDE "target/zx81/def/81fp.def"
ENDIF
IF FORlambda
INCLUDE "target/lambda/def/lambdafp.def"
ENDIF
SECTION code_fp
PUBLIC floor
EXTERN fsetup1
EXTERN stkequ
.floor
call fsetup1
IF FORlambda
defb ZXFP_INT + 128
ELSE
defb ZXFP_INT
defb ZXFP_END_CALC
ENDIF
jp stkequ
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1beb3, %rcx
nop
inc %rsi
mov (%rcx), %rax
nop
nop
nop
nop
add $63057, %r14
lea addresses_UC_ht+0x1ae0b, %rdx
nop
sub $7817, %rsi
mov (%rdx), %r13
nop
nop
nop
nop
nop
add $33192, %rcx
lea addresses_A_ht+0x1ba93, %rsi
lea addresses_UC_ht+0xcbd3, %rdi
clflush (%rdi)
xor %r13, %r13
mov $127, %rcx
rep movsw
nop
xor $52627, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r14
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_WT+0x42f3, %rsi
lea addresses_A+0xca13, %rdi
clflush (%rdi)
nop
nop
nop
inc %rbx
mov $101, %rcx
rep movsq
sub %rbx, %rbx
// REPMOV
lea addresses_WC+0xd167, %rsi
mov $0x1db3c60000000473, %rdi
nop
nop
nop
nop
dec %r12
mov $97, %rcx
rep movsw
nop
nop
nop
nop
add $58291, %rsi
// Store
mov $0x55c8ca0000000c93, %rdi
nop
nop
nop
nop
nop
and $54604, %rcx
mov $0x5152535455565758, %r14
movq %r14, %xmm5
movups %xmm5, (%rdi)
sub %r12, %r12
// Faulty Load
lea addresses_normal+0x1c093, %rsi
nop
nop
nop
nop
nop
add $42145, %r11
movups (%rsi), %xmm7
vpextrq $0, %xmm7, %r12
lea oracles, %r11
and $0xff, %r12
shlq $12, %r12
mov (%r11,%r12,1), %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r14
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_NC', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'34': 62}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
// A BestCell keeps track only of the best path covering its span, in contrast
// to FullCell, which stores the best path covering the span with each start and
// end state.
#ifndef _PERMUTE_BEST_CELL_HH
#define _PERMUTE_BEST_CELL_HH
#include "Cell.hh"
namespace Permute {
class BestCell : public CellImpl {
public:
BestCell ();
virtual bool add (ConstPathRef);
};
}
#endif//_PERMUTE_BEST_CELL_HH
|
; double copysign(double x, double y)
SECTION code_fp_math48
PUBLIC am48_copysign
am48_copysign:
; Make sign of AC' the same as sign of AC
;
; enter : AC' = double x
; AC = double y
;
; exit : AC' = abs(x) * sgn(y)
;
; uses : af, b'
ld a,l
or a
jr z, zero ; sgn(0) is positive
ld a,b
and $80 ; a = sgn(y)
zero:
exx
res 7,b
or b
ld b,a
exx
ret
|
// Include before boost::log headers
#include "restc-cpp/restc-cpp.h"
#include "restc-cpp/logging.h"
#include "restc-cpp/RequestBuilder.h"
#include "restc-cpp/IteratorFromJsonSerializer.h"
#ifdef RESTC_CPP_LOG_WITH_BOOST_LOG
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#endif
#include "restc-cpp/test_helper.h"
#include "lest/lest.hpp"
using namespace std;
using namespace restc_cpp;
const string http_url = "http://localhost:3000/manyposts";
/* The goal is to test with 1000 connections.
* However, I am unable to get more than 500 working reliable (with 100
* connections increment) before I see connection errors. On OS X,
* I was unable to get more than 100 connections working reliable.
* (I have yet to figure out if the limitation is in the library
* or in the test setup / Docker container).
*
* I don't know at this time if it is caused by OS limits in the test
* application, Docker, the container with the mock server or the Linux
* machine itself.
*
* May be I have to write a simple HTTP Mock sever in C++ or use
* nginx-lua with some tweaking / load-balancing to get this test
* to work with the 1000 connection goal.
*
* There is also a problem where several tests hit's the test containers
* from Jenkins. So for now 100 connections must suffice.
*
* 100 connections is sufficient to prove that the client
* works as expected with many co-routines in parallel.
*/
#define CONNECTIONS 100
struct Post {
int id = 0;
string username;
string motto;
};
BOOST_FUSION_ADAPT_STRUCT(
Post,
(int, id)
(string, username)
(string, motto)
)
const lest::test specification[] = {
TEST(TestCRUD)
{
mutex mutex;
mutex.lock();
std::vector<std::future<int>> futures;
std::vector<std::promise<int>> promises;
futures.reserve(CONNECTIONS);
promises.reserve(CONNECTIONS);
Request::Properties properties;
properties.cacheMaxConnections = CONNECTIONS;
properties.cacheMaxConnectionsPerEndpoint = CONNECTIONS;
auto rest_client = RestClient::Create(properties);
for(int i = 0; i < CONNECTIONS; ++i) {
promises.emplace_back();
futures.push_back(promises.back().get_future());
rest_client->Process([i, &promises, &rest_client, &mutex](Context& ctx) {
auto reply = RequestBuilder(ctx)
.Get(GetDockerUrl(http_url))
.Execute();
// Use an iterator to make it simple to fetch some data and
// then wait on the mutex before we finish.
IteratorFromJsonSerializer<Post> results(*reply);
auto it = results.begin();
RESTC_CPP_LOG_DEBUG_("Iteration #" << i
<< " Read item # " << it->id);
promises[i].set_value(i);
// Wait for all connections to be ready
// We can't just wait on the lock since we are in a co-routine.
// So we use the async_wait() to poll in stead.
while(!mutex.try_lock()) {
boost::asio::deadline_timer timer(rest_client->GetIoService(),
boost::posix_time::milliseconds(1));
timer.async_wait(ctx.GetYield());
}
mutex.unlock();
// Fetch the rest
for(; it != results.end(); ++it)
;
});
}
int successful_connections = 0;
for(auto& future : futures) {
try {
auto i = future.get();
RESTC_CPP_LOG_DEBUG_("Iteration #" << i << " is done");
++successful_connections;
} catch (const std::exception& ex) {
RESTC_CPP_LOG_ERROR_("Future threw up: " << ex.what());
}
}
RESTC_CPP_LOG_INFO_("We had " << successful_connections
<< " successful connections.");
CHECK_EQUAL(CONNECTIONS, successful_connections);
mutex.unlock();
rest_client->CloseWhenReady();
}
}; //lest
int main( int argc, char * argv[] )
{
#ifdef RESTC_CPP_LOG_WITH_BOOST_LOG
namespace logging = boost::log;
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::debug
);
#endif
return lest::run( specification, argc, argv );
}
|
; A053835: Sum of digits of n written in base 15.
; 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,5,6,7,8,9,10,11,12,13
lpb $0
dif $0,15
sub $0,1
add $1,1
lpe
mov $0,$1
|
;
; The Multi8 can operate in multiple modes
;
; - Text/character based - 40x25, 80x25 there's attributes there as well
; - Full RGB - they actually end up being superimposed on each other (when in text mode)
;
;
; Text mode = two bytes get written 2k apart
;
; In code_driver so we are low down in memory and hopefully
; never paged out
SECTION code_driver
PUBLIC generic_console_cls
PUBLIC generic_console_printc
PUBLIC generic_console_scrollup
PUBLIC generic_console_set_ink
PUBLIC generic_console_set_paper
PUBLIC generic_console_set_attribute
EXTERN generic_console_xypos_graphics
PUBLIC generic_console_xypos
PUBLIC generic_console_scale
EXTERN printc_MODE2
EXTERN conio_map_colour
EXTERN generic_console_font32
EXTERN generic_console_udg32
EXTERN l_push_di
EXTERN l_pop_ei
EXTERN CRT_FONT
EXTERN CONSOLE_COLUMNS
EXTERN CONSOLE_ROWS
EXTERN __vram_in
EXTERN __vram_out
EXTERN __port29_copy
EXTERN __multi8_mode
EXTERN __multi8_ink
EXTERN __multi8_paper
defc DISPLAY = 0x8000
generic_console_set_ink:
call conio_map_colour
and 7
ld (__multi8_ink),a
ld b,a
ld a,(__multi8_attr)
and 248
or b
ld (__multi8_attr),a
ret
generic_console_set_paper:
call conio_map_colour
and 7
ld (__multi8_paper),a
ret
generic_console_set_attribute:
ld a,(__multi8_attr)
and 0xdf
bit 7,(hl)
jr z,store
or 0x20
store:
ld (__multi8_attr),a
ret
generic_console_cls:
call l_push_di
ld a,(__vram_in) ;Clear hires screens
and @11110000
or @00001000
out ($2a),a
ld hl,DISPLAY
ld de,DISPLAY + 1
ld bc, 16383
ld (hl),0
ldir
and @11110000 ;And clear text screen
or @00000111
out ($2a),a
ld hl, DISPLAY
ld de, DISPLAY +1
ld bc, 80 * 25 - 1
ld (hl),32
ldir
ld hl, DISPLAY + 0x800
ld de, DISPLAY + 0x800 + 1
ld bc, 80 * 25 - 1
ld a,(__multi8_attr)
ld (hl),a
ldir
ld a,(__vram_out)
out ($2a),a
call l_pop_ei
ret
generic_console_scale:
push af
ld a,(__multi8_mode)
cp 1
jr z,no_scale
sla c ;40 -> 80 column
no_scale:
pop af
ret
; c = x
; b = y
; a = d character to print
; e = raw
generic_console_printc:
ld a,(__multi8_mode)
cp 2
jp z, printc_MODE2
ld a,d
call generic_console_scale
call generic_console_xypos
ld e,a
call l_push_di
ld a,(__vram_in)
out ($2a),a
ld (hl),e
ld bc,0x800
add hl,bc
ld a,(__multi8_attr)
ld (hl),a
printc_exit:
ld a,(__vram_out)
out ($2a),a
call l_pop_ei
ret
generic_console_xypos:
ld hl, DISPLAY - 80
ld de,80
inc b
generic_console_printc_1:
add hl,de
djnz generic_console_printc_1
generic_console_printc_3:
add hl,bc ;hl now points to address in display
ret
generic_console_scrollup:
push de
push bc
call l_push_di
ld a,(__multi8_mode)
cp 2
ld a,(__vram_in)
jr z,scrollup_graphics
out ($2a),a
ld hl, DISPLAY + 80
ld de, DISPLAY
ld bc, 80 * 24
ldir
ex de,hl
ld b,80
generic_console_scrollup_3:
ld (hl),32
inc hl
djnz generic_console_scrollup_3
ld hl, DISPLAY + 0x800 + 80
ld de, DISPLAY + 0x800
ld bc,80 * 24
ldir
; blank out last row
ex de,hl
ld b,80
ld a,(__multi8_attr)
generic_console_scrollup_4:
ld (hl),a
inc hl
djnz generic_console_scrollup_4
scrollup_exit:
ld a,(__vram_out)
out ($2a),a
call l_pop_ei
pop bc
pop de
ret
scrollup_graphics:
or @00000110
call scroll_gfx
ld a,(__vram_in)
or @00000101
call scroll_gfx
ld a,(__vram_in)
or @00000011
call scroll_gfx
jr scrollup_exit
scroll_gfx:
out ($2a),a
ld hl, DISPLAY + 80 * 8
ld de, DISPLAY
ld bc, 80 * 192
ldir
ex de,hl
ld d,h
ld e,l
inc de
ld (hl),0
ld bc, 80 * 8
ldir
ret
SECTION data_clib
__multi8_attr:
defb 0x07 ;white ink
SECTION code_crt_init
; Enable colour text mode
ld a,(__port29_copy)
and 127
ld (__port29_copy),a
out ($29),a
; Make the display 25 lines in height
; Write 25 to register 6 of CTC
; Write 7 to register 9 of CTC to set font height
ld a,6
out ($1c),a
ld a,25
out ($1d),a
ld a,9
out ($1c),a
ld a,7
out ($1d),a
|
; ---------------------------------------------------------------------------
; Pallet pointers
; ---------------------------------------------------------------------------
dc.l Pal_SegaBG ; pallet address
dc.w $FB00 ; RAM address
dc.w $1F ; (pallet length / 2) - 1
dc.l Pal_Title
dc.w $FB00
dc.w $1F
dc.l Pal_LevelSel
dc.w $FB00
dc.w $1F
dc.l Pal_Sonic
dc.w $FB00
dc.w 7
dc.l Pal_GHZ
dc.w $FB20
dc.w $17
dc.l Pal_LZ
dc.w $FB20
dc.w $17
dc.l Pal_MZ
dc.w $FB20
dc.w $17
dc.l Pal_SLZ
dc.w $FB20
dc.w $17
dc.l Pal_SYZ
dc.w $FB20
dc.w $17
dc.l Pal_SBZ1
dc.w $FB20
dc.w $17
dc.l Pal_Special
dc.w $FB00
dc.w $1F
dc.l Pal_LZWater
dc.w $FB00
dc.w $1F
dc.l Pal_SBZ3
dc.w $FB20
dc.w $17
dc.l Pal_SBZ3Water
dc.w $FB00
dc.w $1F
dc.l Pal_SBZ2
dc.w $FB20
dc.w $17
dc.l Pal_LZSonWater
dc.w $FB00
dc.w 7
dc.l Pal_SBZ3SonWat
dc.w $FB00
dc.w 7
dc.l Pal_SpeResult
dc.w $FB00
dc.w $1F
dc.l Pal_SpeContinue
dc.w $FB00
dc.w $F
dc.l Pal_Ending
dc.w $FB00
dc.w $1F
dc.l Menu_Palette; pallet address
dc.w $FB00 ; RAM address
dc.w $1F ; (pallet length / 2) - 1 |
#include "Window.h"
#include <iostream>
#include <stdexcept>
static void APIENTRY glDebugOutput(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* message, const void* userParam)
{
// ignore non-significant error/warning codes
if (id == 131169 || id == 131185 || id == 131218 || id == 131204)
return;
std::cout << "---------------" << std::endl;
std::cout << "Debug message (" << id << "): " << message << std::endl;
switch (source)
{
case GL_DEBUG_SOURCE_API:
std::cout << "Source: API";
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
std::cout << "Source: Window System";
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER:
std::cout << "Source: Shader Compiler";
break;
case GL_DEBUG_SOURCE_THIRD_PARTY:
std::cout << "Source: Third Party";
break;
case GL_DEBUG_SOURCE_APPLICATION:
std::cout << "Source: Application";
break;
case GL_DEBUG_SOURCE_OTHER:
std::cout << "Source: Other";
break;
}
std::cout << std::endl;
switch (type)
{
case GL_DEBUG_TYPE_ERROR:
std::cout << "Type: Error";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
std::cout << "Type: Deprecated Behaviour";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
std::cout << "Type: Undefined Behaviour";
break;
case GL_DEBUG_TYPE_PORTABILITY:
std::cout << "Type: Portability";
break;
case GL_DEBUG_TYPE_PERFORMANCE:
std::cout << "Type: Performance";
break;
case GL_DEBUG_TYPE_MARKER:
std::cout << "Type: Marker";
break;
case GL_DEBUG_TYPE_PUSH_GROUP:
std::cout << "Type: Push Group";
break;
case GL_DEBUG_TYPE_POP_GROUP:
std::cout << "Type: Pop Group";
break;
case GL_DEBUG_TYPE_OTHER:
std::cout << "Type: Other";
break;
}
std::cout << std::endl;
switch (severity)
{
case GL_DEBUG_SEVERITY_HIGH:
std::cout << "Severity: high";
break;
case GL_DEBUG_SEVERITY_MEDIUM:
std::cout << "Severity: medium";
break;
case GL_DEBUG_SEVERITY_LOW:
std::cout << "Severity: low";
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
std::cout << "Severity: notification";
break;
}
std::cout << std::endl;
}
Window* Window::s_window = nullptr;
Window::Window(unsigned int width, unsigned int height, const char* title) : m_width(width), m_height(height)
{
if (s_window != nullptr)
{
throw std::runtime_error{"Only single window allowed"};
}
s_window = this;
// Init glfw
if (glfwInit() != GLFW_TRUE)
{
throw std::runtime_error{"Failed to init glfw"};
}
// Setup error callback
glfwSetErrorCallback([](int code, const char* error) { throw std::runtime_error{error}; });
// Setup for Opengl context
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
// Create window
m_window = glfwCreateWindow(width, height, title, nullptr, nullptr);
if (m_window == nullptr)
{
glfwTerminate();
throw std::runtime_error{"Failed to create window"};
}
// Key callback
glfwSetKeyCallback(m_window, [](GLFWwindow* w, int key, int code, int action, int mods) {
if (Window::s_window == nullptr)
return;
Window::s_window->m_keyCallback(*Window::s_window, key, code, action, mods);
});
// Mouse move callback
glfwSetCursorPosCallback(m_window, [](GLFWwindow* w, double x, double y) {
if (Window::s_window == nullptr)
return;
Window::s_window->onCursorMove(x, y);
});
// Scrolling callback
glfwSetScrollCallback(m_window, [](GLFWwindow* w, double xOffset, double yOffset) {
if (Window::s_window == nullptr)
return;
Window::s_window->onScroll(xOffset, yOffset);
});
// Set active context
glfwMakeContextCurrent(m_window);
glfwSetFramebufferSizeCallback(m_window, [](GLFWwindow* window, int width, int height) {
if (Window::s_window == nullptr)
return;
glViewport(0, 0, width, height);
Window::s_window->onResize(width, height);
});
// Load opengl functions
if (gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) == 0)
{
throw std::runtime_error{"Failed to init GL context"};
}
// Debug context
int flags;
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
{
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(glDebugOutput, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
}
// Initial viewport is the entire window
glViewport(0, 0, width, height);
}
Window::~Window()
{
if (m_window != nullptr)
{
glfwDestroyWindow(m_window);
}
glfwTerminate();
s_window = nullptr;
}
void Window::swapBuffers() { glfwSwapBuffers(m_window); }
void Window::setVSync(bool sync)
{
if (sync)
{
glfwSwapInterval(1);
}
else
{
glfwSwapInterval(0);
}
}
void Window::pollEvents()
{
// Reset offsets
m_cursorMovement = glm::vec2{0.f};
m_scrollOffset = glm::vec2{0.f};
// Poll for events, triggers callbacks
glfwPollEvents();
}
void Window::close() { glfwSetWindowShouldClose(m_window, GLFW_TRUE); }
void Window::setKeyCallback(const KeyCallback& callback) { m_keyCallback = callback; }
bool Window::isOpen() const { return glfwWindowShouldClose(m_window) == GLFW_FALSE; }
int Window::getKey(int code) const { return glfwGetKey(m_window, code); }
const glm::vec2& Window::getCursorMovement() const { return m_cursorMovement; }
const glm::vec2& Window::getScrollOffset() const { return m_scrollOffset; }
void Window::setCursorCapture(bool capture)
{
if (m_cursorCaptured == capture)
return;
m_cursorCaptured = capture;
if (capture)
{
glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
else
{
glfwSetInputMode(m_window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
}
bool Window::getCursorCapture() const { return m_cursorCaptured; }
GLFWwindow* Window::getGLFWWindow() const { return m_window; }
unsigned int Window::getWidth() const { return m_width; }
unsigned int Window::getHeight() const { return m_height; }
void Window::onResize(unsigned int width, unsigned int height)
{
m_width = width;
m_height = height;
}
void Window::onCursorMove(double x, double y)
{
auto position = glm::vec2{x, y};
// Prevent huge movement delta on initial call
if (m_firstCursorMove)
{
m_firstCursorMove = false;
}
else
{
m_cursorMovement = position - m_cursorPosition;
// Inverted due to different axis directions
m_cursorMovement.y = -m_cursorMovement.y;
}
m_cursorPosition = position;
}
void Window::onScroll(double xOffset, double yOffset) { m_scrollOffset = glm::vec2{xOffset, yOffset}; } |
; A142342: a(n) = 10*prime(n).
; 20,30,50,70,110,130,170,190,230,290,310,370,410,430,470,530,590,610,670,710,730,790,830,890,970,1010,1030,1070,1090,1130,1270,1310,1370,1390,1490,1510,1570,1630,1670,1730,1790,1810,1910,1930,1970,1990,2110,2230,2270
seq $0,6005 ; The odd prime numbers together with 1.
max $0,2
mul $0,10
|
_PokemonTower2Text_6062d::
text "<RIVAL>: Hey,"
line "<PLAYER>! What"
cont "brings you here?"
cont "Your #MON"
cont "don't look dead!"
para "I can at least"
line "make them faint!"
cont "Let's go, pal!"
done
_PokemonTower2Text_60632::
text "What?"
line "You stinker!"
para "I took it easy on"
line "you too!"
prompt
_PokemonTower2Text_60637::
text "<RIVAL>: Well,"
line "look at all your"
cont "wimpy #MON!"
para "Toughen them up a"
line "bit more!"
prompt
_PokemonTower2Text_6063c::
text "How's your #DEX"
line "coming, pal?"
cont "I just caught a"
cont "CUBONE!"
para "I can't find the"
line "grown-up MAROWAK"
cont "yet!"
para "I doubt there are"
line "any left! Well, I"
cont "better get going!"
cont "I've got a lot to"
cont "accomplish, pal!"
para "Smell ya later!"
done
_PokemonTower2Text2::
text "Even we could not"
line "identify the"
cont "wayward GHOSTs!"
para "A SILPH SCOPE"
line "might be able to"
cont "unmask them."
done
|
; A056119: a(n) = n*(n+13)/2.
; 0,7,15,24,34,45,57,70,84,99,115,132,150,169,189,210,232,255,279,304,330,357,385,414,444,475,507,540,574,609,645,682,720,759,799,840,882,925,969,1014,1060,1107,1155,1204,1254,1305,1357,1410,1464,1519,1575
add $0,7
bin $0,2
mov $1,$0
sub $1,21
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "Arithmetic32.inc"
#include "TestFixture.inc"
radix decimal
udata
global expectedRAA
global expectedRAB
global expectedRAC
global expectedRAD
global expectedCarry
global expectedZero
global carry
global zero
expectedRAA res 1
expectedRAB res 1
expectedRAC res 1
expectedRAD res 1
expectedCarry res 1
expectedZero res 1
capturedStatus res 1
carry res 1
zero res 1
NegateATest code
global testArrange
testArrange:
banksel carry
clrf carry
clrf zero
setCarryToOppositeOfExpected:
movlw 0xff
andwf expectedCarry, W
bcf STATUS, C
btfsc STATUS, Z
bsf STATUS, C
setZeroToOppositeOfExpected:
movlw 0xff
andwf expectedZero, W
testAct:
fcall negateA32
swapf STATUS, W
banksel capturedStatus
movwf capturedStatus
swapf capturedStatus
btfsc capturedStatus, C
bsf carry, 0
btfsc capturedStatus, Z
bsf zero, 0
testAssert:
.aliasForAssert RAA, _a
.aliasForAssert expectedRAA, _b
.assert "_a == _b, 'RAA expectation failure.'"
.aliasForAssert RAB, _a
.aliasForAssert expectedRAB, _b
.assert "_a == _b, 'RAB expectation failure.'"
.aliasForAssert RAC, _a
.aliasForAssert expectedRAC, _b
.assert "_a == _b, 'RAC expectation failure.'"
.aliasForAssert RAD, _a
.aliasForAssert expectedRAD, _b
.assert "_a == _b, 'RAD expectation failure.'"
banksel carry
.assert "carry == expectedCarry, 'Carry expectation failure.'"
.assert "zero == expectedZero, 'Zero expectation failure.'"
return
end
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "irc.h"
#include "db.h"
#include "net.h"
#include "init.h"
#include "addrman.h"
#include "ui_interface.h"
#include "miner.h"
#include "ntp.h"
#ifdef WIN32
#include <string.h>
#endif
using namespace std;
using namespace boost;
static const int MAX_OUTBOUND_CONNECTIONS = 9;
void ThreadMessageHandler2(void* parg);
void ThreadSocketHandler2(void* parg);
void ThreadOpenConnections2(void* parg);
void ThreadOpenAddedConnections2(void* parg);
void ThreadDNSAddressSeed2(void* parg);
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
#ifdef WIN32
#ifndef PROTECTION_LEVEL_UNRESTRICTED
#define PROTECTION_LEVEL_UNRESTRICTED 10
#endif
#ifndef IPV6_PROTECTION_LEVEL
#define IPV6_PROTECTION_LEVEL 23
#endif
#endif
struct LocalServiceInfo {
int nScore;
uint16_t nPort;
};
//
// Global state variables
//
bool fClient = false;
bool fDiscover = true;
uint64_t nLocalServices = (fClient ? 0 : NODE_NETWORK);
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
static CNode* pnodeSync = NULL;
CAddress addrSeenByPeer(CService("0.0.0.0", nPortZero), nLocalServices);
uint64_t nLocalHostNonce = 0;
boost::array<int, THREAD_MAX> vnThreadsRunning;
static std::vector<SOCKET> vhListenSocket;
CAddrMan addrman;
vector<CNode*> vNodes;
CCriticalSection cs_vNodes;
map<CInv, CDataStream> mapRelay;
deque<pair<int64_t, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
map<CInv, int64_t> mapAlreadyAskedFor;
static deque<string> vOneShots;
CCriticalSection cs_vOneShots;
set<CNetAddr> setservAddNodeAddresses;
CCriticalSection cs_setservAddNodeAddresses;
vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;
static CSemaphore *semOutbound = NULL;
void AddOneShot(string strDest)
{
LOCK(cs_vOneShots);
vOneShots.push_back(strDest);
}
unsigned short GetListenPort()
{
return (unsigned short)(GetArg("-port", GetDefaultPort()));
}
void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd)
{
// Filter out duplicate requests
if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd)
return;
pindexLastGetBlocksBegin = pindexBegin;
hashLastGetBlocksEnd = hashEnd;
PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd);
}
// find 'best' local address for a particular peer
bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
{
if (fNoListen)
return false;
int nBestScore = -1;
int nBestReachability = -1;
{
LOCK(cs_mapLocalHost);
for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++)
{
int nScore = (*it).second.nScore;
int nReachability = (*it).first.GetReachabilityFrom(paddrPeer);
if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
{
addr = CService((*it).first, (*it).second.nPort);
nBestReachability = nReachability;
nBestScore = nScore;
}
}
}
return nBestScore >= 0;
}
// get best local address for a particular peer as a CAddress
CAddress GetLocalAddress(const CNetAddr *paddrPeer)
{
CAddress ret(CService("0.0.0.0", nPortZero), 0);
CService addr;
if (GetLocal(addr, paddrPeer))
{
ret = CAddress(addr);
ret.nServices = nLocalServices;
ret.nTime = GetAdjustedTime();
}
return ret;
}
bool RecvLine(SOCKET hSocket, string& strLine)
{
strLine = "";
while (true)
{
char c;
int nBytes = recv(hSocket, &c, 1, 0);
if (nBytes > 0)
{
if (c == '\n')
continue;
if (c == '\r')
return true;
strLine += c;
if (strLine.size() >= 9000)
return true;
}
else if (nBytes <= 0)
{
if (fShutdown)
return false;
if (nBytes < 0)
{
int nErr = WSAGetLastError();
if (nErr == WSAEMSGSIZE)
continue;
if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS)
{
Sleep(10);
continue;
}
}
if (!strLine.empty())
return true;
if (nBytes == 0)
{
// socket closed
printf("socket closed\n");
return false;
}
else
{
// socket error
int nErr = WSAGetLastError();
printf("recv failed: %d\n", nErr);
return false;
}
}
}
}
// used when scores of local addresses may have changed
// pushes better local address to peers
void static AdvertizeLocal()
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (pnode->fSuccessfullyConnected)
{
CAddress addrLocal = GetLocalAddress(&pnode->addr);
if (addrLocal.IsRoutable() && (CService)addrLocal != (CService)pnode->addrLocal)
{
pnode->PushAddress(addrLocal);
pnode->addrLocal = addrLocal;
}
}
}
}
void SetReachable(enum Network net, bool fFlag)
{
LOCK(cs_mapLocalHost);
vfReachable[net] = fFlag;
if (net == NET_IPV6 && fFlag)
vfReachable[NET_IPV4] = true;
}
// learn a new local address
bool AddLocal(const CService& addr, int nScore)
{
if (!addr.IsRoutable())
return false;
if (!fDiscover && nScore < LOCAL_MANUAL)
return false;
if (IsLimited(addr))
return false;
printf("AddLocal(%s,%i)\n", addr.ToString().c_str(), nScore);
{
LOCK(cs_mapLocalHost);
bool fAlready = mapLocalHost.count(addr) > 0;
LocalServiceInfo &info = mapLocalHost[addr];
if (!fAlready || nScore >= info.nScore) {
info.nScore = nScore + (fAlready ? 1 : 0);
info.nPort = addr.GetPort();
}
SetReachable(addr.GetNetwork());
}
AdvertizeLocal();
return true;
}
bool AddLocal(const CNetAddr &addr, int nScore)
{
return AddLocal(CService(addr, GetListenPort()), nScore);
}
/** Make a particular network entirely off-limits (no automatic connects to it) */
void SetLimited(enum Network net, bool fLimited)
{
if (net == NET_UNROUTABLE)
return;
LOCK(cs_mapLocalHost);
vfLimited[net] = fLimited;
}
bool IsLimited(enum Network net)
{
LOCK(cs_mapLocalHost);
return vfLimited[net];
}
bool IsLimited(const CNetAddr &addr)
{
return IsLimited(addr.GetNetwork());
}
/** vote for a local address */
bool SeenLocal(const CService& addr)
{
{
LOCK(cs_mapLocalHost);
if (mapLocalHost.count(addr) == 0)
return false;
mapLocalHost[addr].nScore++;
}
AdvertizeLocal();
return true;
}
/** check whether a given address is potentially local */
bool IsLocal(const CService& addr)
{
LOCK(cs_mapLocalHost);
return mapLocalHost.count(addr) > 0;
}
/** check whether a given address is in a network we can probably connect to */
bool IsReachable(const CNetAddr& addr)
{
LOCK(cs_mapLocalHost);
enum Network net = addr.GetNetwork();
return vfReachable[net] && !vfLimited[net];
}
extern int GetExternalIPbySTUN(uint64_t rnd, struct sockaddr_in *mapped, const char **srv);
// We now get our external IP from the IRC server first and only use this as a backup
bool GetMyExternalIP(CNetAddr& ipRet)
{
struct sockaddr_in mapped;
uint64_t rnd = std::numeric_limits<uint64_t>::max();
const char *srv;
int rc = GetExternalIPbySTUN(rnd, &mapped, &srv);
if(rc >= 0) {
ipRet = CNetAddr(mapped.sin_addr);
printf("GetExternalIPbySTUN(%" PRIu64 ") returned %s in attempt %d; Server=%s\n", rnd, ipRet.ToStringIP().c_str(), rc, srv);
return true;
}
return false;
}
void ThreadGetMyExternalIP(void* parg)
{
// Make this thread recognisable as the external IP detection thread
RenameThread("XP-ext-ip");
CNetAddr addrLocalHost;
if (GetMyExternalIP(addrLocalHost))
{
printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str());
AddLocal(addrLocalHost, LOCAL_HTTP);
}
}
void AddressCurrentlyConnected(const CService& addr)
{
addrman.Connected(addr);
}
uint64_t CNode::nTotalBytesRecv = 0;
uint64_t CNode::nTotalBytesSent = 0;
CCriticalSection CNode::cs_totalBytesRecv;
CCriticalSection CNode::cs_totalBytesSent;
CNode* FindNode(const CNetAddr& ip)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if ((CNetAddr)pnode->addr == ip)
return (pnode);
return NULL;
}
CNode* FindNode(std::string addrName)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->addrName == addrName)
return (pnode);
return NULL;
}
CNode* FindNode(const CService& addr)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if ((CService)pnode->addr == addr)
return (pnode);
return NULL;
}
CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64_t nTimeout)
{
if (pszDest == NULL) {
if (IsLocal(addrConnect))
return NULL;
// Look for an existing connection
CNode* pnode = FindNode((CService)addrConnect);
if (pnode)
{
if (nTimeout != 0)
pnode->AddRef(nTimeout);
else
pnode->AddRef();
return pnode;
}
}
/// debug print
printf("trying connection %s lastseen=%.1fhrs\n",
pszDest ? pszDest : addrConnect.ToString().c_str(),
pszDest ? 0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0);
// Connect
SOCKET hSocket;
if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, GetDefaultPort()) : ConnectSocket(addrConnect, hSocket))
{
addrman.Attempt(addrConnect);
/// debug print
printf("connected %s\n", pszDest ? pszDest : addrConnect.ToString().c_str());
// Set to non-blocking
#ifdef WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
printf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %d\n", WSAGetLastError());
#else
if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
printf("ConnectSocket() : fcntl non-blocking setting failed, error %d\n", errno);
#endif
// Add node
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false);
if (nTimeout != 0)
pnode->AddRef(nTimeout);
else
pnode->AddRef();
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
pnode->nTimeConnected = GetTime();
return pnode;
}
else
{
return NULL;
}
}
void CNode::CloseSocketDisconnect()
{
fDisconnect = true;
if (hSocket != INVALID_SOCKET)
{
printf("disconnecting node %s\n", addrName.c_str());
closesocket(hSocket);
hSocket = INVALID_SOCKET;
vRecv.clear();
}
// in case this fails, we'll empty the recv buffer when the CNode is deleted
TRY_LOCK(cs_vRecv, lockRecv);
if (lockRecv)
vRecv.clear();
// if this was the sync node, we'll need a new one
if (this == pnodeSync)
pnodeSync = NULL;
}
void CNode::Cleanup()
{
}
void CNode::PushVersion()
{
int64_t nTime = GetAdjustedTime();
CAddress addrYou, addrMe;
bool fHidden = false;
if (addr.IsTor()) {
if (mapArgs.count("-torname")) {
// Our hidden service address
CService addrTorName(mapArgs["-torname"], GetListenPort());
if (addrTorName.IsValid()) {
addrYou = addr;
addrMe = CAddress(addrTorName);
fHidden = true;
}
}
}
if (!fHidden) {
addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0", nPortZero)));
addrMe = GetLocalAddress(&addr);
}
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
printf("send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), addrYou.ToString().c_str(), addr.ToString().c_str());
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight);
}
std::map<CNetAddr, int64_t> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
{
setBanned.clear();
}
bool CNode::IsBanned(CNetAddr ip)
{
bool fResult = false;
{
LOCK(cs_setBanned);
std::map<CNetAddr, int64_t>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
int64_t t = (*i).second;
if (GetTime() < t)
fResult = true;
}
}
return fResult;
}
bool CNode::Misbehaving(int howmuch)
{
if (addr.IsLocal())
{
printf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch);
return false;
}
nMisbehavior += howmuch;
if (nMisbehavior >= GetArgInt("-banscore", 100))
{
int64_t banTime = GetTime()+GetArg("-bantime", nOneDay); // Default 24-hour ban
printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
{
LOCK(cs_setBanned);
if (setBanned[addr] < banTime)
setBanned[addr] = banTime;
}
CloseSocketDisconnect();
return true;
} else
printf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
return false;
}
#undef X
#define X(name) stats.name = name
void CNode::copyStats(CNodeStats &stats)
{
X(nServices);
X(nLastSend);
X(nLastRecv);
X(nTimeConnected);
X(addrName);
X(nVersion);
X(strSubVer);
X(fInbound);
X(nReleaseTime);
X(nStartingHeight);
X(nMisbehavior);
X(nSendBytes);
X(nRecvBytes);
stats.fSyncNode = (this == pnodeSync);
}
#undef X
void ThreadSocketHandler(void* parg)
{
// Make this thread recognisable as the networking thread
RenameThread("XP-net");
try
{
vnThreadsRunning[THREAD_SOCKETHANDLER]++;
ThreadSocketHandler2(parg);
vnThreadsRunning[THREAD_SOCKETHANDLER]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_SOCKETHANDLER]--;
PrintException(&e, "ThreadSocketHandler()");
} catch (...) {
vnThreadsRunning[THREAD_SOCKETHANDLER]--;
throw; // support pthread_cancel()
}
printf("ThreadSocketHandler exited\n");
}
static list<CNode*> vNodesDisconnected;
void ThreadSocketHandler2(void* parg)
{
printf("ThreadSocketHandler started\n");
size_t nPrevNodeCount = 0;
while (true)
{
//
// Disconnect nodes
//
{
LOCK(cs_vNodes);
// Disconnect unused nodes
vector<CNode*> vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
if (pnode->fDisconnect ||
(pnode->GetRefCount() <= 0 && pnode->vRecv.empty() && pnode->vSend.empty()))
{
// remove from vNodes
vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
// release outbound grant (if any)
pnode->grantOutbound.Release();
// close socket and cleanup
pnode->CloseSocketDisconnect();
pnode->Cleanup();
// hold in disconnected pool until all refs are released
pnode->nReleaseTime = max(pnode->nReleaseTime, GetTime() + 15 * 60);
if (pnode->fNetworkNode || pnode->fInbound)
pnode->Release();
vNodesDisconnected.push_back(pnode);
}
}
// Delete disconnected nodes
list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
{
// wait until threads are done using it
if (pnode->GetRefCount() <= 0)
{
bool fDelete = false;
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
{
TRY_LOCK(pnode->cs_vRecv, lockRecv);
if (lockRecv)
{
TRY_LOCK(pnode->cs_mapRequests, lockReq);
if (lockReq)
{
TRY_LOCK(pnode->cs_inventory, lockInv);
if (lockInv)
fDelete = true;
}
}
}
}
if (fDelete)
{
vNodesDisconnected.remove(pnode);
delete pnode;
}
}
}
}
if (vNodes.size() != nPrevNodeCount)
{
nPrevNodeCount = vNodes.size();
uiInterface.NotifyNumConnectionsChanged(vNodes.size());
}
//
// Find which sockets have data to receive
//
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 50000; // frequency to poll pnode->vSend
fd_set fdsetRecv;
fd_set fdsetSend;
fd_set fdsetError;
FD_ZERO(&fdsetRecv);
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
SOCKET hSocketMax = 0;
bool have_fds = false;
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) {
FD_SET(hListenSocket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket);
have_fds = true;
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
{
if (pnode->hSocket == INVALID_SOCKET)
continue;
FD_SET(pnode->hSocket, &fdsetRecv);
FD_SET(pnode->hSocket, &fdsetError);
hSocketMax = max(hSocketMax, pnode->hSocket);
have_fds = true;
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend && !pnode->vSend.empty())
FD_SET(pnode->hSocket, &fdsetSend);
}
}
}
vnThreadsRunning[THREAD_SOCKETHANDLER]--;
int nSelect = select(have_fds ? hSocketMax + 1 : 0,
&fdsetRecv, &fdsetSend, &fdsetError, &timeout);
vnThreadsRunning[THREAD_SOCKETHANDLER]++;
if (fShutdown)
return;
if (nSelect == SOCKET_ERROR)
{
if (have_fds)
{
int nErr = WSAGetLastError();
printf("socket select error %d\n", nErr);
for (unsigned int i = 0; i <= hSocketMax; i++)
FD_SET(i, &fdsetRecv);
}
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
Sleep(timeout.tv_usec/1000);
}
//
// Accept new connections
//
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
{
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t len = sizeof(sockaddr);
SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);
CAddress addr;
int nInbound = 0;
if (hSocket != INVALID_SOCKET)
if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr))
printf("Warning: Unknown socket family\n");
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->fInbound)
nInbound++;
}
if (hSocket == INVALID_SOCKET)
{
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK)
printf("socket error accept failed: %d\n", nErr);
}
else if (nInbound >= GetArgInt("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
{
{
LOCK(cs_setservAddNodeAddresses);
if (!setservAddNodeAddresses.count(addr))
closesocket(hSocket);
}
}
else if (CNode::IsBanned(addr))
{
printf("connection from %s dropped (banned)\n", addr.ToString().c_str());
closesocket(hSocket);
}
else
{
printf("accepted connection %s\n", addr.ToString().c_str());
CNode* pnode = new CNode(hSocket, addr, "", true);
pnode->AddRef();
{
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
}
}
//
// Service each socket
//
vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->AddRef();
}
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
if (fShutdown)
return;
//
// Receive
//
if (pnode->hSocket == INVALID_SOCKET)
continue;
if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError))
{
TRY_LOCK(pnode->cs_vRecv, lockRecv);
if (lockRecv)
{
CDataStream& vRecv = pnode->vRecv;
uint64_t nPos = vRecv.size();
if (nPos > ReceiveBufferSize()) {
if (!pnode->fDisconnect)
printf("socket recv flood control disconnect (%" PRIszu " bytes)\n", vRecv.size());
pnode->CloseSocketDisconnect();
}
else {
// typical socket buffer is 8K-64K
char pchBuf[0x10000];
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
if (nBytes > 0)
{
vRecv.resize(nPos + nBytes);
memcpy(&vRecv[nPos], pchBuf, nBytes);
pnode->nLastRecv = GetTime();
pnode->nRecvBytes += nBytes;
pnode->RecordBytesRecv(nBytes);
}
else if (nBytes == 0)
{
// socket closed gracefully
if (!pnode->fDisconnect)
printf("socket closed\n");
pnode->CloseSocketDisconnect();
}
else if (nBytes < 0)
{
// error
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
if (!pnode->fDisconnect)
printf("socket recv error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
}
}
}
//
// Send
//
if (pnode->hSocket == INVALID_SOCKET)
continue;
if (FD_ISSET(pnode->hSocket, &fdsetSend))
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
{
CDataStream& vSend = pnode->vSend;
if (!vSend.empty())
{
int nBytes = send(pnode->hSocket, &vSend[0], vSend.size(), MSG_NOSIGNAL | MSG_DONTWAIT);
if (nBytes > 0)
{
vSend.erase(vSend.begin(), vSend.begin() + nBytes);
pnode->nLastSend = GetTime();
pnode->nSendBytes += nBytes;
pnode->RecordBytesSent(nBytes);
}
else if (nBytes < 0)
{
// error
int nErr = WSAGetLastError();
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
{
printf("socket send error %d\n", nErr);
pnode->CloseSocketDisconnect();
}
}
}
}
}
//
// Inactivity checking
//
if (pnode->vSend.empty())
pnode->nLastSendEmpty = GetTime();
if (GetTime() - pnode->nTimeConnected > 60)
{
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
{
printf("socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastSend > 90*60 && GetTime() - pnode->nLastSendEmpty > 90*60)
{
printf("socket not sending\n");
pnode->fDisconnect = true;
}
else if (GetTime() - pnode->nLastRecv > 90*60)
{
printf("socket inactivity timeout\n");
pnode->fDisconnect = true;
}
}
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
Sleep(10);
}
}
// DNS seeds
// Each pair gives a source name and a seed name.
// The first name is used as information source for addrman.
// The second name should resolve to a list of seed addresses.
static const char *strDNSSeed[][2] = {
{"seed1.xpcoin.io", "seed1.xpcoin.io"},
{"seed2.xpcoin.io", "seed2.xpcoin.io"},
{"seed3.xpcoin.io", "seed3.xpcoin.io"},
{"seed4.xpcoin.io", "seed4.xpcoin.io"}
};
void ThreadDNSAddressSeed(void* parg)
{
// Make this thread recognisable as the DNS seeding thread
RenameThread("XP-dnsseed");
try
{
vnThreadsRunning[THREAD_DNSSEED]++;
ThreadDNSAddressSeed2(parg);
vnThreadsRunning[THREAD_DNSSEED]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_DNSSEED]--;
PrintException(&e, "ThreadDNSAddressSeed()");
} catch (...) {
vnThreadsRunning[THREAD_DNSSEED]--;
throw; // support pthread_cancel()
}
printf("ThreadDNSAddressSeed exited\n");
}
void ThreadDNSAddressSeed2(void* parg)
{
printf("ThreadDNSAddressSeed started\n");
int found = 0;
if (!fTestNet)
{
printf("Loading addresses from DNS seeds (could take a while)\n");
for (unsigned int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) {
if (HaveNameProxy()) {
AddOneShot(strDNSSeed[seed_idx][1]);
} else {
vector<CNetAddr> vaddr;
vector<CAddress> vAdd;
if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
{
BOOST_FOREACH(CNetAddr& ip, vaddr)
{
CAddress addr = CAddress(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
vAdd.push_back(addr);
found++;
}
}
addrman.Add(vAdd, CNetAddr(strDNSSeed[seed_idx][0], true));
}
}
}
printf("%d addresses found from DNS seeds\n", found);
}
uint32_t pnSeed[] =
{
0xa52bf0da, 0x30aa43d8, 0x614488d5, 0x517b6fd5, 0xd4bf62d4, 0xb7d638d4, 0xbc12bcd1, 0xa2501bc6,
0xfde617c6, 0x3337b1c6, 0x1dcd71c3, 0x2c1544c1, 0xe05f6ac1, 0x852f63c0, 0x3e2363c0, 0x15f563c0,
0x430d63c0, 0x50d6a9c0, 0xf0a679c0, 0xefdeedbf, 0x7aaee8bc, 0x3a3dbbbc, 0xef218abc, 0x0bef78bc,
0x8baa3eb2, 0x2bf913b2, 0x24ed9fb2, 0xb42289b2, 0x718a09b0, 0xe9433eb0, 0x559425b0, 0xc97e1fb0,
0x18e1d4b0, 0x8f6cc1b0, 0xac3838ae, 0x86c0ffad, 0x6b0272a7, 0xa463f8a2, 0x6f17f3a2, 0xb3d6f3a2,
0x9cd8f997, 0xd513fb94, 0x39e64880, 0x3859dd6f, 0x0b08fe6d, 0xe601fe6d, 0xeb44a26d, 0xfe53186c,
0x203c2e68, 0x1c542868, 0x0caa8368, 0xb8748368, 0xccca4762, 0xc637555f, 0x638a545f, 0x59b2205f,
0x52568c5f, 0xba568c5f, 0x8a568c5f, 0x31b0f45e, 0x54a0f45e, 0x37d6f15e, 0xc520175e, 0x7620175e,
0xc310175e, 0x8e33b45e, 0x7abb5f5d, 0xd3014c5d, 0xa1e1485d, 0x9947645d, 0xfab8ff5c, 0xa979e65b,
0xa879e65b, 0x9f79e65b, 0x9fa3d25b, 0x112a925b, 0x7b92905b, 0x60647a5b, 0x1e389d5a, 0x851afa59,
0x0185ef59, 0x26549b59, 0x1c9efe57, 0xc54c1256, 0x1ad51955, 0x19d21955, 0x73c41955, 0x3f74ee55,
0x633eea55, 0x6883d655, 0xfb72c655, 0x5360a653, 0x17c1ea52, 0xc661c852, 0x1ecdc852, 0x006a9752,
0xf72d9252, 0x82650551, 0x36f1c851, 0x33f1c851, 0xd5c1864f, 0xb6bf1b4e, 0x96da184e, 0x40d0234d,
0x9a96ab4c, 0x8fc2a84c, 0xb5dbd048, 0xf4644447, 0x2d51af47, 0xa9625445, 0x83f05243, 0x89672941,
0x3a8bad3e, 0xf0a05436, 0x6ab7c936, 0x49971d32, 0xadd4482e, 0xcffd212e, 0x6730bc2e, 0x839aa12e,
0x68d9692e, 0xc7183b25, 0x6c47bb25, 0x2490bb25, 0xad651c1f, 0x048a861f, 0x6937811f, 0x064b2d05,
0x4d226805,
};
const char* pchTorSeed[] =
{
"wgehbgohin7yzmir.onion",
"onhgygezjmjtxhgy.onion"
};
void DumpAddresses()
{
int64_t nStart = GetTimeMillis();
CAddrDB adb;
adb.Write(addrman);
printf("Flushed %d addresses to peers.dat %" PRId64 "ms\n",
addrman.size(), GetTimeMillis() - nStart);
}
void ThreadDumpAddress2(void* parg)
{
printf("ThreadDumpAddress started\n");
vnThreadsRunning[THREAD_DUMPADDRESS]++;
while (!fShutdown)
{
DumpAddresses();
vnThreadsRunning[THREAD_DUMPADDRESS]--;
Sleep(600000);
vnThreadsRunning[THREAD_DUMPADDRESS]++;
}
vnThreadsRunning[THREAD_DUMPADDRESS]--;
}
void ThreadDumpAddress(void* parg)
{
// Make this thread recognisable as the address dumping thread
RenameThread("XP-adrdump");
try
{
ThreadDumpAddress2(parg);
}
catch (std::exception& e) {
PrintException(&e, "ThreadDumpAddress()");
}
printf("ThreadDumpAddress exited\n");
}
void ThreadOpenConnections(void* parg)
{
// Make this thread recognisable as the connection opening thread
RenameThread("XP-opencon");
try
{
vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
ThreadOpenConnections2(parg);
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
PrintException(&e, "ThreadOpenConnections()");
} catch (...) {
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
PrintException(NULL, "ThreadOpenConnections()");
}
printf("ThreadOpenConnections exited\n");
}
void static ProcessOneShot()
{
string strDest;
{
LOCK(cs_vOneShots);
if (vOneShots.empty())
return;
strDest = vOneShots.front();
vOneShots.pop_front();
}
CAddress addr;
CSemaphoreGrant grant(*semOutbound, true);
if (grant) {
if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true))
AddOneShot(strDest);
}
}
void ThreadOpenConnections2(void* parg)
{
printf("ThreadOpenConnections started\n");
// Connect to specific addresses
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0)
{
for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
{
CAddress addr;
OpenNetworkConnection(addr, NULL, strAddr.c_str());
for (int i = 0; i < 10 && i < nLoop; i++)
{
Sleep(500);
if (fShutdown)
return;
}
}
Sleep(500);
}
}
// Initiate network connections
int64_t nStart = GetTime();
while (true)
{
ProcessOneShot();
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
Sleep(500);
vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
if (fShutdown)
return;
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
CSemaphoreGrant grant(*semOutbound);
vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
if (fShutdown)
return;
// Add seed nodes if IRC isn't working
if (!IsLimited(NET_IPV4) && addrman.size()==0 && (GetTime() - nStart > 60) && !fTestNet)
{
std::vector<CAddress> vAdd;
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time' of between one and two
// weeks ago.
const int64_t nOneWeek = 7*24*60*60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
vAdd.push_back(addr);
}
addrman.Add(vAdd, CNetAddr("127.0.0.1"));
}
// Add Tor nodes if we have connection with onion router
if (mapArgs.count("-tor"))
{
std::vector<CAddress> vAdd;
for (unsigned int i = 0; i < ARRAYLEN(pchTorSeed); i++)
{
const int64_t nOneWeek = 7*24*60*60;
CAddress addr(CService(pchTorSeed[i], GetDefaultPort()));
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
vAdd.push_back(addr);
}
addrman.Add(vAdd, CNetAddr("dummyaddress.onion"));
}
//
// Choose an address to connect to based on most recently seen
//
CAddress addrConnect;
// Only connect out to one peer per network group (/16 for IPv4).
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
int nOutbound = 0;
set<vector<unsigned char> > setConnected;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes) {
if (!pnode->fInbound) {
setConnected.insert(pnode->addr.GetGroup());
nOutbound++;
}
}
}
int64_t nANow = GetAdjustedTime();
int nTries = 0;
while (true)
{
// use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections)
CAddress addr = addrman.Select(10 + min(nOutbound,8)*10);
// if we selected an invalid address, restart
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
break;
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
// already-connected network ranges, ...) before trying new addrman addresses.
nTries++;
if (nTries > 100)
break;
if (IsLimited(addr))
continue;
// only consider very recently tried nodes after 30 failed attempts
if (nANow - addr.nLastTry < 600 && nTries < 30)
continue;
// do not allow non-default ports, unless after 50 invalid addresses selected already
if (addr.GetPort() != GetDefaultPort() && nTries < 50)
continue;
addrConnect = addr;
break;
}
if (addrConnect.IsValid())
OpenNetworkConnection(addrConnect, &grant);
}
}
void ThreadOpenAddedConnections(void* parg)
{
// Make this thread recognisable as the connection opening thread
RenameThread("XP-opencon");
try
{
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++;
ThreadOpenAddedConnections2(parg);
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--;
PrintException(&e, "ThreadOpenAddedConnections()");
} catch (...) {
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--;
PrintException(NULL, "ThreadOpenAddedConnections()");
}
printf("ThreadOpenAddedConnections exited\n");
}
void ThreadOpenAddedConnections2(void* parg)
{
printf("ThreadOpenAddedConnections started\n");
{
LOCK(cs_vAddedNodes);
vAddedNodes = mapMultiArgs["-addnode"];
}
if (HaveNameProxy()) {
while(!fShutdown) {
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(string& strAddNode, vAddedNodes)
lAddresses.push_back(strAddNode);
}
BOOST_FOREACH(string& strAddNode, lAddresses) {
CAddress addr;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(addr, &grant, strAddNode.c_str());
Sleep(500);
}
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--;
Sleep(120000); // Retry every 2 minutes
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++;
}
return;
}
for (uint32_t i = 0; true; i++)
{
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(string& strAddNode, vAddedNodes)
lAddresses.push_back(strAddNode);
}
list<vector<CService> > lservAddressesToAdd(0);
BOOST_FOREACH(string& strAddNode, lAddresses)
{
vector<CService> vservNode(0);
if (Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0))
{
lservAddressesToAdd.push_back(vservNode);
{
LOCK(cs_setservAddNodeAddresses);
BOOST_FOREACH(CService& serv, vservNode)
setservAddNodeAddresses.insert(serv);
}
}
}
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
{
BOOST_FOREACH(CService& addrNode, *(it))
if (pnode->addr == addrNode)
{
it = lservAddressesToAdd.erase(it);
if(it != lservAddressesToAdd.begin())
it--;
break;
}
if (it == lservAddressesToAdd.end())
break;
}
}
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
{
if (vserv.size() == 0)
continue;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
Sleep(500);
if (fShutdown)
return;
}
if (fShutdown)
return;
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]--;
Sleep(120000); // Retry every 2 minutes
vnThreadsRunning[THREAD_ADDEDCONNECTIONS]++;
if (fShutdown)
return;
}
}
// if successful, this moves the passed grant to the constructed node
bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound, const char *strDest, bool fOneShot)
{
//
// Initiate outbound network connection
//
if (fShutdown)
return false;
if (!strDest)
if (IsLocal(addrConnect) ||
FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort().c_str()))
return false;
if (strDest && FindNode(strDest))
return false;
vnThreadsRunning[THREAD_OPENCONNECTIONS]--;
CNode* pnode = ConnectNode(addrConnect, strDest);
vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
if (fShutdown)
return false;
if (!pnode)
return false;
if (grantOutbound)
grantOutbound->MoveTo(pnode->grantOutbound);
pnode->fNetworkNode = true;
if (fOneShot)
pnode->fOneShot = true;
return true;
}
// for now, use a very simple selection metric: the node from which we received
// most recently
static int64_t NodeSyncScore(const CNode *pnode) {
return pnode->nLastRecv;
}
void static StartSync(const vector<CNode*> &vNodes) {
CNode *pnodeNewSync = NULL;
int64_t nBestScore = 0;
// Iterate over all nodes
BOOST_FOREACH(CNode* pnode, vNodes) {
// check preconditions for allowing a sync
if (!pnode->fClient && !pnode->fOneShot &&
!pnode->fDisconnect && pnode->fSuccessfullyConnected &&
(pnode->nStartingHeight > (nBestHeight - 144)) &&
(pnode->nVersion < NOBLKS_VERSION_START || pnode->nVersion >= NOBLKS_VERSION_END)) {
// if ok, compare node's score with the best so far
int64_t nScore = NodeSyncScore(pnode);
if (pnodeNewSync == NULL || nScore > nBestScore) {
pnodeNewSync = pnode;
nBestScore = nScore;
}
}
}
// if a new sync candidate was found, start sync!
if (pnodeNewSync) {
pnodeNewSync->fStartSync = true;
pnodeSync = pnodeNewSync;
}
}
void ThreadMessageHandler(void* parg)
{
// Make this thread recognisable as the message handling thread
RenameThread("XP-msghand");
try
{
vnThreadsRunning[THREAD_MESSAGEHANDLER]++;
ThreadMessageHandler2(parg);
vnThreadsRunning[THREAD_MESSAGEHANDLER]--;
}
catch (std::exception& e) {
vnThreadsRunning[THREAD_MESSAGEHANDLER]--;
PrintException(&e, "ThreadMessageHandler()");
} catch (...) {
vnThreadsRunning[THREAD_MESSAGEHANDLER]--;
PrintException(NULL, "ThreadMessageHandler()");
}
printf("ThreadMessageHandler exited\n");
}
void ThreadMessageHandler2(void* parg)
{
printf("ThreadMessageHandler started\n");
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
while (!fShutdown)
{
bool fHaveSyncNode = false;
vector<CNode*> vNodesCopy;
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy) {
pnode->AddRef();
if (pnode == pnodeSync)
fHaveSyncNode = true;
}
}
if (!fHaveSyncNode)
StartSync(vNodesCopy);
// Poll the connected nodes for messages
CNode* pnodeTrickle = NULL;
if (!vNodesCopy.empty())
pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
// Receive messages
{
TRY_LOCK(pnode->cs_vRecv, lockRecv);
if (lockRecv)
ProcessMessages(pnode);
}
if (fShutdown)
return;
// Send messages
{
TRY_LOCK(pnode->cs_vSend, lockSend);
if (lockSend)
SendMessages(pnode, pnode == pnodeTrickle);
}
if (fShutdown)
return;
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
// Wait and allow messages to bunch up.
// Reduce vnThreadsRunning so StopNode has permission to exit while
// we're sleeping, but we must always check fShutdown after doing this.
vnThreadsRunning[THREAD_MESSAGEHANDLER]--;
Sleep(100);
if (fRequestShutdown)
StartShutdown();
vnThreadsRunning[THREAD_MESSAGEHANDLER]++;
if (fShutdown)
return;
}
}
bool BindListenPort(const CService &addrBind, string& strError)
{
strError = "";
int nOne = 1;
// Create socket for listening for incoming connections
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
#else
struct sockaddr sockaddr;
#endif
socklen_t len = sizeof(sockaddr);
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
{
strError = strprintf("Error: bind address family for %s not supported", addrBind.ToString().c_str());
printf("%s\n", strError.c_str());
return false;
}
SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP);
if (hListenSocket == INVALID_SOCKET)
{
strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
return false;
}
#ifndef WIN32
#ifdef SO_NOSIGPIPE
// Different way of disabling SIGPIPE on BSD
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
#endif
// Allow binding if the port is still in TIME_WAIT state after
// the program was closed and restarted. Not an issue on windows!
setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
#endif
#ifdef WIN32
// Set to non-blocking, incoming connections will also inherit this
if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)
#else
if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
#endif
{
strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
return false;
}
#ifdef USE_IPV6
// some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
// and enable it by default or not. Try to enable it, if possible.
if (addrBind.IsIPv6()) {
#ifdef IPV6_V6ONLY
#ifdef WIN32
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif
#endif
#ifdef WIN32
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int));
#endif
}
#endif
if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR)
{
int nErr = WSAGetLastError();
if (nErr == WSAEADDRINUSE)
strError = strprintf(_("Unable to bind to %s on this computer. XP is probably already running."), addrBind.ToString().c_str());
else
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr));
printf("%s\n", strError.c_str());
closesocket(hListenSocket);
return false;
}
printf("Bound to %s\n", addrBind.ToString().c_str());
// Listen for incoming connections
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
{
strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError());
printf("%s\n", strError.c_str());
closesocket(hListenSocket);
return false;
}
vhListenSocket.push_back(hListenSocket);
if (addrBind.IsRoutable() && fDiscover)
AddLocal(addrBind, LOCAL_BIND);
return true;
}
void static Discover()
{
if (!fDiscover)
return;
#ifdef WIN32
// Get local host IP
char pszHostName[1000] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
{
vector<CNetAddr> vaddr;
if (LookupHost(pszHostName, vaddr))
{
BOOST_FOREACH (const CNetAddr &addr, vaddr)
{
AddLocal(addr, LOCAL_IF);
}
}
}
#else
// Get local host ip
struct ifaddrs* myaddrs;
if (getifaddrs(&myaddrs) == 0)
{
for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL) continue;
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
if (strcmp(ifa->ifa_name, "lo") == 0) continue;
if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
if (ifa->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
CNetAddr addr(s4->sin_addr);
if (AddLocal(addr, LOCAL_IF))
printf("IPv4 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
}
#ifdef USE_IPV6
else if (ifa->ifa_addr->sa_family == AF_INET6)
{
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
CNetAddr addr(s6->sin6_addr);
if (AddLocal(addr, LOCAL_IF))
printf("IPv6 %s: %s\n", ifa->ifa_name, addr.ToString().c_str());
}
#endif
}
freeifaddrs(myaddrs);
}
#endif
// Don't use external IPv4 discovery, when -onlynet="IPv6"
if (!IsLimited(NET_IPV4))
NewThread(ThreadGetMyExternalIP, NULL);
}
void StartNode(void* parg)
{
// Make this thread recognisable as the startup thread
RenameThread("XP-start");
if (semOutbound == NULL) {
// initialize semaphore
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, GetArgInt("-maxconnections", 125));
semOutbound = new CSemaphore(nMaxOutbound);
}
if (pnodeLocalHost == NULL)
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", nPortZero), nLocalServices));
Discover();
//
// Start threads
//
if (!GetBoolArg("-dnsseed", true))
printf("DNS seeding disabled\n");
else
if (!NewThread(ThreadDNSAddressSeed, NULL))
printf("Error: NewThread(ThreadDNSAddressSeed) failed\n");
// Get addresses from IRC and advertise ours
if (!GetBoolArg("-irc", true))
printf("IRC seeding disabled\n");
else
if (!NewThread(ThreadIRCSeed, NULL))
printf("Error: NewThread(ThreadIRCSeed) failed\n");
// Send and receive from sockets, accept connections
if (!NewThread(ThreadSocketHandler, NULL))
printf("Error: NewThread(ThreadSocketHandler) failed\n");
// Initiate outbound connections from -addnode
if (!NewThread(ThreadOpenAddedConnections, NULL))
printf("Error: NewThread(ThreadOpenAddedConnections) failed\n");
// Initiate outbound connections
if (!NewThread(ThreadOpenConnections, NULL))
printf("Error: NewThread(ThreadOpenConnections) failed\n");
// Process messages
if (!NewThread(ThreadMessageHandler, NULL))
printf("Error: NewThread(ThreadMessageHandler) failed\n");
// Dump network addresses
if (!NewThread(ThreadDumpAddress, NULL))
printf("Error; NewThread(ThreadDumpAddress) failed\n");
// Mine proof-of-stake blocks in the background
if (!NewThread(ThreadStakeMiner, pwalletMain))
printf("Error: NewThread(ThreadStakeMiner) failed\n");
// Trusted NTP server, it's localhost by default.
strTrustedUpstream = GetArg("-ntp", "localhost");
// Start periodical NTP sampling thread
NewThread(ThreadNtpSamples, NULL);
}
bool StopNode()
{
printf("StopNode()\n");
fShutdown = true;
nTransactionsUpdated++;
int64_t nStart = GetTime();
{
LOCK(cs_main);
ThreadScriptCheckQuit();
}
if (semOutbound)
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post();
do
{
int nThreadsRunning = 0;
for (int n = 0; n < THREAD_MAX; n++)
nThreadsRunning += vnThreadsRunning[n];
if (nThreadsRunning == 0)
break;
if (GetTime() - nStart > 20)
break;
Sleep(20);
} while(true);
if (vnThreadsRunning[THREAD_SOCKETHANDLER] > 0) printf("ThreadSocketHandler still running\n");
if (vnThreadsRunning[THREAD_OPENCONNECTIONS] > 0) printf("ThreadOpenConnections still running\n");
if (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0) printf("ThreadMessageHandler still running\n");
if (vnThreadsRunning[THREAD_RPCLISTENER] > 0) printf("ThreadRPCListener still running\n");
if (vnThreadsRunning[THREAD_RPCHANDLER] > 0) printf("ThreadsRPCServer still running\n");
if (vnThreadsRunning[THREAD_DNSSEED] > 0) printf("ThreadDNSAddressSeed still running\n");
if (vnThreadsRunning[THREAD_ADDEDCONNECTIONS] > 0) printf("ThreadOpenAddedConnections still running\n");
if (vnThreadsRunning[THREAD_DUMPADDRESS] > 0) printf("ThreadDumpAddresses still running\n");
if (vnThreadsRunning[THREAD_MINTER] > 0) printf("ThreadStakeMinter still running\n");
if (vnThreadsRunning[THREAD_SCRIPTCHECK] > 0) printf("ThreadScriptCheck still running\n");
while (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0 || vnThreadsRunning[THREAD_RPCHANDLER] > 0 || vnThreadsRunning[THREAD_SCRIPTCHECK] > 0)
Sleep(20);
Sleep(50);
DumpAddresses();
return true;
}
class CNetCleanup
{
public:
CNetCleanup()
{
}
~CNetCleanup()
{
// Close sockets
BOOST_FOREACH(CNode* pnode, vNodes)
if (pnode->hSocket != INVALID_SOCKET)
closesocket(pnode->hSocket);
BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
if (hListenSocket != INVALID_SOCKET)
if (closesocket(hListenSocket) == SOCKET_ERROR)
printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
// clean up some globals (to help leak detection)
BOOST_FOREACH(CNode *pnode, vNodes)
delete pnode;
BOOST_FOREACH(CNode *pnode, vNodesDisconnected)
delete pnode;
vNodes.clear();
vNodesDisconnected.clear();
delete semOutbound;
semOutbound = NULL;
delete pnodeLocalHost;
pnodeLocalHost = NULL;
#ifdef WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif
}
}
instance_of_cnetcleanup;
void RelayTransaction(const CTransaction& tx, const uint256& hash)
{
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(10000);
ss << tx;
RelayTransaction(tx, hash, ss);
}
void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss)
{
CInv inv(MSG_TX, hash);
{
LOCK(cs_mapRelay);
// Expire old relay messages
while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime())
{
mapRelay.erase(vRelayExpiration.front().second);
vRelayExpiration.pop_front();
}
// Save original serialized message so newer versions are preserved
mapRelay.insert(std::make_pair(inv, ss));
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
}
RelayInventory(inv);
}
void CNode::RecordBytesRecv(uint64_t bytes)
{
LOCK(cs_totalBytesRecv);
nTotalBytesRecv += bytes;
}
void CNode::RecordBytesSent(uint64_t bytes)
{
LOCK(cs_totalBytesSent);
nTotalBytesSent += bytes;
}
uint64_t CNode::GetTotalBytesRecv()
{
LOCK(cs_totalBytesRecv);
return nTotalBytesRecv;
}
uint64_t CNode::GetTotalBytesSent()
{
LOCK(cs_totalBytesSent);
return nTotalBytesSent;
}
|
; =============================================================================
; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems
; Copyright (C) 2008-2015 Return Infinity -- see LICENSE.TXT
;
; PCI Functions. http://wiki.osdev.org/PCI
; =============================================================================
; -----------------------------------------------------------------------------
; os_pci_read_reg -- Read a register from a PCI device
; IN: BL = Bus number
; CL = Device/Function number
; DL = Register number
; OUT: EAX = Register information
; All other registers preserved
; Data form is binary 10000000 bbbbbbbb dddddfff rrrrrr00
os_pci_read_reg:
push rdx
push rcx
push rbx
shl ebx, 16 ; Move Bus to bits 23 - 16
shl ecx, 8 ; Move Device/Function to bits 15 - 8
mov bx, cx
shl edx, 2 ; Move Register to bits 7 - 2
mov bl, dl
and ebx, 0x00ffffff ; Clear bits 31 - 24
or ebx, 0x80000000 ; Set bit 31
mov eax, ebx
mov dx, PCI_CONFIG_ADDRESS
out dx, eax
mov dx, PCI_CONFIG_DATA
in eax, dx
pop rbx
pop rcx
pop rdx
ret
; -----------------------------------------------------------------------------
;Configuration Mechanism One has two IO port rages associated with it.
;The address port (0xcf8-0xcfb) and the data port (0xcfc-0xcff).
;A configuration cycle consists of writing to the address port to specify which device and register you want to access and then reading or writing the data to the data port.
PCI_CONFIG_ADDRESS EQU 0x0CF8
PCI_CONFIG_DATA EQU 0x0CFC
;ddress dd 10000000000000000000000000000000b
; /\ /\ /\ /\ /\ /\
; E Res Bus Dev F Reg 0
; Bits
; 31 Enable bit = set to 1
; 30 - 24 Reserved = set to 0
; 23 - 16 Bus number = 256 options
; 15 - 11 Device/Slot number = 32 options
; 10 - 8 Function number = will leave at 0 (8 options)
; 7 - 2 Register number = will leave at 0 (64 options) 64 x 4 bytes = 256 bytes worth of accessible registers
; 1 - 0 Set to 0
; =============================================================================
; EOF
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1eb97, %r10
clflush (%r10)
nop
nop
nop
cmp %rdi, %rdi
movups (%r10), %xmm1
vpextrq $0, %xmm1, %r11
and $56458, %r9
lea addresses_A_ht+0xff17, %rbp
clflush (%rbp)
nop
nop
add %rbx, %rbx
mov (%rbp), %r13
add $26239, %r13
lea addresses_A_ht+0x1872b, %rsi
lea addresses_WC_ht+0x1e617, %rdi
inc %rbx
mov $69, %rcx
rep movsb
nop
cmp %r9, %r9
lea addresses_UC_ht+0x1b397, %r11
clflush (%r11)
nop
nop
nop
xor %r10, %r10
mov $0x6162636465666768, %r9
movq %r9, %xmm3
vmovups %ymm3, (%r11)
nop
nop
nop
nop
sub $5521, %r10
lea addresses_WC_ht+0x1ad97, %rsi
nop
nop
dec %r10
movl $0x61626364, (%rsi)
nop
nop
nop
xor $12406, %rdi
lea addresses_UC_ht+0x827, %rsi
lea addresses_UC_ht+0x1bd97, %rdi
nop
mfence
mov $112, %rcx
rep movsb
nop
nop
nop
cmp $57148, %rcx
lea addresses_WC_ht+0x8e47, %rcx
nop
cmp %r10, %r10
movb $0x61, (%rcx)
nop
nop
nop
dec %rbx
lea addresses_A_ht+0xab97, %rbp
sub $17974, %rsi
movb (%rbp), %r13b
nop
nop
nop
nop
xor %rbx, %rbx
lea addresses_UC_ht+0x2e1b, %rsi
lea addresses_D_ht+0x10e97, %rdi
clflush (%rsi)
add %rbx, %rbx
mov $77, %rcx
rep movsw
nop
xor %r11, %r11
lea addresses_D_ht+0x2877, %rsi
nop
nop
inc %rdi
vmovups (%rsi), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %rbx
nop
add $63173, %rsi
lea addresses_D_ht+0x1cc97, %r10
clflush (%r10)
nop
and %rdi, %rdi
movups (%r10), %xmm3
vpextrq $0, %xmm3, %rcx
nop
nop
xor $35791, %rbx
lea addresses_normal_ht+0x1ea50, %r10
nop
cmp %r13, %r13
movb $0x61, (%r10)
nop
dec %r10
lea addresses_normal_ht+0xa61b, %rsi
lea addresses_WT_ht+0xc057, %rdi
nop
nop
nop
nop
nop
mfence
mov $108, %rcx
rep movsb
nop
nop
nop
inc %rbx
lea addresses_A_ht+0x17097, %rsi
lea addresses_A_ht+0x11227, %rdi
clflush (%rsi)
add $12213, %rbx
mov $65, %rcx
rep movsw
nop
and %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r15
push %rax
push %rdx
// Faulty Load
mov $0x7111780000000b97, %r12
nop
add %rdx, %rdx
mov (%r12), %r14
lea oracles, %r15
and $0xff, %r14
shlq $12, %r14
mov (%r15,%r14,1), %r14
pop %rdx
pop %rax
pop %r15
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}}
{'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
*/
|
; A152423: A variation of the Josephus problem, removing every other person, starting with person 1; a(n) is the last person remaining.
; 1,2,2,4,2,4,6,8,2,4,6,8,10,12,14,16,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,2,4,6,8,10,12,14,16,18,20
mov $1,1
mov $2,$0
lpb $0,1
mul $0,2
mov $1,$0
sub $0,1
trn $0,$2
lpe
|
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)
int _ = (
#ifndef LOCAL
std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
std::cout.precision(10), std::cout.setf(std::ios::fixed));
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;
static constexpr bool is_odd(ll n) { return n & 0x01 != 0; }
static constexpr bool is_multiple_of_4(ll n) { return n % 4 == 0; }
int main() {
ll N;
cin >> N;
ll odd = 0, multi4 = 0;
REP(i, N) {
ll a;
cin >> a;
if (is_odd(a)) {
odd++;
} else if (is_multiple_of_4(a)) {
multi4++;
}
}
if (odd == 0) {
cout << "Yes" << endl;
return 0;
}
const ll multi2not4 = N - odd - multi4;
const ll not4chunk = odd + (multi2not4 > 0);
cout << (multi4 >= not4chunk - 1 ? "Yes" : "No") << endl;
return 0;
}
|
; A133294: a(n) = 2*a(n-1) + 10*a(n-2), a(0)=1, a(1)=1.
; 1,1,12,34,188,716,3312,13784,60688,259216,1125312,4842784,20938688,90305216,389997312,1683046784,7266066688,31362601216,135385869312,584397750784,2522654194688,10889285897216,47005113741312,202903086454784,875857310322688,3780745485193216
mov $4,$0
mov $5,$0
add $5,1
lpb $5
mov $0,$4
sub $5,1
sub $0,$5
mov $13,$0
mov $15,2
lpb $15
mov $0,$13
sub $15,1
add $0,$15
sub $0,1
mov $9,$0
mov $11,2
lpb $11
mov $0,$9
sub $11,1
add $0,$11
mov $2,0
mov $3,0
mov $8,2
lpb $0
sub $0,1
mov $7,$3
mov $3,$2
mul $3,5
add $8,$7
mul $8,2
mov $2,$8
lpe
mov $7,$2
mov $12,$11
lpb $12
mov $10,$7
sub $12,1
lpe
lpe
lpb $9
mov $9,0
sub $10,$7
lpe
mov $6,$15
mov $7,$10
lpb $6
sub $6,1
mov $14,$7
lpe
lpe
lpb $13
mov $13,0
sub $14,$7
lpe
mov $7,$14
div $7,4
add $1,$7
lpe
|
#include "menu.hpp"
#include "window.hpp"
#ifndef PATH_SAVING
#define PATH_SAVING "./tmp/data"
#endif
#ifndef PATH_RESOURSE
#define PATH_RESOURSE "./data"
#endif
int main() {
Settings settings(PATH_SAVING "/settings", PATH_RESOURSE);
Graphic::Window window(settings);
Menu menu(settings);
sf::Event event;
bool active = true;
while (active) {
window.draw(menu);
while (window.poll_event(event))
active &= menu.process_event(event);
}
}
|
// Copyright (c) 2012 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 "remoting/protocol/jingle_session.h"
#include <stdint.h>
#include <limits>
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "remoting/base/constants.h"
#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/content_description.h"
#include "remoting/protocol/jingle_messages.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/session_plugin.h"
#include "remoting/protocol/transport.h"
#include "remoting/signaling/iq_sender.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
#include "third_party/libjingle_xmpp/xmpp/constants.h"
#include "third_party/webrtc/api/candidate.h"
using jingle_xmpp::XmlElement;
namespace remoting {
namespace protocol {
namespace {
// Timeouts have been temporarily increased for testing.
// TODO(rkjnsn): Revert default and session timeouts once done with testing.
// How long we should wait for a response from the other end. This value is used
// for all requests except |transport-info|.
// const int kDefaultMessageTimeout = 10;
const int kDefaultMessageTimeout = 35; // For testing
// During a reconnection, it usually takes longer for the peer to respond due to
// pending messages in the channel from the previous session. From experiment,
// it can take up to 20s for the session to reconnect. To make it safe, setting
// the timeout to 30s.
// const int kSessionInitiateAndAcceptTimeout = kDefaultMessageTimeout * 3;
const int kSessionInitiateAndAcceptTimeout = 45; // For testing
// Timeout for the transport-info messages.
const int kTransportInfoTimeout = 10 * 60;
// Special value for an invalid sequential ID for an incoming IQ.
const int kInvalid = -1;
// Special value indicating that any sequential ID is valid for the next
// incoming IQ.
const int kAny = -1;
ErrorCode AuthRejectionReasonToErrorCode(
Authenticator::RejectionReason reason) {
switch (reason) {
case Authenticator::INVALID_CREDENTIALS:
return AUTHENTICATION_FAILED;
case Authenticator::PROTOCOL_ERROR:
return INCOMPATIBLE_PROTOCOL;
case Authenticator::INVALID_ACCOUNT:
return INVALID_ACCOUNT;
case Authenticator::TOO_MANY_CONNECTIONS:
return SESSION_REJECTED;
case Authenticator::REJECTED_BY_USER:
return SESSION_REJECTED;
}
NOTREACHED();
return UNKNOWN_ERROR;
}
// Extracts a sequential id from the id attribute of the IQ stanza.
int GetSequentialId(const std::string& id) {
std::vector<std::string> tokens =
SplitString(id, "_", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
// Legacy endpoints does not encode the IQ ordering in the ID attribute
if (tokens.size() != 2) {
return kInvalid;
}
int result = kInvalid;
if (!base::StringToInt(tokens[1], &result)) {
return kInvalid;
}
return result;
}
} // namespace
// A Queue that sorts incoming messages and returns them in the ascending order
// of sequence ids. The sequence id can be extracted from the ID attribute of
// an IQ stanza, which have the following format <opaque_string>_<sequence_id>.
//
// Background:
// The chromoting signaling channel does not guarantee that the incoming IQs are
// delivered in the order that it is sent.
//
// This behavior leads to transient session setup failures. For instance,
// a <transport-info> that is sent after a <session-info> message is sometimes
// delivered to the client out of order, causing the client to close the
// session due to an unexpected request.
class JingleSession::OrderedMessageQueue {
public:
OrderedMessageQueue() = default;
~OrderedMessageQueue() = default;
// Returns the list of messages ordered by their sequential IDs.
std::vector<PendingMessage> OnIncomingMessage(
const std::string& id,
PendingMessage&& pending_message);
// Sets the initial ID of the session initiate message.
void SetInitialId(const std::string& id);
private:
// Implements an ordered list by using map with the |sequence_id| as the key,
// so that |queue_| is always sorted by |sequence_id|.
std::map<int, PendingMessage> queue_;
int next_incoming_ = kAny;
DISALLOW_COPY_AND_ASSIGN(OrderedMessageQueue);
};
std::vector<JingleSession::PendingMessage>
JingleSession::OrderedMessageQueue::OnIncomingMessage(
const std::string& id,
JingleSession::PendingMessage&& message) {
std::vector<JingleSession::PendingMessage> result;
int current = GetSequentialId(id);
// If there is no sequencing order encoded in the id, just return the
// message.
if (current == kInvalid) {
result.push_back(std::move(message));
return result;
}
if (next_incoming_ == kAny) {
next_incoming_ = current;
}
// Ensure there are no duplicate sequence ids.
DCHECK_GE(current, next_incoming_);
DCHECK(queue_.find(current) == queue_.end());
queue_.insert(std::make_pair(current, std::move(message)));
auto it = queue_.begin();
while (it != queue_.end() && it->first == next_incoming_) {
result.push_back(std::move(it->second));
it = queue_.erase(it);
next_incoming_++;
}
if (current - next_incoming_ >= 3) {
LOG(WARNING) << "Multiple messages are missing: expected= "
<< next_incoming_ << " current= " << current;
}
return result;
}
void JingleSession::OrderedMessageQueue::SetInitialId(const std::string& id) {
int current = GetSequentialId(id);
if (current != kInvalid)
next_incoming_ = current + 1;
}
JingleSession::PendingMessage::PendingMessage() = default;
JingleSession::PendingMessage::PendingMessage(PendingMessage&& moved) = default;
JingleSession::PendingMessage::PendingMessage(
std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback)
: message(std::move(message)), reply_callback(reply_callback) {}
JingleSession::PendingMessage::~PendingMessage() = default;
JingleSession::PendingMessage& JingleSession::PendingMessage::operator=(
PendingMessage&& moved) = default;
JingleSession::JingleSession(JingleSessionManager* session_manager)
: session_manager_(session_manager),
event_handler_(nullptr),
state_(INITIALIZING),
error_(OK),
message_queue_(new OrderedMessageQueue) {}
JingleSession::~JingleSession() {
DCHECK(thread_checker_.CalledOnValidThread());
session_manager_->SessionDestroyed(this);
}
void JingleSession::SetEventHandler(Session::EventHandler* event_handler) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(event_handler);
event_handler_ = event_handler;
}
ErrorCode JingleSession::error() {
DCHECK(thread_checker_.CalledOnValidThread());
return error_;
}
void JingleSession::StartConnection(
const SignalingAddress& peer_address,
std::unique_ptr<Authenticator> authenticator) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(authenticator.get());
DCHECK_EQ(authenticator->state(), Authenticator::MESSAGE_READY);
peer_address_ = peer_address;
authenticator_ = std::move(authenticator);
// Generate random session ID. There are usually not more than 1
// concurrent session per host, so a random 64-bit integer provides
// enough entropy. In the worst case connection will fail when two
// clients generate the same session ID concurrently.
session_id_ = base::NumberToString(
base::RandGenerator(std::numeric_limits<uint64_t>::max()));
// Delay sending session-initiate message to ensure SessionPlugin can be
// attached before the message.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&JingleSession::SendSessionInitiateMessage,
weak_factory_.GetWeakPtr()));
SetState(CONNECTING);
}
void JingleSession::InitializeIncomingConnection(
const std::string& message_id,
const JingleMessage& initiate_message,
std::unique_ptr<Authenticator> authenticator) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(initiate_message.description.get());
DCHECK(authenticator.get());
DCHECK_EQ(authenticator->state(), Authenticator::WAITING_MESSAGE);
peer_address_ = initiate_message.from;
authenticator_ = std::move(authenticator);
session_id_ = initiate_message.sid;
message_queue_->SetInitialId(message_id);
SetState(ACCEPTING);
config_ =
SessionConfig::SelectCommon(initiate_message.description->config(),
session_manager_->protocol_config_.get());
if (!config_) {
LOG(WARNING) << "Rejecting connection from " << peer_address_.id()
<< " because no compatible configuration has been found.";
Close(INCOMPATIBLE_PROTOCOL);
return;
}
}
void JingleSession::AcceptIncomingConnection(
const JingleMessage& initiate_message) {
DCHECK(config_);
ProcessIncomingPluginMessage(initiate_message);
// Process the first authentication message.
const jingle_xmpp::XmlElement* first_auth_message =
initiate_message.description->authenticator_message();
if (!first_auth_message) {
Close(INCOMPATIBLE_PROTOCOL);
return;
}
DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE);
// |authenticator_| is owned, so Unretained() is safe here.
authenticator_->ProcessMessage(
first_auth_message,
base::BindOnce(&JingleSession::ContinueAcceptIncomingConnection,
base::Unretained(this)));
}
void JingleSession::ContinueAcceptIncomingConnection() {
DCHECK_NE(authenticator_->state(), Authenticator::PROCESSING_MESSAGE);
if (authenticator_->state() == Authenticator::REJECTED) {
Close(AuthRejectionReasonToErrorCode(authenticator_->rejection_reason()));
return;
}
// Send the session-accept message.
std::unique_ptr<JingleMessage> message(new JingleMessage(
peer_address_, JingleMessage::SESSION_ACCEPT, session_id_));
std::unique_ptr<jingle_xmpp::XmlElement> auth_message;
if (authenticator_->state() == Authenticator::MESSAGE_READY)
auth_message = authenticator_->GetNextMessage();
message->description.reset(new ContentDescription(
CandidateSessionConfig::CreateFrom(*config_), std::move(auth_message)));
SendMessage(std::move(message));
// Update state.
SetState(ACCEPTED);
if (authenticator_->state() == Authenticator::ACCEPTED) {
OnAuthenticated();
} else {
DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE);
if (authenticator_->started()) {
SetState(AUTHENTICATING);
}
}
}
const std::string& JingleSession::jid() {
DCHECK(thread_checker_.CalledOnValidThread());
return peer_address_.id();
}
const SessionConfig& JingleSession::config() {
DCHECK(thread_checker_.CalledOnValidThread());
return *config_;
}
void JingleSession::SetTransport(Transport* transport) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!transport_);
DCHECK(transport);
transport_ = transport;
}
void JingleSession::SendTransportInfo(
std::unique_ptr<jingle_xmpp::XmlElement> transport_info) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(state_, AUTHENTICATED);
std::unique_ptr<JingleMessage> message(new JingleMessage(
peer_address_, JingleMessage::TRANSPORT_INFO, session_id_));
message->transport_info = std::move(transport_info);
AddPluginAttachments(message.get());
std::unique_ptr<jingle_xmpp::XmlElement> stanza = message->ToXml();
stanza->AddAttr(jingle_xmpp::QN_ID, GetNextOutgoingId());
auto request = session_manager_->iq_sender()->SendIq(
std::move(stanza), base::BindOnce(&JingleSession::OnTransportInfoResponse,
base::Unretained(this)));
if (request) {
request->SetTimeout(base::TimeDelta::FromSeconds(kTransportInfoTimeout));
transport_info_requests_.push_back(std::move(request));
} else {
LOG(ERROR) << "Failed to send a transport-info message";
}
}
void JingleSession::Close(protocol::ErrorCode error) {
DCHECK(thread_checker_.CalledOnValidThread());
if (is_session_active()) {
// Send session-terminate message with the appropriate error code.
JingleMessage::Reason reason;
switch (error) {
case OK:
reason = JingleMessage::SUCCESS;
break;
case SESSION_REJECTED:
case AUTHENTICATION_FAILED:
case INVALID_ACCOUNT:
reason = JingleMessage::DECLINE;
break;
case INCOMPATIBLE_PROTOCOL:
reason = JingleMessage::INCOMPATIBLE_PARAMETERS;
break;
case HOST_OVERLOAD:
reason = JingleMessage::CANCEL;
break;
case MAX_SESSION_LENGTH:
reason = JingleMessage::EXPIRED;
break;
case HOST_CONFIGURATION_ERROR:
reason = JingleMessage::FAILED_APPLICATION;
break;
default:
reason = JingleMessage::GENERAL_ERROR;
}
std::unique_ptr<JingleMessage> message(new JingleMessage(
peer_address_, JingleMessage::SESSION_TERMINATE, session_id_));
message->reason = reason;
message->error_code = error;
SendMessage(std::move(message));
}
error_ = error;
if (state_ != FAILED && state_ != CLOSED) {
if (error != OK) {
SetState(FAILED);
} else {
SetState(CLOSED);
}
}
}
void JingleSession::AddPlugin(SessionPlugin* plugin) {
DCHECK(plugin);
plugins_.push_back(plugin);
}
void JingleSession::SendMessage(std::unique_ptr<JingleMessage> message) {
DCHECK(thread_checker_.CalledOnValidThread());
if (message->action != JingleMessage::SESSION_TERMINATE) {
// When the host accepts session-initiate message from a client JID it
// doesn't recognize it sends session-terminate without session-accept.
// Attaching plugin information to this session-terminate message may lead
// to privacy issues (e.g. leaking Windows version to someone who does not
// own the host). So a simply approach is to ignore plugins when sending
// SESSION_TERMINATE message.
AddPluginAttachments(message.get());
}
std::unique_ptr<jingle_xmpp::XmlElement> stanza = message->ToXml();
stanza->AddAttr(jingle_xmpp::QN_ID, GetNextOutgoingId());
auto request = session_manager_->iq_sender()->SendIq(
std::move(stanza),
base::BindOnce(&JingleSession::OnMessageResponse, base::Unretained(this),
message->action));
int timeout = kDefaultMessageTimeout;
if (message->action == JingleMessage::SESSION_INITIATE ||
message->action == JingleMessage::SESSION_ACCEPT) {
timeout = kSessionInitiateAndAcceptTimeout;
}
if (request) {
request->SetTimeout(base::TimeDelta::FromSeconds(timeout));
pending_requests_.push_back(std::move(request));
} else {
LOG(ERROR) << "Failed to send a "
<< JingleMessage::GetActionName(message->action) << " message";
}
}
void JingleSession::OnMessageResponse(
JingleMessage::ActionType request_type,
IqRequest* request,
const jingle_xmpp::XmlElement* response) {
DCHECK(thread_checker_.CalledOnValidThread());
// Delete the request from the list of pending requests.
pending_requests_.erase(
std::find_if(pending_requests_.begin(), pending_requests_.end(),
[request](const std::unique_ptr<IqRequest>& ptr) {
return ptr.get() == request;
}));
// Ignore all responses after session was closed.
if (state_ == CLOSED || state_ == FAILED)
return;
std::string type_str = JingleMessage::GetActionName(request_type);
// |response| will be nullptr if the request timed out.
if (!response) {
LOG(ERROR) << type_str << " request timed out.";
Close(SIGNALING_TIMEOUT);
return;
} else {
const std::string& type =
response->Attr(jingle_xmpp::QName(std::string(), "type"));
if (type != "result") {
LOG(ERROR) << "Received error in response to " << type_str
<< " message: \"" << response->Str()
<< "\". Terminating the session.";
// TODO(sergeyu): There may be different reasons for error
// here. Parse the response stanza to find failure reason.
Close(PEER_IS_OFFLINE);
}
}
}
void JingleSession::OnTransportInfoResponse(IqRequest* request,
const jingle_xmpp::XmlElement* response) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!transport_info_requests_.empty());
// Consider transport-info requests sent before this one lost and delete
// all IqRequest objects in front of |request|.
auto request_it = std::find_if(
transport_info_requests_.begin(), transport_info_requests_.end(),
[request](const std::unique_ptr<IqRequest>& ptr) {
return ptr.get() == request;
});
DCHECK(request_it != transport_info_requests_.end());
transport_info_requests_.erase(transport_info_requests_.begin(),
request_it + 1);
// Ignore transport-info timeouts.
if (!response) {
LOG(ERROR) << "transport-info request has timed out.";
return;
}
const std::string& type = response->Attr(jingle_xmpp::QName(std::string(), "type"));
if (type != "result") {
LOG(ERROR) << "Received error in response to transport-info message: \""
<< response->Str() << "\". Terminating the session.";
Close(PEER_IS_OFFLINE);
}
}
void JingleSession::OnIncomingMessage(const std::string& id,
std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
ProcessIncomingPluginMessage(*message);
std::vector<PendingMessage> ordered = message_queue_->OnIncomingMessage(
id, PendingMessage{std::move(message), reply_callback});
base::WeakPtr<JingleSession> self = weak_factory_.GetWeakPtr();
for (auto& message : ordered) {
ProcessIncomingMessage(std::move(message.message), message.reply_callback);
if (!self)
return;
}
}
void JingleSession::ProcessIncomingMessage(
std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
if (peer_address_ != message->from) {
// Ignore messages received from a different Jid.
reply_callback.Run(JingleMessageReply::INVALID_SID);
return;
}
switch (message->action) {
case JingleMessage::SESSION_ACCEPT:
OnAccept(std::move(message), reply_callback);
break;
case JingleMessage::SESSION_INFO:
OnSessionInfo(std::move(message), reply_callback);
break;
case JingleMessage::TRANSPORT_INFO:
OnTransportInfo(std::move(message), reply_callback);
break;
case JingleMessage::SESSION_TERMINATE:
OnTerminate(std::move(message), reply_callback);
break;
default:
reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
}
}
void JingleSession::OnAccept(std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
if (state_ != CONNECTING) {
reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
return;
}
reply_callback.Run(JingleMessageReply::NONE);
const jingle_xmpp::XmlElement* auth_message =
message->description->authenticator_message();
if (!auth_message) {
DLOG(WARNING) << "Received session-accept without authentication message ";
Close(INCOMPATIBLE_PROTOCOL);
return;
}
if (!InitializeConfigFromDescription(message->description.get())) {
Close(INCOMPATIBLE_PROTOCOL);
return;
}
SetState(ACCEPTED);
DCHECK(authenticator_->state() == Authenticator::WAITING_MESSAGE);
authenticator_->ProcessMessage(
auth_message, base::BindOnce(&JingleSession::ProcessAuthenticationStep,
base::Unretained(this)));
}
void JingleSession::OnSessionInfo(std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
if (!message->info.get() ||
!Authenticator::IsAuthenticatorMessage(message->info.get())) {
reply_callback.Run(JingleMessageReply::UNSUPPORTED_INFO);
return;
}
if ((state_ != ACCEPTED && state_ != AUTHENTICATING) ||
authenticator_->state() != Authenticator::WAITING_MESSAGE) {
LOG(WARNING) << "Received unexpected authenticator message "
<< message->info->Str();
reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
Close(INCOMPATIBLE_PROTOCOL);
return;
}
reply_callback.Run(JingleMessageReply::NONE);
authenticator_->ProcessMessage(
message->info.get(),
base::BindOnce(&JingleSession::ProcessAuthenticationStep,
base::Unretained(this)));
}
void JingleSession::OnTransportInfo(std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
if (!message->transport_info) {
reply_callback.Run(JingleMessageReply::BAD_REQUEST);
return;
}
if (state_ == AUTHENTICATING) {
pending_transport_info_.push_back(
PendingMessage{std::move(message), reply_callback});
} else if (state_ == AUTHENTICATED) {
reply_callback.Run(
transport_->ProcessTransportInfo(message->transport_info.get())
? JingleMessageReply::NONE
: JingleMessageReply::BAD_REQUEST);
} else {
LOG(ERROR) << "Received unexpected transport-info message.";
reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
}
}
void JingleSession::OnTerminate(std::unique_ptr<JingleMessage> message,
const ReplyCallback& reply_callback) {
if (!is_session_active()) {
LOG(WARNING) << "Received unexpected session-terminate message.";
reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST);
return;
}
reply_callback.Run(JingleMessageReply::NONE);
error_ = message->error_code;
if (error_ == UNKNOWN_ERROR) {
// get error code from message.reason for compatibility with older versions
// that do not add <error-code>.
switch (message->reason) {
case JingleMessage::SUCCESS:
if (state_ == CONNECTING) {
error_ = SESSION_REJECTED;
} else {
error_ = OK;
}
break;
case JingleMessage::DECLINE:
error_ = AUTHENTICATION_FAILED;
break;
case JingleMessage::CANCEL:
error_ = HOST_OVERLOAD;
break;
case JingleMessage::EXPIRED:
error_ = MAX_SESSION_LENGTH;
break;
case JingleMessage::INCOMPATIBLE_PARAMETERS:
error_ = INCOMPATIBLE_PROTOCOL;
break;
case JingleMessage::FAILED_APPLICATION:
error_ = HOST_CONFIGURATION_ERROR;
break;
case JingleMessage::GENERAL_ERROR:
error_ = CHANNEL_CONNECTION_ERROR;
break;
default:
error_ = UNKNOWN_ERROR;
}
} else if (error_ == SESSION_REJECTED) {
// For backward compatibility, we still use AUTHENTICATION_FAILED for
// SESSION_REJECTED error.
// TODO(zijiehe): Handle SESSION_REJECTED error in WebApp. Tracked by
// http://crbug.com/618036.
error_ = AUTHENTICATION_FAILED;
}
if (error_ != OK) {
SetState(FAILED);
} else {
SetState(CLOSED);
}
}
bool JingleSession::InitializeConfigFromDescription(
const ContentDescription* description) {
DCHECK(description);
config_ = SessionConfig::GetFinalConfig(description->config());
if (!config_) {
LOG(ERROR) << "session-accept does not specify configuration";
return false;
}
if (!session_manager_->protocol_config_->IsSupported(*config_)) {
LOG(ERROR) << "session-accept specifies an invalid configuration";
return false;
}
return true;
}
void JingleSession::ProcessAuthenticationStep() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_NE(authenticator_->state(), Authenticator::PROCESSING_MESSAGE);
if (state_ != ACCEPTED && state_ != AUTHENTICATING) {
DCHECK(state_ == FAILED || state_ == CLOSED);
// The remote host closed the connection while the authentication was being
// processed asynchronously, nothing to do.
return;
}
if (authenticator_->state() == Authenticator::MESSAGE_READY) {
std::unique_ptr<JingleMessage> message(new JingleMessage(
peer_address_, JingleMessage::SESSION_INFO, session_id_));
message->info = authenticator_->GetNextMessage();
DCHECK(message->info.get());
SendMessage(std::move(message));
}
DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY);
if (authenticator_->started()) {
base::WeakPtr<JingleSession> self = weak_factory_.GetWeakPtr();
SetState(AUTHENTICATING);
if (!self)
return;
}
if (authenticator_->state() == Authenticator::ACCEPTED) {
OnAuthenticated();
} else if (authenticator_->state() == Authenticator::REJECTED) {
Close(AuthRejectionReasonToErrorCode(
authenticator_->rejection_reason()));
}
}
void JingleSession::OnAuthenticated() {
transport_->Start(authenticator_.get(),
base::Bind(&JingleSession::SendTransportInfo,
weak_factory_.GetWeakPtr()));
base::WeakPtr<JingleSession> self = weak_factory_.GetWeakPtr();
std::vector<PendingMessage> messages_to_process;
std::swap(messages_to_process, pending_transport_info_);
for (auto& message : messages_to_process) {
message.reply_callback.Run(
transport_->ProcessTransportInfo(message.message->transport_info.get())
? JingleMessageReply::NONE
: JingleMessageReply::BAD_REQUEST);
if (!self)
return;
}
SetState(AUTHENTICATED);
}
void JingleSession::SetState(State new_state) {
DCHECK(thread_checker_.CalledOnValidThread());
if (new_state != state_) {
DCHECK_NE(state_, CLOSED);
DCHECK_NE(state_, FAILED);
state_ = new_state;
if (event_handler_)
event_handler_->OnSessionStateChange(new_state);
}
}
bool JingleSession::is_session_active() {
return state_ == CONNECTING || state_ == ACCEPTING || state_ == ACCEPTED ||
state_ == AUTHENTICATING || state_ == AUTHENTICATED;
}
void JingleSession::ProcessIncomingPluginMessage(
const JingleMessage& message) {
if (!message.attachments) {
return;
}
for (auto* plugin : plugins_) {
plugin->OnIncomingMessage(*(message.attachments));
}
}
void JingleSession::AddPluginAttachments(JingleMessage* message) {
DCHECK(message);
for (auto* plugin : plugins_) {
std::unique_ptr<XmlElement> attachment = plugin->GetNextMessage();
if (attachment) {
message->AddAttachment(std::move(attachment));
}
}
}
void JingleSession::SendSessionInitiateMessage() {
if (state_ != CONNECTING) {
return;
}
std::unique_ptr<JingleMessage> message(new JingleMessage(
peer_address_, JingleMessage::SESSION_INITIATE, session_id_));
message->initiator =
session_manager_->signal_strategy_->GetLocalAddress().id();
message->description.reset(new ContentDescription(
session_manager_->protocol_config_->Clone(),
authenticator_->GetNextMessage()));
SendMessage(std::move(message));
}
std::string JingleSession::GetNextOutgoingId() {
return outgoing_id_prefix_ + "_" + base::NumberToString(++next_outgoing_id_);
}
} // namespace protocol
} // namespace remoting
|
; A126446: Column 0 of triangle A126445; a(n) = binomial( binomial(n+2,3), n).
; 1,1,6,120,4845,324632,32468436,4529365776,840261910995,200063149171380,59473554359599446,21592914273609648996,9403538945961296957821,4838670732821812768919800,2904538537066424425438417800,2011833832070058843657188795040,1592750845170051165316494786714111,1429332076374782446386001770096933036,1443307447383616905970742100562129832250,1629250951941467551609098618147806008682400,2043997754624564351096173822070236625718911520,2834971165582079152279796368679613738615573414876
mov $1,$0
add $0,2
bin $0,3
bin $0,$1
|
;// Subtracting three integers (SubThree.asm)
INCLUDE Irvine32.inc
;// Data segment
.data
Rval SWORD ?
Int1 SWORD 26
Int2 SWORD 30
Int3 SWORD 40
;// Code Segment
.code
main PROC
;// AX register is lower half or EAX register
;// Therfore clear out the upper half with zeros
MOV EAX, 0 ;// EAX = 0000 - 0000 - 0000 - 0000
;// | AX |
;// | AH | AL |
;// Expression: Rval = (Int1 - Int2 - Int3)
MOV AX, Int1 ;// AX = 26
SUB AX, Int2 ;// AX = (26-30) = -4
SUB AX, Int3 ;// AX = (-4 - 40) = -44
MOV Rval, AX ;// Rval = -44
;// This means EAX should look like |00|00|FF|D4|
;// |AH|AL|
;// | AX |
;// | EAX |
CALL DumpRegs ;// Display registers
exit
main ENDP
END main
|
// Copyright (c) 2018-2020 The Cash2 developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "gtest/gtest.h"
#include "Logging/LoggerMessage.h"
#include "Logging/ConsoleLogger.h"
using namespace Logging;
// constructor
TEST(LoggerMessage, 1)
{
ConsoleLogger logger;
std::string category = "myCategory";
Level level = Level::DEBUGGING;
std::string color = "green";
LoggerMessage(logger, category, level, color);
}
// constructor
TEST(LoggerMessage, 2)
{
ConsoleLogger logger;
std::string category = "myCategory";
Level level = Level::DEBUGGING;
std::string color = "green";
LoggerMessage loggerMessage1(logger, category, level, color);
LoggerMessage loggerMessage2(std::move(loggerMessage1));
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} |
; A259623: Strictly increasing list of F and F + 1, where F = A000045, the Fibonacci numbers.
; 1,2,3,4,5,6,8,9,13,14,21,22,34,35,55,56,89,90,144,145,233,234,377,378,610,611,987,988,1597,1598,2584,2585,4181,4182,6765,6766,10946,10947,17711,17712,28657,28658,46368,46369,75025,75026,121393,121394,196418,196419,317811,317812,514229,514230,832040,832041,1346269,1346270,2178309,2178310,3524578,3524579,5702887,5702888,9227465,9227466,14930352,14930353,24157817,24157818,39088169,39088170,63245986,63245987,102334155,102334156,165580141,165580142,267914296,267914297,433494437,433494438,701408733
add $0,1
mov $3,$0
lpb $0
sub $1,$0
sub $0,1
trn $0,1
trn $1,3
add $2,$3
mov $3,$1
mov $1,$2
lpe
mov $0,$1
|
;bootload.asm
;Michael Black, 2007
;
;This is a simple bootloader that loads and executes a kernel at sector 3
bits 16
KSEG equ 0x1000 ;kernel goes into memory at 0x10000
KSIZE equ 10 ;kernel is at most 10 sectors (and probably less)
KSTART equ 3 ;kernel lives at sector 3 (makes room for map & dir)
;boot loader starts at 0 in segment 0x7c00
org 0h
;let's put the kernel at KSEG:0
;set up the segment registers
mov ax,KSEG
mov ds,ax
mov ss,ax
mov es,ax
;let's have the stack start at KSEG:fff0
mov ax,0xfff0
mov sp,ax
mov bp,ax
;read in the kernel from the disk
mov cl,KSTART+1 ;cl holds sector number
mov dh,0 ;dh holds head number - 0
mov ch,0 ;ch holds track number - 0
mov ah,2 ;absolute disk read
mov al,KSIZE ;read KSIZE sectors
mov dl,0 ;read from floppy disk A
mov bx,0 ;read into 0 (in the segment)
int 13h ;call BIOS disk read function
;call the kernel
jmp KSEG:0
times 510-($-$$) db 0
;AA55 tells BIOS that this is a valid bootloader
dw 0xAA55
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: intCommonMain.asm
AUTHOR: jimmy lefkowitz
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/15/92 Initial version.
DESCRIPTION:
contains 80X87 code to do the same thing for each routine
found in our floating point emulation library
$Id: intCommonMain.asm,v 1.1 97/04/04 17:48:36 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CommonCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87SetChop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the coprocessor to chop results
CALLED BY: (INTERNAL) Intel80X87Frac, Intel80X87Round,
Intel80X87_2ToTheX, Intel80X87TruncInternal
PASS: nothing
RETURN: nothing
DESTROYED: ax
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 1/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87SetChop proc near
control local word
.enter
fstcw control
fwait ; wait for it to arrive
CheckHack <RC_CHOP eq 3 and width CW_ROUND_CONTROL eq 2>
ornf ss:[control], RC_CHOP shl offset CW_ROUND_CONTROL
fldcw control
.leave
ret
Intel80X87SetChop endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87SetNearest
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the coprocessor to round results to nearest
CALLED BY: (INTERNAL) Intel80X87Frac, Intel80X87Round,
Intel80X87_2ToTheX, Intel80X87TruncInternal
PASS: nothing
RETURN: nothing
DESTROYED: ax
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 1/ 8/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87SetNearest proc near
control local word
.enter
fstcw control
fwait ; wait for it to arrive
CheckHack <RC_NEAREST_OR_EVEN eq 0 and width CW_ROUND_CONTROL eq 2>
andnf ss:[control], not mask CW_ROUND_CONTROL
fldcw control
.leave
ret
Intel80X87SetNearest endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87RestoreState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: restore the hardware state
CALLED BY: Math Library
PASS: si = handle of state block
RETURN: si = same handle
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87RestoreState proc far
uses ds, bx, ax
.enter
mov bx, si
call MemLock
mov ds, ax
frstor ds:[0]
fwait
call MemUnlock
.leave
ret
Intel80X87RestoreState endp
public Intel80X87RestoreState
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87SaveState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: save the chips state
CALLED BY: Math Library
PASS: si = handle of block to save state to
RETURN: si = same handle
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87SaveState proc far
uses ds, bx, ax
.enter
mov bx, si
call MemLock
mov ds, ax
fsave ds:[0]
fwait
call MemUnlock
.leave
ret
Intel80X87SaveState endp
public Intel80X87SaveState
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87GetHardwareStackSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get the size of the hardware stack
CALLED BY: Math Library
PASS: nothing
RETURN: cx = size of hardware stack
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87GetHardwareStackSize proc far
.enter
mov cx, INTEL_STACK_SIZE
.leave
ret
Intel80X87GetHardwareStackSize endp
public Intel80X87GetHardwareStackSize
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87GetEnvSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get the size of the environment (state) of the coprocessor
CALLED BY: Math Library
PASS: nothing
RETURN: cx = size in bytes
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/29/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87GetEnvSize proc far
.enter
mov cx, INTEL_ENV_SIZE
.leave
ret
Intel80X87GetEnvSize endp
public Intel80X87GetEnvSize
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87DoHardwareInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: do an actual hardware init
CALLED BY: Math Library
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/29/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87DoHardwareInit proc far
.enter
finit
fwait
.leave
ret
Intel80X87DoHardwareInit endp
public Intel80X87DoHardwareInit
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87SetStackSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: set the stack size
CALLED BY: GLOBAL
PASS: ax
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 6/19/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87SetStackSize proc far
.enter
cmp ax, INTEL_STACK_SIZE
jle done
sub ax, INTEL_STACK_SIZE
call FloatSetStackSizeInternal
done:
.leave
ret
Intel80X87SetStackSize endp
public Intel80X87SetStackSize
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Minus1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a negative one on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: return carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Minus1 proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld1
fchs
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Minus1 endp
public Intel80X87Minus1
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87MinusPoint5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a -.5 on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: return carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
int87PointFive dword 0x3f000000
Intel80X87MinusPoint5 proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld cs:[int87PointFive]
fchs
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87MinusPoint5 endp
public Intel80X87MinusPoint5
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87LoadFPUConst
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Co-routine to load a constant that's stored in the
coprocessor.
CALLED BY: (INTERNAL)
PASS: nothing
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 1/13/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87LoadFPUConst proc near
push bp
mov bp, sp
push ax
mov ax, 1
call FloatHardwareEnter
jc done
push cs
call {word}ss:[bp+2]
clr ax
call FloatHardwareLeave
done:
pop ax
pop bp
inc sp
inc sp
retf
Intel80X87LoadFPUConst endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Zero
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a zero on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: return carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Zero proc far
call Intel80X87LoadFPUConst
fldz
ret
Intel80X87Zero endp
public Intel80X87Zero
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Point5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a .5 on the FP stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Point5 proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld cs:[int87PointFive]
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Point5 endp
public Intel80X87Point5
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87One
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a 1 on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87One proc far
call Intel80X87LoadFPUConst
fld1
ret
Intel80X87One endp
public Intel80X87One
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87LoadIntConst
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Load an integer constant onto the FP stack
CALLED BY: (INTERNAL)
PASS: at return address: word constant to load
RETURN: carry set on overflow:
ax = error code
carry clear if ok:
ax = destroyed
constant on stack
RETURNS TO CALLER'S CALLER
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 1/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87LoadIntConst proc near
on_stack retn
pop ax
on_stack ret=ax
push bx
mov_tr bx, ax
on_stack ret=bx
mov ax, 1
call FloatHardwareEnter
jc done
fild {word}cs:[bx]
dec ax ; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
pop bx
retf
Intel80X87LoadIntConst endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Two
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a two on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Two proc far
call Intel80X87LoadIntConst
.unreached
int87Two word 2
Intel80X87Two endp
public Intel80X87Two
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Five
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a five on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Five proc far
call Intel80X87LoadIntConst
.unreached
word 5
Intel80X87Five endp
public Intel80X87Five
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Ten
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a ten on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Ten proc far
call Intel80X87LoadIntConst
.unreached
int87Ten word 10
Intel80X87Ten endp
public Intel80X87Ten
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87_3600
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a 3600 on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87_3600 proc far
call Intel80X87LoadIntConst
.unreached
word 3600
Intel80X87_3600 endp
public Intel80X87_3600
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87_16384
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a 16384 pn the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87_16384 proc far
call Intel80X87LoadIntConst
.unreached
word 16384
Intel80X87_16384 endp
public Intel80X87_16384
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87_86400
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a 86400 on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
eightysixThousandFourHundred dword 86400
Intel80X87_86400 proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fild cs:[eightysixThousandFourHundred]
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87_86400 endp
public Intel80X87_86400
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Abs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = abs(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Abs proc far
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fabs
call FloatHardwareLeave ; (ax still 0)
done:
.leave
ret
Intel80X87Abs endp
public Intel80X87Abs
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Add
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st + st(1)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if any bad values
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Add proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fadd
dec ax ; ax <- -1 (one value popped)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Add endp
public Intel80X87Add
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcCos
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arccos(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if st a NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
; the hardware only does an arctan so we must convert
; arccos(x) = arctan(sqrt((1-x^2)/x^2))
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcCos proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
; compute the arcsin
call Intel80X87ArcSinInternal
; arccos(x) = pi/2 - arcsin(x)...
fldpi
fidiv cs:[int87Two]
fsubrp
neg ax ; (ax still 2)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcCos endp
public Intel80X87ArcCos
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcCosh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arccosh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
; the hardware only does ln, so convert
;arccosh(x) = ln(x+sqrt(x^2 - 1))
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcCosh proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st
fmul st ; st <- st^2
fld1
fsubp ; st <- st^2-1
fsqrt
faddp ; st <- x+sqrt(x^2 - 1)
fldln2
fxch st(1)
fyl2x
neg ax ; (ax still 2)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcCosh endp
public Intel80X87ArcCosh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcTanInternal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: do an partial arctan making sure both args are positive
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY: if neither or both args rae positive just do it
else do it to the absolute values and change the sign
of the answer
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 3/12/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcTanInternal proc near
uses bx, ax
.enter
clr bx
ftst
StatusToAX
test ax, mask SW_CONDITION_CODE_0 ; see if its negative
jz tstTwo
fabs
inc bx
tstTwo:
fxch
ftst
StatusToAX
test ax, mask SW_CONDITION_CODE_0 ; see if its negative
jz unswap
fabs
dec bx
unswap:
fxch
fpatan
tst bx
jz done
fchs
done:
.leave
ret
Intel80X87ArcTanInternal endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcSinInternal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Compute the arcsin of st
CALLED BY: (INTERNAL) Intel80X87ArcSin, Intel80X87ArcCos
PASS: st = number of which to take arcsin
2 slots in fpu stack reserved
RETURN: st = arcsin(st)
DESTROYED: nothing
SIDE EFFECTS: none
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 1/13/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcSinInternal proc near
.enter
EC < call Intel80X87Check1Arg >
fld st ; (fp: x x)
fmul st, st(1) ; (fp: x x^2)
fld1 ; (fp: x x^2 1)
fsubrp ; (fp: x 1-x^2)
fsqrt ; (fp: x sqrt(1-x^2))
call Intel80X87ArcTanInternal
; fpatan ; (fp: arctan(x/sqrt(1-x^2)))
.leave
ret
Intel80X87ArcSinInternal endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcSin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arcsin(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
arcsin(x) = arctan(x/sqrt(1-x^2))
the fpatan instruction nicely performs the divide for us,
so take advantage of it by saving x, then computing just
sqrt(1-x^2) and using fpatan
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcSin proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
call Intel80X87ArcSinInternal
neg ax ; (ax still 2)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcSin endp
public Intel80X87ArcSin
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcSinh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arcsinh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
; arcsinh(x) = ln(x+sqrt(x^2+1))
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcSinh proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st ; FloatDup
fmul st, st(1) ; FloatSqr
fld1
faddp ; x x^2+1
fsqrt
faddp ; x+sqrt(x^2+1)
fldln2 ; now figure the natural log of that
fxch st(1)
fyl2x
neg ax ; (ax still 2)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcSinh endp
public Intel80X87ArcSinh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcTan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arctan(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcTan proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld1
call Intel80X87ArcTanInternal
; fpatan
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcTan endp
public Intel80X87ArcTan
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcTan2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arctan(st(1)/st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
x y result
--- --- ---------
+ + 0 to PI/2
- + PI/2 to PI
- - -PI to -PI/2
+ - -PI/2 to 0
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcTan2 proc far
uses bx, cx
.enter
clr ax
mov cx, ax ; cx will be the quadrant
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fxch ; must match software interface
; we need to check the four cases so as to return an answer in the
; proper quadrant
ftst
StatusToAX
mov_tr bx, ax ; save status in bx
fxch
ftst
StatusToAX
fxch ; swap back
test bx, mask SW_CONDITION_CODE_0
jnz xneg
test ax, mask SW_CONDITION_CODE_0
jnz xpos_yneg
; ok, both non-negative, if both zero return error
test bx, mask SW_CONDITION_CODE_3
jz arcTan
test ax, mask SW_CONDITION_CODE_3
jz arcTan
fdivp ; creates an error value on the stack
jmp leaveHardware
xpos_yneg:
mov cx, 3 ; 3rd quadrant
jmp arcTan
xneg:
test ax, mask SW_CONDITION_CODE_0
jnz xneg_yneg
; xneg_ypos
mov cx, 1
jmp arcTan
xneg_yneg:
mov cx, 2
arcTan:
call Intel80X87ArcTanInternal
jcxz leaveHardware
cmp cx, 1
jne try2
fldpi
faddp ; add PI to get into proper quadrant
jmp leaveHardware
try2:
cmp cx, 2
jne leaveHardware ; if in last quadrant, answer already OK
fldpi
fsubp ; subract PI to get into proper quadrant
jmp leaveHardware
leaveHardware:
mov ax, -1
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcTan2 endp
public Intel80X87ArcTan2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87ArcTanh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = arctanh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
; arctanh(x) = ln((1+x)/(1-x))/2
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87ArcTanh proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld1
fxch
fsub st(1), st ; ( 1-x x )
fld1
faddp ; ( 1-x 1+x )
fdivrp ; ( 1+x/1-x )
fldln2
fxch st(1)
fyl2x ; ( ln(1-x/1+x) )
fild cs:[int87Two] ; divide that by 2
fdivp
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87ArcTanh endp
public Intel80X87ArcTanh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87CompAndDrop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: compare st(1), st
CALLED BY: GLOBAL
PASS: X1, X2 on the fp stack (X2 = top)
RETURN: flags set by what you may consider to be a cmp X1,X2
both numbers are popped off
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87CompAndDrop proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fxch
fcompp
StatusToAX
push ax
mov ax, -2
call FloatHardwareLeave
pop ax
call Intel80X87DoFlags
done:
.leave
ret
Intel80X87CompAndDrop endp
public Intel80X87CompAndDrop
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Comp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: compare st, st(1)
CALLED BY: GLOBAL
PASS: X1, X2 on the fp stack (X2 = top)
RETURN: flags set by what you may consider to be a cmp X1,X2
numbers are left intact
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Comp proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fxch
fcom
StatusToAX
fxch
push ax
clr ax
call FloatHardwareLeave
pop ax
call Intel80X87DoFlags
done:
.leave
ret
Intel80X87Comp endp
public Intel80X87Comp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87CompESDI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: compare the top number on the fp stack to a floating
point number located as es:di
CALLED BY: GLOBAL
PASS: nothing
RETUN: if ax = 0, regs set as if a normal compare was done
else error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/30/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87CompESDI proc far
.enter
mov ax, 1 ; need one slot
call FloatHardwareEnter
jc done
fld {FloatNum}es:[di] ; push the beast
fcomp
StatusToAX
call Intel80X87DoFlags
pushf
mov ax, -1
call FloatHardwareLeave
clr ax
popf
done:
.leave
ret
Intel80X87CompESDI endp
public Intel80X87CompESDI
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Cosh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = cosh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
; cosh(x) = (exp(x) + exp(-x)) /2
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Cosh proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fldl2e
fmulp
call Intel80X87_2ToTheX ; ( e^x )
fld1 ; ( e^x 1 )
fld st(1) ; ( e^x 1 e^x )
fdivp ; ( e^x 1/e^x )
faddp ; ( e^x+1/e^x )
fild cs:[int87Two] ; ( e^x+1/e^x 2 )
fdivp
neg ax ; (ax still 2)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Cosh endp
public Intel80X87Cosh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Depth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get the stack depth
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax = depth
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Depth proc far
uses cx
.enter
clr ax
call FloatHardwareEnter
jc done
call FloatGetStackDepth
clr cx
xchg ax, cx
call FloatHardwareLeave
xchg ax, cx
done:
.leave
ret
Intel80X87Depth endp
public Intel80X87Depth
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87DIV
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: do an integer divide (ie divide and truncate)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
ax = error information if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87DIV proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fdiv
call Intel80X87TruncInternal
dec ax ; 1 popped (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87DIV endp
public Intel80X87DIV
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87CheckNormalNumberAndLeave
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: sees if a number is normal or not
CALLED BY: GLOBAL
PASS: number to check on top of FP stack
RETURN: carry set on a NON normal number
al = FloatErrorType
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
from The Processor and CoProcessor page 715:
condition flags: c3 c2 c1 c0
0 0 0 0 +Unnormal
0 0 1 0 -Unnormal
0 0 0 1 +Nan
0 0 1 1 -Nan
0 1 0 0 +Normal
0 1 1 0 -Normal
0 1 0 1 +INFINITY
0 1 1 1 -INFINITY
1 0 0 0 +0.0
1 0 1 0 -0.0
1 0 0 1 Empty
1 0 1 1 Empty
1 1 0 0 +Denormal
1 1 1 0 -Denormal
1 1 0 1 Empty 8087, 80187 only
1 1 1 1 Empty 8087, 80187 only
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 9/14/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87CheckNormalNumberAndLeave proc far
uses bx
.enter
mov_tr bx, ax
fxam
StatusToAX
test ax, mask SW_CONDITION_CODE_3
jnz c3_on
test ax, mask SW_CONDITION_CODE_2
jz genErr
test ax, mask SW_CONDITION_CODE_0
jz normal
test ax, mask SW_CONDITION_CODE_1
jz posINF
mov al, FLOAT_NEG_INFINITY
jmp notNormal
posINF:
mov al, FLOAT_POS_INFINITY
jmp notNormal
c3_on:
test ax, mask SW_CONDITION_CODE_2
jnz genErr
test ax, mask SW_CONDITION_CODE_0
jnz genErr
normal:
clc
done:
pushf
xchg ax, bx
call FloatHardwareLeave
mov_tr ax, bx
popf
.leave
ret
genErr:
mov al, FLOAT_GEN_ERR
notNormal:
stc
jmp done
Intel80X87CheckNormalNumberAndLeave endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Divide
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st(1) / st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
ax = error info in carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Divide proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fdiv
dec ax ; one popped (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Divide endp
public Intel80X87Divide
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Divide2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st/2
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Divide2 proc far
uses ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fild cs:[int87Two]
fdivp
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Divide2 endp
public Intel80X87Divide2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Divide10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st/10
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on NAN or infinity
ax = error info if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Divide10 proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fild cs:[int87Ten]
fdivp
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Divide10 endp
public Intel80X87Divide10
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Drop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: pop off top of fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: nothing
DESTROYED: nothing (flags preserved)
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Drop proc far
uses ax
.enter
pushf
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fstp st
dec ax ; (ax still 0)
call FloatHardwareLeave
done:
popf
.leave
ret
Intel80X87Drop endp
public Intel80X87Drop
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Dup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: duplicate the top of the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on overflow
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Dup proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st
clr ax
call FloatHardwareLeave
done:
.leave
ret
Intel80X87Dup endp
public Intel80X87Dup
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Eq0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: compare the top of the fp stack to zero
CALLED BY: GLOBAL
PASS: nothing
RETURN: flags set to appropriate values
should check jp first, if on non comparable
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Eq0 proc far
status local word
uses ax
.enter
mov ax, 0
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
ftst
fstsw status
fstp st ; pop the number
dec ax ; (ax still 0)
call FloatHardwareLeave
mov ax, status
sahf
stc
je done
clc
done:
.leave
ret
Intel80X87Eq0 endp
public Intel80X87Eq0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Exp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = e^st
CALLED BY: GLOBAL
PASS: nothing
RETURN: return carry in result NAN or Infinity
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Exp proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fldl2e
fmulp
call Intel80X87_2ToTheX
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Exp endp
public Intel80X87Exp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Exponential
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st(1)^st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
ax = error info if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
st(1)^st = 2^(st*lg(st(1)))
if the base is a negative number then the exponent must be
an integer...
if the base is zero we must also have it as a special case
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Exponential proc far
temp local word
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fxch ; st = base, st(1) = exponent
ftst
StatusToAX
test ax, mask SW_CONDITION_CODE_2
jnz error ; => it's NaN or
test ax, mask SW_CONDITION_CODE_0 ; is it negative
jnz doBaseNegative
test ax, mask SW_CONDITION_CODE_3
jnz doBaseZero
fyl2x
call Intel80X87_2ToTheX
done:
mov ax, -3 ;
call Intel80X87CheckNormalNumberAndLeave
exit:
.leave
ret
error:
; on an error we still need to clean up and release the coprocessor
mov ax, -3
call FloatHardwareLeave
mov ax, FLOAT_GEN_ERR
stc
jmp exit
doBaseZero:
; if the exponent is a NAN or negative report an error
; if the exponent is 0, the result is 1
; if the exponent is > 0 then the result is zero
fxch
ftst
StatusToAX
test ax, mask SW_CONDITION_CODE_2 or mask SW_CONDITION_CODE_0
jnz error ; => it's NaN or
test ax, mask SW_CONDITION_CODE_3 ; is it zero
jnz doOne
fstp st
fstp st
fldz ; 0^X for X > 0 = 0
jmp done
doOne:
fstp st
fstp st
fld1 ; load 1 onto the stack
jmp done
doBaseNegative:
fxch ; get the exponent back on top
; if the base is negative, then the exponent must be an integer
fld st ; dupluicate
frndint ; round the number and see ifs equal
fcomp ; comapare and pop off extra value
StatusToAX
test ax, mask SW_CONDITION_CODE_2
jnz error
test ax, mask SW_CONDITION_CODE_3
jz error
; what needs to happen here is that we do a x^y with negative x
; and then just change the sign of the final answer depending on
; whether y was even or odd...
fld st
mov temp, 2
fild temp
fdivp ; divide by two and see if we get an integer
fld st
frndint
fcompp
StatusToAX
mov temp, ax ; save away
fxch ; unswap things
fchs ; change the sign to positive
fyl2x
call Intel80X87_2ToTheX
test temp, mask SW_CONDITION_CODE_3
jnz done
fchs
jmp done
Intel80X87Exponential endp
public Intel80X87Exponential
COMMENT @-----------------------------------------------------------------------
FUNCTION: Intel80X87FloatToAscii
DESCRIPTION: Converts the floating point number into an ASCII string.
This routine requires that you initialize the FFA_stackFrame.
CALLED BY: GLOBAL ()
PASS: ss:bp - FFA_stackFrame stack frame
es:di - destination address of string
this buffer must either be FLOAT_TO_ASCII_NORMAL_BUF_LEN or
FLOAT_TO_ASCII_HUGE_BUF_LEN in size (see math)
If FFA_stackFrame.FFA_FROM_ADDR = 1
ds:si - location of number to convert
NOTE:
-----
* Numbers are rounded away from 0.
eg. if number of fractional digits desired = 1,
0.56 will round to 1
-0.56 will round to -1
* Commas only apply to the integer portion of fixed and
percentage format numbers.
ie. scientific formats, the fractional and exponent portions
of numbers will have no commas even if FFAF_USE_COMMAS is
passed.
RETURN: cx - number of characters in the string
(excluding the null terminator)
some useful fields in the stack frame, see math.def
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
FloatFloatToAscii is a big body of code!
A FloatFloatToAsciiFixed routine exists to format fixed format numbers
quickly. Some demands may exceed its ability, so once this is detected,
it bails and the generalized (& significantly slower) FloatFloatToAscii
routine takes over.
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/92 Initial version
-------------------------------------------------------------------------------@
Intel80X87FloatToAscii proc far
FFA_local local FFA_stackFrame
.enter inherit far
push ax, bx, ds, si
mov ax, 0
call FloatHardwareEnter
jc done
sub sp, size FloatNum
test FFA_local.FFA_float.FFA_params.formatFlags, mask FFAF_FROM_ADDR
jnz cont
mov bx, sp
fstp {FloatNum}ss:[bx]
fwait
segmov ds, ss, si
mov si, sp
or FFA_local.FFA_float.FFA_params.formatFlags, mask FFAF_FROM_ADDR
mov ax, -1
cont:
call FloatFloatToAsciiInternal
add sp, size FloatNum
call FloatHardwareLeave
done:
pop ax, bx, ds, si
.leave
ret
Intel80X87FloatToAscii endp
public Intel80X87FloatToAscii
COMMENT @-----------------------------------------------------------------------
FUNCTION: Intel80X87FloatToAscii_StdFormat
DESCRIPTION: Converts the floating point number into an ASCII string
in the format specified by al.
This routine provides a way to obtain an ASCII string from
a floating point number without having to deal with the
FFA_stackFrame.
!!! NOTE !!!
Rounding is based on decimalDigits and not total Digits.
CALLED BY: GLOBAL ()
PASS: ax - FloatFloatToAsciiFormatFlags
Flags permitted:
FFAF_FROM_ADDR - source of number
If FFAF_FROM_ADDR=1,
Use the number at the given address
ds:si - location
If FFAF_FROM_ADDR=0,
Use number from the fp stack.
Number will be popped
FFAF_SCIENTIFIC - scientific format
If FFAF_SCIENTIFIC=1,
Returns numbers in the form x.xxxE+xxx
in accordance with bh and bl
Numbers are normalized ie. the mantissa m satisfies
1 <= m < 10
If FFAF_SCIENTIFIC=0,
Returns numbers in the form xxx.xxx
in accordance with bh and bl
FFAF_PERCENT - percentage format
Returns numbers in the form xxx.xxx%
in accordance with bh and bl
FFAF_USE_COMMAS
FFAF_NO_TRAIL_ZEROS
bh - number of significant digits desired (>=1)
(A significant digit is a decimal digit derived from
the floating point number's mantissa and it may preceed
or follow a decimal point).
Fixed format numbers that require more digits than limited
will be forced into scientific notation.
bl - number of fractional digits desired (ie. number of
digits following the decimal point)
es:di - destination address of string
this buffer must either be FLOAT_TO_ASCII_NORMAL_BUF_LEN or
FLOAT_TO_ASCII_HUGE_BUF_LEN in size (see math.def)
NOTE:
-----
* Numbers are rounded away from 0.
eg. if number of fractional digits desired = 1,
0.56 will round to 1
-0.56 will round to -1
* Commas only apply to the integer portion of fixed and
percentage format numbers.
ie. scientific formats, the fractional and exponent portions
of numbers will have no commas even if FFAF_USE_COMMAS is
passed.
RETURN: cx - number of characters in the string
(excluding the null terminator)
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
if from address than just call the routine
otherwise take the top of the hardware stack
put in memory and then call the routine
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/92 Initial version
-------------------------------------------------------------------------------@
Intel80X87FloatToAscii_StdFormat proc far
myfloat local FloatNum
doLeave local word
uses ds, si, ax
.enter
clr doLeave
test ax, mask FFAF_FROM_ADDR
jnz cont
mov doLeave, 1
push ax
clr ax
call FloatHardwareEnter
pop ax
jc done
fstp myfloat
segmov ds, ss, si
lea si, myfloat
or ax, mask FFAF_FROM_ADDR
fwait
cont:
call FloatFloatToAscii_StdFormatInternal
tst doLeave
jz done
mov ax, -1
call FloatHardwareLeave
done:
.leave
ret
Intel80X87FloatToAscii_StdFormat endp
public Intel80X87FloatToAscii_StdFormat
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Factorial
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st!
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Factorial proc far
myint32 local dword
uses cx
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fistp myint32
fwait
tst myint32.high
jnz error
mov ax, myint32.low
cmp ax, FACTORIAL_LIMIT
jg error
tst ax
jnz cont
fld1
jmp checkStatus
cont:
mov cx, ax
call Intel80X87DoFactorial
checkStatus:
mov ax, -2
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
error:
call Intel80X87Err
jmp checkStatus
Intel80X87Factorial endp
public Intel80X87Factorial
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87DoFactorial
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: do the actual factorial function
CALLED BY: INTERNAL
PASS: cx = integer form of value on top of stack
RETURN: Void.
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87DoFactorial proc near
.enter
fld1 ; partial result
fld1 ; start from 1
factorialloop:
fmul st(1) ; st(1) = partial result
fld1 ; st += 1
faddp
loop factorialloop
fstp st ; get rid of temp value
.leave
ret
Intel80X87DoFactorial endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Frac
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = fractionalpart(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on bad value
ax = error info if bad value
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Frac proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st
call Intel80X87TruncInternal
fsubp
fabs
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Frac endp
public Intel80X87Frac
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87GetNumDigitsInIntegerPart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get number of digits of integer part on number on fp stack
number gets pooped off
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax = number of digits in integer part
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87GetNumDigitsInIntegerPart proc far
myfloat local FloatNum
uses bx, es, ds, si
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
call FloatGetSoftwareStackHandle
call MemLock
mov es, ax
fstp myfloat
segmov ds, ss, si
lea si, myfloat
fwait
call FloatPushNumberInternal
segmov ds, es ; ds <- FP stack
call FloatGetNumDigitsInIntegerPartInternal
call MemUnlock
push ax
mov ax, -1
call FloatHardwareLeave
pop ax
done:
.leave
ret
Intel80X87GetNumDigitsInIntegerPart endp
public Intel80X87GetNumDigitsInIntegerPart
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Gt0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: test top of fp stack against zero
CALLED BY: GLOBAL
PASS: nothing
RETURN: flags set to appropriate values
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Gt0 proc far
status local word
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
ftst
fstsw status
fstp st
dec ax ; (ax still 0)
call FloatHardwareLeave
jc done
mov ax, status
sahf
cmc ; invert the sense (was set if neg, clear if non-neg)
jne done ; this means we have to deal with eq 0 specially...
clc ; it ain't > 0
done:
.leave
ret
Intel80X87Gt0 endp
public Intel80X87Gt0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Int
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = INT(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: ax.
PSEUDOCODE/STRATEGY: round towards -Infinity so:
6.7 -> 6
-6.7 -> -7
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Int proc far
control local word
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fstcw control
fwait ; wait for it to arrive
mov ax, control
andnf ax, not mask CW_ROUND_CONTROL
ornf ax, RC_DOWN shl offset CW_ROUND_CONTROL
mov control, ax
fldcw control
frndint
call Intel80X87SetNearest
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Int endp
public Intel80X87Int
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87IntFrac
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: leaves integer and fractional part of top of fp stack
on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87IntFrac proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st
call Intel80X87TruncInternal
fsub st(1), st ; st(1) <- frac
fxch st(1) ; st <- frac, st(1) <- int
fabs
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87IntFrac endp
public Intel80X87IntFrac
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Inverse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = 1/st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on bad values
ax = error info if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Inverse proc far
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld1
fdivrp
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
ret
Intel80X87Inverse endp
public Intel80X87Inverse
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Lg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = lg(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on bad values
ax = error info if carry set
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Lg proc far
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld1
fxch st(1)
fyl2x
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
ret
Intel80X87Lg endp
public Intel80X87Lg
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Lg10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = lg(10)
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/22/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Lg10 proc far
call Intel80X87LoadFPUConst
fldl2t
ret
Intel80X87Lg10 endp
public Intel80X87Lg10
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Ln
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = ln(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Ln proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fldln2
fxch st(1)
fyl2x
neg ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Ln endp
public Intel80X87Ln
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Ln1plusX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = ln(st+1)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
used to use the fyl2xp1 instruction, but its domain is
too restrictive (-(1-sqrt(2)/2) <= st <= sqrt(2)-1), so
we just perform the addition and take the natural log
in the usual way.
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Ln1plusX proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld1
faddp
fldln2
fxch st(1)
fyl2x
neg ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Ln1plusX endp
public Intel80X87Ln1plusX
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Ln2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = ln(2)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Ln2 proc far
call Intel80X87LoadFPUConst
fldln2
ret
Intel80X87Ln2 endp
public Intel80X87Ln2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Ln10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a ln(10) on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Ln10 proc far
.enter
mov ax, 2
call FloatHardwareEnter
jc done
fldln2
fldl2t
fmulp
mov ax, -1
call FloatHardwareLeave
done:
.leave
ret
Intel80X87Ln10 endp
public Intel80X87Ln10
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Log
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = log(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Log proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fldlg2
fxch st(1)
fyl2x
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Log endp
public Intel80X87Log
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Lt0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: sees if top of fp stack is less than zero
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if true, clear if otherwise
top of stack popped off
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/21/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Lt0 proc far
status local word
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
ftst
fstsw status
fstp st ; pop the number
dec ax ; (ax still 0)
call FloatHardwareLeave
mov ax, status
sahf
jb done ; => negative (carry already set)
clc
done:
.leave
ret
Intel80X87Lt0 endp
public Intel80X87Lt0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Max
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: do max of top two stack elements
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Max proc far
.enter
clr ax
call FloatHardwareEnter
jc exit
EC < call Intel80X87Check2Args >
fcom
StatusToAX
sahf
jp error
jb dropTop
fxch
dropTop:
fstp st
clc
done:
mov ax, -1
call Intel80X87CheckNormalNumberAndLeave
exit:
.leave
ret
error:
stc
jmp done
Intel80X87Max endp
public Intel80X87Max
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Min
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: takes min of top two elements of fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Min proc far
.enter
clr ax
call FloatHardwareEnter
jc exit
EC < call Intel80X87Check2Args >
fcom
StatusToAX
sahf
jp error
ja dropTop
fxch
dropTop:
fstp st
clc
done:
mov ax, -1
call Intel80X87CheckNormalNumberAndLeave
exit:
.leave
ret
error:
stc
jmp done
Intel80X87Min endp
public Intel80X87Min
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FUNCTION: Float2Scale (originally /2SCALE)
DESCRIPTION: Multiply the topmost fp num by the given factor of 2.
( N --- )( fp: X --- X*2^N )
CALLED BY: INTERNAL (FloatSqrt, FloatExpC, FloatExp)
PASS: bx - factor of 2 to multiply number by
X on fp stack
RETURN: X*2^N on fp stack
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87_2Scale proc near
factor local word push bx
.enter
EC< call Intel80X87Check1Arg >
fild ss:[factor]
fxch
fscale
fstp st(1) ; pop st(1) (the scale factor)
.leave
ret
Intel80X87_2Scale endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FUNCTION: FloatSign (originally /FSIGN)
DESCRIPTION: Returns the exponent of the topmost fp number.
This exponent has these convenient properties:
* positive if the number is positive
* 0 if the number is zero (+ or - 0)
* negative if the number is negative
( fp: X --- X )
CALLED BY: INTERNAL (many)
PASS: X on fp stack
ds - fp stack seg
RETURN: X unchanged on fp stack
bx - negative if fp number is negative
non-negative otherwise
flags set by a "cmp bx, 0"
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Sign proc near
myfloat local FloatNum
uses si
.enter
EC< call Intel80X87Check1Arg >
fstp myfloat
fld myfloat
mov bx, myfloat.F_exponent ; get exponent
cmp bx, 8000h ; negative 0?
jne done
clr bx ; change -0 to 0
done:
cmp bx, 0
fwait ; make sure FPU done with myfloat before
; destroying it
.leave
ret
Intel80X87Sign endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Mod
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = MOD(st, ST(1))
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
the algorithm is effectively:
for (n = exponent(div)-exponent(mod); n >= 0; n--) {
if (div >= mod*2**n) {
div -= mod*2**n;
}
}
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Mod proc far
uses di, bx, cx
.enter
mov ax, 2 ; need two extra slots (one for copy of
; mod, and one for 2Scale)
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
;
; Fetch exponent of modulus after making modulus non-negative.
;
fabs
call Intel80X87Sign
je cleanStack ; error if exponent (i.e. modulus) is 0
;
; Fetch exponent of dividend, saving the sign away for proper
; adjustment of the result.
;
; NOTE: in these comments exp(x) means the exponent word of the number
; x, not e^x.
;
mov cx, bx ; cx <- exp(abs(X2))
fxch
call Intel80X87Sign
mov di, bx ; di <- exp(X1)
fabs
andnf bx, not mask FE_SIGN ; bx <- exp(abs(X1))
;
; bx = exp(abs(X1)), di = exp(X1), cx = exp(abs(X2))
;
cmp cx, bx ; X2 > X1 ?
jg modGotten ; branch if so (X1/X2 < 1, so X1 is
; remainder)
;
; cx <= bx, exp(abs(X2)) <= exp(abs(X1))
;
sub cx, bx
neg cx
modLoop:
fld st(1)
mov bx, cx
call Intel80X87_2Scale ; scale modulus by 2^n
fcom ; cmp mod*2^n, div
StatusToAX
sahf
jbe doSub ; subtract mod*2^n from div if it's
; less than div. results are
fstp st ; else discard scaled modulus
jmp over ; and loop
doSub:
fsub
over:
dec cx
cmp cx, 0
jge modLoop
modGotten:
tst di ; exp X1 < 0 ?
jge signOK
fchs
signOK:
fxch
fstp st
clc
done:
pushf
mov ax, -3 ; extra slots, plus modulus now
; gone
call Intel80X87CheckNormalNumberAndLeave
jc nonnormal
popf
exit:
.leave
ret
nonnormal:
inc sp
inc sp
jmp exit
cleanStack:
fstp st
fstp st
stc
jmp short done
Intel80X87Mod endp
public Intel80X87Mod
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Multiply
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st(1) = st*st(1)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 4/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Multiply proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fmul
dec ax ; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Multiply endp
public Intel80X87Multiply
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Multiply2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = 2 * st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if any problems
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/29/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Multiply2 proc far
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
fimul cs:[int87Two]
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Multiply2 endp
public Intel80X87Multiply2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Multiply10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = 10*st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set if an problems
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/29/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Multiply10 proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fimul cs:[int87Ten]
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Multiply10 endp
public Intel80X87Multiply10
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Negate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = -st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Negate proc far
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fchs
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Negate endp
public Intel80X87Negate
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Over
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: copy the second number on the fp stack onto the
top of the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Over proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fld st(1)
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
.leave
done:
ret
Intel80X87Over endp
public Intel80X87Over
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Pi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: push pi onto fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 4/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Pi proc far
call Intel80X87LoadFPUConst
fldpi
ret
Intel80X87Pi endp
public Intel80X87Pi
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87PiDiv2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: puts a pi/2 on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87PiDiv2 proc far
call Intel80X87LoadFPUConst
fldpi
fidiv cs:[int87Two]
ret
Intel80X87PiDiv2 endp
public Intel80X87PiDiv2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Pick
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: takes the nth stack element and copies it onto the
top of the stack
CALLED BY: GLOBAL
PASS: bx = which element (n) to select
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Pick proc far
myfloat local FloatNum
uses cx, bx
.enter
EC < tst bx >
EC < ERROR_Z MUST_BE_GREATER_THAN_ZERO >
EC < call FloatGetStackDepth >
EC < cmp bx, ax >
EC < ERROR_G INSUFFICIENT_ARGUMENTS_ON_STACK >
mov ax, 1
call FloatHardwareEnter
jc done
cmp bx, INTEL_STACK_SIZE
jge getFromSoftware
dec bx ; start from 0
shl bx
jmp cs:[fpRegisters][bx]
reg0:
fld st
jmp done
reg1:
fld st(1)
jmp done
reg2:
fld st(2)
jmp done
reg3:
fld st(3)
jmp done
reg4:
fld st(4)
jmp done
reg5:
fld st(5)
jmp done
reg6:
fld st(6)
jmp done
reg7:
fld st(7)
done:
clr ax
call FloatHardwareLeave
.leave
ret
fpRegisters nptr reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7
getFromSoftware:
; if it's in the software stack, copy it to the top
; of the software stack using FloatPick and
; then pop it off the software stack and push it
; onto the hardware stack
push ds, es, di
mov cx, bx
; we need to increment cx because we slid one of the numbers down
; from hardware to software to make room for the new one
inc cx
call FloatGetSoftwareStackHandle
call MemLock
mov ds, ax
sub cx, INTEL_STACK_SIZE
xchg bx, cx ; bx <- number to pick, cx = mem handle
call FloatPickInternal
segmov es, ss
lea di, myfloat
call FloatPopNumberInternal
mov_tr bx, cx ; bx <- mem handle
call MemUnlock
fld myfloat
pop ds, es, di
jmp done
Intel80X87Pick endp
public Intel80X87Pick
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87PopNumber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: pops the top off of the fp stack
CALLED BY: GLOBAL
PASS: es:di = location to write number to (10 bytes)
RETURN: carry set on error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87PopNumber proc far
uses ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fstp {FloatNum}es:[di]
fwait
dec ax ; (ax still 0)
call FloatHardwareLeave
done:
.leave
ret
Intel80X87PopNumber endp
public Intel80X87PopNumber
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87PushNumber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: push a number onto the fp stack
CALLED BY: GLOBAL
PASS: ds:si = number to push
RETURN: carry set on error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87PushNumber proc far
uses ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld {FloatNum}ds:[si]
dec ax ; (ax still 0)
call FloatHardwareLeave
done:
.leave
ret
Intel80X87PushNumber endp
public Intel80X87PushNumber
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Random
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a random number on the fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDO CODE/STRATEGY:
We want to generate a number such that a list of such generated numbers
will satisfy all of the statistical tests that a random sequence
would satisfy.
Algorithm taken from Knuth Vol 2 Chapter 3 - Random Numbers
-----------------------------------------------------------
The linear congruential method:
The detailed investigations suggest that the following procedure
will generate "nice" and "simple" random numbers. At the beginning
of the program, set an integer variable X to some value Xo. This
variable X is to be used only for the purpose of random number
generation. Whenever a new random number is required by the program,
set
X <- (aX + c) mod m
and use the new value of X as the random value. It is necessary to
choose Xo, a, c, and m properly, according to the following principles:
1) The "seed" number Xo may be chosen arbitrarily. We use the
current date and time since that is convenient.
2) The number m should be large, say at least 2^30. The computation
of (aX + c)mod m must be done exactly, with no roundoff error.
3) If m is a power of 2, pick a so that a mod 8 = 5.
If m is a power of 10, choose a so that a mod 200 = 21.
The choice of a together with the choice of c given below
ensures that the random number generator will produce all
m different possible values of X before it starts to repeat
and ensures high "potency".
4) The multiplier a should preferably be chosen between 0.01m
0.99m, and its binary or decimal digits should not have a simple
regular pattern. By choosing a = 314159261 (which satisfies
both of the conditions in 3), one almost always obtains a
reasonably good multiplier. There are several tests that can
be performed before it is considered to have a truly clean
bill of health.
5) The value of c is immaterial when a is a good multiplier,
except that c must have no factor in common with m.
Thus we may choose c=1 or c=a.
6) The least significant digits of X are not very random, so
decisions based on the number X should always be influenced
primarily by the most significant digits.
It is generally best to think of X as a random fraction
between 0 and 1. To compute a random integer between 0
and k-1, one should multiply by k and truncate the result.
Implementation notes:
---------------------
Desirable properties:
* the same seed generates the same sequence of random numbers
* 2 different threads accessing the routine will not lose
their "place" in the random number sequence. This is important
because the property of Uniform Distribution will be adversely
affected if one thread's behaviour can alter the next number
seen by another thread.
This "state" is wholly represented by X since the other
parameters a, c, and m are hardwired in the code. The
question then is where to save X. We can force the user
to preserve X on the floating point stack but that may
be inconvenient because the caller will then have to
place calls to FloatDup to duplicate the number and pop
it off when done.
We instead save X in the floating point stack header.
This costs 5 words and it seems affordable.
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Random proc far
myfloat local FloatNum
uses es, bx, di, ds
.enter
mov ax, 1
call FloatHardwareEnter
jc done
call FloatGetSoftwareStackHandle
call MemLock
mov ds, ax
call FloatRandomInternal
segmov es, ss
lea di, myfloat
call FloatPopNumberInternal
call MemUnlock
fld myfloat
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Random endp
public Intel80X87Random
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Randomize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Prime the random number generator. The caller may choose to
pass a seed or have the routine generate one.
If the seed is small ( << 2^32 ), the random number
generator needs to be primed before use by calling
FloatRandom and discarding the results.
CALLED BY: GLOBAL
PASS: al - RandomGenInitFlags
RGIF_USE_SEED
RGIF_GENERATE_SEED
cx:dx - seed if RGIF_USE_SEED
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Randomize proc far
uses ds, bx
.enter
push ax
clr ax
call FloatHardwareEnter
pop ax
jc done
push ax
call FloatGetSoftwareStackHandle
call MemLock
mov ds, ax
pop ax
call FloatRandomizeInternal
call MemUnlock
clr ax
call FloatHardwareLeave
done:
.leave
ret
Intel80X87Randomize endp
public Intel80X87Randomize
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87RandomN
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: returns a random number between 1 and N-1
CALLED BY: GLOBAL
PASS: N on fp stack, 0 <= N < 2^31
ds - fp stack seg
RETURN: return carry set on error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87RandomN proc far
myfloat local FloatNum
uses es, ds, si, bx, di, ax
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fstp myfloat
fwait
call FloatGetSoftwareStackHandle
call MemLock
mov es, ax
segmov ds, ss, si
lea si, myfloat
call FloatPushNumberInternal
mov ds, ax
call FloatRandomNInternal
segmov es, ss, di
lea di, myfloat
call FloatPopNumberInternal
call MemUnlock
fld myfloat
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87RandomN endp
public Intel80X87RandomN
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Roll
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: move Nth element to top of stack
CALLED BY: GLOBAL
PASS: bx = N (which element to bring up)
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Roll proc far
tempStack local INTEL_STACK_SIZE dup(FloatNum)
uses ds, di, cx, es, si, bx
.enter
EC < pushf >
EC < tst bx >
EC < ERROR_LE ROLL_MUST_BE_POSITIVE >
EC < call FloatGetStackDepth >
EC < cmp ax, bx >
EC < ERROR_L INSUFFICIENT_ARGUMENTS_ON_STACK >
EC < popf >
clr ax
call FloatHardwareEnter
jc done
; if bl <= INTEL_STACK_SIZE we don't have to worry about the
; software stack at all
cmp bl, INTEL_STACK_SIZE
jg doSoftwareRoll
; only hardware....
; what I do, is pop off all the relavent elements into memory
; and then push them back on in the right order
clr ch
mov cl, bl
lea di, tempStack
add di, FPSIZE ; start at position 1, not 0
dec cx
jcxz myleave
; this loop pops the first N-1 elements off and into memory
; and writing them to memory starting from position 1 rather than
; position 0
storeloop:
fstp {FloatNum}ss:[di] ; store number
add di, FPSIZE ; advance pointer
loop storeloop
; now write Nth element in 0 poisition
lea di, tempStack
fstp {FloatNum}ss:[di]
mov al, FPSIZE
mul bl
add di, ax
sub di, FPSIZE
mov cl, bl
; because I have popped them off in the right order, I can
; just push them all back on from bottom to top
loadloop:
fld {FloatNum}ss:[di] ; push number back on
sub di, FPSIZE ; advance pointer
loop loadloop
myleave:
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
doSoftwareRoll:
; for the software case, I must do the following
; first pop the bottom of the hardware stack off
; and push it onto the top of the softwares stack
; then do a Roll of (N-(INTELSTACK_SIZE-1)) on the
; software stack, then pop of the top of the software
; stack and push in onto the top of the hardware stack
; trust me, it works...;)
mov cx, bx
call FloatGetSoftwareStackHandle
call MemLock ; lock down the software stack
push bx
mov es, ax
fdecstp ; mov hardware pointer to the bottom
fstp {FloatNum}tempStack ; pop off bottom element
fwait
segmov ds, ss, si
lea si, tempStack
call FloatPushNumberInternal ; push it onto software stack
segxchg ds, es
mov bx, cx
sub bl, (INTEL_STACK_SIZE - 1)
call FloatRollInternal ; Roll software stack
lea di, tempStack
call FloatPopNumberInternal ; pop off top number
fld {FloatNum}tempStack ; push it onto hardware stack
pop bx
call MemUnlock
jmp myleave
Intel80X87Roll endp
public Intel80X87Roll
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87RollDown
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: to a roll of top N elements (opposite direction of Roll
CALLED BY: GLOBAL
PASS: bl = N, number of elements to Roll
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87RollDown proc far
tempStack local INTEL_STACK_SIZE dup(FloatNum)
uses bx, es, ds, di, si, cx
.enter
EC < tst bx >
EC < ERROR_LE ROLL_MUST_BE_POSITIVE >
EC < call FloatGetStackDepth >
EC < cmp ax, bx >
EC < ERROR_L INSUFFICIENT_ARGUMENTS_ON_STACK >
clr ax
call FloatHardwareEnter
jc done
; if N < the hardware stack size we don't have to deal with
; the software stack at all, just pop off the top N elements
; into memory and then push them back on in the right order
cmp bl, INTEL_STACK_SIZE
jg doSoftwareRoll
cmp bl, 1
je myleave ; do nothing to roll 1 element
; push the first one onto the bottom position in memory
; then push the rest starting from position 0 down to N-2
mov al, FPSIZE
mul bl
lea di, tempStack
add di, ax
sub di, FPSIZE
; store the first one at the bottom
fstp {FloatNum}ss:[di]
lea di, tempStack
dec bl
clr ch
mov cl, bl
; now store the rest on the current order
storeloop:
fstp {FloatNum}ss:[di]
add di, FPSIZE
loop storeloop
mov cl, bl
inc cl
; since we stored them in the right order, we can just push
; them back on in the order they lie in memory starting from the
; bottom
loadloop:
fld {FloatNum}ss:[di]
sub di, FPSIZE
loop loadloop
myleave:
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
doSoftwareRoll:
; for the case in which N > the hardware stack size...
; first pop off the top element, push in onto the software
; stack, RollDown the software stack by (N - (INTEL_STACK_SIZE-1))
; pop the top element off the software stack and push it onto the
; top of the hardware stack
fstp {FloatNum}tempStack ; pop off the top element
fwait
mov cx, bx
call FloatGetSoftwareStackHandle
call MemLock ; lock down the software stack
push bx
mov es, ax
segmov ds, ss, si
lea si, tempStack
call FloatPushNumberInternal ; push old top element onto software
segxchg ds, es ; stack
mov bx, cx
sub bx, (INTEL_STACK_SIZE - 1)
call FloatRollDownInternal ; now roll softeware stack
lea di, tempStack
call FloatPopNumberInternal ; pop top element off of software
fld {FloatNum}tempStack ; push it onto hardware stack
fincstp
pop bx
call MemUnlock ; unlock software stack
jmp myleave
Intel80X87RollDown endp
public Intel80X87RollDown
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Rot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: rotates first three numbers on fp stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 9/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Rot proc far
.enter
EC < call FloatGetStackDepth >
EC < cmp ax, 3 >
EC < ERROR_L INSUFFICIENT_ARGUMENTS_ON_STACK >
clr ax
call FloatHardwareEnter
jc done
; start: fp: x1 x2 x3 (x3 = top)
fxch ; fp: x1 x3 x2
fxch st(2) ; fp: x2 x3 x1
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Rot endp
public Intel80X87Rot
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Round
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: round off number on top of FP stack
CALLED BY: GLOBAL
PASS: al = number of decimal places to round to
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 6/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Round proc far
int16 local word push ax
.enter
mov ax, 2
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
; now multiply by 10^ax
and int16, 00ffh
fild int16 ; st = ax
fldl2t
fmulp
call Intel80X87_2ToTheX ; st = 10^ax
fxch
fld st(1) ; dup 10^ax
fmulp ; st = st*10^ax
frndint ; round to nearest int
fdivrp ; st = st(1)/10^ax
mov ax, -2
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Round endp
public Intel80X87Round
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Sinh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = sinh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry flag set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
; sinh(x) = (e^x - e^-x)/2
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Sinh proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fldl2e
fmulp
call Intel80X87_2ToTheX
fld1
fdivr st, st(1)
fsubp
fidiv cs:[int87Two]
mov ax, -1
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Sinh endp
public Intel80X87Sinh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Sqr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st*st
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Sqr proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fmul st, st
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Sqr endp
public Intel80X87Sqr
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Sqrt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = st^1/2
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Sqrt proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fsqrt
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Sqrt endp
public Intel80X87Sqrt
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Sqrt2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = square root of 2
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
int87Sqrt2 FloatNum <0x6485, 0xF9DE, 0xF333, 0xB504, 0x3FFF>
Intel80X87Sqrt2 proc far
uses ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld cs:[int87Sqrt2]
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Sqrt2 endp
public Intel80X87Sqrt2
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87AsciiToFloat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Given a parsed string, convert it into a floating point
number.
CALLED BY: GLOBAL ()
PASS: al - FloatAsciiToFloatFlags
FAF_PUSH_RESULT - place result onto the fp stack
FAF_STORE_NUMBER - store result into the location given by
es:di
cx - number of characters in the string that the routine
should concern itself with
ds:si - string in this format:
"[+-] dddd.dddd [Ee] [+-] dddd"
Notes:
------
* The string is assumed to be legal because duplicating
the error checking that is done in the parser seems
unnecessary.
* There can be at most a single decimal point.
* Spaces and thousands seperators are ignored.
RETURN: carry clear if successful
carry set if error
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87AsciiToFloat proc far
myfloat local FloatNum
uses ds, es, di, bx, ax
.enter
mov_tr bx, ax
mov ax, 1
call FloatHardwareEnter
jc done
mov_tr ax, bx
call FloatAsciiToFloatInternal
jc error ;branch if error
test al, mask FAF_PUSH_RESULT
jz error ; not really an error but same code
call FloatGetSoftwareStackHandle
call MemLock
mov ds, ax
segmov es, ss, di
lea di, myfloat
call FloatPopNumberInternal
call MemUnlock
fld myfloat
finish:
clr ax
leaveHardware:
pushf
call FloatHardwareLeave ;clears carry (no error)
popf
done:
.leave
ret
error:
mov ax, -1
jmp leaveHardware
Intel80X87AsciiToFloat endp
public Intel80X87AsciiToFloat
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Sub
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st(1) = st(1) - st, st popped off
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Sub proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fsub
dec ax ; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Sub endp
public Intel80X87Sub
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Swap
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: swap top two stack registers
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Swap proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check2Args >
fxch
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Swap endp
public Intel80X87Swap
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Tan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = tan(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Tan proc far
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fptan
fdivp
neg ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Tan endp
public Intel80X87Tan
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Tanh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = tanh(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
; tanh(x) = (e^x - e^-x) / (e^x + e^-x)
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Tanh proc far
.enter
mov ax, 3
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st ; FloatDup (fp: z z)
fldl2e ; FloatExp
fmulp ; ...
call Intel80X87_2ToTheX ; ... (fp: z a)
fxch ; FloatSwap (fp: e^z z)
fchs ; FloatNegate (fp: e^z -z)
fldl2e ; FloatExp (fp: e^z -z l2e)
fmulp ; ... (fp: e^z -z*l2e)
call Intel80X87_2ToTheX ; ... (fp: e^z e^-z)
; a = e^z, b = e^-z
fld st(1) ; FloatOver (fp: a b a)
fld st(1) ; FloatOver (fp: a b a b)
fsubp ; FloatSub (fp: a b a-b)
fxch st(2) ; FloatRot/ (fp: a-b b a)
fxch ; FloatRot (fp: a-b a b)
faddp ; FloatAdd (fp: a-b a+b)
fdivp ; FloatDivide (fp: tanh)
neg ax ; (ax still 3)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Tanh endp
public Intel80X87Tanh
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87_2ToTheX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = 2^st
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: nothing
PSEUDOCODE/STRATEGY:
because the only thing we get in hardware is
2^x - 1 when 0 <= x <= .5 we must do some silly things
since 2^x = (2^integerpart(x))(2^fractionalpart(x))
first, if x is negative, set sign = minus, x = -x;
we can do the following :
let y = integerpart(x)
let z = fractionalpart(x)
now to get s = 2^y do the following
s = 1;
while (y--)
s*=2;
now if z <= .5 we can just call 2xm1 and add 1
else let z = z - .5, and do a 2xm1 and add 1
and the do another 2xm1 add 1 on remaining z
if (sign == minus) we must invert the answer
KNOWN BUGS/SIDEFFECTS/IDEAS:
the routine increases the stack by up to ONE
element at the most at any one time
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/21/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87_2ToTheX proc near
sign local word
fractPart local FloatNum ; fractional part
tempFloat local FloatNum
uses ax, bx, cx, dx, di, si
.enter
; first, get the sign of the operand (stored in SW_CONDITION_CODE_0 of
; status, which is 1 if the thing is negative)
ftst
StatusToAX
mov sign, ax
test ax, mask SW_CONDITION_CODE_2
jnz error ; => it's NaN or something similarly evil
test ax, mask SW_CONDITION_CODE_3
jz notZero ; see if the exponent is zero
fstp st ; pop off zero
mov sign, 1
fild sign ; load in a 1 as anything^0 = 1
jmp done
notZero:
; test ax, mask SW_CONDITION_CODE_3
; jnz error ; => it's NaN or something similarly evil
; now that we have the sign, make it positive
fabs
; get the fractional and integer parts
; now to get the integer part of x, chop x
fld st ; first save x
call Intel80X87TruncInternal ; chop x
; now to get fractional part, subtract chopped part from original
fsub st(1) ; st <- int, st(1) <- frac
fxch
fstp fractPart ; save fractional
fld1
fscale ; st <- 2^int
fstp tempFloat
fstp st ; drop int
; now see if the fractional part is <= .5
fld fractPart
fld cs:[int87PointFive]
fcom
StatusToAX
sahf
jp error
jae doRest
; if so then jump ahead and finish up
; otherwise, do 2^.5, and then do 2^(fractPart-.5) and
; muliply the two halves together
; 2^.5 is just sqrt(2), of course, so...
fsub ; st <- st(1)-.5
f2xm1
fld1
faddp
fld cs:[int87Sqrt2] ; want full precision, so load treal...
fmulp
jmp combineAnswer
doRest:
fstp st ; pop the .5
f2xm1
fld1
faddp ; st = 2^fractPart
combineAnswer:
fld tempFloat ; recover 2^int
fmulp
; if negative, 2^(-x) = 1/(2^x), so do st = 1/st
test sign, mask SW_CONDITION_CODE_0
jz done
fld1
fdivrp
done:
.leave
ret
error:
stc
jmp done
Intel80X87_2ToTheX endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X8710ToTheX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = 10^st
CALLED BY: GLOBAL
PASS: ax = exponent
RETURN: carry set on error
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
; 10ToTheX(x) = 2^(x*lg(10))
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/18/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X8710ToTheX proc far
myint local word push ax
.enter
mov ax, 2
call FloatHardwareEnter
jc done
fild myint
fldl2t
fmulp
call Intel80X87_2ToTheX
mov ax, -1
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X8710ToTheX endp
public Intel80X8710ToTheX
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Trunc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = trucn(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: carry set on error
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/12/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Trunc proc far
.enter
clr ax
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
call Intel80X87TruncInternal
; (ax still 0)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87Trunc endp
public Intel80X87Trunc
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87TruncInternal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: st = trunc(st)
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87TruncInternal proc near
uses ax
.enter
call Intel80X87SetChop
frndint
call Intel80X87SetNearest
.leave
ret
Intel80X87TruncInternal endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87FloatToDword
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: pop off st and put it into dx:ax
CALLED BY: GLOBAL
PASS: nothing
RETURN: dx:ax = top of stack which is then popped off
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 1/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87FloatToDword proc far
int32 local dword
.enter
mov ax, 0
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fistp int32
fwait
dec ax ; (ax still 0)
call FloatHardwareLeave
movdw dxax, int32
done:
.leave
ret
Intel80X87FloatToDword endp
public Intel80X87FloatToDword
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87DwordToFloat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a dword integer on the fp stack
CALLED BY: GLOBAL
PASS: dx:ax dword integer
RETURN: integer on top of fp stack
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87DwordToFloat proc far
int32 local dword push dx, ax
uses dx
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fild int32
fwait
clr ax
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87DwordToFloat endp
public Intel80X87DwordToFloat
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87WordToFloat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: put a word integer onto the fp stack
CALLED BY: GLOBAL
PASS: ax = word integer
RETURN: integer on top of fp stack
DESTROYED: ax.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 4/20/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87WordToFloat proc far
int16 local word push ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fild int16
fwait
dec ax ; (ax still 1)
call Intel80X87CheckNormalNumberAndLeave
done:
.leave
ret
Intel80X87WordToFloat endp
public Intel80X87WordToFloat
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87GetStackPointer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get the top of the fp stack pointer
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax = top of stack pointer
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
Primarily for use by applications for error recovery.
Applications can bail out of involved operations by saving
the stack pointer prior to commencing operations and
restoring the stack pointer in the event of an error.
NOTE:
-----
If you set the stack pointer, the current stack pointer
must be less than or equal to the value you pass. Ie.
you must be throwing something (or nothing) away.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87GetStackPointer proc far
.enter
clr ax
call FloatHardwareEnter
jc done
call FloatGetStackDepth
push ax
clr ax
call FloatHardwareLeave
pop ax
done:
.leave
ret
Intel80X87GetStackPointer endp
public Intel80X87GetStackPointer
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87SetStackPointer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: set the top of the fp stack pointer
CALLED BY: GLOBAL
PASS: ax = new value for top of stack pointer
RETURN: carry set on error
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
the new value passes must be >= current value of top of stack
KNOWN BUGS/SIDEFFECTS/IDEAS:
Primarily for use by applications for error recovery.
Applications can bail out of involved operations by saving
the stack pointer prior to commencing operations and
restoring the stack pointer in the event of an error.
NOTE:
-----
If you set the stack pointer, the current stack pointer
must be greater than or equal to the value you pass. Ie.
you must be throwing something (or nothing) away.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87SetStackPointer proc far
dummy local FloatNum
stackDepth local word
newDepth local word
poppedOffH local word
memHandle local hptr
uses bx, cx, es, di, ds, ax
.enter
mov newDepth, ax
clr ax
call FloatHardwareEnter
LONG jc done
; first, get rid of stuff on hardware stack that is not needed
; calculate how many numbers to pop off
mov bx, newDepth
call FloatGetStackDepth ; ax = current depth
; if we are already at the depth we want to set do nothing
mov stackDepth, ax
sub ax, bx
LONG je done2 ; we are already there, so go home
cmp ax, INTEL_STACK_SIZE
jge initializeHardware
mov cx, ax
; pop off numbers
poploopHardware:
fstp st
loop poploopHardware
mov poppedOffH, ax
clr ax
jmp clearSoftware
initializeHardware:
; if more than INTEL_STACK_SIZE things are popped off,
; then just do an finit, and pop the rest off the
; software stack
finit
sub ax, INTEL_STACK_SIZE
mov poppedOffH, INTEL_STACK_SIZE
clearSoftware:
mov bx, stackDepth
cmp bx, INTEL_STACK_SIZE
jle done
push ax
; set up the software stack block
call FloatGetSoftwareStackHandle
mov memHandle, bx
call MemLock
mov ds, ax
segmov es, ss
lea di, dummy ; es:di <- dummy
pop cx
jcxz swapIn
; pop off numbers off the software stack
poploopSoftware:
call FloatPopNumberInternal
loop poploopSoftware
swapIn:
mov cx, INTEL_STACK_SIZE ; used a lot here so put in cx
; no figure out how much room is left on the hardware stack
; to move things up from the software stack, and see how many
; numbers are left on the software stack to move up
mov bx, cx
sub bx, poppedOffH ; bx = actual depth of hardware stack now
mov ax, cx
sub ax, bx
mov bx, newDepth
cmp bx, cx
jg doSwap
sub bx, cx
add ax, bx
tst ax
jz doneMemUnlock
doSwap:
mov cx, poppedOffH
dec cx
tst cx
jz afterSetUp
; set up stack pointer in hardware so that the numbers get
; pushed on in the right order, they have to be pushed on in
; reverse order from how they come off the softwares stack, so
; set up pointer, push one, and then increment the pointer
; twice so that the next one goes in "before" the one just
; pushed...
setUpPointer:
fdecstp
loop setUpPointer
afterSetUp:
mov cx, ax
swapLoop:
call FloatPopNumberInternal
fld dummy
fincstp
fincstp
loop swapLoop
; now we need to make sure that the hardware pointer is put
; back to point and the correct top number
;restore:
mov ax, newDepth
cmp ax, INTEL_STACK_SIZE
jl restoreLess
mov cx, 1
jmp restoreLoop
restoreLess:
mov cx, newDepth
inc cx
restoreLoop:
fdecstp
loop restoreLoop
doneMemUnlock:
mov bx, memHandle
call MemUnlock
done:
mov ax, newDepth
call FloatSetStackDepth
done2:
clr ax
call FloatHardwareLeave
.leave
ret
Intel80X87SetStackPointer endp
public Intel80X87SetStackPointer
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87IEEE64ToGeos80
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Convert a floating point number in IEEE 64 bit format into an
fp number in Geos 80 bit format and push it onto the fp stack.
Geos 80 bit format is almost the same as the IEEE 80 bit format
except that we do not have an implied msb 1.
A 64 bit number has a 52 bit mantissa and a 12 bit exponent.
An 80 bit number has a 64 bit mantissa and a 16 bit exponent.
CALLED BY: INTERNAL ()
PASS:
ds:si - IEEE 64 bit number
RETURN: float number on the fp stack
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/15/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87IEEE64ToGeos80 proc far
uses ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld {qword}ds:[si]
dec ax ; (ax still 1)
call FloatHardwareLeave
done:
.leave
ret
Intel80X87IEEE64ToGeos80 endp
public Intel80X87IEEE64ToGeos80
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87IEEE32ToGeos80
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Convert a floating point number in IEEE 32 bit format into an
fp number in Geos 80 bit format and push it onto the fp stack.
Geos 80 bit format is almost the same as the IEEE 80 bit format
except that we do not have an implied msb 1.
A 64 bit number has a 23 bit mantissa and a 9 bit exponent.
An 80 bit number has a 64 bit mantissa and a 16 bit exponent.
CALLED BY: GLOBAL
PASS:
ds:ax = IEEE32 number
RETURN: float number on the fp stack
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/15/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87IEEE32ToGeos80 proc far
myfloat local dword push dx, ax
uses ax
.enter
mov ax, 1
call FloatHardwareEnter
jc done
fld myfloat
fwait
dec ax ; (ax still 1)
call FloatHardwareLeave
done:
.leave
ret
Intel80X87IEEE32ToGeos80 endp
public Intel80X87IEEE32ToGeos80
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Geos80ToIEEE64
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Convert a floating point number in Geos 80 bit format into an
fp number in IEEE 64 bit format and push it onto the fp stack.
Geos 80 bit format is almost the same as the IEEE 80 bit format
except that we do not have an implied msb 1.
An 80 bit number has a 64 bit mantissa and a 16 bit exponent.
A 64 bit number has a 52 bit mantissa and a 12 bit exponent.
CALLED BY: INTERNAL ()
PASS: ds - fp stack seg
es:di - location to store the IEEE 64 bit number
RETURN: carry clear if successful
carry set otherwise
float number popped off stack in either case
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/15/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Geos80ToIEEE64 proc far
.enter
clr ax
call FloatHardwareEnter
jc done
fstp {qword}es:[di]
fwait
mov ax, -1
call FloatHardwareLeave
done:
.leave
ret
Intel80X87Geos80ToIEEE64 endp
public Intel80X87Geos80ToIEEE64
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Geos80ToIEEE32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Convert a floating point number in Geos 80 bit format into an
fp number in IEEE 32 bit format and push it onto the fp stack.
Geos 80 bit format is almost the same as the IEEE 80 bit format
except that we do not have an implied msb 1.
An 80 bit number has a 64 bit mantissa and a 16 bit exponent.
A 64 bit number has a 23 bit mantissa and a 9 bit exponent.
CALLED BY: GLOBAL
PASS: number on fp stack
RETURN: carry clear if successful
carry set otherwise
dx:ax = IEEE32 number
float number popped off stack in either case
DESTROYED: ax
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 5/15/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Geos80ToIEEE32 proc far
myfloat local dword
.enter
clr ax
call FloatHardwareEnter
jc done
fstp myfloat
fwait
dec ax ; (ax still 0)
call FloatHardwareLeave
jc done
movdw dxax, myfloat
done:
.leave
ret
Intel80X87Geos80ToIEEE32 endp
public Intel80X87Geos80ToIEEE32
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Epsilon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: produces an epsilon value based on the top fp number
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 6/30/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Epsilon proc far
myfloat local FloatNum
.enter
mov ax, 1
call FloatHardwareEnter
jc done
EC < call Intel80X87Check1Arg >
fld st ; duplicate, as it must remain on the
; stack.
fstp myfloat
clr ax
mov myfloat.F_mantissa_wd3, ax
mov myfloat.F_mantissa_wd2, ax
mov myfloat.F_mantissa_wd1, ax
mov myfloat.F_mantissa_wd0, 1
fld myfloat
call FloatHardwareLeave
done:
.leave
ret
Intel80X87Epsilon endp
public Intel80X87Epsilon
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INTEL80X87FSTSW
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: get the status word of the coprocessor
CALLED BY: GLOBAL
PASS: nothing
RETURN: ax = status word
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 9/24/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
global INTEL80X87FSTSW:far
INTEL80X87FSTSW proc far
status local StatusWord
.enter
clr ax
call FloatHardwareEnter
jc done
fstsw status
fwait
call FloatHardwareLeave
mov ax, status
done:
.leave
ret
INTEL80X87FSTSW endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Intel80X87Err
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: push an ERROR NAN on the stack
CALLED BY: GLOBAL
PASS: nothing
RETURN: Void.
DESTROYED: Nada.
PSEUDOCODE/STRATEGY:
KNOWN BUGS/SIDEFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 3/16/93 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Intel80X87Err proc near
.enter
fld {FloatNum}tableErr
.leave
ret
Intel80X87Err endp
tableErr label word
word 0, 0, 0, 0c000h, FP_NAN
CommonCode ends
|
; A212988: Number of (w,x,y) with all terms in {0,...,n} and 4*w = x+y.
; 1,1,2,4,7,9,12,16,21,25,30,36,43,49,56,64,73,81,90,100,111,121,132,144,157,169,182,196,211,225,240,256,273,289,306,324,343,361,380,400,421,441,462,484,507,529,552,576,601,625,650,676,703,729,756,784
mul $0,2
add $0,1
lpb $0
trn $0,4
add $1,1
add $1,$0
trn $0,4
lpe
mov $0,$1
|
; movingData.nasm
;
; Author : bigb0ss
; Created date : 05/19/2020
; Last update : 05/19/2020
;
; Description : This is just example of mine. You can modify anything to play the data.
; Global Entry Point
global _start
section .text
_start
; mov - Move data into register
mov eax, 0xaabbccdd
mov al, 0xff ; a-low
mov ah, 0xff ; a-high
mov ax, 0xffff
mov ebx, 0xaabbccdd
mov bl, 0xdd
mov bh, 0xdd
mov bx, 0xdddd
mov ebx, 0x00
mov ecx, 0x00
; mov - Move register into register
mov ebx, eax
mov cl, al
mov ch, ah
mov cx, ax
mov eax, 0x00
; mov - Move memory into register
mov al, [test] ; Moving fist test value (0x11) into al
mov ah, [test +1] ; Moving second test value (0x22) into ah
mov bl, [test +2] ; Moving third test value (0x33) into bl
mov bh, [test +3] ; Moving forth test value (0x44) into bh
mov ecx, [test]
mov eax, 0x00
mov ebx, 0x00
; mov - Move register into memory
mov eax, 0xAABBCCDD
mov byte [test], al ; Moving al (0xDD) into first byte of test
mov word [test], ax ; Moving ax (0xCCDD) into first and second bytes of test
mov dwrod [test], eax ; Moving eax (0xAABBCCDD) into 1,2,3 and 4th bytes of test
; Load Effective Address (LEA)
lea ebx, [test]
lea ecx, [ebx]
; Exchange (XCHG)
mov eax, 0x11223344
mov ebx, 0xaabbccdd
xchg eax, ebx
; exit()
mov eax, 1
mov ebx, 0
int 0x80
section .data
test: db 0x11, 0x22, 0x33, 0x44
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r15
push %rax
push %rbp
push %rdi
push %rsi
lea addresses_A_ht+0x10186, %rsi
clflush (%rsi)
sub $54196, %r15
movb (%rsi), %r14b
nop
nop
nop
dec %rbp
lea addresses_UC_ht+0x188f6, %rsi
nop
nop
nop
cmp $35720, %r14
mov (%rsi), %r11
nop
dec %rbp
lea addresses_normal_ht+0xed96, %rax
nop
nop
nop
nop
and %rdi, %rdi
movw $0x6162, (%rax)
dec %rsi
lea addresses_WC_ht+0x5226, %rbp
nop
nop
and $19187, %r15
vmovups (%rbp), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %r14
nop
nop
nop
nop
add $62251, %rsi
lea addresses_A_ht+0x1af96, %r15
nop
nop
nop
cmp %rdi, %rdi
mov (%r15), %ax
nop
nop
cmp $2828, %rax
pop %rsi
pop %rdi
pop %rbp
pop %rax
pop %r15
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WT+0x14296, %rcx
cmp $22323, %r10
movw $0x5152, (%rcx)
nop
nop
nop
nop
dec %rdx
// Store
lea addresses_PSE+0x14e72, %rdi
nop
nop
nop
nop
and $52918, %r14
mov $0x5152535455565758, %rcx
movq %rcx, %xmm7
vmovups %ymm7, (%rdi)
nop
nop
nop
nop
nop
dec %r11
// Store
lea addresses_WC+0x12d16, %rdi
nop
nop
nop
cmp $42825, %rdx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm0
movups %xmm0, (%rdi)
nop
nop
nop
nop
and $20906, %r10
// Faulty Load
lea addresses_normal+0x1d96, %r10
nop
nop
sub $9442, %rdi
vmovups (%r10), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $1, %xmm7, %r14
lea oracles, %r10
and $0xff, %r14
shlq $12, %r14
mov (%r10,%r14,1), %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_WT', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 32}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WC', 'AVXalign': False, 'size': 16}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_normal', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2}}
{'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'src': {'NT': True, 'same': False, 'congruent': 9, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
; A035328: a(n) = n*(2*n-1)*(2*n+1).
; 0,3,30,105,252,495,858,1365,2040,2907,3990,5313,6900,8775,10962,13485,16368,19635,23310,27417,31980,37023,42570,48645,55272,62475,70278,78705,87780,97527,107970,119133,131040,143715,157182,171465,186588,202575,219450,237237,255960,275643,296310,317985,340692,364455,389298,415245,442320,470547,499950,530553,562380,595455,629802,665445,702408,740715,780390,821457,863940,907863,953250,1000125,1048512,1098435,1149918,1202985,1257660,1313967,1371930,1431573,1492920,1555995,1620822,1687425,1755828,1826055,1898130,1972077,2047920,2125683,2205390,2287065,2370732,2456415,2544138,2633925,2725800,2819787,2915910,3014193,3114660,3217335,3322242,3429405,3538848,3650595,3764670,3881097,3999900,4121103,4244730,4370805,4499352,4630395,4763958,4900065,5038740,5180007,5323890,5470413,5619600,5771475,5926062,6083385,6243468,6406335,6572010,6740517,6911880,7086123,7263270,7443345,7626372,7812375,8001378,8193405,8388480,8586627,8787870,8992233,9199740,9410415,9624282,9841365,10061688,10285275,10512150,10742337,10975860,11212743,11453010,11696685,11943792,12194355,12448398,12705945,12967020,13231647,13499850,13771653,14047080,14326155,14608902,14895345,15185508,15479415,15777090,16078557,16383840,16692963,17005950,17322825,17643612,17968335,18297018,18629685,18966360,19307067,19651830,20000673,20353620,20710695,21071922,21437325,21806928,22180755,22558830,22941177,23327820,23718783,24114090,24513765,24917832,25326315,25739238,26156625,26578500,27004887,27435810,27871293,28311360,28756035,29205342,29659305,30117948,30581295,31049370,31522197,31999800,32482203,32969430,33461505,33958452,34460295,34967058,35478765,35995440,36517107,37043790,37575513,38112300,38654175,39201162,39753285,40310568,40873035,41440710,42013617,42591780,43175223,43763970,44358045,44957472,45562275,46172478,46788105,47409180,48035727,48667770,49305333,49948440,50597115,51251382,51911265,52576788,53247975,53924850,54607437,55295760,55989843,56689710,57395385,58106892,58824255,59547498,60276645,61011720,61752747
mov $1,$0
pow $1,3
mul $1,4
sub $1,$0
|
FanClub_h:
db INTERIOR ; tileset
db POKEMON_FAN_CLUB_HEIGHT, POKEMON_FAN_CLUB_WIDTH ; dimensions (y, x)
dw FanClubBlocks, FanClubTextPointers, FanClubScript ; blocks, texts, scripts
db $00 ; connections
dw FanClubObject ; objects
|
; int fscanf(FILE *stream, const char *format, ...)
INCLUDE "clib_cfg.asm"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _fscanf
EXTERN asm_fscanf
_fscanf:
push ix
call asm_fscanf
pop ix
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _fscanf
EXTERN _fscanf_unlocked
defc _fscanf = _fscanf_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; TEXT STARTS HERE
; What does the sketch do? What it's output?
; Short answer: The sketch divides 200 by 5 and prints the result to stdout
; in binary form
; For detailed explanation, See Comments added in the sketch
; TEXT ENDS HERE
start:
mov AL, 200 ; Store dividend in 8-bit register AL
; 11001000b
mov CX, 1 ; Assign 1 to CX. The loop counter
mov BL,5 ; Store divisor in in BL
; 00000101b
div BL ; Perform division -> 200 / 5 -> AL / BL
; 40D -> 00101000b
; Move AL value to BL. Why? Printing to stdout
; requires a system call number in AH
; before calling an interrupt.
; That overwrites AL
mov BL, AL
shl CX,3 ; 1 << 3 = 1000b = 8d = no. of bits in BL
somewhere:
mov AH, 2 ; Call number to write char to stdout
mov DL, 30h ; DL = '0'
; AND BL with 10000000b
; If MSB is zero, jmp to elsewhere
test BL, 10000000b
jz elsewhere
; Else, MSB = 1
; DL = '1'
mov DL, 31h
elsewhere:
int 21h ; Print ascii value in DL
shl BL, 1 ; BL << 1. Test next MSB
; Repeat until CX = 0
; i.e 8d times
loop somewhere
; Final Stdoutput -> 00101000b [40d]
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x5212, %rdi
nop
nop
nop
nop
sub %rbx, %rbx
mov $0x6162636465666768, %r12
movq %r12, %xmm1
movups %xmm1, (%rdi)
sub %r12, %r12
lea addresses_UC_ht+0x1323a, %rdi
nop
nop
nop
nop
xor $4755, %r13
mov (%rdi), %r8w
nop
nop
nop
nop
xor $54282, %rbx
lea addresses_WT_ht+0x17a3a, %rbp
nop
nop
nop
nop
nop
and $46603, %r12
mov (%rbp), %edi
nop
nop
nop
nop
inc %rbx
lea addresses_A_ht+0xadba, %r12
xor $60932, %rdx
movb $0x61, (%r12)
nop
inc %rdi
lea addresses_WT_ht+0xf88e, %rsi
lea addresses_UC_ht+0x101a, %rdi
nop
cmp $3555, %r13
mov $0, %rcx
rep movsq
nop
nop
xor $65514, %r8
lea addresses_WT_ht+0x18f3a, %rsi
lea addresses_UC_ht+0x11f9a, %rdi
nop
nop
nop
and $63157, %rbp
mov $126, %rcx
rep movsb
and %r12, %r12
lea addresses_UC_ht+0x15432, %rsi
nop
nop
nop
cmp $46628, %r8
vmovups (%rsi), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %r13
nop
xor %rbp, %rbp
lea addresses_A_ht+0x297a, %r12
nop
nop
nop
nop
nop
sub $50155, %rcx
movw $0x6162, (%r12)
nop
nop
and $437, %rbx
lea addresses_WT_ht+0x1223a, %rcx
nop
inc %rdi
mov (%rcx), %ebp
nop
nop
nop
nop
sub %rcx, %rcx
lea addresses_WT_ht+0xb6a6, %rbx
nop
nop
nop
nop
nop
sub $50673, %r12
and $0xffffffffffffffc0, %rbx
vmovntdqa (%rbx), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $1, %xmm3, %rsi
nop
mfence
lea addresses_WC_ht+0x8f62, %rdi
nop
nop
cmp %rsi, %rsi
mov (%rdi), %r13
nop
nop
nop
nop
nop
xor %rbp, %rbp
lea addresses_A_ht+0x167fa, %rsi
lea addresses_UC_ht+0x14f7a, %rdi
nop
nop
nop
inc %rbp
mov $5, %rcx
rep movsq
nop
nop
sub $58435, %rcx
lea addresses_normal_ht+0x1d7ba, %rcx
nop
nop
nop
nop
add $61840, %r12
vmovups (%rcx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rdx
nop
nop
dec %r12
lea addresses_normal_ht+0x7dba, %rsi
lea addresses_A_ht+0x6e2a, %rdi
nop
nop
nop
nop
and %rbp, %rbp
mov $44, %rcx
rep movsb
nop
nop
add $41404, %rdx
lea addresses_WT_ht+0x13a3a, %rcx
nop
cmp %rdi, %rdi
movb (%rcx), %r12b
nop
nop
nop
nop
nop
and %rbp, %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r9
push %rax
push %rbp
push %rbx
// Faulty Load
lea addresses_D+0x1423a, %rbx
add $27231, %rbp
vmovups (%rbx), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rax
lea oracles, %r11
and $0xff, %rax
shlq $12, %rax
mov (%r11,%rax,1), %rax
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': True, 'congruent': 8, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 1, 'NT': True, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
.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, 09
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 0a
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, 29
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 2a
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, 49
ld(hl++), a
inc l
inc l
ld a, d
ld(hl++), a
ld a, 4a
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, 02
ldff(43), a
.text@1000
lstatint:
nop
.text@1095
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
|
SECTION code_fp_math48
PUBLIC asm_atan
EXTERN am48_atan
defc asm_atan = am48_atan
|
global flush_gdt
extern gp
flush_gdt:
lgdt [gp]
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:flush2
flush2:
ret
|
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;
const int N = 1e3 + 2;
int gcd[N][N];
void init() {
for (int i = 0; i < N; ++i) gcd[i][0] = gcd[0][i] = i;
for (int i = 1; i < N; ++i) {
for (int j = i; j < N; ++j) gcd[i][j] = gcd[j % i][i];
for (int j = 1; j <= i; ++j) gcd[i][j] = gcd[j][i];
}
}
int main() {
//freopen("in", "r", stdin);
std::cin.tie(nullptr)->sync_with_stdio(false);
init();
int cas;
std::cin >> cas;
while (cas--) {
int n;
std::cin >> n;
int a[n];
bool v[n] = {};
for (int i = 0; i < n; ++i) std::cin >> a[i];
int id = std::max_element(a, a + n) - a;
std::vector<int> ans;
ans.push_back(a[id]);
v[id] = 1;
int now = a[id];
while (ans.size() != n) {
int mx = 0;
for (int i = 0; i < n; ++i) if (!v[i]) {
mx = std::max(mx, gcd[now][a[i]]);
}
for (int i = 0; i < n; ++i) if (!v[i]) {
if(mx == gcd[now][a[i]]) {
ans.push_back(a[i]);
v[i] = 1;
}
}
now = mx;
}
for (auto x : ans) std::cout << x << " ";
std::cout << std::endl;
}
return 0;
} |
; A063522: a(n) = n*(5*n^2 - 3)/2.
; 0,1,17,63,154,305,531,847,1268,1809,2485,3311,4302,5473,6839,8415,10216,12257,14553,17119,19970,23121,26587,30383,34524,39025,43901,49167,54838,60929,67455,74431,81872,89793,98209,107135,116586,126577,137123,148239,159940,172241,185157,198703,212894,227745,243271,259487,276408,294049,312425,331551,351442,372113,393579,415855,438956,462897,487693,513359,539910,567361,595727,625023,655264,686465,718641,751807,785978,821169,857395,894671,933012,972433,1012949,1054575,1097326,1141217,1186263,1232479,1279880,1328481,1378297,1429343,1481634,1535185,1590011,1646127,1703548,1762289,1822365,1883791,1946582,2010753,2076319,2143295,2211696,2281537,2352833,2425599
mov $2,$0
pow $0,2
mul $0,$2
sub $2,$0
sub $0,$2
sub $2,$0
sub $0,$2
div $0,2
|
_FuchsiaCityText1::
text "Did you try the"
line "SAFARI GAME? Some"
cont "#MON can only"
cont "be caught there."
done
_FuchsiaCityText2::
text "SAFARI ZONE has a"
line "zoo in front of"
cont "the entrance."
para "Out back is the"
line "SAFARI GAME for"
cont "catching #MON."
done
_FuchsiaCityText3::
text "ERIK: Where's"
line "SARA? I said I'd"
cont "meet her here."
done
_FuchsiaCityText4::
text "That item ball in"
line "there is really a"
cont "#MON."
done
_FuchsiaCityText5::
text "!"
done
_FuchsiaCityText11::
text "FUCHSIA CITY"
line "Behold! It's"
cont "Passion Pink!"
done
_FuchsiaCityText13::
text "SAFARI GAME"
line "#MON-U-CATCH!"
done
_FuchsiaCityText16::
text "SAFARI ZONE"
line "WARDEN's HOME"
done
_FuchsiaCityText17::
text "#MON PARADISE"
line "SAFARI ZONE"
done
_FuchsiaCityText18::
text "FUCHSIA CITY"
line "#MON GYM"
cont "LEADER: KOGA"
para "The Poisonous"
line "Ninja Master"
done
_FuchsiaCityChanseyText::
text "Name: CHANSEY"
para "Catching one is"
line "all up to chance."
prompt
_FuchsiaCityVoltorbText::
text "Name: VOLTORB"
para "The very image of"
line "a # BALL."
prompt
_FuchsiaCityKangaskhanText::
text "Name: KANGASKHAN"
para "A maternal #MON"
line "that raises its"
cont "young in a pouch"
cont "on its belly."
prompt
_FuchsiaCitySlowpokeText::
text "Name: SLOWPOKE"
para "Friendly and very"
line "slow moving."
prompt
_FuchsiaCityLaprasText::
text "Name: LAPRAS"
para "A.K.A. the king"
line "of the seas."
prompt
_FuchsiaCityOmanyteText::
text "Name: OMANYTE"
para "A #MON that"
line "was resurrected"
cont "from a fossil."
prompt
_FuchsiaCityKabutoText::
text "Name: KABUTO"
para "A #MON that"
line "was resurrected"
cont "from a fossil."
prompt
_FuchsiaCityText_19b2a::
text "..."
done
|
RockTunnel1Script:
call EnableAutoTextBoxDrawing
ld hl, RockTunnel1TrainerHeaders
ld de, RockTunnel1ScriptPointers
ld a, [wRockTunnel1CurScript]
call ExecuteCurMapScriptInTable
ld [wRockTunnel1CurScript], a
ret
RockTunnel1ScriptPointers:
dw CheckFightingMapTrainers
dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RockTunnel1TextPointers:
dw RockTunnel1Text1
dw RockTunnel1Text2
dw RockTunnel1Text3
dw RockTunnel1Text4
dw RockTunnel1Text5
dw RockTunnel1Text6
dw RockTunnel1Text7
dw RockTunnel1Text8
RockTunnel1TrainerHeaders:
RockTunnel1TrainerHeader1:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_1
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_1
dw RockTunnel1BattleText1 ; TextBeforeBattle
dw RockTunnel1AfterBattleText1 ; TextAfterBattle
dw RockTunnel1EndBattleText1 ; TextEndBattle
dw RockTunnel1EndBattleText1 ; TextEndBattle
RockTunnel1TrainerHeader2:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_2
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_2
dw RockTunnel1BattleText2 ; TextBeforeBattle
dw RockTunnel1AfterBattleText2 ; TextAfterBattle
dw RockTunnel1EndBattleText2 ; TextEndBattle
dw RockTunnel1EndBattleText2 ; TextEndBattle
RockTunnel1TrainerHeader3:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_3
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_3
dw RockTunnel1BattleText3 ; TextBeforeBattle
dw RockTunnel1AfterBattleText3 ; TextAfterBattle
dw RockTunnel1EndBattleText3 ; TextEndBattle
dw RockTunnel1EndBattleText3 ; TextEndBattle
RockTunnel1TrainerHeader4:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_4
db ($3 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_4
dw RockTunnel1BattleText4 ; TextBeforeBattle
dw RockTunnel1AfterBattleText4 ; TextAfterBattle
dw RockTunnel1EndBattleText4 ; TextEndBattle
dw RockTunnel1EndBattleText4 ; TextEndBattle
RockTunnel1TrainerHeader5:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_5
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_5
dw RockTunnel1BattleText5 ; TextBeforeBattle
dw RockTunnel1AfterBattleText5 ; TextAfterBattle
dw RockTunnel1EndBattleText5 ; TextEndBattle
dw RockTunnel1EndBattleText5 ; TextEndBattle
RockTunnel1TrainerHeader6:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_6
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_6
dw RockTunnel1BattleText6 ; TextBeforeBattle
dw RockTunnel1AfterBattleText6 ; TextAfterBattle
dw RockTunnel1EndBattleText6 ; TextEndBattle
dw RockTunnel1EndBattleText6 ; TextEndBattle
RockTunnel1TrainerHeader7:
dbEventFlagBit EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_7
db ($4 << 4) ; trainer's view range
dwEventFlagAddress EVENT_BEAT_ROCK_TUNNEL_1_TRAINER_7
dw RockTunnel1BattleText7 ; TextBeforeBattle
dw RockTunnel1AfterBattleText7 ; TextAfterBattle
dw RockTunnel1EndBattleText7 ; TextEndBattle
dw RockTunnel1EndBattleText7 ; TextEndBattle
db $ff
RockTunnel1Text1:
TX_ASM
ld hl, RockTunnel1TrainerHeader1
jr RockTunnel1TalkToTrainer
RockTunnel1Text2:
TX_ASM
ld hl, RockTunnel1TrainerHeader2
jr RockTunnel1TalkToTrainer
RockTunnel1Text3:
TX_ASM
ld hl, RockTunnel1TrainerHeader3
jr RockTunnel1TalkToTrainer
RockTunnel1Text4:
TX_ASM
ld hl, RockTunnel1TrainerHeader4
jr RockTunnel1TalkToTrainer
RockTunnel1Text5:
TX_ASM
ld hl, RockTunnel1TrainerHeader5
jr RockTunnel1TalkToTrainer
RockTunnel1Text6:
TX_ASM
ld hl, RockTunnel1TrainerHeader6
jr RockTunnel1TalkToTrainer
RockTunnel1Text7:
TX_ASM
ld hl, RockTunnel1TrainerHeader7
RockTunnel1TalkToTrainer:
call TalkToTrainer
jp TextScriptEnd
RockTunnel1BattleText1:
TX_FAR _RockTunnel1BattleText1
db "@"
RockTunnel1EndBattleText1:
TX_FAR _RockTunnel1EndBattleText1
db "@"
RockTunnel1AfterBattleText1:
TX_FAR _RockTunnel1AfterBattleText1
db "@"
RockTunnel1BattleText2:
TX_FAR _RockTunnel1BattleText2
db "@"
RockTunnel1EndBattleText2:
TX_FAR _RockTunnel1EndBattleText2
db "@"
RockTunnel1AfterBattleText2:
TX_FAR _RockTunnel1AfterBattleText2
db "@"
RockTunnel1BattleText3:
TX_FAR _RockTunnel1BattleText3
db "@"
RockTunnel1EndBattleText3:
TX_FAR _RockTunnel1EndBattleText3
db "@"
RockTunnel1AfterBattleText3:
TX_FAR _RockTunnel1AfterBattleText3
db "@"
RockTunnel1BattleText4:
TX_FAR _RockTunnel1BattleText4
db "@"
RockTunnel1EndBattleText4:
TX_FAR _RockTunnel1EndBattleText4
db "@"
RockTunnel1AfterBattleText4:
TX_FAR _RockTunnel1AfterBattleText4
db "@"
RockTunnel1BattleText5:
TX_FAR _RockTunnel1BattleText5
db "@"
RockTunnel1EndBattleText5:
TX_FAR _RockTunnel1EndBattleText5
db "@"
RockTunnel1AfterBattleText5:
TX_FAR _RockTunnel1AfterBattleText5
db "@"
RockTunnel1BattleText6:
TX_FAR _RockTunnel1BattleText6
db "@"
RockTunnel1EndBattleText6:
TX_FAR _RockTunnel1EndBattleText6
db "@"
RockTunnel1AfterBattleText6:
TX_FAR _RockTunnel1AfterBattleText6
db "@"
RockTunnel1BattleText7:
TX_FAR _RockTunnel1BattleText7
db "@"
RockTunnel1EndBattleText7:
TX_FAR _RockTunnel1EndBattleText7
db "@"
RockTunnel1AfterBattleText7:
TX_FAR _RockTunnel1AfterBattleText7
db "@"
RockTunnel1Text8:
TX_FAR _RockTunnel1Text8
db "@"
|
#ifdef BUILD_TESTS
// Copyright 2021 Hcnet Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "invariant/OrderBookIsNotCrossed.h"
#include "invariant/test/InvariantTestUtils.h"
#include "ledger/LedgerTxn.h"
#include "lib/catch.hpp"
#include "test/TestAccount.h"
#include "test/TestUtils.h"
#include "test/TxTests.h"
#include "test/test.h"
namespace hcnet
{
namespace
{
void
applyCheck(Application& app, std::vector<LedgerEntry> const& current,
std::vector<LedgerEntry> const& previous, bool shouldPass)
{
hcnet::InvariantTestUtils::UpdateList updates;
if (previous.empty())
{
updates = InvariantTestUtils::makeUpdateList(current, nullptr);
}
else if (current.empty())
{
updates = InvariantTestUtils::makeUpdateList(nullptr, previous);
}
else
{
std::vector<LedgerKey> curKeys;
std::vector<LedgerKey> prevKeys;
std::transform(current.begin(), current.end(),
std::back_inserter(curKeys), LedgerEntryKey);
std::transform(previous.begin(), previous.end(),
std::back_inserter(prevKeys), LedgerEntryKey);
REQUIRE(curKeys == prevKeys);
updates = InvariantTestUtils::makeUpdateList(current, previous);
}
REQUIRE(InvariantTestUtils::store(app, updates, nullptr, nullptr) ==
shouldPass);
}
LedgerEntry
createOffer(Asset const& ask, Asset const& bid, int64 amount,
Price const& price, bool passive = false)
{
auto offer = InvariantTestUtils::generateOffer(ask, bid, amount, price);
offer.data.offer().flags = passive ? PASSIVE_FLAG : 0;
return offer;
}
LedgerEntry
modifyOffer(LedgerEntry offer, bool passive)
{
offer.data.offer().flags = passive ? PASSIVE_FLAG : 0;
return offer;
}
LedgerEntry
modifyOffer(LedgerEntry offer, int64 amount, Price const& price)
{
offer.data.offer().amount = amount;
offer.data.offer().price = price;
return offer;
}
LedgerEntry
modifyOffer(LedgerEntry offer, Asset const& ask, Asset const& bid, int64 amount,
Price const& price)
{
offer.data.offer().selling = ask;
offer.data.offer().buying = bid;
return modifyOffer(offer, amount, price);
}
}
TEST_CASE("Comparison of offers meets ordering requirements",
"[invariant][OrderBookIsNotCrossed]")
{
OrderBookIsNotCrossed::OfferEntryCmp cmp;
OfferEntry l, r;
l.price = Price{1, 1};
l.flags = PASSIVE_FLAG;
r.price = Price{2, 1};
r.flags = 0;
REQUIRE(cmp(l, r));
REQUIRE(!cmp(r, l));
l.price = Price{1, 1};
l.flags = 0;
l.offerID = 2;
r.price = Price{1, 1};
r.flags = PASSIVE_FLAG;
r.offerID = 1;
REQUIRE(cmp(l, r));
REQUIRE(!cmp(r, l));
}
TEST_CASE("OrderBookIsNotCrossed in-memory order book is consistent with "
"application behaviour",
"[invariant][OrderBookIsNotCrossed]")
{
VirtualClock clock;
auto cfg = getTestConfig(0);
// When testing the order book not crossed invariant, enable it and no other
// invariants (these tests do things which violate other invariants).
cfg.INVARIANT_CHECKS = {};
auto app = createTestApplication(clock, cfg);
OrderBookIsNotCrossed::registerAndEnableInvariant(*app);
auto root = TestAccount::createRoot(*app);
auto const cur1 = root.asset("CUR1");
auto const cur2 = root.asset("CUR2");
LedgerTxn ltxOuter{app->getLedgerTxnRoot()};
auto const invariant = std::make_shared<OrderBookIsNotCrossed>();
auto offer = InvariantTestUtils::generateOffer(cur1, cur2, 3, Price{3, 2});
// create
{
LedgerTxn ltx{ltxOuter};
ltx.create(offer);
invariant->checkOnOperationApply({}, OperationResult{}, ltx.getDelta());
auto const& orders = invariant->getOrderBook().at({cur1, cur2});
REQUIRE(orders.size() == 1);
auto const& offerToCheck = *orders.cbegin();
REQUIRE(offerToCheck.amount == 3);
REQUIRE(offerToCheck.price.n == 3);
REQUIRE(offerToCheck.price.d == 2);
ltx.commit();
}
// modify
{
LedgerTxn ltx{ltxOuter};
offer.data.offer().amount = 2;
offer.data.offer().price = Price{5, 3};
auto entry = ltx.load(LedgerEntryKey(offer));
entry.current() = offer;
invariant->checkOnOperationApply({}, OperationResult{}, ltx.getDelta());
auto const& orders = invariant->getOrderBook().at({cur1, cur2});
REQUIRE(orders.size() == 1);
auto const& offerToCheck = *orders.cbegin();
REQUIRE(offerToCheck.amount == 2);
REQUIRE(offerToCheck.price.n == 5);
ltx.commit();
}
// delete
{
LedgerTxn ltx{ltxOuter};
auto entry = ltx.load(LedgerEntryKey(offer));
entry.erase();
invariant->checkOnOperationApply({}, OperationResult{}, ltx.getDelta());
REQUIRE(invariant->getOrderBook().at({cur1, cur2}).size() == 0);
}
}
TEST_CASE("OrderBookIsNotCrossed properly throws if order book is crossed",
"[invariant][OrderBookIsNotCrossed]")
{
VirtualClock clock;
auto cfg = getTestConfig(0);
// When testing the order book not crossed invariant, enable it and no other
// invariants (these tests do things which violate other invariants).
cfg.INVARIANT_CHECKS = {};
auto app = createTestApplication(clock, cfg);
OrderBookIsNotCrossed::registerAndEnableInvariant(*app);
auto root = TestAccount::createRoot(*app);
auto const cur1 = root.asset("CUR1");
auto const cur2 = root.asset("CUR2");
auto const cur3 = root.asset("CUR3");
auto const cur4 = root.asset("CUR4");
auto const cur5 = root.asset("CUR5");
// the initial set up for the order book follows where:
// A = cur1, B = cur2, and C = cur3
// A against B
// offer1: 3 A @ 3/2 (B/A)
// offer2: 2 A @ 5/3 (B/A)
auto const offer1 = createOffer(cur1, cur2, 3, Price{3, 2});
auto const offer2 = createOffer(cur1, cur2, 2, Price{5, 3});
// B against A
// offer3: 4 B @ 3/4 (A/B)
// offer4: 1 B @ 4/5 (A/B)
auto const offer3 = createOffer(cur2, cur1, 4, Price{3, 4});
auto const offer4 = createOffer(cur2, cur1, 1, Price{4, 5});
// B against C
// offer5: 3 B @ 3/2 (C/B)
// offer6: 2 B @ 5/3 (C/B)
auto const offer5 = createOffer(cur2, cur3, 3, Price{3, 2});
auto const offer6 = createOffer(cur2, cur3, 2, Price{5, 3});
// C against B
// offer7: 4 C @ 3/4 (B/C)
// offer8: 1 C @ 4/5 (B/C)
auto const offer7 = createOffer(cur3, cur2, 4, Price{3, 4});
auto const offer8 = createOffer(cur3, cur2, 1, Price{4, 5});
applyCheck(*app,
{offer1, offer2, offer3, offer4, offer5, offer6, offer7, offer8},
{}, true);
SECTION("Not crossed when highest bid < lowest ask")
{
// Create - Offer 9: 7 A @ 8/5 (B/A)
auto const offer9 = createOffer(cur1, cur2, 7, Price{8, 5});
applyCheck(*app, {offer9}, {}, true);
// Modify - Offer 10: 7 A @ 16/11 (B/A)
auto const offer10 = modifyOffer(offer9, 7, Price{16, 11});
applyCheck(*app, {offer10}, {offer9}, true);
// Delete - Offer 10
applyCheck(*app, {}, {offer10}, true);
}
SECTION("Change an asset without crossing book")
{
auto const offer9 = modifyOffer(offer7, cur1, cur2, 4, Price{13, 10});
applyCheck(*app, {offer9}, {offer7}, false);
}
SECTION("Cross book by changing an asset")
{
auto const offer9 = modifyOffer(offer7, cur1, cur2, 4, Price{3, 4});
applyCheck(*app, {offer9}, {offer7}, false);
}
SECTION("Swap assets without crossing book")
{
auto const offer9 = modifyOffer(offer7, cur2, cur3, 4, Price{4, 3});
applyCheck(*app, {offer9}, {offer7}, true);
}
SECTION("Cross book by swapping assets")
{
auto const offer9 = modifyOffer(offer8, cur2, cur3, 1, Price{5, 4});
applyCheck(*app, {offer9}, {offer8}, false);
}
SECTION("Crossed where highest bid = lowest ask")
{
// Create - Offer 9: 7 A @ 4/3 (B/A)
auto const offer9 = createOffer(cur1, cur2, 7, Price{4, 3});
applyCheck(*app, {offer9}, {}, false);
// Modify - Offer 10: 3 A @ 4/3 (B/A)
auto const offer10 = modifyOffer(offer9, 3, Price{4, 3});
applyCheck(*app, {offer10}, {offer9}, false);
// Delete - Offer 10
applyCheck(*app, {}, {offer10}, true);
}
SECTION("Not crossed where highest bid = lowest ask but only because of "
"passive offer(s)")
{
// Create - Offer 9: 7 A @ 4/3 (B/A) (passive)
auto const offer9 = createOffer(cur1, cur2, 7, Price{4, 3}, true);
applyCheck(*app, {offer9}, {}, true);
// Modify - Offer 10: 3 A @ 4/3 (B/A)
auto const offer10 = modifyOffer(offer9, 3, Price{4, 3});
applyCheck(*app, {offer10}, {offer9}, true);
SECTION("Cross book by making an offer non-passive")
{
auto const offer11 = modifyOffer(offer10, false);
applyCheck(*app, {offer11}, {offer10}, false);
}
// Create - Offer 11: 7 A @ 1/1 (B/A) (passive)
// This offer should cross even though it's passive, because the price
// ratio between the ask and the bid is not exactly 1.
auto const offer11 = createOffer(cur1, cur2, 7, Price{1, 1}, true);
applyCheck(*app, {offer11}, {}, false);
// Delete - Offer 10
applyCheck(*app, {}, {offer10}, true);
}
SECTION("Crossed where highest bid > lowest ask")
{
// Create - Offer 9: 7 A @ 1/1 (B/A)
auto const offer9 = createOffer(cur1, cur2, 7, Price{1, 1});
applyCheck(*app, {offer9}, {}, false);
// Modify - Offer 6: 3 A @ 100/76 (B/A)
auto const offer10 = modifyOffer(offer9, 3, Price{100, 76});
applyCheck(*app, {offer10}, {offer9}, false);
// Delete - Offer 10
applyCheck(*app, {}, {offer10}, true);
}
SECTION("Multiple assets not crossed (PathPayment)")
{
// Create - Offer 9: 7 A @ 8/5 (B/A)
// Create - Offer 10: 7 B @ 8/5 (C/B)
auto const offer9 = createOffer(cur1, cur2, 7, Price{8, 5});
auto const offer10 = createOffer(cur2, cur3, 7, Price{8, 5});
applyCheck(*app, {offer9, offer10}, {}, true);
// Modify - Offer 11: 7 A @ 16/11 (B/A)
// Modify - Offer 12: 7 B @ 16/11 (C/B)
auto const offer11 = modifyOffer(offer9, 7, Price{16, 11});
auto const offer12 = modifyOffer(offer10, 7, Price{16, 11});
applyCheck(*app, {offer11, offer12}, {offer9, offer10}, true);
// Delete - Offer 11
// Delete - Offer 12
applyCheck(*app, {}, {offer11, offer12}, true);
}
SECTION("Multiple assets crossed where only one crosses (PathPayment)")
{
// Create - Offer 9: 7 A @ 4/3 (B/A) - CROSSED
// Create - Offer 10: 7 B @ 8/5 (C/B)
auto const offer9 = createOffer(cur1, cur2, 7, Price{4, 3});
auto const offer10 = createOffer(cur2, cur3, 7, Price{8, 5});
applyCheck(*app, {offer9, offer10}, {}, false);
// Modify - Offer 11: 3 A @ 16/11 (B/A)
// Modify - Offer 12: 3 B @ 100/76 (C/B) - CROSSED
auto const offer11 = modifyOffer(offer9, 3, Price{16, 11});
auto const offer12 = modifyOffer(offer10, 3, Price{100, 76});
applyCheck(*app, {offer11, offer12}, {offer9, offer10}, false);
}
SECTION("Multiple assets crossed where both crossed (PathPayment)")
{
// Create - Offer 9: 7 A @ 4/3 (B/A)
// Create - Offer 10: 7 B @ 4/3 (C/B)
auto const offer9 = createOffer(cur1, cur2, 7, Price{4, 3});
auto const offer10 = createOffer(cur2, cur3, 7, Price{4, 3});
applyCheck(*app, {offer9, offer10}, {}, false);
}
SECTION("Multiple assets not crossed when deleting offers with allow trust")
{
// Delete both of offer3 and offer5, as if, for example, their creator's
// trustline to B had been revoked.
applyCheck(*app, {}, {offer3, offer5}, true);
}
}
}
#endif // BUILD_TESTS
|
; A044672: Numbers n such that string 4,4 occurs in the base 9 representation of n but not of n+1.
; 40,121,202,283,368,445,526,607,688,769,850,931,1012,1097,1174,1255,1336,1417,1498,1579,1660,1741,1826,1903,1984,2065,2146,2227,2308,2389,2470,2555,2632,2713,2794,2875,2956,3037,3118
mul $0,2
seq $0,44632 ; Numbers n such that string 0,0 occurs in the base 9 representation of n but not of n+1.
div $0,2
|
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
L0:
mov (1|M0) r22.5<1>:ud 0x1000100:ud
mov (1|M0) f0.0<1>:uw r24.0<0;1,0>:ub
(W&~f0.0)jmpi L240
L48:
add (1|M0) a0.0<1>:ud r24.5<0;1,0>:ud 0x50EB100:ud
mov (1|M0) r16.2<1>:ud 0x0:ud
cmp (1|M0) (eq)f1.0 null.0<1>:w r24.2<0;1,0>:ub 0x1:uw
(~f1.0) add (1|M0) r26.1<1>:ud r7.12<0;1,0>:uw 0x1:ud
(f1.0) add (1|M0) r26.1<1>:ud r7.12<0;1,0>:uw 0x3:ud
mov (8|M0) r17.0<1>:ud r26.0<8;8,1>:ud
send (1|M0) r46:uw r16:ub 0x2 a0.0
mov (1|M0) a0.8<1>:uw 0x5C0:uw
mov (1|M0) a0.9<1>:uw 0x600:uw
mov (1|M0) a0.10<1>:uw 0x640:uw
mov (1|M0) a0.11<1>:uw 0x680:uw
add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw
L240:
nop
|
CeladonMansion1Script:
call EnableAutoTextBoxDrawing
ret
CeladonMansion1TextPointers:
dw CeladonMansion1Text1
dw CeladonMansion1Text2
dw CeladonMansion1Text3
dw CeladonMansion1Text4
dw CeladonMansion1Text5
CeladonMansion1Text1:
TX_FAR _CeladonMansion1Text1
TX_ASM
ld a, MEOWTH
call PlayCry
jp TextScriptEnd
CeladonMansion1Text2:
TX_ASM
callba Func_f1e70
ld a, [wPikachuHappiness]
cp 251
jr c, .asm_485d9
ld c, 50
call DelayFrames
ldpikacry e, PikachuCry23
callab PlayPikachuSoundClip
.asm_485d9
jp TextScriptEnd
CeladonMansion1Text3:
TX_FAR _CeladonMansion1Text3
TX_ASM
ld a, CLEFAIRY
call PlayCry
jp TextScriptEnd
CeladonMansion1Text4:
TX_FAR _CeladonMansion1Text4
TX_ASM
ld a, NIDORAN_F
call PlayCry
jp TextScriptEnd
CeladonMansion1Text5:
TX_FAR _CeladonMansion1Text5
db "@"
|
; Digger Remastered
; Copyright (c) Andrew Jenner 1998-2004
PUBLIC _olddelay,_getkips,_inittimer,_gethrt,_getlrt
PUBLIC _s0initint8,_s0restoreint8,_s0soundoff,_s0setspkrt2,_s0settimer0
PUBLIC _s0timer0,_s0settimer2,_s0timer2,_s0soundinitglob,_s0soundkillglob
PUBLIC _s1initint8,_s1restoreint8,_setsounddevice,_initsounddevice
PUBLIC _killsounddevice
PUBLIC _initkeyb,_restorekeyb,_getkey,_kbhit
PUBLIC _graphicsoff,_gretrace
PUBLIC _cgainit,_cgaclear,_cgapal,_cgainten,_cgaputi,_cgageti,_cgaputim
PUBLIC _cgawrite,_cgagetpix,_cgawrite,_cgatitle
PUBLIC _vgainit,_vgaclear,_vgapal,_vgainten,_vgaputi,_vgageti,_vgaputim
PUBLIC _vgawrite,_vgagetpix,_vgawrite,_vgatitle
_TEXT SEGMENT WORD PUBLIC 'CODE'
;Timing routines
_olddelay:
PUSH BP
SUB SP,6
MOV BP,SP
PUSH CX
MOV CX,W[_volume]
delay0ltop:
MOV W[BP+2],0
o24a:
MOV AX,W[BP+2]
CMP AX,W[BP+0a]
JGE o267
MOV W[BP+4],0
o257:
CMP W[BP+4],064
JGE o262
INC W[BP+4]
JMP o257
o262:
INC W[BP+2]
JMP o24a
o267:
LOOP delay0ltop
POP CX
ADD SP,6
POP BP
RET
_getkips:
PUSH ES
PUSH SI
MOV AX,040
MOV ES,AX
XOR AX,AX
XOR DX,DX
ES: MOV SI,W[06c]
zerotime:
ES: CMP SI,W[06c]
JZ zerotime
ES: MOV SI,W[06c]
getkloop:
CALL timekips
ES: CMP SI,W[06c]
JNZ donetime
INC AX
JNZ getkloop
INC DX
JMP getkloop
donetime:
POP SI
POP ES
RET
timekips:
PUSH AX
PUSH DX
PUSH SI
MOV BX,0
MOV SI,0
DW 0a0f7,0
DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0
DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0
DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0
DW 09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0,09801,0
DW 09801,0,09801,0,09801,0,09801,0
POP SI
POP DX
POP AX
RET
_inittimer:
XOR AX,AX
MOV W[_hrt],AX
MOV W[_hrt+2],AX
RET
_gethrt:
PUSH SI
PUSH DI
LEA SI,W[_hrt]
LEA DI,W[_hrt+2]
retryhrt:
MOV AL,4 ;Latch counter 0 value
CLI
OUT 043,AL
MOV BX,W[SI] ;Ideally, these four instructions would be executed
MOV DX,W[DI] ;simultaneously - no time for an interrupt.
MOV CX,W[countval] ; NB they probably are on heavily pipelined processors.
IN AL,040
MOV AH,AL
IN AL,040
STI
XCHG AL,AH
SUB CX,AX
MOV AX,CX
CMP AX,020
JB retryhrt
ADD AX,BX
ADC DX,0
POP DI
POP SI
RET
_getlrt:
PUSH ES
MOV AX,040
MOV ES,AX
ES: MOV AX,W[06c]
ES: MOV DX,W[06e]
POP ES
RET
; New sound routines
_s1initint8:
PUSH DI
MOV AX,DS
CS: MOV W[dssave8],AX
PUSH DS
MOV AX,0
MOV DS,AX
MOV DI,020
MOV AX,W[DI]
MOV BX,W[DI+2]
CS: MOV W[int8save],AX
CS: MOV W[int8save+2],BX
MOV CX,offset interrupt8v2
MOV DX,CS
CLI
MOV W[DI],CX
MOV W[DI+2],DX
STI
XOR AX,AX
PUSH AX
CALL _s0settimer0
POP AX
POP DS
POP DI
RET
interrupt8v2:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH ES
CS: MOV AX,W[dssave8]
MOV DS,AX
MOV ES,AX
CALL W[_fillbuffer]
MOV AX,W[countval]
DEC AX
XOR DX,DX
ADD AX,1
ADC DX,0
ADD W[_hrt],AX
ADC W[_hrt+2],DX
MOV BX,W[newcount]
MOV W[countval],BX
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
CS: JMP D[int8save]
_setsounddevice:
PUSH BP
MOV BP,SP
MOV AX,W[BP+4] ;Port (0210, 0220, 0230, 0240, 0250 or 0260)
MOV W[sbport],AX
MOV W[irqport],021
MOV AX,W[BP+6] ;IRQ (2, 3, 5, or 7)
ADD AX,8
CMP AX,010
JL lowirq
ADD AX,060
MOV W[irqport],0a1
lowirq:
MOV W[sbint],AX
MOV AX,W[BP+8] ;DMA channel (0, 1 or 3)
SHL AX,1
MOV W[sbdma],AX
MOV BX,W[BP+0a] ;Transfer frequency in Hz
MOV DX,0f
MOV AX,04240
DIV BX
MOV DX,256
SUB DX,AX
MOV W[sbfrq],DX
MOV AX,W[BP+0c] ;Length in bytes
MOV W[sblen],AX
SHL AX,1
PUSH AX
CALL _malloc
POP CX
CMP AX,0
JE endsetsb
MOV W[sbbuf],AX
endsetsb:
POP BP
RET
_initsounddevice:
PUSH BP
PUSH SI
PUSH DI
MOV DX,W[sbport]
ADD DX,6
MOV AL,1
OUT DX,AL
PUSH DX
CALL _gethrt
MOV SI,AX
MOV DI,DX
ADD SI,4 ;3 microseconds
ADC DI,0
delayloop:
CALL _gethrt
SUB AX,SI
SBB DX,DI
JC delayloop
POP DX
XOR AL,AL
OUT DX,AL
PUSH DX
CALL _gethrt
MOV SI,AX
MOV DI,DX
ADD SI,239 ;200 microseconds
ADC DI,0
POP DX
ADD DX,8
waitloop:
IN AL,DX
TEST AL,080
JNZ gotsb
PUSH DX
CALL _gethrt
SUB AX,SI
SBB DX,DI
POP DX
JC waitloop
nosb:
XOR AX,AX
JMP endreset
gotsb:
SUB DX,4
IN AL,DX
CMP AL,0aa
JNZ nosb
MOV BX,W[sbint]
SHL BX,1
SHL BX,1
PUSH ES
XOR AX,AX
MOV ES,AX
ES: MOV AX,W[BX]
MOV W[sboldint],AX
ES: MOV AX,W[BX+2]
MOV W[sboldint+2],AX
CS: MOV W[sbsaveds],DS
CLI
MOV AX,offset sbhandler
ES: MOV W[BX],AX
MOV AX,CS
ES: MOV W[BX+2],AX
STI
MOV CL,B[sbint]
AND CL,7
MOV DX,W[irqport]
MOV AH,1
SHL AH,CL
IN AL,DX
NOT AH
AND AL,AH
OUT DX,AL
POP ES
MOV AL,040
CALL writedsp
MOV AL,B[sbfrq]
CALL writedsp
MOV AL,0d1
CALL writedsp
CALL playsample
MOV AX,-1
endreset:
POP DI
POP SI
POP BP
RET
_killsounddevice:
MOV W[sbdonef],0
MOV W[sbendf],-1
waitsendloop:
CMP W[sbdonef],0
JE waitsendloop
MOV BX,W[sbint]
SHL BX,1
SHL BX,1
PUSH ES
XOR AX,AX
MOV ES,AX
CLI
MOV AX,W[sboldint]
ES: MOV W[BX],AX
MOV AX,W[sboldint+2]
ES: MOV W[BX+2],AX
STI
POP ES
MOV CL,B[sbint]
AND CL,7
MOV DX,W[irqport]
MOV AH,1
SHL AH,CL
IN AL,DX
OR AL,AH
OUT DX,AL
RET
writedsp:
PUSH AX
MOV DX,W[sbport]
ADD DX,0c
waitdsp:
IN AL,DX
OR AL,AL
JS waitdsp
POP AX
OUT DX,AL
RET
playsample:
PUSH SI
PUSH DI
MOV AX,W[sbbuf]
MOV SI,DS
MOV DI,DS
MOV CL,4
SHL SI,CL
MOV CL,12
SHR DI,CL
ADD SI,AX
ADC DI,0
MOV AX,SI
MOV CX,W[sblen]
ADD AX,CX
JNC boundaryokay
INC DI
XOR SI,SI
boundaryokay:
DEC CX
MOV BX,W[sbdma]
MOV DX,W[BX+dmamaskregs]
MOV AL,BL
SHR AL,1
OR AL,4
OUT DX,AL
MOV DX,W[BX+dmaclearregs]
XOR AL,AL
OUT DX,AL
MOV DX,W[BX+dmamoderegs]
MOV AL,BL
SHR AL,1
OR AL,048
OUT DX,AL
MOV DX,W[BX+dmaaddressregs]
MOV AX,SI
OUT DX,AL
MOV AL,AH
OUT DX,AL
MOV DX,W[BX+dmapageregs]
MOV AX,DI
OUT DX,AL
MOV DX,W[BX+dmalengthregs]
MOV AX,CX
OUT DX,AL
MOV AL,AH
OUT DX,AL
MOV DX,W[BX+dmamaskregs]
MOV AL,BL
SHR AL,1
OUT DX,AL
MOV AL,014
CALL writedsp
MOV AL,CL
CALL writedsp
MOV AL,CH
CALL writedsp
POP DI
POP SI
RET
sbsaveds:
DW 0
sbhandler:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH ES
PUSH SI
PUSH DI
CS: MOV AX,W[sbsaveds]
MOV DS,AX
MOV ES,AX
MOV DX,W[sbport]
ADD DL,0e
IN AL,DX
CMP W[sbendf],0
JNZ endsbint
MOV SI,W[_buffer]
MOV BX,W[_firsts]
ADD SI,BX
MOV DI,W[sbbuf]
MOV DX,W[_size]
MOV CX,W[sblen]
copylooptop:
MOVSB
INC BX
CMP BX,DX
JNE contloop
XOR BX,BX
MOV SI,W[_buffer]
contloop:
LOOP copylooptop
MOV W[_firsts],BX
CALL playsample
finsbint:
MOV AL,020
OUT 020,AL
POP DI
POP SI
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
IRET
endsbint:
MOV W[sbdonef],-1
MOV W[sbendf],0
JMP finsbint
;Original style sound routines
_s0initint8:
PUSH DI
MOV AX,DS
CS: MOV W[dssave8],AX
PUSH DS
MOV AX,0
MOV DS,AX
MOV DI,020
MOV AX,W[DI]
MOV BX,W[DI+2]
CS: MOV W[int8save],AX
CS: MOV W[int8save+2],BX
MOV CX,offset interrupt8
MOV DX,CS
CLI
MOV W[DI],CX
MOV W[DI+2],DX
STI
POP DS
POP DI
RET
_s1restoreint8:
_s0restoreint8:
PUSH DI
CLI
MOV AL,034
OUT 043,AL
XOR AL,AL
OUT 040,AL
OUT 040,AL
CS: MOV AX,W[int8save]
CS: MOV BX,W[int8save+2]
MOV DI,020
PUSH DS
XOR CX,CX
MOV DS,CX
MOV W[DI],AX
MOV W[DI+2],BX
STI
POP DS
POP DI
RET
int8save:
DW 0,0
dssave8:
DW 0
interrupt8:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH ES
CS: MOV AX,W[dssave8]
MOV DS,AX
MOV ES,AX
MOV AX,W[countval]
DEC AX
XOR DX,DX
ADD AX,1
ADC DX,0
ADD W[_hrt],AX
ADC W[_hrt+2],DX
MOV BX,W[newcount]
MOV W[countval],BX
CMP W[_spkrmode],0
JZ o3ce
CMP W[_spkrmode],1
JZ o3be
IN AL,061
XOR AL,2
OUT 061,AL
JMP o3ce
o3be:
MOV CX,W[_pulsewidth]
IN AL,061
OR AL,2
OUT 061,AL
o3c9:
LOOP o3c9
AND AL,0fd
OUT 061,AL
o3ce:
MOV AX,W[_timerrate]
CMP AX,0
JZ autoback
ADD W[_timercount],AX
PUSHF
MOV AX,W[_timercount]
AND AX,0c000
CS: CMP AX,W[ttbtc]
JE nointyet
CS: MOV W[ttbtc],AX
CALL _soundint
nointyet:
POPF
JNC o3ea
back:
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
CS: JMP D[int8save]
autoback:
CALL _soundint
JMP back
o3ea:
MOV AL,020
OUT 020,AL
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
IRET
ttbtc: ;Top two bits of _timercount
DW 0
_s0soundoff:
IN AL,061
AND AL,0fc
OUT 061,AL
RET
_s0setspkrt2:
IN AL,061
OR AL,3
OUT 061,AL
RET
_s0settimer0:
PUSH BP
MOV BP,SP
MOV AL,034
OUT 043,AL
MOV AX,W[BP+4]
MOV W[countval],AX
MOV W[newcount],AX
OUT 040,AL
MOV AL,AH
OUT 040,AL
XOR AX,AX
MOV W[_hrt],AX
MOV W[_hrt+2],AX
POP BP
RET
_s0timer0:
PUSH BP
MOV BP,SP
MOV AX,W[BP+4]
MOV W[newcount],AX
OUT 040,AL
MOV AL,AH
OUT 040,AL
POP BP
RET
_s0settimer2:
PUSH BP
MOV BP,SP
MOV AL,0b6
OUT 043,AL
MOV AX,W[BP+4]
OUT 042,AL
MOV AL,AH
OUT 042,AL
POP BP
RET
_s0timer2:
PUSH BP
MOV BP,SP
MOV AX,W[BP+4]
OUT 042,AL
MOV AL,AH
OUT 042,AL
POP BP
RET
_s0soundinitglob:
_s0soundkillglob:
RET
;Keyboard routines
_initkeyb:
PUSH DI
MOV AX,DS
CS: MOV W[dssave9],AX
PUSH DS
MOV AX,0
MOV DS,AX
MOV DI,024
MOV AX,W[DI]
MOV BX,W[DI+2]
MOV CX,offset interrupt9
MOV DX,CS
CLI
MOV W[DI],CX
MOV W[DI+2],DX
STI
POP DS
CS: MOV W[int9save],AX
CS: MOV W[int9save+2],BX
POP DI
RET
_restorekeyb:
PUSH DI
PUSH ES
MOV AX,0
MOV ES,AX
MOV DI,024
CLI
CS: MOV AX,W[int9save]
ES: MOV W[DI],AX
CS: MOV AX,W[int9save+2]
ES: MOV W[DI+2],AX
STI
POP ES
POP DI
RET
int9save:
DW 0,0
dssave9:
DW 0
interrupt9:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH DS
PUSH ES
CS: MOV AX,W[dssave9]
MOV DS,AX
IN AL,060
XOR AH,AH
PUSH AX
CALL _processkey
POP AX
POP ES
POP DS
POP DX
POP CX
POP BX
POP AX
CS: JMP D[int9save]
_getkey:
MOV AH,0
INT 016
CMP AL,0
JNE getlow
MOV AL,AH
MOV AH,1
JMP endgetkey
getlow:
MOV AH,0
endgetkey:
RET
_kbhit:
MOV AH,1
INT 016
JZ nokeypressed
MOV AX,1
JMP donekbhit
nokeypressed:
XOR AX,AX
donekbhit:
RET
;Miscellaneous graphics
_graphicsoff:
MOV AX,3
INT 010
RET
_gretrace:
CMP B[_retrflag],0
JNZ o513
RET
o513:
PUSH DX
PUSH AX
MOV DX,03da
o518:
IN AL,DX
TEST AL,8
JNZ o518
oo518:
IN AL,DX
TEST AL,8
JZ oo518
POP AX
POP DX
RET
;CGA graphics
_cgainit:
MOV B[_paletten],0
MOV AX,4
INT 010
MOV AH,0b
MOV BX,0
INT 010
MOV BX,0100
INT 010
RET
_cgaclear:
PUSH DI
PUSH ES
MOV AX,0b800
MOV ES,AX
MOV CX,02000
XOR DI,DI
XOR AX,AX
REP STOSW
POP ES
POP DI
RET
_cgapal:
PUSH BP
MOV BP,SP
CALL _gretrace
CMP W[_biosflag],1
JZ biospalette
MOV AL,B[BP+4]
AND AL,1
SHL AL,1
MOV AH,B[_paletten]
AND AH,0fd
OR AL,AH
JMP cgasetpal
biospalette:
MOV BL,B[BP+4]
AND BL,1
MOV AH,0b
MOV BH,1
INT 010
POP BP
RET
_cgainten:
PUSH BP
MOV BP,SP
CALL _gretrace
CMP W[_biosflag],1
JZ biosintensity
MOV AL,B[BP+4]
AND AL,1
MOV AH,B[_paletten]
AND AH,0fe
OR AL,AH
JMP cgasetpal
biosintensity:
MOV BL,B[BP+4]
AND BL,1
MOV CL,4
SHL BL,CL
MOV AH,0b
MOV BH,0
INT 010
POP BP
RET
cgasetpal:
XOR AH,AH
MOV BX,AX
SHL BX,1
ADD BX,AX
ADD BX,offset cgacolours
MOV CL,4
SHL AL,CL
MOV DX,03d9
OUT DX,AX
MOV DX,03ba
IN AL,DX
MOV DX,03da
IN AL,DX ;Make port 3c0 the index
MOV DX,03c0
MOV AL,1
OUT DX,AL
MOV AL,B[BX]
OUT DX,AL
MOV AL,2
OUT DX,AL
MOV AL,B[BX+1]
OUT DX,AL
MOV AL,3
OUT DX,AL
MOV AL,B[BX+2]
OUT DX,AL
MOV AL,020
OUT DX,AL
POP BP
RET
_cgaputi:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH ES
MOV BX,W[BP+4]
MOV AX,W[BP+6]
MOV DI,AX
AND DI,1
MOV CL,0d
SHL DI,CL
SAR AX,1
MOV CL,80
MUL CL
ADD DI,AX
SAR BX,1
SAR BX,1
ADD DI,BX
MOV DX,W[BP+0a]
MOV CX,W[BP+0c]
MOV SI,W[BP+8]
MOV AX,0b800
MOV ES,AX
CLD
cpiyt:
MOV BX,CX
MOV CX,DX
REP MOVSB
MOV CX,BX
SUB DI,DX
ADD DI,02000
CMP DI,04000
JL cpiok
SUB DI,03fb0
cpiok:
LOOP cpiyt
POP ES
POP DI
POP SI
POP BP
RET
_cgageti:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV BX,W[BP+4]
MOV AX,W[BP+6]
MOV SI,AX
AND SI,1
MOV CL,0d
SHL SI,CL
SAR AX,1
MOV CL,80
MUL CL
ADD SI,AX
SAR BX,1
SAR BX,1
ADD SI,BX
MOV DX,W[BP+0a]
MOV CX,W[BP+0c]
MOV DI,W[BP+8]
MOV ES,DS
MOV AX,0b800
MOV DS,AX
CLD
cgiyt:
MOV BX,CX
MOV CX,DX
REP MOVSB
MOV CX,BX
SUB SI,DX
ADD SI,02000
CMP SI,04000
JL cgiok
SUB SI,03fb0
cgiok:
LOOP cgiyt
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_cgaputim:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV BX,W[BP+4]
MOV AX,W[BP+6]
MOV DI,AX
AND DI,1
MOV CL,0d
SHL DI,CL
SAR AX,1
MOV CL,80
MUL CL
ADD DI,AX
SAR BX,1
SAR BX,1
ADD DI,BX
PUSH DI
MOV AX,0b800
MOV ES,AX
CLD
MOV DX,W[BP+0a]
MOV CX,W[BP+0c]
PUSH CX
MOV SI,W[BP+8]
MOV AX,seg _cgatable
MOV DS,AX
SHL SI,1
SHL SI,1
PUSH SI
ADD SI,2
MOV AX,W[SI+offset _cgatable]
MOV SI,AX
cpmiyt:
MOV BX,CX
MOV CX,DX
cpmixt:
LODSB
ES: AND B[DI],AL
INC DI
LOOP cpmixt
MOV CX,BX
SUB DI,DX
ADD DI,02000
CMP DI,04000
JL cpmiok
SUB DI,03fb0
cpmiok:
LOOP cpmiyt
POP SI
MOV AX,W[SI+offset _cgatable]
MOV SI,AX
POP CX
POP DI
cpimyt:
MOV BX,CX
MOV CX,DX
cpimxt:
LODSB
ES: OR B[DI],AL
INC DI
LOOP cpimxt
MOV CX,BX
SUB DI,DX
ADD DI,02000
CMP DI,04000
JL cpimok
SUB DI,03fb0
cpimok:
LOOP cpimyt
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_cgagetpix:
PUSH BP
MOV BP,SP
PUSH DI
MOV AX,0b800
MOV ES,AX
MOV BX,W[BP+6] ;y
AND BX,1
MOV CL,0d
SHL BX,CL
MOV AX,W[BP+6] ;y
SAR AX,1
MOV CL,80
MUL CL
ADD BX,AX
MOV AX,W[BP+4] ;x
SAR AX,1
SAR AX,1
ADD BX,AX
ES: MOV AL,B[BX]
POP DI
POP BP
RET
_cgawrite:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV BX,W[BP+4]
MOV AX,W[BP+6]
MOV DI,AX
AND DI,1
MOV CL,0d
SHL DI,CL
SAR AX,1
MOV CL,80
MUL CL
ADD DI,AX
SAR BX,1
SAR BX,1
ADD DI,BX
MOV DL,B[BP+0a]
AND DL,3
XOR DH,DH
MOV AX,05555
MUL DX
MOV DX,AX
MOV BX,W[BP+8]
XOR BH,BH
SUB BX,020
JL cganochar
CMP BX,05f
JGE cganochar
SHL BX,1
MOV AX,seg _ascii2cga
MOV DS,AX
MOV SI,W[BX+offset _ascii2cga]
CMP SI,0
JE cganochar
MOV BX,020
MOV AX,0b800
MOV ES,AX
MOV CX,12
cytop:
LODSW
AND AX,DX
STOSW
LODSB
AND AL,DL
STOSB
ADD DI,01ffd
CMP DI,04000
JL cgaok
SUB DI,03fb0
cgaok:
LOOP cytop
cganochar:
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_cgatitle:
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV AX,0b800
MOV ES,AX
MOV DI,0
MOV SI,offset _cgatitledat
MOV AX,seg _cgatitledat
MOV DS,AX
ctlt:
MOV AL,B[SI]
CMP AL,0fe
JE ctrle
ES: MOV B[DI],AL
INC DI
INC SI
CMP DI,04000
JNZ ctlt
JMP ctdone
ctrle:
INC SI
MOV BL,B[SI]
INC SI
MOV AL,B[SI]
INC SI
ctrlt:
ES: MOV B[DI],AL
INC DI
CMP DI,04000
JZ ctdone
DEC BL
JNZ ctrlt
JMP ctlt
ctdone:
POP ES
POP DS
POP DI
POP SI
RET
;VGA graphics
_vgainit:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
MOV B[_paletten],0
MOV AX,012
INT 010
MOV DX,03c2
MOV AL,063
OUT DX,AL
CLI
MOV DX,03da
vrdly1:
IN AL,DX
TEST AL,8
JNZ vrdly1
vrdly2:
IN AL,DX
TEST AL,8
JZ vrdly2
MOV DX,03c4
MOV AX,0100
OUT DX,AX
MOV DX,03c4
MOV AX,0300
OUT DX,AX
MOV DX,03d4
MOV AL,011
OUT DX,AL
INC DX
IN AL,DX
DEC DX
AND AL,070
MOV AH,0e
OR AH,AL
MOV AL,011
PUSH AX
OUT DX,AX
MOV AX,09c10
OUT DX,AX
MOV AX,08f12
OUT DX,AX
MOV AX,09615
OUT DX,AX
MOV AX,0b916
OUT DX,AX
MOV AX,0bf06
OUT DX,AX
MOV AL,9
OUT DX,AL
INC DX
IN AL,DX
DEC DX
AND AL,09f
OR AL,040
MOV AH,AL
MOV AL,9
OUT DX,AX
MOV AX,01f07
OUT DX,AX
POP AX
OR AH,080
OUT DX,AX
STI
MOV DX,03c4
MOV AX,0300
OUT DX,AX
XOR DI,DI
MOV CX,0ff
MOV SI,offset vgacolours
MOV DX,03c8
slooptop:
MOV AX,DI
OUT DX,AL
INC DX
LODSB
OUT DX,AL
LODSB
OUT DX,AL
LODSB
OUT DX,AL
DEC DX
INC DI
LOOP slooptop
POP DI
POP SI
MOV AL,020
MOV B[_paletten],AL
MOV AX,-1
POP BP
RET
_vgaclear:
PUSH DI
PUSH ES
MOV AX,0f02
MOV DX,03c4
OUT DX,AX
MOV AX,0a000
MOV ES,AX
XOR AX,AX
XOR DI,DI
MOV CX,16000
CLD
REP STOSW
POP ES
POP DI
RET
_vgapal:
PUSH BP
MOV BP,SP
CALL _gretrace
MOV BL,B[BP+4]
AND BL,1
MOV CL,3
SHL BL,CL
MOV AL,B[_paletten]
AND AL,0f7
OR AL,BL
MOV B[_paletten],AL
CALL vgasetpal
POP BP
RET
_vgainten:
PUSH BP
MOV BP,SP
CALL _gretrace
MOV BL,B[BP+4]
AND BL,1
MOV CL,2
SHL BL,CL
MOV AL,B[_paletten]
AND AL,0fb
OR AL,BL
MOV B[_paletten],AL
CALL vgasetpal
POP BP
RET
vgasetpal:
PUSH AX
MOV DX,03da
IN AL,DX
MOV DX,03ba
IN AL,DX
MOV AL,014
MOV DX,03c0 ;I'm using the VGA's colour select register to provide the
OUT DX,AL ;equivalent of the CGA's palette/intensity functions.
POP AX
OUT DX,AL
MOV AL,020
MOV DX,03c0
OUT DX,AL
RET
_vgaputi:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH ES
MOV AX,W[BP+6]
MOV DI,W[BP+4]
MOV CL,160
MUL CL
SHR DI,1
SHR DI,1
ADD DI,AX
MOV SI,W[BP+8]
MOV BX,W[BP+0a]
MOV AX,0a000
MOV ES,AX
MOV DX,03c4
MOV CX,4
PUSH DI
CLD
vpipt:
PUSH CX
DEC CL
MOV AX,0102
SHL AH,CL
OUT DX,AX
MOV CX,W[BP+0c]
SHL CX,1
vpiyt:
MOV AX,CX
MOV CX,BX
REP MOVSB
MOV CX,AX
SUB DI,BX
ADD DI,80
LOOP vpiyt
POP CX
POP DI
PUSH DI
LOOP vpipt
POP DI
POP ES
POP DI
POP SI
POP BP
RET
_vgageti:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV AX,W[BP+6]
MOV SI,W[BP+4]
MOV CL,160
MUL CL
SHR SI,1
SHR SI,1
ADD SI,AX
MOV DI,W[BP+8]
MOV BX,W[BP+0a]
MOV ES,DS
MOV AX,0a000
MOV DS,AX
MOV DX,03ce
MOV CX,4
PUSH SI
CLD
vgipt:
PUSH CX
DEC CL
MOV AL,4
MOV AH,CL
OUT DX,AX
SS: MOV CX,W[BP+0c]
SHL CX,1
vgiyt:
MOV AX,CX
MOV CX,BX
REP MOVSB
MOV CX,AX
SUB SI,BX
ADD SI,80
LOOP vgiyt
POP CX
POP SI
PUSH SI
LOOP vgipt
POP SI
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_vgaputim:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV AX,W[BP+6]
MOV DI,W[BP+4]
MOV CL,160
MUL CL
SHR DI,1
SHR DI,1
ADD DI,AX
MOV BX,W[BP+0a]
MOV SI,W[BP+8]
MOV AX,seg _vgatable
MOV DS,AX
SHL SI,1
SHL SI,1
PUSH SI
ADD SI,2
MOV AX,W[SI+offset _vgatable]
MOV SI,AX
PUSH SI
PUSH DI
MOV AX,0a000
MOV ES,AX
MOV CX,4
MOV DX,03c4
CLD
vpmipt:
PUSH CX
DEC CL
MOV AX,0102
SHL AH,CL
OUT DX,AX
MOV AL,4
MOV AH,CL
MOV DL,0ce
OUT DX,AX
MOV DL,0c4
SS: MOV CX,W[BP+0c]
SHL CX,1
vpmiyt:
PUSH CX
MOV CX,BX
vpmixt:
LODSB
ES: AND B[DI],AL
INC DI
LOOP vpmixt
POP CX
SUB DI,BX
ADD DI,80
LOOP vpmiyt
POP CX
POP DI
POP SI
PUSH SI
PUSH DI
LOOP vpmipt
POP DI
POP SI
POP SI
MOV AX,W[SI+offset _vgatable]
MOV SI,AX
PUSH DI
MOV CX,4
vpimpt:
PUSH CX
DEC CL
MOV AX,0102
SHL AH,CL
OUT DX,AX
MOV AL,4
MOV AH,CL
MOV DL,0ce
OUT DX,AX
MOV DL,0c4
SS: MOV CX,W[BP+0c]
SHL CX,1
vpimyt:
PUSH CX
MOV CX,BX
vpimxt:
LODSB
ES: OR B[DI],AL
INC DI
LOOP vpimxt
POP CX
SUB DI,BX
ADD DI,80
LOOP vpimyt
POP CX
POP DI
PUSH DI
LOOP vpimpt
POP DI
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_vgagetpix:
PUSH BP
MOV BP,SP
PUSH DI
XOR DI,DI
MOV AX,0a000
MOV ES,AX
MOV AX,W[BP+6]
MOV CX,160
MUL CX
MOV CX,AX
MOV BX,W[BP+4]
SAR BX,1
SAR BX,1
ADD BX,CX
MOV CX,4
get4ptop:
PUSH CX
DEC CL
MOV DX,03ce
MOV AL,4
MOV AH,CL
OUT DX,AX
ES: MOV CL,B[BX]
OR DI,CX
ES: MOV CL,B[BX+80]
OR DI,CX
POP CX
LOOP get4ptop
MOV AX,DI
AND AX,0ee ;Long story, to do with the height of fire going to 16 pixels
POP DI
POP BP
RET
vganochar:
JMP vganochar2
_vgawrite:
PUSH BP
MOV BP,SP
PUSH SI
PUSH DI
PUSH DS
PUSH ES
MOV BX,W[BP+8]
XOR BH,BH
SUB BX,020
JL vganochar2
CMP BX,05f
JGE vganochar2
SHL BX,1
PUSH DS
MOV AX,seg _ascii2vga
MOV DS,AX
MOV SI,W[BX+offset _ascii2vga]
POP DS
CMP SI,0
JE vganochar2
MOV BX,020
MOV AX,W[BP+6]
MOV DI,W[BP+4]
MOV CL,160
MUL CL
SHR DI,1
SHR DI,1
ADD DI,AX
MOV BL,B[BP+0a]
XOR BH,BH
SHL BX,1
SHL BX,1
SHL BX,1
ADD BX,offset _textoffdat
MOV CX,4
MOV AX,0a000
MOV ES,AX
MOV DX,03c4
MOV AX,seg _ascii2vga
MOV DS,AX
planetop:
PUSH CX
DEC CX
MOV AX,0102
SHL AH,CL
OUT DX,AX
ADD SI,W[BX]
INC BX
INC BX
MOV CX,24
ytop:
MOVSW
MOVSB
ADD DI,77
LOOP ytop
POP CX
SUB DI,1920
LOOP planetop
vganochar2:
POP ES
POP DS
POP DI
POP SI
POP BP
RET
_vgatitle:
PUSH ES
PUSH DS
PUSH DI
PUSH SI
MOV AX,0a000
MOV ES,AX
MOV SI,offset _vgatitledat
MOV AX,seg _vgatitledat
MOV DS,AX
MOV CX,4
MOV DX,03c4
vtplt:
XOR DI,DI
DEC CX
MOV AX,0102
SHL AH,CL
OUT DX,AX
INC CX
vtlt:
MOV AL,B[SI]
CMP AL,254
JE vtrle
ES: MOV B[DI],AL
INC DI
INC SI
CMP DI,07d00
JNZ vtlt
JMP vtdone
vtrle:
INC SI
MOV BL,B[SI]
INC SI
MOV AL,B[SI]
INC SI
vtrlt:
ES: MOV B[DI],AL
INC DI
CMP DI,07d00
JZ vtdone
DEC BL
JNZ vtrlt
JMP vtlt
vtdone:
LOOP vtplt
POP SI
POP DI
POP DS
POP ES
RET
_DATA SEGMENT WORD PUBLIC 'DATA'
_paletten:
DB 0
_hrt:
DW 0,0
countval:
DW 0
newcount:
DW 0
cgacolours:
DB 2,4,6,18,20,22,3,5,7,19,21,23
vgacolours:
DB 0, 0, 0, 0, 0,32, 0,32, 0, 0,32,32
DB 32, 0, 0, 32, 0,32, 32,32, 0, 32,32,32
DB 0, 0,16, 0, 0,63, 0,32,16, 0,32,63
DB 32, 0,16, 32, 0,63, 32,32,16, 32,32,32
DB 0,16, 0, 0,16,32, 0,63, 0, 0,63,32
DB 32,16, 0, 32,16,32, 32,63, 0, 32,63,32
DB 0,16,16, 0,16,63, 0,63,16, 0,63,63
DB 32,16,16, 32,16,63, 32,63,16, 32,63,63
DB 16, 0, 0, 16, 0,32, 16,32, 0, 16,32,32
DB 63, 0, 0, 63, 0,32, 63,32, 0, 63,32,32
DB 16, 0,16, 16, 0,63, 16,32,16, 16,32,63
DB 63, 0,16, 63, 0,63, 63,32,16, 63,32,63
DB 16,16, 0, 16,16,32, 16,63, 0, 16,63,32
DB 63,16, 0, 63,16,32, 63,63, 0, 63,63,32
DB 16,16,16, 0, 0,63, 0,63, 0, 0,63,63
DB 63, 0, 0, 63, 0,63, 63,63, 0, 63,63,63
DB 0, 0, 0, 0, 0,63, 0,63, 0, 0,63,63
DB 63, 0, 0, 63, 0,63, 63,63, 0, 48,48,48
DB 0, 0,21, 0, 0,63, 0,42,21, 0,42,63
DB 42, 0,21, 42, 0,63, 42,42,21, 42,42,63
DB 0,21, 0, 0,21,42, 0,63, 0, 0,63,42
DB 63,32, 0, 42,21,42, 42,63, 0, 42,63,42
DB 0,21,21, 0,21,63, 0,63,21, 0,63,63
DB 42,21,21, 42,21,63, 42,63,21, 42,63,63
DB 21, 0, 0, 21, 0,42, 21,42, 0, 21,42,42
DB 63, 0, 0, 63, 0,42, 63,42, 0, 63,42,42
DB 21, 0,21, 21, 0,63, 21,42,21, 21,42,63
DB 63, 0,21, 63, 0,63, 63,42,21, 63,42,63
DB 21,21, 0, 21,21,42, 21,63, 0, 21,63,42
DB 63,21, 0, 63,21,42, 63,63, 0, 63,63,42
DB 32,32,32, 32,32,63, 32,63,32, 32,63,63
DB 63,32,32, 63,32,63, 63,63,32, 63,63,63
DB 0, 0, 0, 0,32, 0, 32, 0, 0, 32,16, 0
DB 0, 0,32, 0,32,32, 32, 0,32, 32,32,32
DB 0,16, 0, 0,63, 0, 32,16, 0, 32,63, 0
DB 0,16,32, 0,63,32, 32,16,32, 32,32,32
DB 16, 0, 0, 16,32, 0, 63, 0, 0, 63,32, 0
DB 32, 0,32, 16,32,32, 63, 0,32, 63,32,32
DB 16,16, 0, 16,63, 0, 63,16, 0, 63,63, 0
DB 16,16,32, 16,63,32, 63,16,32, 63,63,32
DB 0, 0,16, 0,32,16, 32, 0,16, 32,32,16
DB 0, 0,63, 0,32,63, 32, 0,63, 32,32,63
DB 0,16,16, 0,63,16, 32,16,16, 32,63,16
DB 0,16,63, 0,63,63, 32,16,63, 32,63,63
DB 16, 0,16, 16,32,16, 63, 0,16, 63,32,16
DB 16, 0,63, 16,32,63, 63, 0,63, 63,32,63
DB 16,16,16, 0,63, 0, 63, 0, 0, 63,63, 0
DB 0, 0,63, 0,63,63, 63, 0,63, 63,63,63
DB 0, 0, 0, 0,63, 0, 63, 0, 0, 63,32, 0
DB 0, 0,63, 0,63,63, 63, 0,63, 48,48,48
DB 0,21, 0, 0,63, 0, 42,21, 0, 42,63, 0
DB 0,21,42, 0,63,42, 42,21,42, 42,63,42
DB 21, 0, 0, 21,42, 0, 63, 0, 0, 63,42, 0
DB 63, 0,63, 21,42,42, 63, 0,42, 63,42,42
DB 21,21, 0, 21,63, 0, 63,21, 0, 63,63, 0
DB 21,21,42, 21,63,42, 63,21,42, 63,63,42
DB 0, 0,21, 0,42,21, 42, 0,21, 42,42,21
DB 0, 0,63, 0,42,63, 42, 0,63, 42,42,63
DB 0,21,21, 0,63,21, 42,21,21, 42,63,21
DB 0,21,63, 0,63,63, 42,21,63, 42,63,63
DB 21, 0,21, 21,42,21, 63, 0,21, 63,42,21
DB 21, 0,63, 21,42,63, 63, 0,63, 63,42,63
DB 32,32,32, 32,63,32, 63,32,32, 63,63,32
DB 32,32,63, 32,63,63, 63,32,63, 63,63,63
sbport:
DW 0220
sbint:
DW 0f
sbdma:
DW 2
sbfrq:
DW 200
sblen:
DW 100
sbbuf:
DW 0
sboldint:
DW 0,0
sbendf:
DW 0
sbdonef:
DW 0
irqport:
DW 021
dmapageregs:
DW 087,083,081,082,08f,08b,089,08a
dmaaddressregs:
DW 0,2,4,6,0c0,0c4,0c8,0cc
dmalengthregs:
DW 1,3,5,7,0c2,0c6,0ca,0ce
dmamaskregs:
DW 0a,0a,0a,0a,0d4,0d4,0d4,0d4
dmamoderegs:
DW 0b,0b,0b,0b,0d6,0d6,0d6,0d6
dmaclearregs:
DW 0c,0c,0c,0c,0d8,0d8,0d8,0d8
|
; DO NOT MODIFY THIS FILE DIRECTLY!
; author: @TinySecEx
; ssdt asm stub for 6.1.7601-sp1-windows-7 amd64
option casemap:none
option prologue:none
option epilogue:none
.code
; ULONG64 __stdcall NtMapUserPhysicalPagesScatter( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtMapUserPhysicalPagesScatter PROC STDCALL
mov r10 , rcx
mov eax , 0
;syscall
db 0Fh , 05h
ret
NtMapUserPhysicalPagesScatter ENDP
; ULONG64 __stdcall NtWaitForSingleObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtWaitForSingleObject PROC STDCALL
mov r10 , rcx
mov eax , 1
;syscall
db 0Fh , 05h
ret
NtWaitForSingleObject ENDP
; ULONG64 __stdcall NtCallbackReturn( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCallbackReturn PROC STDCALL
mov r10 , rcx
mov eax , 2
;syscall
db 0Fh , 05h
ret
NtCallbackReturn ENDP
; ULONG64 __stdcall NtReadFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtReadFile PROC STDCALL
mov r10 , rcx
mov eax , 3
;syscall
db 0Fh , 05h
ret
NtReadFile ENDP
; ULONG64 __stdcall NtDeviceIoControlFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtDeviceIoControlFile PROC STDCALL
mov r10 , rcx
mov eax , 4
;syscall
db 0Fh , 05h
ret
NtDeviceIoControlFile ENDP
; ULONG64 __stdcall NtWriteFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtWriteFile PROC STDCALL
mov r10 , rcx
mov eax , 5
;syscall
db 0Fh , 05h
ret
NtWriteFile ENDP
; ULONG64 __stdcall NtRemoveIoCompletion( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtRemoveIoCompletion PROC STDCALL
mov r10 , rcx
mov eax , 6
;syscall
db 0Fh , 05h
ret
NtRemoveIoCompletion ENDP
; ULONG64 __stdcall NtReleaseSemaphore( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtReleaseSemaphore PROC STDCALL
mov r10 , rcx
mov eax , 7
;syscall
db 0Fh , 05h
ret
NtReleaseSemaphore ENDP
; ULONG64 __stdcall NtReplyWaitReceivePort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtReplyWaitReceivePort PROC STDCALL
mov r10 , rcx
mov eax , 8
;syscall
db 0Fh , 05h
ret
NtReplyWaitReceivePort ENDP
; ULONG64 __stdcall NtReplyPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtReplyPort PROC STDCALL
mov r10 , rcx
mov eax , 9
;syscall
db 0Fh , 05h
ret
NtReplyPort ENDP
; ULONG64 __stdcall NtSetInformationThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationThread PROC STDCALL
mov r10 , rcx
mov eax , 10
;syscall
db 0Fh , 05h
ret
NtSetInformationThread ENDP
; ULONG64 __stdcall NtSetEvent( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetEvent PROC STDCALL
mov r10 , rcx
mov eax , 11
;syscall
db 0Fh , 05h
ret
NtSetEvent ENDP
; ULONG64 __stdcall NtClose( ULONG64 arg_01 );
NtClose PROC STDCALL
mov r10 , rcx
mov eax , 12
;syscall
db 0Fh , 05h
ret
NtClose ENDP
; ULONG64 __stdcall NtQueryObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryObject PROC STDCALL
mov r10 , rcx
mov eax , 13
;syscall
db 0Fh , 05h
ret
NtQueryObject ENDP
; ULONG64 __stdcall NtQueryInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 14
;syscall
db 0Fh , 05h
ret
NtQueryInformationFile ENDP
; ULONG64 __stdcall NtOpenKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenKey PROC STDCALL
mov r10 , rcx
mov eax , 15
;syscall
db 0Fh , 05h
ret
NtOpenKey ENDP
; ULONG64 __stdcall NtEnumerateValueKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtEnumerateValueKey PROC STDCALL
mov r10 , rcx
mov eax , 16
;syscall
db 0Fh , 05h
ret
NtEnumerateValueKey ENDP
; ULONG64 __stdcall NtFindAtom( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtFindAtom PROC STDCALL
mov r10 , rcx
mov eax , 17
;syscall
db 0Fh , 05h
ret
NtFindAtom ENDP
; ULONG64 __stdcall NtQueryDefaultLocale( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryDefaultLocale PROC STDCALL
mov r10 , rcx
mov eax , 18
;syscall
db 0Fh , 05h
ret
NtQueryDefaultLocale ENDP
; ULONG64 __stdcall NtQueryKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryKey PROC STDCALL
mov r10 , rcx
mov eax , 19
;syscall
db 0Fh , 05h
ret
NtQueryKey ENDP
; ULONG64 __stdcall NtQueryValueKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQueryValueKey PROC STDCALL
mov r10 , rcx
mov eax , 20
;syscall
db 0Fh , 05h
ret
NtQueryValueKey ENDP
; ULONG64 __stdcall NtAllocateVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAllocateVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 21
;syscall
db 0Fh , 05h
ret
NtAllocateVirtualMemory ENDP
; ULONG64 __stdcall NtQueryInformationProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationProcess PROC STDCALL
mov r10 , rcx
mov eax , 22
;syscall
db 0Fh , 05h
ret
NtQueryInformationProcess ENDP
; ULONG64 __stdcall NtWaitForMultipleObjects32( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtWaitForMultipleObjects32 PROC STDCALL
mov r10 , rcx
mov eax , 23
;syscall
db 0Fh , 05h
ret
NtWaitForMultipleObjects32 ENDP
; ULONG64 __stdcall NtWriteFileGather( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtWriteFileGather PROC STDCALL
mov r10 , rcx
mov eax , 24
;syscall
db 0Fh , 05h
ret
NtWriteFileGather ENDP
; ULONG64 __stdcall NtSetInformationProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationProcess PROC STDCALL
mov r10 , rcx
mov eax , 25
;syscall
db 0Fh , 05h
ret
NtSetInformationProcess ENDP
; ULONG64 __stdcall NtCreateKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtCreateKey PROC STDCALL
mov r10 , rcx
mov eax , 26
;syscall
db 0Fh , 05h
ret
NtCreateKey ENDP
; ULONG64 __stdcall NtFreeVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtFreeVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 27
;syscall
db 0Fh , 05h
ret
NtFreeVirtualMemory ENDP
; ULONG64 __stdcall NtImpersonateClientOfPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtImpersonateClientOfPort PROC STDCALL
mov r10 , rcx
mov eax , 28
;syscall
db 0Fh , 05h
ret
NtImpersonateClientOfPort ENDP
; ULONG64 __stdcall NtReleaseMutant( ULONG64 arg_01 , ULONG64 arg_02 );
NtReleaseMutant PROC STDCALL
mov r10 , rcx
mov eax , 29
;syscall
db 0Fh , 05h
ret
NtReleaseMutant ENDP
; ULONG64 __stdcall NtQueryInformationToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationToken PROC STDCALL
mov r10 , rcx
mov eax , 30
;syscall
db 0Fh , 05h
ret
NtQueryInformationToken ENDP
; ULONG64 __stdcall NtRequestWaitReplyPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtRequestWaitReplyPort PROC STDCALL
mov r10 , rcx
mov eax , 31
;syscall
db 0Fh , 05h
ret
NtRequestWaitReplyPort ENDP
; ULONG64 __stdcall NtQueryVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQueryVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 32
;syscall
db 0Fh , 05h
ret
NtQueryVirtualMemory ENDP
; ULONG64 __stdcall NtOpenThreadToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenThreadToken PROC STDCALL
mov r10 , rcx
mov eax , 33
;syscall
db 0Fh , 05h
ret
NtOpenThreadToken ENDP
; ULONG64 __stdcall NtQueryInformationThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationThread PROC STDCALL
mov r10 , rcx
mov eax , 34
;syscall
db 0Fh , 05h
ret
NtQueryInformationThread ENDP
; ULONG64 __stdcall NtOpenProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenProcess PROC STDCALL
mov r10 , rcx
mov eax , 35
;syscall
db 0Fh , 05h
ret
NtOpenProcess ENDP
; ULONG64 __stdcall NtSetInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtSetInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 36
;syscall
db 0Fh , 05h
ret
NtSetInformationFile ENDP
; ULONG64 __stdcall NtMapViewOfSection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtMapViewOfSection PROC STDCALL
mov r10 , rcx
mov eax , 37
;syscall
db 0Fh , 05h
ret
NtMapViewOfSection ENDP
; ULONG64 __stdcall NtAccessCheckAndAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtAccessCheckAndAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 38
;syscall
db 0Fh , 05h
ret
NtAccessCheckAndAuditAlarm ENDP
; ULONG64 __stdcall NtUnmapViewOfSection( ULONG64 arg_01 , ULONG64 arg_02 );
NtUnmapViewOfSection PROC STDCALL
mov r10 , rcx
mov eax , 39
;syscall
db 0Fh , 05h
ret
NtUnmapViewOfSection ENDP
; ULONG64 __stdcall NtReplyWaitReceivePortEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtReplyWaitReceivePortEx PROC STDCALL
mov r10 , rcx
mov eax , 40
;syscall
db 0Fh , 05h
ret
NtReplyWaitReceivePortEx ENDP
; ULONG64 __stdcall NtTerminateProcess( ULONG64 arg_01 , ULONG64 arg_02 );
NtTerminateProcess PROC STDCALL
mov r10 , rcx
mov eax , 41
;syscall
db 0Fh , 05h
ret
NtTerminateProcess ENDP
; ULONG64 __stdcall NtSetEventBoostPriority( ULONG64 arg_01 );
NtSetEventBoostPriority PROC STDCALL
mov r10 , rcx
mov eax , 42
;syscall
db 0Fh , 05h
ret
NtSetEventBoostPriority ENDP
; ULONG64 __stdcall NtReadFileScatter( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtReadFileScatter PROC STDCALL
mov r10 , rcx
mov eax , 43
;syscall
db 0Fh , 05h
ret
NtReadFileScatter ENDP
; ULONG64 __stdcall NtOpenThreadTokenEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtOpenThreadTokenEx PROC STDCALL
mov r10 , rcx
mov eax , 44
;syscall
db 0Fh , 05h
ret
NtOpenThreadTokenEx ENDP
; ULONG64 __stdcall NtOpenProcessTokenEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenProcessTokenEx PROC STDCALL
mov r10 , rcx
mov eax , 45
;syscall
db 0Fh , 05h
ret
NtOpenProcessTokenEx ENDP
; ULONG64 __stdcall NtQueryPerformanceCounter( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryPerformanceCounter PROC STDCALL
mov r10 , rcx
mov eax , 46
;syscall
db 0Fh , 05h
ret
NtQueryPerformanceCounter ENDP
; ULONG64 __stdcall NtEnumerateKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtEnumerateKey PROC STDCALL
mov r10 , rcx
mov eax , 47
;syscall
db 0Fh , 05h
ret
NtEnumerateKey ENDP
; ULONG64 __stdcall NtOpenFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtOpenFile PROC STDCALL
mov r10 , rcx
mov eax , 48
;syscall
db 0Fh , 05h
ret
NtOpenFile ENDP
; ULONG64 __stdcall NtDelayExecution( ULONG64 arg_01 , ULONG64 arg_02 );
NtDelayExecution PROC STDCALL
mov r10 , rcx
mov eax , 49
;syscall
db 0Fh , 05h
ret
NtDelayExecution ENDP
; ULONG64 __stdcall NtQueryDirectoryFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtQueryDirectoryFile PROC STDCALL
mov r10 , rcx
mov eax , 50
;syscall
db 0Fh , 05h
ret
NtQueryDirectoryFile ENDP
; ULONG64 __stdcall NtQuerySystemInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtQuerySystemInformation PROC STDCALL
mov r10 , rcx
mov eax , 51
;syscall
db 0Fh , 05h
ret
NtQuerySystemInformation ENDP
; ULONG64 __stdcall NtOpenSection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenSection PROC STDCALL
mov r10 , rcx
mov eax , 52
;syscall
db 0Fh , 05h
ret
NtOpenSection ENDP
; ULONG64 __stdcall NtQueryTimer( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryTimer PROC STDCALL
mov r10 , rcx
mov eax , 53
;syscall
db 0Fh , 05h
ret
NtQueryTimer ENDP
; ULONG64 __stdcall NtFsControlFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtFsControlFile PROC STDCALL
mov r10 , rcx
mov eax , 54
;syscall
db 0Fh , 05h
ret
NtFsControlFile ENDP
; ULONG64 __stdcall NtWriteVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtWriteVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 55
;syscall
db 0Fh , 05h
ret
NtWriteVirtualMemory ENDP
; ULONG64 __stdcall NtCloseObjectAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCloseObjectAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 56
;syscall
db 0Fh , 05h
ret
NtCloseObjectAuditAlarm ENDP
; ULONG64 __stdcall NtDuplicateObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtDuplicateObject PROC STDCALL
mov r10 , rcx
mov eax , 57
;syscall
db 0Fh , 05h
ret
NtDuplicateObject ENDP
; ULONG64 __stdcall NtQueryAttributesFile( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryAttributesFile PROC STDCALL
mov r10 , rcx
mov eax , 58
;syscall
db 0Fh , 05h
ret
NtQueryAttributesFile ENDP
; ULONG64 __stdcall NtClearEvent( ULONG64 arg_01 );
NtClearEvent PROC STDCALL
mov r10 , rcx
mov eax , 59
;syscall
db 0Fh , 05h
ret
NtClearEvent ENDP
; ULONG64 __stdcall NtReadVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtReadVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 60
;syscall
db 0Fh , 05h
ret
NtReadVirtualMemory ENDP
; ULONG64 __stdcall NtOpenEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenEvent PROC STDCALL
mov r10 , rcx
mov eax , 61
;syscall
db 0Fh , 05h
ret
NtOpenEvent ENDP
; ULONG64 __stdcall NtAdjustPrivilegesToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAdjustPrivilegesToken PROC STDCALL
mov r10 , rcx
mov eax , 62
;syscall
db 0Fh , 05h
ret
NtAdjustPrivilegesToken ENDP
; ULONG64 __stdcall NtDuplicateToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtDuplicateToken PROC STDCALL
mov r10 , rcx
mov eax , 63
;syscall
db 0Fh , 05h
ret
NtDuplicateToken ENDP
; ULONG64 __stdcall NtContinue( ULONG64 arg_01 , ULONG64 arg_02 );
NtContinue PROC STDCALL
mov r10 , rcx
mov eax , 64
;syscall
db 0Fh , 05h
ret
NtContinue ENDP
; ULONG64 __stdcall NtQueryDefaultUILanguage( ULONG64 arg_01 );
NtQueryDefaultUILanguage PROC STDCALL
mov r10 , rcx
mov eax , 65
;syscall
db 0Fh , 05h
ret
NtQueryDefaultUILanguage ENDP
; ULONG64 __stdcall NtQueueApcThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueueApcThread PROC STDCALL
mov r10 , rcx
mov eax , 66
;syscall
db 0Fh , 05h
ret
NtQueueApcThread ENDP
; ULONG64 __stdcall NtYieldExecution( );
NtYieldExecution PROC STDCALL
mov r10 , rcx
mov eax , 67
;syscall
db 0Fh , 05h
ret
NtYieldExecution ENDP
; ULONG64 __stdcall NtAddAtom( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAddAtom PROC STDCALL
mov r10 , rcx
mov eax , 68
;syscall
db 0Fh , 05h
ret
NtAddAtom ENDP
; ULONG64 __stdcall NtCreateEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtCreateEvent PROC STDCALL
mov r10 , rcx
mov eax , 69
;syscall
db 0Fh , 05h
ret
NtCreateEvent ENDP
; ULONG64 __stdcall NtQueryVolumeInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryVolumeInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 70
;syscall
db 0Fh , 05h
ret
NtQueryVolumeInformationFile ENDP
; ULONG64 __stdcall NtCreateSection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtCreateSection PROC STDCALL
mov r10 , rcx
mov eax , 71
;syscall
db 0Fh , 05h
ret
NtCreateSection ENDP
; ULONG64 __stdcall NtFlushBuffersFile( ULONG64 arg_01 , ULONG64 arg_02 );
NtFlushBuffersFile PROC STDCALL
mov r10 , rcx
mov eax , 72
;syscall
db 0Fh , 05h
ret
NtFlushBuffersFile ENDP
; ULONG64 __stdcall NtApphelpCacheControl( ULONG64 arg_01 , ULONG64 arg_02 );
NtApphelpCacheControl PROC STDCALL
mov r10 , rcx
mov eax , 73
;syscall
db 0Fh , 05h
ret
NtApphelpCacheControl ENDP
; ULONG64 __stdcall NtCreateProcessEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtCreateProcessEx PROC STDCALL
mov r10 , rcx
mov eax , 74
;syscall
db 0Fh , 05h
ret
NtCreateProcessEx ENDP
; ULONG64 __stdcall NtCreateThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtCreateThread PROC STDCALL
mov r10 , rcx
mov eax , 75
;syscall
db 0Fh , 05h
ret
NtCreateThread ENDP
; ULONG64 __stdcall NtIsProcessInJob( ULONG64 arg_01 , ULONG64 arg_02 );
NtIsProcessInJob PROC STDCALL
mov r10 , rcx
mov eax , 76
;syscall
db 0Fh , 05h
ret
NtIsProcessInJob ENDP
; ULONG64 __stdcall NtProtectVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtProtectVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 77
;syscall
db 0Fh , 05h
ret
NtProtectVirtualMemory ENDP
; ULONG64 __stdcall NtQuerySection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQuerySection PROC STDCALL
mov r10 , rcx
mov eax , 78
;syscall
db 0Fh , 05h
ret
NtQuerySection ENDP
; ULONG64 __stdcall NtResumeThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtResumeThread PROC STDCALL
mov r10 , rcx
mov eax , 79
;syscall
db 0Fh , 05h
ret
NtResumeThread ENDP
; ULONG64 __stdcall NtTerminateThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtTerminateThread PROC STDCALL
mov r10 , rcx
mov eax , 80
;syscall
db 0Fh , 05h
ret
NtTerminateThread ENDP
; ULONG64 __stdcall NtReadRequestData( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtReadRequestData PROC STDCALL
mov r10 , rcx
mov eax , 81
;syscall
db 0Fh , 05h
ret
NtReadRequestData ENDP
; ULONG64 __stdcall NtCreateFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtCreateFile PROC STDCALL
mov r10 , rcx
mov eax , 82
;syscall
db 0Fh , 05h
ret
NtCreateFile ENDP
; ULONG64 __stdcall NtQueryEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryEvent PROC STDCALL
mov r10 , rcx
mov eax , 83
;syscall
db 0Fh , 05h
ret
NtQueryEvent ENDP
; ULONG64 __stdcall NtWriteRequestData( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtWriteRequestData PROC STDCALL
mov r10 , rcx
mov eax , 84
;syscall
db 0Fh , 05h
ret
NtWriteRequestData ENDP
; ULONG64 __stdcall NtOpenDirectoryObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenDirectoryObject PROC STDCALL
mov r10 , rcx
mov eax , 85
;syscall
db 0Fh , 05h
ret
NtOpenDirectoryObject ENDP
; ULONG64 __stdcall NtAccessCheckByTypeAndAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 , ULONG64 arg_13 , ULONG64 arg_14 , ULONG64 arg_15 , ULONG64 arg_16 );
NtAccessCheckByTypeAndAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 86
;syscall
db 0Fh , 05h
ret
NtAccessCheckByTypeAndAuditAlarm ENDP
; ULONG64 __stdcall NtQuerySystemTime( ULONG64 arg_01 );
NtQuerySystemTime PROC STDCALL
mov r10 , rcx
mov eax , 87
;syscall
db 0Fh , 05h
ret
NtQuerySystemTime ENDP
; ULONG64 __stdcall NtWaitForMultipleObjects( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtWaitForMultipleObjects PROC STDCALL
mov r10 , rcx
mov eax , 88
;syscall
db 0Fh , 05h
ret
NtWaitForMultipleObjects ENDP
; ULONG64 __stdcall NtSetInformationObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationObject PROC STDCALL
mov r10 , rcx
mov eax , 89
;syscall
db 0Fh , 05h
ret
NtSetInformationObject ENDP
; ULONG64 __stdcall NtCancelIoFile( ULONG64 arg_01 , ULONG64 arg_02 );
NtCancelIoFile PROC STDCALL
mov r10 , rcx
mov eax , 90
;syscall
db 0Fh , 05h
ret
NtCancelIoFile ENDP
; ULONG64 __stdcall NtTraceEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtTraceEvent PROC STDCALL
mov r10 , rcx
mov eax , 91
;syscall
db 0Fh , 05h
ret
NtTraceEvent ENDP
; ULONG64 __stdcall NtPowerInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtPowerInformation PROC STDCALL
mov r10 , rcx
mov eax , 92
;syscall
db 0Fh , 05h
ret
NtPowerInformation ENDP
; ULONG64 __stdcall NtSetValueKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtSetValueKey PROC STDCALL
mov r10 , rcx
mov eax , 93
;syscall
db 0Fh , 05h
ret
NtSetValueKey ENDP
; ULONG64 __stdcall NtCancelTimer( ULONG64 arg_01 , ULONG64 arg_02 );
NtCancelTimer PROC STDCALL
mov r10 , rcx
mov eax , 94
;syscall
db 0Fh , 05h
ret
NtCancelTimer ENDP
; ULONG64 __stdcall NtSetTimer( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtSetTimer PROC STDCALL
mov r10 , rcx
mov eax , 95
;syscall
db 0Fh , 05h
ret
NtSetTimer ENDP
; ULONG64 __stdcall NtAcceptConnectPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAcceptConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 96
;syscall
db 0Fh , 05h
ret
NtAcceptConnectPort ENDP
; ULONG64 __stdcall NtAccessCheck( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtAccessCheck PROC STDCALL
mov r10 , rcx
mov eax , 97
;syscall
db 0Fh , 05h
ret
NtAccessCheck ENDP
; ULONG64 __stdcall NtAccessCheckByType( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtAccessCheckByType PROC STDCALL
mov r10 , rcx
mov eax , 98
;syscall
db 0Fh , 05h
ret
NtAccessCheckByType ENDP
; ULONG64 __stdcall NtAccessCheckByTypeResultList( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtAccessCheckByTypeResultList PROC STDCALL
mov r10 , rcx
mov eax , 99
;syscall
db 0Fh , 05h
ret
NtAccessCheckByTypeResultList ENDP
; ULONG64 __stdcall NtAccessCheckByTypeResultListAndAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 , ULONG64 arg_13 , ULONG64 arg_14 , ULONG64 arg_15 , ULONG64 arg_16 );
NtAccessCheckByTypeResultListAndAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 100
;syscall
db 0Fh , 05h
ret
NtAccessCheckByTypeResultListAndAuditAlarm ENDP
; ULONG64 __stdcall NtAccessCheckByTypeResultListAndAuditAlarmByHandle( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 , ULONG64 arg_13 , ULONG64 arg_14 , ULONG64 arg_15 , ULONG64 arg_16 , ULONG64 arg_17 );
NtAccessCheckByTypeResultListAndAuditAlarmByHandle PROC STDCALL
mov r10 , rcx
mov eax , 101
;syscall
db 0Fh , 05h
ret
NtAccessCheckByTypeResultListAndAuditAlarmByHandle ENDP
; ULONG64 __stdcall NtAddBootEntry( ULONG64 arg_01 , ULONG64 arg_02 );
NtAddBootEntry PROC STDCALL
mov r10 , rcx
mov eax , 102
;syscall
db 0Fh , 05h
ret
NtAddBootEntry ENDP
; ULONG64 __stdcall NtAddDriverEntry( ULONG64 arg_01 , ULONG64 arg_02 );
NtAddDriverEntry PROC STDCALL
mov r10 , rcx
mov eax , 103
;syscall
db 0Fh , 05h
ret
NtAddDriverEntry ENDP
; ULONG64 __stdcall NtAdjustGroupsToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAdjustGroupsToken PROC STDCALL
mov r10 , rcx
mov eax , 104
;syscall
db 0Fh , 05h
ret
NtAdjustGroupsToken ENDP
; ULONG64 __stdcall NtAlertResumeThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtAlertResumeThread PROC STDCALL
mov r10 , rcx
mov eax , 105
;syscall
db 0Fh , 05h
ret
NtAlertResumeThread ENDP
; ULONG64 __stdcall NtAlertThread( ULONG64 arg_01 );
NtAlertThread PROC STDCALL
mov r10 , rcx
mov eax , 106
;syscall
db 0Fh , 05h
ret
NtAlertThread ENDP
; ULONG64 __stdcall NtAllocateLocallyUniqueId( ULONG64 arg_01 );
NtAllocateLocallyUniqueId PROC STDCALL
mov r10 , rcx
mov eax , 107
;syscall
db 0Fh , 05h
ret
NtAllocateLocallyUniqueId ENDP
; ULONG64 __stdcall NtAllocateReserveObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAllocateReserveObject PROC STDCALL
mov r10 , rcx
mov eax , 108
;syscall
db 0Fh , 05h
ret
NtAllocateReserveObject ENDP
; ULONG64 __stdcall NtAllocateUserPhysicalPages( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAllocateUserPhysicalPages PROC STDCALL
mov r10 , rcx
mov eax , 109
;syscall
db 0Fh , 05h
ret
NtAllocateUserPhysicalPages ENDP
; ULONG64 __stdcall NtAllocateUuids( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtAllocateUuids PROC STDCALL
mov r10 , rcx
mov eax , 110
;syscall
db 0Fh , 05h
ret
NtAllocateUuids ENDP
; ULONG64 __stdcall NtAlpcAcceptConnectPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtAlpcAcceptConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 111
;syscall
db 0Fh , 05h
ret
NtAlpcAcceptConnectPort ENDP
; ULONG64 __stdcall NtAlpcCancelMessage( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcCancelMessage PROC STDCALL
mov r10 , rcx
mov eax , 112
;syscall
db 0Fh , 05h
ret
NtAlpcCancelMessage ENDP
; ULONG64 __stdcall NtAlpcConnectPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtAlpcConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 113
;syscall
db 0Fh , 05h
ret
NtAlpcConnectPort ENDP
; ULONG64 __stdcall NtAlpcCreatePort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcCreatePort PROC STDCALL
mov r10 , rcx
mov eax , 114
;syscall
db 0Fh , 05h
ret
NtAlpcCreatePort ENDP
; ULONG64 __stdcall NtAlpcCreatePortSection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAlpcCreatePortSection PROC STDCALL
mov r10 , rcx
mov eax , 115
;syscall
db 0Fh , 05h
ret
NtAlpcCreatePortSection ENDP
; ULONG64 __stdcall NtAlpcCreateResourceReserve( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtAlpcCreateResourceReserve PROC STDCALL
mov r10 , rcx
mov eax , 116
;syscall
db 0Fh , 05h
ret
NtAlpcCreateResourceReserve ENDP
; ULONG64 __stdcall NtAlpcCreateSectionView( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcCreateSectionView PROC STDCALL
mov r10 , rcx
mov eax , 117
;syscall
db 0Fh , 05h
ret
NtAlpcCreateSectionView ENDP
; ULONG64 __stdcall NtAlpcCreateSecurityContext( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcCreateSecurityContext PROC STDCALL
mov r10 , rcx
mov eax , 118
;syscall
db 0Fh , 05h
ret
NtAlpcCreateSecurityContext ENDP
; ULONG64 __stdcall NtAlpcDeletePortSection( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcDeletePortSection PROC STDCALL
mov r10 , rcx
mov eax , 119
;syscall
db 0Fh , 05h
ret
NtAlpcDeletePortSection ENDP
; ULONG64 __stdcall NtAlpcDeleteResourceReserve( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcDeleteResourceReserve PROC STDCALL
mov r10 , rcx
mov eax , 120
;syscall
db 0Fh , 05h
ret
NtAlpcDeleteResourceReserve ENDP
; ULONG64 __stdcall NtAlpcDeleteSectionView( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcDeleteSectionView PROC STDCALL
mov r10 , rcx
mov eax , 121
;syscall
db 0Fh , 05h
ret
NtAlpcDeleteSectionView ENDP
; ULONG64 __stdcall NtAlpcDeleteSecurityContext( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcDeleteSecurityContext PROC STDCALL
mov r10 , rcx
mov eax , 122
;syscall
db 0Fh , 05h
ret
NtAlpcDeleteSecurityContext ENDP
; ULONG64 __stdcall NtAlpcDisconnectPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtAlpcDisconnectPort PROC STDCALL
mov r10 , rcx
mov eax , 123
;syscall
db 0Fh , 05h
ret
NtAlpcDisconnectPort ENDP
; ULONG64 __stdcall NtAlpcImpersonateClientOfPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcImpersonateClientOfPort PROC STDCALL
mov r10 , rcx
mov eax , 124
;syscall
db 0Fh , 05h
ret
NtAlpcImpersonateClientOfPort ENDP
; ULONG64 __stdcall NtAlpcOpenSenderProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAlpcOpenSenderProcess PROC STDCALL
mov r10 , rcx
mov eax , 125
;syscall
db 0Fh , 05h
ret
NtAlpcOpenSenderProcess ENDP
; ULONG64 __stdcall NtAlpcOpenSenderThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAlpcOpenSenderThread PROC STDCALL
mov r10 , rcx
mov eax , 126
;syscall
db 0Fh , 05h
ret
NtAlpcOpenSenderThread ENDP
; ULONG64 __stdcall NtAlpcQueryInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtAlpcQueryInformation PROC STDCALL
mov r10 , rcx
mov eax , 127
;syscall
db 0Fh , 05h
ret
NtAlpcQueryInformation ENDP
; ULONG64 __stdcall NtAlpcQueryInformationMessage( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtAlpcQueryInformationMessage PROC STDCALL
mov r10 , rcx
mov eax , 128
;syscall
db 0Fh , 05h
ret
NtAlpcQueryInformationMessage ENDP
; ULONG64 __stdcall NtAlpcRevokeSecurityContext( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtAlpcRevokeSecurityContext PROC STDCALL
mov r10 , rcx
mov eax , 129
;syscall
db 0Fh , 05h
ret
NtAlpcRevokeSecurityContext ENDP
; ULONG64 __stdcall NtAlpcSendWaitReceivePort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtAlpcSendWaitReceivePort PROC STDCALL
mov r10 , rcx
mov eax , 130
;syscall
db 0Fh , 05h
ret
NtAlpcSendWaitReceivePort ENDP
; ULONG64 __stdcall NtAlpcSetInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtAlpcSetInformation PROC STDCALL
mov r10 , rcx
mov eax , 131
;syscall
db 0Fh , 05h
ret
NtAlpcSetInformation ENDP
; ULONG64 __stdcall NtAreMappedFilesTheSame( ULONG64 arg_01 , ULONG64 arg_02 );
NtAreMappedFilesTheSame PROC STDCALL
mov r10 , rcx
mov eax , 132
;syscall
db 0Fh , 05h
ret
NtAreMappedFilesTheSame ENDP
; ULONG64 __stdcall NtAssignProcessToJobObject( ULONG64 arg_01 , ULONG64 arg_02 );
NtAssignProcessToJobObject PROC STDCALL
mov r10 , rcx
mov eax , 133
;syscall
db 0Fh , 05h
ret
NtAssignProcessToJobObject ENDP
; ULONG64 __stdcall NtCancelIoFileEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCancelIoFileEx PROC STDCALL
mov r10 , rcx
mov eax , 134
;syscall
db 0Fh , 05h
ret
NtCancelIoFileEx ENDP
; ULONG64 __stdcall NtCancelSynchronousIoFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCancelSynchronousIoFile PROC STDCALL
mov r10 , rcx
mov eax , 135
;syscall
db 0Fh , 05h
ret
NtCancelSynchronousIoFile ENDP
; ULONG64 __stdcall NtCommitComplete( ULONG64 arg_01 , ULONG64 arg_02 );
NtCommitComplete PROC STDCALL
mov r10 , rcx
mov eax , 136
;syscall
db 0Fh , 05h
ret
NtCommitComplete ENDP
; ULONG64 __stdcall NtCommitEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtCommitEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 137
;syscall
db 0Fh , 05h
ret
NtCommitEnlistment ENDP
; ULONG64 __stdcall NtCommitTransaction( ULONG64 arg_01 , ULONG64 arg_02 );
NtCommitTransaction PROC STDCALL
mov r10 , rcx
mov eax , 138
;syscall
db 0Fh , 05h
ret
NtCommitTransaction ENDP
; ULONG64 __stdcall NtCompactKeys( ULONG64 arg_01 , ULONG64 arg_02 );
NtCompactKeys PROC STDCALL
mov r10 , rcx
mov eax , 139
;syscall
db 0Fh , 05h
ret
NtCompactKeys ENDP
; ULONG64 __stdcall NtCompareTokens( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCompareTokens PROC STDCALL
mov r10 , rcx
mov eax , 140
;syscall
db 0Fh , 05h
ret
NtCompareTokens ENDP
; ULONG64 __stdcall NtCompleteConnectPort( ULONG64 arg_01 );
NtCompleteConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 141
;syscall
db 0Fh , 05h
ret
NtCompleteConnectPort ENDP
; ULONG64 __stdcall NtCompressKey( ULONG64 arg_01 );
NtCompressKey PROC STDCALL
mov r10 , rcx
mov eax , 142
;syscall
db 0Fh , 05h
ret
NtCompressKey ENDP
; ULONG64 __stdcall NtConnectPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 143
;syscall
db 0Fh , 05h
ret
NtConnectPort ENDP
; ULONG64 __stdcall NtCreateDebugObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateDebugObject PROC STDCALL
mov r10 , rcx
mov eax , 144
;syscall
db 0Fh , 05h
ret
NtCreateDebugObject ENDP
; ULONG64 __stdcall NtCreateDirectoryObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCreateDirectoryObject PROC STDCALL
mov r10 , rcx
mov eax , 145
;syscall
db 0Fh , 05h
ret
NtCreateDirectoryObject ENDP
; ULONG64 __stdcall NtCreateEnlistment( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtCreateEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 146
;syscall
db 0Fh , 05h
ret
NtCreateEnlistment ENDP
; ULONG64 __stdcall NtCreateEventPair( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCreateEventPair PROC STDCALL
mov r10 , rcx
mov eax , 147
;syscall
db 0Fh , 05h
ret
NtCreateEventPair ENDP
; ULONG64 __stdcall NtCreateIoCompletion( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateIoCompletion PROC STDCALL
mov r10 , rcx
mov eax , 148
;syscall
db 0Fh , 05h
ret
NtCreateIoCompletion ENDP
; ULONG64 __stdcall NtCreateJobObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCreateJobObject PROC STDCALL
mov r10 , rcx
mov eax , 149
;syscall
db 0Fh , 05h
ret
NtCreateJobObject ENDP
; ULONG64 __stdcall NtCreateJobSet( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtCreateJobSet PROC STDCALL
mov r10 , rcx
mov eax , 150
;syscall
db 0Fh , 05h
ret
NtCreateJobSet ENDP
; ULONG64 __stdcall NtCreateKeyTransacted( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtCreateKeyTransacted PROC STDCALL
mov r10 , rcx
mov eax , 151
;syscall
db 0Fh , 05h
ret
NtCreateKeyTransacted ENDP
; ULONG64 __stdcall NtCreateKeyedEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateKeyedEvent PROC STDCALL
mov r10 , rcx
mov eax , 152
;syscall
db 0Fh , 05h
ret
NtCreateKeyedEvent ENDP
; ULONG64 __stdcall NtCreateMailslotFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtCreateMailslotFile PROC STDCALL
mov r10 , rcx
mov eax , 153
;syscall
db 0Fh , 05h
ret
NtCreateMailslotFile ENDP
; ULONG64 __stdcall NtCreateMutant( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateMutant PROC STDCALL
mov r10 , rcx
mov eax , 154
;syscall
db 0Fh , 05h
ret
NtCreateMutant ENDP
; ULONG64 __stdcall NtCreateNamedPipeFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 , ULONG64 arg_13 , ULONG64 arg_14 );
NtCreateNamedPipeFile PROC STDCALL
mov r10 , rcx
mov eax , 155
;syscall
db 0Fh , 05h
ret
NtCreateNamedPipeFile ENDP
; ULONG64 __stdcall NtCreatePagingFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreatePagingFile PROC STDCALL
mov r10 , rcx
mov eax , 156
;syscall
db 0Fh , 05h
ret
NtCreatePagingFile ENDP
; ULONG64 __stdcall NtCreatePort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtCreatePort PROC STDCALL
mov r10 , rcx
mov eax , 157
;syscall
db 0Fh , 05h
ret
NtCreatePort ENDP
; ULONG64 __stdcall NtCreatePrivateNamespace( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreatePrivateNamespace PROC STDCALL
mov r10 , rcx
mov eax , 158
;syscall
db 0Fh , 05h
ret
NtCreatePrivateNamespace ENDP
; ULONG64 __stdcall NtCreateProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtCreateProcess PROC STDCALL
mov r10 , rcx
mov eax , 159
;syscall
db 0Fh , 05h
ret
NtCreateProcess ENDP
; ULONG64 __stdcall NtCreateProfile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtCreateProfile PROC STDCALL
mov r10 , rcx
mov eax , 160
;syscall
db 0Fh , 05h
ret
NtCreateProfile ENDP
; ULONG64 __stdcall NtCreateProfileEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtCreateProfileEx PROC STDCALL
mov r10 , rcx
mov eax , 161
;syscall
db 0Fh , 05h
ret
NtCreateProfileEx ENDP
; ULONG64 __stdcall NtCreateResourceManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtCreateResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 162
;syscall
db 0Fh , 05h
ret
NtCreateResourceManager ENDP
; ULONG64 __stdcall NtCreateSemaphore( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtCreateSemaphore PROC STDCALL
mov r10 , rcx
mov eax , 163
;syscall
db 0Fh , 05h
ret
NtCreateSemaphore ENDP
; ULONG64 __stdcall NtCreateSymbolicLinkObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateSymbolicLinkObject PROC STDCALL
mov r10 , rcx
mov eax , 164
;syscall
db 0Fh , 05h
ret
NtCreateSymbolicLinkObject ENDP
; ULONG64 __stdcall NtCreateThreadEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtCreateThreadEx PROC STDCALL
mov r10 , rcx
mov eax , 165
;syscall
db 0Fh , 05h
ret
NtCreateThreadEx ENDP
; ULONG64 __stdcall NtCreateTimer( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtCreateTimer PROC STDCALL
mov r10 , rcx
mov eax , 166
;syscall
db 0Fh , 05h
ret
NtCreateTimer ENDP
; ULONG64 __stdcall NtCreateToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 , ULONG64 arg_13 );
NtCreateToken PROC STDCALL
mov r10 , rcx
mov eax , 167
;syscall
db 0Fh , 05h
ret
NtCreateToken ENDP
; ULONG64 __stdcall NtCreateTransaction( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtCreateTransaction PROC STDCALL
mov r10 , rcx
mov eax , 168
;syscall
db 0Fh , 05h
ret
NtCreateTransaction ENDP
; ULONG64 __stdcall NtCreateTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtCreateTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 169
;syscall
db 0Fh , 05h
ret
NtCreateTransactionManager ENDP
; ULONG64 __stdcall NtCreateUserProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 );
NtCreateUserProcess PROC STDCALL
mov r10 , rcx
mov eax , 170
;syscall
db 0Fh , 05h
ret
NtCreateUserProcess ENDP
; ULONG64 __stdcall NtCreateWaitablePort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtCreateWaitablePort PROC STDCALL
mov r10 , rcx
mov eax , 171
;syscall
db 0Fh , 05h
ret
NtCreateWaitablePort ENDP
; ULONG64 __stdcall NtCreateWorkerFactory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtCreateWorkerFactory PROC STDCALL
mov r10 , rcx
mov eax , 172
;syscall
db 0Fh , 05h
ret
NtCreateWorkerFactory ENDP
; ULONG64 __stdcall NtDebugActiveProcess( ULONG64 arg_01 , ULONG64 arg_02 );
NtDebugActiveProcess PROC STDCALL
mov r10 , rcx
mov eax , 173
;syscall
db 0Fh , 05h
ret
NtDebugActiveProcess ENDP
; ULONG64 __stdcall NtDebugContinue( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtDebugContinue PROC STDCALL
mov r10 , rcx
mov eax , 174
;syscall
db 0Fh , 05h
ret
NtDebugContinue ENDP
; ULONG64 __stdcall NtDeleteAtom( ULONG64 arg_01 );
NtDeleteAtom PROC STDCALL
mov r10 , rcx
mov eax , 175
;syscall
db 0Fh , 05h
ret
NtDeleteAtom ENDP
; ULONG64 __stdcall NtDeleteBootEntry( ULONG64 arg_01 );
NtDeleteBootEntry PROC STDCALL
mov r10 , rcx
mov eax , 176
;syscall
db 0Fh , 05h
ret
NtDeleteBootEntry ENDP
; ULONG64 __stdcall NtDeleteDriverEntry( ULONG64 arg_01 );
NtDeleteDriverEntry PROC STDCALL
mov r10 , rcx
mov eax , 177
;syscall
db 0Fh , 05h
ret
NtDeleteDriverEntry ENDP
; ULONG64 __stdcall NtDeleteFile( ULONG64 arg_01 );
NtDeleteFile PROC STDCALL
mov r10 , rcx
mov eax , 178
;syscall
db 0Fh , 05h
ret
NtDeleteFile ENDP
; ULONG64 __stdcall NtDeleteKey( ULONG64 arg_01 );
NtDeleteKey PROC STDCALL
mov r10 , rcx
mov eax , 179
;syscall
db 0Fh , 05h
ret
NtDeleteKey ENDP
; ULONG64 __stdcall NtDeleteObjectAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtDeleteObjectAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 180
;syscall
db 0Fh , 05h
ret
NtDeleteObjectAuditAlarm ENDP
; ULONG64 __stdcall NtDeletePrivateNamespace( ULONG64 arg_01 );
NtDeletePrivateNamespace PROC STDCALL
mov r10 , rcx
mov eax , 181
;syscall
db 0Fh , 05h
ret
NtDeletePrivateNamespace ENDP
; ULONG64 __stdcall NtDeleteValueKey( ULONG64 arg_01 , ULONG64 arg_02 );
NtDeleteValueKey PROC STDCALL
mov r10 , rcx
mov eax , 182
;syscall
db 0Fh , 05h
ret
NtDeleteValueKey ENDP
; ULONG64 __stdcall NtDisableLastKnownGood( );
NtDisableLastKnownGood PROC STDCALL
mov r10 , rcx
mov eax , 183
;syscall
db 0Fh , 05h
ret
NtDisableLastKnownGood ENDP
; ULONG64 __stdcall NtDisplayString( ULONG64 arg_01 );
NtDisplayString PROC STDCALL
mov r10 , rcx
mov eax , 184
;syscall
db 0Fh , 05h
ret
NtDisplayString ENDP
; ULONG64 __stdcall NtDrawText( ULONG64 arg_01 );
NtDrawText PROC STDCALL
mov r10 , rcx
mov eax , 185
;syscall
db 0Fh , 05h
ret
NtDrawText ENDP
; ULONG64 __stdcall NtEnableLastKnownGood( );
NtEnableLastKnownGood PROC STDCALL
mov r10 , rcx
mov eax , 186
;syscall
db 0Fh , 05h
ret
NtEnableLastKnownGood ENDP
; ULONG64 __stdcall NtEnumerateBootEntries( ULONG64 arg_01 , ULONG64 arg_02 );
NtEnumerateBootEntries PROC STDCALL
mov r10 , rcx
mov eax , 187
;syscall
db 0Fh , 05h
ret
NtEnumerateBootEntries ENDP
; ULONG64 __stdcall NtEnumerateDriverEntries( ULONG64 arg_01 , ULONG64 arg_02 );
NtEnumerateDriverEntries PROC STDCALL
mov r10 , rcx
mov eax , 188
;syscall
db 0Fh , 05h
ret
NtEnumerateDriverEntries ENDP
; ULONG64 __stdcall NtEnumerateSystemEnvironmentValuesEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtEnumerateSystemEnvironmentValuesEx PROC STDCALL
mov r10 , rcx
mov eax , 189
;syscall
db 0Fh , 05h
ret
NtEnumerateSystemEnvironmentValuesEx ENDP
; ULONG64 __stdcall NtEnumerateTransactionObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtEnumerateTransactionObject PROC STDCALL
mov r10 , rcx
mov eax , 190
;syscall
db 0Fh , 05h
ret
NtEnumerateTransactionObject ENDP
; ULONG64 __stdcall NtExtendSection( ULONG64 arg_01 , ULONG64 arg_02 );
NtExtendSection PROC STDCALL
mov r10 , rcx
mov eax , 191
;syscall
db 0Fh , 05h
ret
NtExtendSection ENDP
; ULONG64 __stdcall NtFilterToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtFilterToken PROC STDCALL
mov r10 , rcx
mov eax , 192
;syscall
db 0Fh , 05h
ret
NtFilterToken ENDP
; ULONG64 __stdcall NtFlushInstallUILanguage( ULONG64 arg_01 , ULONG64 arg_02 );
NtFlushInstallUILanguage PROC STDCALL
mov r10 , rcx
mov eax , 193
;syscall
db 0Fh , 05h
ret
NtFlushInstallUILanguage ENDP
; ULONG64 __stdcall NtFlushInstructionCache( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtFlushInstructionCache PROC STDCALL
mov r10 , rcx
mov eax , 194
;syscall
db 0Fh , 05h
ret
NtFlushInstructionCache ENDP
; ULONG64 __stdcall NtFlushKey( ULONG64 arg_01 );
NtFlushKey PROC STDCALL
mov r10 , rcx
mov eax , 195
;syscall
db 0Fh , 05h
ret
NtFlushKey ENDP
; ULONG64 __stdcall NtFlushProcessWriteBuffers( );
NtFlushProcessWriteBuffers PROC STDCALL
mov r10 , rcx
mov eax , 196
;syscall
db 0Fh , 05h
ret
NtFlushProcessWriteBuffers ENDP
; ULONG64 __stdcall NtFlushVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtFlushVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 197
;syscall
db 0Fh , 05h
ret
NtFlushVirtualMemory ENDP
; ULONG64 __stdcall NtFlushWriteBuffer( );
NtFlushWriteBuffer PROC STDCALL
mov r10 , rcx
mov eax , 198
;syscall
db 0Fh , 05h
ret
NtFlushWriteBuffer ENDP
; ULONG64 __stdcall NtFreeUserPhysicalPages( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtFreeUserPhysicalPages PROC STDCALL
mov r10 , rcx
mov eax , 199
;syscall
db 0Fh , 05h
ret
NtFreeUserPhysicalPages ENDP
; ULONG64 __stdcall NtFreezeRegistry( ULONG64 arg_01 );
NtFreezeRegistry PROC STDCALL
mov r10 , rcx
mov eax , 200
;syscall
db 0Fh , 05h
ret
NtFreezeRegistry ENDP
; ULONG64 __stdcall NtFreezeTransactions( ULONG64 arg_01 , ULONG64 arg_02 );
NtFreezeTransactions PROC STDCALL
mov r10 , rcx
mov eax , 201
;syscall
db 0Fh , 05h
ret
NtFreezeTransactions ENDP
; ULONG64 __stdcall NtGetContextThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtGetContextThread PROC STDCALL
mov r10 , rcx
mov eax , 202
;syscall
db 0Fh , 05h
ret
NtGetContextThread ENDP
; ULONG64 __stdcall NtGetCurrentProcessorNumber( );
NtGetCurrentProcessorNumber PROC STDCALL
mov r10 , rcx
mov eax , 203
;syscall
db 0Fh , 05h
ret
NtGetCurrentProcessorNumber ENDP
; ULONG64 __stdcall NtGetDevicePowerState( ULONG64 arg_01 , ULONG64 arg_02 );
NtGetDevicePowerState PROC STDCALL
mov r10 , rcx
mov eax , 204
;syscall
db 0Fh , 05h
ret
NtGetDevicePowerState ENDP
; ULONG64 __stdcall NtGetMUIRegistryInfo( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtGetMUIRegistryInfo PROC STDCALL
mov r10 , rcx
mov eax , 205
;syscall
db 0Fh , 05h
ret
NtGetMUIRegistryInfo ENDP
; ULONG64 __stdcall NtGetNextProcess( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtGetNextProcess PROC STDCALL
mov r10 , rcx
mov eax , 206
;syscall
db 0Fh , 05h
ret
NtGetNextProcess ENDP
; ULONG64 __stdcall NtGetNextThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtGetNextThread PROC STDCALL
mov r10 , rcx
mov eax , 207
;syscall
db 0Fh , 05h
ret
NtGetNextThread ENDP
; ULONG64 __stdcall NtGetNlsSectionPtr( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtGetNlsSectionPtr PROC STDCALL
mov r10 , rcx
mov eax , 208
;syscall
db 0Fh , 05h
ret
NtGetNlsSectionPtr ENDP
; ULONG64 __stdcall NtGetNotificationResourceManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtGetNotificationResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 209
;syscall
db 0Fh , 05h
ret
NtGetNotificationResourceManager ENDP
; ULONG64 __stdcall NtGetPlugPlayEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtGetPlugPlayEvent PROC STDCALL
mov r10 , rcx
mov eax , 210
;syscall
db 0Fh , 05h
ret
NtGetPlugPlayEvent ENDP
; ULONG64 __stdcall NtGetWriteWatch( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtGetWriteWatch PROC STDCALL
mov r10 , rcx
mov eax , 211
;syscall
db 0Fh , 05h
ret
NtGetWriteWatch ENDP
; ULONG64 __stdcall NtImpersonateAnonymousToken( ULONG64 arg_01 );
NtImpersonateAnonymousToken PROC STDCALL
mov r10 , rcx
mov eax , 212
;syscall
db 0Fh , 05h
ret
NtImpersonateAnonymousToken ENDP
; ULONG64 __stdcall NtImpersonateThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtImpersonateThread PROC STDCALL
mov r10 , rcx
mov eax , 213
;syscall
db 0Fh , 05h
ret
NtImpersonateThread ENDP
; ULONG64 __stdcall NtInitializeNlsFiles( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtInitializeNlsFiles PROC STDCALL
mov r10 , rcx
mov eax , 214
;syscall
db 0Fh , 05h
ret
NtInitializeNlsFiles ENDP
; ULONG64 __stdcall NtInitializeRegistry( ULONG64 arg_01 );
NtInitializeRegistry PROC STDCALL
mov r10 , rcx
mov eax , 215
;syscall
db 0Fh , 05h
ret
NtInitializeRegistry ENDP
; ULONG64 __stdcall NtInitiatePowerAction( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtInitiatePowerAction PROC STDCALL
mov r10 , rcx
mov eax , 216
;syscall
db 0Fh , 05h
ret
NtInitiatePowerAction ENDP
; ULONG64 __stdcall NtIsSystemResumeAutomatic( );
NtIsSystemResumeAutomatic PROC STDCALL
mov r10 , rcx
mov eax , 217
;syscall
db 0Fh , 05h
ret
NtIsSystemResumeAutomatic ENDP
; ULONG64 __stdcall NtIsUILanguageComitted( );
NtIsUILanguageComitted PROC STDCALL
mov r10 , rcx
mov eax , 218
;syscall
db 0Fh , 05h
ret
NtIsUILanguageComitted ENDP
; ULONG64 __stdcall NtListenPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtListenPort PROC STDCALL
mov r10 , rcx
mov eax , 219
;syscall
db 0Fh , 05h
ret
NtListenPort ENDP
; ULONG64 __stdcall NtLoadDriver( ULONG64 arg_01 );
NtLoadDriver PROC STDCALL
mov r10 , rcx
mov eax , 220
;syscall
db 0Fh , 05h
ret
NtLoadDriver ENDP
; ULONG64 __stdcall NtLoadKey( ULONG64 arg_01 , ULONG64 arg_02 );
NtLoadKey PROC STDCALL
mov r10 , rcx
mov eax , 221
;syscall
db 0Fh , 05h
ret
NtLoadKey ENDP
; ULONG64 __stdcall NtLoadKey2( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtLoadKey2 PROC STDCALL
mov r10 , rcx
mov eax , 222
;syscall
db 0Fh , 05h
ret
NtLoadKey2 ENDP
; ULONG64 __stdcall NtLoadKeyEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtLoadKeyEx PROC STDCALL
mov r10 , rcx
mov eax , 223
;syscall
db 0Fh , 05h
ret
NtLoadKeyEx ENDP
; ULONG64 __stdcall NtLockFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtLockFile PROC STDCALL
mov r10 , rcx
mov eax , 224
;syscall
db 0Fh , 05h
ret
NtLockFile ENDP
; ULONG64 __stdcall NtLockProductActivationKeys( ULONG64 arg_01 , ULONG64 arg_02 );
NtLockProductActivationKeys PROC STDCALL
mov r10 , rcx
mov eax , 225
;syscall
db 0Fh , 05h
ret
NtLockProductActivationKeys ENDP
; ULONG64 __stdcall NtLockRegistryKey( ULONG64 arg_01 );
NtLockRegistryKey PROC STDCALL
mov r10 , rcx
mov eax , 226
;syscall
db 0Fh , 05h
ret
NtLockRegistryKey ENDP
; ULONG64 __stdcall NtLockVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtLockVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 227
;syscall
db 0Fh , 05h
ret
NtLockVirtualMemory ENDP
; ULONG64 __stdcall NtMakePermanentObject( ULONG64 arg_01 );
NtMakePermanentObject PROC STDCALL
mov r10 , rcx
mov eax , 228
;syscall
db 0Fh , 05h
ret
NtMakePermanentObject ENDP
; ULONG64 __stdcall NtMakeTemporaryObject( ULONG64 arg_01 );
NtMakeTemporaryObject PROC STDCALL
mov r10 , rcx
mov eax , 229
;syscall
db 0Fh , 05h
ret
NtMakeTemporaryObject ENDP
; ULONG64 __stdcall NtMapCMFModule( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtMapCMFModule PROC STDCALL
mov r10 , rcx
mov eax , 230
;syscall
db 0Fh , 05h
ret
NtMapCMFModule ENDP
; ULONG64 __stdcall NtMapUserPhysicalPages( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtMapUserPhysicalPages PROC STDCALL
mov r10 , rcx
mov eax , 231
;syscall
db 0Fh , 05h
ret
NtMapUserPhysicalPages ENDP
; ULONG64 __stdcall NtModifyBootEntry( ULONG64 arg_01 );
NtModifyBootEntry PROC STDCALL
mov r10 , rcx
mov eax , 232
;syscall
db 0Fh , 05h
ret
NtModifyBootEntry ENDP
; ULONG64 __stdcall NtModifyDriverEntry( ULONG64 arg_01 );
NtModifyDriverEntry PROC STDCALL
mov r10 , rcx
mov eax , 233
;syscall
db 0Fh , 05h
ret
NtModifyDriverEntry ENDP
; ULONG64 __stdcall NtNotifyChangeDirectoryFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtNotifyChangeDirectoryFile PROC STDCALL
mov r10 , rcx
mov eax , 234
;syscall
db 0Fh , 05h
ret
NtNotifyChangeDirectoryFile ENDP
; ULONG64 __stdcall NtNotifyChangeKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 );
NtNotifyChangeKey PROC STDCALL
mov r10 , rcx
mov eax , 235
;syscall
db 0Fh , 05h
ret
NtNotifyChangeKey ENDP
; ULONG64 __stdcall NtNotifyChangeMultipleKeys( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 );
NtNotifyChangeMultipleKeys PROC STDCALL
mov r10 , rcx
mov eax , 236
;syscall
db 0Fh , 05h
ret
NtNotifyChangeMultipleKeys ENDP
; ULONG64 __stdcall NtNotifyChangeSession( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 );
NtNotifyChangeSession PROC STDCALL
mov r10 , rcx
mov eax , 237
;syscall
db 0Fh , 05h
ret
NtNotifyChangeSession ENDP
; ULONG64 __stdcall NtOpenEnlistment( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtOpenEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 238
;syscall
db 0Fh , 05h
ret
NtOpenEnlistment ENDP
; ULONG64 __stdcall NtOpenEventPair( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenEventPair PROC STDCALL
mov r10 , rcx
mov eax , 239
;syscall
db 0Fh , 05h
ret
NtOpenEventPair ENDP
; ULONG64 __stdcall NtOpenIoCompletion( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenIoCompletion PROC STDCALL
mov r10 , rcx
mov eax , 240
;syscall
db 0Fh , 05h
ret
NtOpenIoCompletion ENDP
; ULONG64 __stdcall NtOpenJobObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenJobObject PROC STDCALL
mov r10 , rcx
mov eax , 241
;syscall
db 0Fh , 05h
ret
NtOpenJobObject ENDP
; ULONG64 __stdcall NtOpenKeyEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenKeyEx PROC STDCALL
mov r10 , rcx
mov eax , 242
;syscall
db 0Fh , 05h
ret
NtOpenKeyEx ENDP
; ULONG64 __stdcall NtOpenKeyTransacted( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenKeyTransacted PROC STDCALL
mov r10 , rcx
mov eax , 243
;syscall
db 0Fh , 05h
ret
NtOpenKeyTransacted ENDP
; ULONG64 __stdcall NtOpenKeyTransactedEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtOpenKeyTransactedEx PROC STDCALL
mov r10 , rcx
mov eax , 244
;syscall
db 0Fh , 05h
ret
NtOpenKeyTransactedEx ENDP
; ULONG64 __stdcall NtOpenKeyedEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenKeyedEvent PROC STDCALL
mov r10 , rcx
mov eax , 245
;syscall
db 0Fh , 05h
ret
NtOpenKeyedEvent ENDP
; ULONG64 __stdcall NtOpenMutant( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenMutant PROC STDCALL
mov r10 , rcx
mov eax , 246
;syscall
db 0Fh , 05h
ret
NtOpenMutant ENDP
; ULONG64 __stdcall NtOpenObjectAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 , ULONG64 arg_10 , ULONG64 arg_11 , ULONG64 arg_12 );
NtOpenObjectAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 247
;syscall
db 0Fh , 05h
ret
NtOpenObjectAuditAlarm ENDP
; ULONG64 __stdcall NtOpenPrivateNamespace( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenPrivateNamespace PROC STDCALL
mov r10 , rcx
mov eax , 248
;syscall
db 0Fh , 05h
ret
NtOpenPrivateNamespace ENDP
; ULONG64 __stdcall NtOpenProcessToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenProcessToken PROC STDCALL
mov r10 , rcx
mov eax , 249
;syscall
db 0Fh , 05h
ret
NtOpenProcessToken ENDP
; ULONG64 __stdcall NtOpenResourceManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtOpenResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 250
;syscall
db 0Fh , 05h
ret
NtOpenResourceManager ENDP
; ULONG64 __stdcall NtOpenSemaphore( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenSemaphore PROC STDCALL
mov r10 , rcx
mov eax , 251
;syscall
db 0Fh , 05h
ret
NtOpenSemaphore ENDP
; ULONG64 __stdcall NtOpenSession( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenSession PROC STDCALL
mov r10 , rcx
mov eax , 252
;syscall
db 0Fh , 05h
ret
NtOpenSession ENDP
; ULONG64 __stdcall NtOpenSymbolicLinkObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenSymbolicLinkObject PROC STDCALL
mov r10 , rcx
mov eax , 253
;syscall
db 0Fh , 05h
ret
NtOpenSymbolicLinkObject ENDP
; ULONG64 __stdcall NtOpenThread( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtOpenThread PROC STDCALL
mov r10 , rcx
mov eax , 254
;syscall
db 0Fh , 05h
ret
NtOpenThread ENDP
; ULONG64 __stdcall NtOpenTimer( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtOpenTimer PROC STDCALL
mov r10 , rcx
mov eax , 255
;syscall
db 0Fh , 05h
ret
NtOpenTimer ENDP
; ULONG64 __stdcall NtOpenTransaction( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtOpenTransaction PROC STDCALL
mov r10 , rcx
mov eax , 256
;syscall
db 0Fh , 05h
ret
NtOpenTransaction ENDP
; ULONG64 __stdcall NtOpenTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtOpenTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 257
;syscall
db 0Fh , 05h
ret
NtOpenTransactionManager ENDP
; ULONG64 __stdcall NtPlugPlayControl( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtPlugPlayControl PROC STDCALL
mov r10 , rcx
mov eax , 258
;syscall
db 0Fh , 05h
ret
NtPlugPlayControl ENDP
; ULONG64 __stdcall NtPrePrepareComplete( ULONG64 arg_01 , ULONG64 arg_02 );
NtPrePrepareComplete PROC STDCALL
mov r10 , rcx
mov eax , 259
;syscall
db 0Fh , 05h
ret
NtPrePrepareComplete ENDP
; ULONG64 __stdcall NtPrePrepareEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtPrePrepareEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 260
;syscall
db 0Fh , 05h
ret
NtPrePrepareEnlistment ENDP
; ULONG64 __stdcall NtPrepareComplete( ULONG64 arg_01 , ULONG64 arg_02 );
NtPrepareComplete PROC STDCALL
mov r10 , rcx
mov eax , 261
;syscall
db 0Fh , 05h
ret
NtPrepareComplete ENDP
; ULONG64 __stdcall NtPrepareEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtPrepareEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 262
;syscall
db 0Fh , 05h
ret
NtPrepareEnlistment ENDP
; ULONG64 __stdcall NtPrivilegeCheck( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtPrivilegeCheck PROC STDCALL
mov r10 , rcx
mov eax , 263
;syscall
db 0Fh , 05h
ret
NtPrivilegeCheck ENDP
; ULONG64 __stdcall NtPrivilegeObjectAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtPrivilegeObjectAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 264
;syscall
db 0Fh , 05h
ret
NtPrivilegeObjectAuditAlarm ENDP
; ULONG64 __stdcall NtPrivilegedServiceAuditAlarm( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtPrivilegedServiceAuditAlarm PROC STDCALL
mov r10 , rcx
mov eax , 265
;syscall
db 0Fh , 05h
ret
NtPrivilegedServiceAuditAlarm ENDP
; ULONG64 __stdcall NtPropagationComplete( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtPropagationComplete PROC STDCALL
mov r10 , rcx
mov eax , 266
;syscall
db 0Fh , 05h
ret
NtPropagationComplete ENDP
; ULONG64 __stdcall NtPropagationFailed( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtPropagationFailed PROC STDCALL
mov r10 , rcx
mov eax , 267
;syscall
db 0Fh , 05h
ret
NtPropagationFailed ENDP
; ULONG64 __stdcall NtPulseEvent( ULONG64 arg_01 , ULONG64 arg_02 );
NtPulseEvent PROC STDCALL
mov r10 , rcx
mov eax , 268
;syscall
db 0Fh , 05h
ret
NtPulseEvent ENDP
; ULONG64 __stdcall NtQueryBootEntryOrder( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryBootEntryOrder PROC STDCALL
mov r10 , rcx
mov eax , 269
;syscall
db 0Fh , 05h
ret
NtQueryBootEntryOrder ENDP
; ULONG64 __stdcall NtQueryBootOptions( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryBootOptions PROC STDCALL
mov r10 , rcx
mov eax , 270
;syscall
db 0Fh , 05h
ret
NtQueryBootOptions ENDP
; ULONG64 __stdcall NtQueryDebugFilterState( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryDebugFilterState PROC STDCALL
mov r10 , rcx
mov eax , 271
;syscall
db 0Fh , 05h
ret
NtQueryDebugFilterState ENDP
; ULONG64 __stdcall NtQueryDirectoryObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 );
NtQueryDirectoryObject PROC STDCALL
mov r10 , rcx
mov eax , 272
;syscall
db 0Fh , 05h
ret
NtQueryDirectoryObject ENDP
; ULONG64 __stdcall NtQueryDriverEntryOrder( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryDriverEntryOrder PROC STDCALL
mov r10 , rcx
mov eax , 273
;syscall
db 0Fh , 05h
ret
NtQueryDriverEntryOrder ENDP
; ULONG64 __stdcall NtQueryEaFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtQueryEaFile PROC STDCALL
mov r10 , rcx
mov eax , 274
;syscall
db 0Fh , 05h
ret
NtQueryEaFile ENDP
; ULONG64 __stdcall NtQueryFullAttributesFile( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryFullAttributesFile PROC STDCALL
mov r10 , rcx
mov eax , 275
;syscall
db 0Fh , 05h
ret
NtQueryFullAttributesFile ENDP
; ULONG64 __stdcall NtQueryInformationAtom( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationAtom PROC STDCALL
mov r10 , rcx
mov eax , 276
;syscall
db 0Fh , 05h
ret
NtQueryInformationAtom ENDP
; ULONG64 __stdcall NtQueryInformationEnlistment( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 277
;syscall
db 0Fh , 05h
ret
NtQueryInformationEnlistment ENDP
; ULONG64 __stdcall NtQueryInformationJobObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationJobObject PROC STDCALL
mov r10 , rcx
mov eax , 278
;syscall
db 0Fh , 05h
ret
NtQueryInformationJobObject ENDP
; ULONG64 __stdcall NtQueryInformationPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationPort PROC STDCALL
mov r10 , rcx
mov eax , 279
;syscall
db 0Fh , 05h
ret
NtQueryInformationPort ENDP
; ULONG64 __stdcall NtQueryInformationResourceManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 280
;syscall
db 0Fh , 05h
ret
NtQueryInformationResourceManager ENDP
; ULONG64 __stdcall NtQueryInformationTransaction( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationTransaction PROC STDCALL
mov r10 , rcx
mov eax , 281
;syscall
db 0Fh , 05h
ret
NtQueryInformationTransaction ENDP
; ULONG64 __stdcall NtQueryInformationTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 282
;syscall
db 0Fh , 05h
ret
NtQueryInformationTransactionManager ENDP
; ULONG64 __stdcall NtQueryInformationWorkerFactory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryInformationWorkerFactory PROC STDCALL
mov r10 , rcx
mov eax , 283
;syscall
db 0Fh , 05h
ret
NtQueryInformationWorkerFactory ENDP
; ULONG64 __stdcall NtQueryInstallUILanguage( ULONG64 arg_01 );
NtQueryInstallUILanguage PROC STDCALL
mov r10 , rcx
mov eax , 284
;syscall
db 0Fh , 05h
ret
NtQueryInstallUILanguage ENDP
; ULONG64 __stdcall NtQueryIntervalProfile( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryIntervalProfile PROC STDCALL
mov r10 , rcx
mov eax , 285
;syscall
db 0Fh , 05h
ret
NtQueryIntervalProfile ENDP
; ULONG64 __stdcall NtQueryIoCompletion( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryIoCompletion PROC STDCALL
mov r10 , rcx
mov eax , 286
;syscall
db 0Fh , 05h
ret
NtQueryIoCompletion ENDP
; ULONG64 __stdcall NtQueryLicenseValue( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryLicenseValue PROC STDCALL
mov r10 , rcx
mov eax , 287
;syscall
db 0Fh , 05h
ret
NtQueryLicenseValue ENDP
; ULONG64 __stdcall NtQueryMultipleValueKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQueryMultipleValueKey PROC STDCALL
mov r10 , rcx
mov eax , 288
;syscall
db 0Fh , 05h
ret
NtQueryMultipleValueKey ENDP
; ULONG64 __stdcall NtQueryMutant( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQueryMutant PROC STDCALL
mov r10 , rcx
mov eax , 289
;syscall
db 0Fh , 05h
ret
NtQueryMutant ENDP
; ULONG64 __stdcall NtQueryOpenSubKeys( ULONG64 arg_01 , ULONG64 arg_02 );
NtQueryOpenSubKeys PROC STDCALL
mov r10 , rcx
mov eax , 290
;syscall
db 0Fh , 05h
ret
NtQueryOpenSubKeys ENDP
; ULONG64 __stdcall NtQueryOpenSubKeysEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtQueryOpenSubKeysEx PROC STDCALL
mov r10 , rcx
mov eax , 291
;syscall
db 0Fh , 05h
ret
NtQueryOpenSubKeysEx ENDP
; ULONG64 __stdcall NtQueryPortInformationProcess( );
NtQueryPortInformationProcess PROC STDCALL
mov r10 , rcx
mov eax , 292
;syscall
db 0Fh , 05h
ret
NtQueryPortInformationProcess ENDP
; ULONG64 __stdcall NtQueryQuotaInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtQueryQuotaInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 293
;syscall
db 0Fh , 05h
ret
NtQueryQuotaInformationFile ENDP
; ULONG64 __stdcall NtQuerySecurityAttributesToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQuerySecurityAttributesToken PROC STDCALL
mov r10 , rcx
mov eax , 294
;syscall
db 0Fh , 05h
ret
NtQuerySecurityAttributesToken ENDP
; ULONG64 __stdcall NtQuerySecurityObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQuerySecurityObject PROC STDCALL
mov r10 , rcx
mov eax , 295
;syscall
db 0Fh , 05h
ret
NtQuerySecurityObject ENDP
; ULONG64 __stdcall NtQuerySemaphore( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQuerySemaphore PROC STDCALL
mov r10 , rcx
mov eax , 296
;syscall
db 0Fh , 05h
ret
NtQuerySemaphore ENDP
; ULONG64 __stdcall NtQuerySymbolicLinkObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtQuerySymbolicLinkObject PROC STDCALL
mov r10 , rcx
mov eax , 297
;syscall
db 0Fh , 05h
ret
NtQuerySymbolicLinkObject ENDP
; ULONG64 __stdcall NtQuerySystemEnvironmentValue( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtQuerySystemEnvironmentValue PROC STDCALL
mov r10 , rcx
mov eax , 298
;syscall
db 0Fh , 05h
ret
NtQuerySystemEnvironmentValue ENDP
; ULONG64 __stdcall NtQuerySystemEnvironmentValueEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtQuerySystemEnvironmentValueEx PROC STDCALL
mov r10 , rcx
mov eax , 299
;syscall
db 0Fh , 05h
ret
NtQuerySystemEnvironmentValueEx ENDP
; ULONG64 __stdcall NtQuerySystemInformationEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQuerySystemInformationEx PROC STDCALL
mov r10 , rcx
mov eax , 300
;syscall
db 0Fh , 05h
ret
NtQuerySystemInformationEx ENDP
; ULONG64 __stdcall NtQueryTimerResolution( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtQueryTimerResolution PROC STDCALL
mov r10 , rcx
mov eax , 301
;syscall
db 0Fh , 05h
ret
NtQueryTimerResolution ENDP
; ULONG64 __stdcall NtQueueApcThreadEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtQueueApcThreadEx PROC STDCALL
mov r10 , rcx
mov eax , 302
;syscall
db 0Fh , 05h
ret
NtQueueApcThreadEx ENDP
; ULONG64 __stdcall NtRaiseException( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtRaiseException PROC STDCALL
mov r10 , rcx
mov eax , 303
;syscall
db 0Fh , 05h
ret
NtRaiseException ENDP
; ULONG64 __stdcall NtRaiseHardError( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtRaiseHardError PROC STDCALL
mov r10 , rcx
mov eax , 304
;syscall
db 0Fh , 05h
ret
NtRaiseHardError ENDP
; ULONG64 __stdcall NtReadOnlyEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtReadOnlyEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 305
;syscall
db 0Fh , 05h
ret
NtReadOnlyEnlistment ENDP
; ULONG64 __stdcall NtRecoverEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtRecoverEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 306
;syscall
db 0Fh , 05h
ret
NtRecoverEnlistment ENDP
; ULONG64 __stdcall NtRecoverResourceManager( ULONG64 arg_01 );
NtRecoverResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 307
;syscall
db 0Fh , 05h
ret
NtRecoverResourceManager ENDP
; ULONG64 __stdcall NtRecoverTransactionManager( ULONG64 arg_01 );
NtRecoverTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 308
;syscall
db 0Fh , 05h
ret
NtRecoverTransactionManager ENDP
; ULONG64 __stdcall NtRegisterProtocolAddressInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtRegisterProtocolAddressInformation PROC STDCALL
mov r10 , rcx
mov eax , 309
;syscall
db 0Fh , 05h
ret
NtRegisterProtocolAddressInformation ENDP
; ULONG64 __stdcall NtRegisterThreadTerminatePort( ULONG64 arg_01 );
NtRegisterThreadTerminatePort PROC STDCALL
mov r10 , rcx
mov eax , 310
;syscall
db 0Fh , 05h
ret
NtRegisterThreadTerminatePort ENDP
; ULONG64 __stdcall NtReleaseKeyedEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtReleaseKeyedEvent PROC STDCALL
mov r10 , rcx
mov eax , 311
;syscall
db 0Fh , 05h
ret
NtReleaseKeyedEvent ENDP
; ULONG64 __stdcall NtReleaseWorkerFactoryWorker( ULONG64 arg_01 );
NtReleaseWorkerFactoryWorker PROC STDCALL
mov r10 , rcx
mov eax , 312
;syscall
db 0Fh , 05h
ret
NtReleaseWorkerFactoryWorker ENDP
; ULONG64 __stdcall NtRemoveIoCompletionEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtRemoveIoCompletionEx PROC STDCALL
mov r10 , rcx
mov eax , 313
;syscall
db 0Fh , 05h
ret
NtRemoveIoCompletionEx ENDP
; ULONG64 __stdcall NtRemoveProcessDebug( ULONG64 arg_01 , ULONG64 arg_02 );
NtRemoveProcessDebug PROC STDCALL
mov r10 , rcx
mov eax , 314
;syscall
db 0Fh , 05h
ret
NtRemoveProcessDebug ENDP
; ULONG64 __stdcall NtRenameKey( ULONG64 arg_01 , ULONG64 arg_02 );
NtRenameKey PROC STDCALL
mov r10 , rcx
mov eax , 315
;syscall
db 0Fh , 05h
ret
NtRenameKey ENDP
; ULONG64 __stdcall NtRenameTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 );
NtRenameTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 316
;syscall
db 0Fh , 05h
ret
NtRenameTransactionManager ENDP
; ULONG64 __stdcall NtReplaceKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtReplaceKey PROC STDCALL
mov r10 , rcx
mov eax , 317
;syscall
db 0Fh , 05h
ret
NtReplaceKey ENDP
; ULONG64 __stdcall NtReplacePartitionUnit( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtReplacePartitionUnit PROC STDCALL
mov r10 , rcx
mov eax , 318
;syscall
db 0Fh , 05h
ret
NtReplacePartitionUnit ENDP
; ULONG64 __stdcall NtReplyWaitReplyPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtReplyWaitReplyPort PROC STDCALL
mov r10 , rcx
mov eax , 319
;syscall
db 0Fh , 05h
ret
NtReplyWaitReplyPort ENDP
; ULONG64 __stdcall NtRequestPort( ULONG64 arg_01 , ULONG64 arg_02 );
NtRequestPort PROC STDCALL
mov r10 , rcx
mov eax , 320
;syscall
db 0Fh , 05h
ret
NtRequestPort ENDP
; ULONG64 __stdcall NtResetEvent( ULONG64 arg_01 , ULONG64 arg_02 );
NtResetEvent PROC STDCALL
mov r10 , rcx
mov eax , 321
;syscall
db 0Fh , 05h
ret
NtResetEvent ENDP
; ULONG64 __stdcall NtResetWriteWatch( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtResetWriteWatch PROC STDCALL
mov r10 , rcx
mov eax , 322
;syscall
db 0Fh , 05h
ret
NtResetWriteWatch ENDP
; ULONG64 __stdcall NtRestoreKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtRestoreKey PROC STDCALL
mov r10 , rcx
mov eax , 323
;syscall
db 0Fh , 05h
ret
NtRestoreKey ENDP
; ULONG64 __stdcall NtResumeProcess( ULONG64 arg_01 );
NtResumeProcess PROC STDCALL
mov r10 , rcx
mov eax , 324
;syscall
db 0Fh , 05h
ret
NtResumeProcess ENDP
; ULONG64 __stdcall NtRollbackComplete( ULONG64 arg_01 , ULONG64 arg_02 );
NtRollbackComplete PROC STDCALL
mov r10 , rcx
mov eax , 325
;syscall
db 0Fh , 05h
ret
NtRollbackComplete ENDP
; ULONG64 __stdcall NtRollbackEnlistment( ULONG64 arg_01 , ULONG64 arg_02 );
NtRollbackEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 326
;syscall
db 0Fh , 05h
ret
NtRollbackEnlistment ENDP
; ULONG64 __stdcall NtRollbackTransaction( ULONG64 arg_01 , ULONG64 arg_02 );
NtRollbackTransaction PROC STDCALL
mov r10 , rcx
mov eax , 327
;syscall
db 0Fh , 05h
ret
NtRollbackTransaction ENDP
; ULONG64 __stdcall NtRollforwardTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 );
NtRollforwardTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 328
;syscall
db 0Fh , 05h
ret
NtRollforwardTransactionManager ENDP
; ULONG64 __stdcall NtSaveKey( ULONG64 arg_01 , ULONG64 arg_02 );
NtSaveKey PROC STDCALL
mov r10 , rcx
mov eax , 329
;syscall
db 0Fh , 05h
ret
NtSaveKey ENDP
; ULONG64 __stdcall NtSaveKeyEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSaveKeyEx PROC STDCALL
mov r10 , rcx
mov eax , 330
;syscall
db 0Fh , 05h
ret
NtSaveKeyEx ENDP
; ULONG64 __stdcall NtSaveMergedKeys( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSaveMergedKeys PROC STDCALL
mov r10 , rcx
mov eax , 331
;syscall
db 0Fh , 05h
ret
NtSaveMergedKeys ENDP
; ULONG64 __stdcall NtSecureConnectPort( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 , ULONG64 arg_07 , ULONG64 arg_08 , ULONG64 arg_09 );
NtSecureConnectPort PROC STDCALL
mov r10 , rcx
mov eax , 332
;syscall
db 0Fh , 05h
ret
NtSecureConnectPort ENDP
; ULONG64 __stdcall NtSerializeBoot( );
NtSerializeBoot PROC STDCALL
mov r10 , rcx
mov eax , 333
;syscall
db 0Fh , 05h
ret
NtSerializeBoot ENDP
; ULONG64 __stdcall NtSetBootEntryOrder( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetBootEntryOrder PROC STDCALL
mov r10 , rcx
mov eax , 334
;syscall
db 0Fh , 05h
ret
NtSetBootEntryOrder ENDP
; ULONG64 __stdcall NtSetBootOptions( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetBootOptions PROC STDCALL
mov r10 , rcx
mov eax , 335
;syscall
db 0Fh , 05h
ret
NtSetBootOptions ENDP
; ULONG64 __stdcall NtSetContextThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetContextThread PROC STDCALL
mov r10 , rcx
mov eax , 336
;syscall
db 0Fh , 05h
ret
NtSetContextThread ENDP
; ULONG64 __stdcall NtSetDebugFilterState( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSetDebugFilterState PROC STDCALL
mov r10 , rcx
mov eax , 337
;syscall
db 0Fh , 05h
ret
NtSetDebugFilterState ENDP
; ULONG64 __stdcall NtSetDefaultHardErrorPort( ULONG64 arg_01 );
NtSetDefaultHardErrorPort PROC STDCALL
mov r10 , rcx
mov eax , 338
;syscall
db 0Fh , 05h
ret
NtSetDefaultHardErrorPort ENDP
; ULONG64 __stdcall NtSetDefaultLocale( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetDefaultLocale PROC STDCALL
mov r10 , rcx
mov eax , 339
;syscall
db 0Fh , 05h
ret
NtSetDefaultLocale ENDP
; ULONG64 __stdcall NtSetDefaultUILanguage( ULONG64 arg_01 );
NtSetDefaultUILanguage PROC STDCALL
mov r10 , rcx
mov eax , 340
;syscall
db 0Fh , 05h
ret
NtSetDefaultUILanguage ENDP
; ULONG64 __stdcall NtSetDriverEntryOrder( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetDriverEntryOrder PROC STDCALL
mov r10 , rcx
mov eax , 341
;syscall
db 0Fh , 05h
ret
NtSetDriverEntryOrder ENDP
; ULONG64 __stdcall NtSetEaFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetEaFile PROC STDCALL
mov r10 , rcx
mov eax , 342
;syscall
db 0Fh , 05h
ret
NtSetEaFile ENDP
; ULONG64 __stdcall NtSetHighEventPair( ULONG64 arg_01 );
NtSetHighEventPair PROC STDCALL
mov r10 , rcx
mov eax , 343
;syscall
db 0Fh , 05h
ret
NtSetHighEventPair ENDP
; ULONG64 __stdcall NtSetHighWaitLowEventPair( ULONG64 arg_01 );
NtSetHighWaitLowEventPair PROC STDCALL
mov r10 , rcx
mov eax , 344
;syscall
db 0Fh , 05h
ret
NtSetHighWaitLowEventPair ENDP
; ULONG64 __stdcall NtSetInformationDebugObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtSetInformationDebugObject PROC STDCALL
mov r10 , rcx
mov eax , 345
;syscall
db 0Fh , 05h
ret
NtSetInformationDebugObject ENDP
; ULONG64 __stdcall NtSetInformationEnlistment( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationEnlistment PROC STDCALL
mov r10 , rcx
mov eax , 346
;syscall
db 0Fh , 05h
ret
NtSetInformationEnlistment ENDP
; ULONG64 __stdcall NtSetInformationJobObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationJobObject PROC STDCALL
mov r10 , rcx
mov eax , 347
;syscall
db 0Fh , 05h
ret
NtSetInformationJobObject ENDP
; ULONG64 __stdcall NtSetInformationKey( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationKey PROC STDCALL
mov r10 , rcx
mov eax , 348
;syscall
db 0Fh , 05h
ret
NtSetInformationKey ENDP
; ULONG64 __stdcall NtSetInformationResourceManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationResourceManager PROC STDCALL
mov r10 , rcx
mov eax , 349
;syscall
db 0Fh , 05h
ret
NtSetInformationResourceManager ENDP
; ULONG64 __stdcall NtSetInformationToken( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationToken PROC STDCALL
mov r10 , rcx
mov eax , 350
;syscall
db 0Fh , 05h
ret
NtSetInformationToken ENDP
; ULONG64 __stdcall NtSetInformationTransaction( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationTransaction PROC STDCALL
mov r10 , rcx
mov eax , 351
;syscall
db 0Fh , 05h
ret
NtSetInformationTransaction ENDP
; ULONG64 __stdcall NtSetInformationTransactionManager( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationTransactionManager PROC STDCALL
mov r10 , rcx
mov eax , 352
;syscall
db 0Fh , 05h
ret
NtSetInformationTransactionManager ENDP
; ULONG64 __stdcall NtSetInformationWorkerFactory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetInformationWorkerFactory PROC STDCALL
mov r10 , rcx
mov eax , 353
;syscall
db 0Fh , 05h
ret
NtSetInformationWorkerFactory ENDP
; ULONG64 __stdcall NtSetIntervalProfile( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetIntervalProfile PROC STDCALL
mov r10 , rcx
mov eax , 354
;syscall
db 0Fh , 05h
ret
NtSetIntervalProfile ENDP
; ULONG64 __stdcall NtSetIoCompletion( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtSetIoCompletion PROC STDCALL
mov r10 , rcx
mov eax , 355
;syscall
db 0Fh , 05h
ret
NtSetIoCompletion ENDP
; ULONG64 __stdcall NtSetIoCompletionEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtSetIoCompletionEx PROC STDCALL
mov r10 , rcx
mov eax , 356
;syscall
db 0Fh , 05h
ret
NtSetIoCompletionEx ENDP
; ULONG64 __stdcall NtSetLdtEntries( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtSetLdtEntries PROC STDCALL
mov r10 , rcx
mov eax , 357
;syscall
db 0Fh , 05h
ret
NtSetLdtEntries ENDP
; ULONG64 __stdcall NtSetLowEventPair( ULONG64 arg_01 );
NtSetLowEventPair PROC STDCALL
mov r10 , rcx
mov eax , 358
;syscall
db 0Fh , 05h
ret
NtSetLowEventPair ENDP
; ULONG64 __stdcall NtSetLowWaitHighEventPair( ULONG64 arg_01 );
NtSetLowWaitHighEventPair PROC STDCALL
mov r10 , rcx
mov eax , 359
;syscall
db 0Fh , 05h
ret
NtSetLowWaitHighEventPair ENDP
; ULONG64 __stdcall NtSetQuotaInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetQuotaInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 360
;syscall
db 0Fh , 05h
ret
NtSetQuotaInformationFile ENDP
; ULONG64 __stdcall NtSetSecurityObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSetSecurityObject PROC STDCALL
mov r10 , rcx
mov eax , 361
;syscall
db 0Fh , 05h
ret
NtSetSecurityObject ENDP
; ULONG64 __stdcall NtSetSystemEnvironmentValue( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetSystemEnvironmentValue PROC STDCALL
mov r10 , rcx
mov eax , 362
;syscall
db 0Fh , 05h
ret
NtSetSystemEnvironmentValue ENDP
; ULONG64 __stdcall NtSetSystemEnvironmentValueEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtSetSystemEnvironmentValueEx PROC STDCALL
mov r10 , rcx
mov eax , 363
;syscall
db 0Fh , 05h
ret
NtSetSystemEnvironmentValueEx ENDP
; ULONG64 __stdcall NtSetSystemInformation( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSetSystemInformation PROC STDCALL
mov r10 , rcx
mov eax , 364
;syscall
db 0Fh , 05h
ret
NtSetSystemInformation ENDP
; ULONG64 __stdcall NtSetSystemPowerState( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSetSystemPowerState PROC STDCALL
mov r10 , rcx
mov eax , 365
;syscall
db 0Fh , 05h
ret
NtSetSystemPowerState ENDP
; ULONG64 __stdcall NtSetSystemTime( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetSystemTime PROC STDCALL
mov r10 , rcx
mov eax , 366
;syscall
db 0Fh , 05h
ret
NtSetSystemTime ENDP
; ULONG64 __stdcall NtSetThreadExecutionState( ULONG64 arg_01 , ULONG64 arg_02 );
NtSetThreadExecutionState PROC STDCALL
mov r10 , rcx
mov eax , 367
;syscall
db 0Fh , 05h
ret
NtSetThreadExecutionState ENDP
; ULONG64 __stdcall NtSetTimerEx( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSetTimerEx PROC STDCALL
mov r10 , rcx
mov eax , 368
;syscall
db 0Fh , 05h
ret
NtSetTimerEx ENDP
; ULONG64 __stdcall NtSetTimerResolution( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 );
NtSetTimerResolution PROC STDCALL
mov r10 , rcx
mov eax , 369
;syscall
db 0Fh , 05h
ret
NtSetTimerResolution ENDP
; ULONG64 __stdcall NtSetUuidSeed( ULONG64 arg_01 );
NtSetUuidSeed PROC STDCALL
mov r10 , rcx
mov eax , 370
;syscall
db 0Fh , 05h
ret
NtSetUuidSeed ENDP
; ULONG64 __stdcall NtSetVolumeInformationFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtSetVolumeInformationFile PROC STDCALL
mov r10 , rcx
mov eax , 371
;syscall
db 0Fh , 05h
ret
NtSetVolumeInformationFile ENDP
; ULONG64 __stdcall NtShutdownSystem( ULONG64 arg_01 );
NtShutdownSystem PROC STDCALL
mov r10 , rcx
mov eax , 372
;syscall
db 0Fh , 05h
ret
NtShutdownSystem ENDP
; ULONG64 __stdcall NtShutdownWorkerFactory( ULONG64 arg_01 , ULONG64 arg_02 );
NtShutdownWorkerFactory PROC STDCALL
mov r10 , rcx
mov eax , 373
;syscall
db 0Fh , 05h
ret
NtShutdownWorkerFactory ENDP
; ULONG64 __stdcall NtSignalAndWaitForSingleObject( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtSignalAndWaitForSingleObject PROC STDCALL
mov r10 , rcx
mov eax , 374
;syscall
db 0Fh , 05h
ret
NtSignalAndWaitForSingleObject ENDP
; ULONG64 __stdcall NtSinglePhaseReject( ULONG64 arg_01 , ULONG64 arg_02 );
NtSinglePhaseReject PROC STDCALL
mov r10 , rcx
mov eax , 375
;syscall
db 0Fh , 05h
ret
NtSinglePhaseReject ENDP
; ULONG64 __stdcall NtStartProfile( ULONG64 arg_01 );
NtStartProfile PROC STDCALL
mov r10 , rcx
mov eax , 376
;syscall
db 0Fh , 05h
ret
NtStartProfile ENDP
; ULONG64 __stdcall NtStopProfile( ULONG64 arg_01 );
NtStopProfile PROC STDCALL
mov r10 , rcx
mov eax , 377
;syscall
db 0Fh , 05h
ret
NtStopProfile ENDP
; ULONG64 __stdcall NtSuspendProcess( ULONG64 arg_01 );
NtSuspendProcess PROC STDCALL
mov r10 , rcx
mov eax , 378
;syscall
db 0Fh , 05h
ret
NtSuspendProcess ENDP
; ULONG64 __stdcall NtSuspendThread( ULONG64 arg_01 , ULONG64 arg_02 );
NtSuspendThread PROC STDCALL
mov r10 , rcx
mov eax , 379
;syscall
db 0Fh , 05h
ret
NtSuspendThread ENDP
; ULONG64 __stdcall NtSystemDebugControl( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtSystemDebugControl PROC STDCALL
mov r10 , rcx
mov eax , 380
;syscall
db 0Fh , 05h
ret
NtSystemDebugControl ENDP
; ULONG64 __stdcall NtTerminateJobObject( ULONG64 arg_01 , ULONG64 arg_02 );
NtTerminateJobObject PROC STDCALL
mov r10 , rcx
mov eax , 381
;syscall
db 0Fh , 05h
ret
NtTerminateJobObject ENDP
; ULONG64 __stdcall NtTestAlert( );
NtTestAlert PROC STDCALL
mov r10 , rcx
mov eax , 382
;syscall
db 0Fh , 05h
ret
NtTestAlert ENDP
; ULONG64 __stdcall NtThawRegistry( );
NtThawRegistry PROC STDCALL
mov r10 , rcx
mov eax , 383
;syscall
db 0Fh , 05h
ret
NtThawRegistry ENDP
; ULONG64 __stdcall NtThawTransactions( );
NtThawTransactions PROC STDCALL
mov r10 , rcx
mov eax , 384
;syscall
db 0Fh , 05h
ret
NtThawTransactions ENDP
; ULONG64 __stdcall NtTraceControl( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 , ULONG64 arg_06 );
NtTraceControl PROC STDCALL
mov r10 , rcx
mov eax , 385
;syscall
db 0Fh , 05h
ret
NtTraceControl ENDP
; ULONG64 __stdcall NtTranslateFilePath( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtTranslateFilePath PROC STDCALL
mov r10 , rcx
mov eax , 386
;syscall
db 0Fh , 05h
ret
NtTranslateFilePath ENDP
; ULONG64 __stdcall NtUmsThreadYield( ULONG64 arg_01 );
NtUmsThreadYield PROC STDCALL
mov r10 , rcx
mov eax , 387
;syscall
db 0Fh , 05h
ret
NtUmsThreadYield ENDP
; ULONG64 __stdcall NtUnloadDriver( ULONG64 arg_01 );
NtUnloadDriver PROC STDCALL
mov r10 , rcx
mov eax , 388
;syscall
db 0Fh , 05h
ret
NtUnloadDriver ENDP
; ULONG64 __stdcall NtUnloadKey( ULONG64 arg_01 );
NtUnloadKey PROC STDCALL
mov r10 , rcx
mov eax , 389
;syscall
db 0Fh , 05h
ret
NtUnloadKey ENDP
; ULONG64 __stdcall NtUnloadKey2( ULONG64 arg_01 , ULONG64 arg_02 );
NtUnloadKey2 PROC STDCALL
mov r10 , rcx
mov eax , 390
;syscall
db 0Fh , 05h
ret
NtUnloadKey2 ENDP
; ULONG64 __stdcall NtUnloadKeyEx( ULONG64 arg_01 , ULONG64 arg_02 );
NtUnloadKeyEx PROC STDCALL
mov r10 , rcx
mov eax , 391
;syscall
db 0Fh , 05h
ret
NtUnloadKeyEx ENDP
; ULONG64 __stdcall NtUnlockFile( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 , ULONG64 arg_05 );
NtUnlockFile PROC STDCALL
mov r10 , rcx
mov eax , 392
;syscall
db 0Fh , 05h
ret
NtUnlockFile ENDP
; ULONG64 __stdcall NtUnlockVirtualMemory( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtUnlockVirtualMemory PROC STDCALL
mov r10 , rcx
mov eax , 393
;syscall
db 0Fh , 05h
ret
NtUnlockVirtualMemory ENDP
; ULONG64 __stdcall NtVdmControl( ULONG64 arg_01 , ULONG64 arg_02 );
NtVdmControl PROC STDCALL
mov r10 , rcx
mov eax , 394
;syscall
db 0Fh , 05h
ret
NtVdmControl ENDP
; ULONG64 __stdcall NtWaitForDebugEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtWaitForDebugEvent PROC STDCALL
mov r10 , rcx
mov eax , 395
;syscall
db 0Fh , 05h
ret
NtWaitForDebugEvent ENDP
; ULONG64 __stdcall NtWaitForKeyedEvent( ULONG64 arg_01 , ULONG64 arg_02 , ULONG64 arg_03 , ULONG64 arg_04 );
NtWaitForKeyedEvent PROC STDCALL
mov r10 , rcx
mov eax , 396
;syscall
db 0Fh , 05h
ret
NtWaitForKeyedEvent ENDP
; ULONG64 __stdcall NtWaitForWorkViaWorkerFactory( ULONG64 arg_01 , ULONG64 arg_02 );
NtWaitForWorkViaWorkerFactory PROC STDCALL
mov r10 , rcx
mov eax , 397
;syscall
db 0Fh , 05h
ret
NtWaitForWorkViaWorkerFactory ENDP
; ULONG64 __stdcall NtWaitHighEventPair( ULONG64 arg_01 );
NtWaitHighEventPair PROC STDCALL
mov r10 , rcx
mov eax , 398
;syscall
db 0Fh , 05h
ret
NtWaitHighEventPair ENDP
; ULONG64 __stdcall NtWaitLowEventPair( ULONG64 arg_01 );
NtWaitLowEventPair PROC STDCALL
mov r10 , rcx
mov eax , 399
;syscall
db 0Fh , 05h
ret
NtWaitLowEventPair ENDP
; ULONG64 __stdcall NtWorkerFactoryWorkerReady( ULONG64 arg_01 );
NtWorkerFactoryWorkerReady PROC STDCALL
mov r10 , rcx
mov eax , 400
;syscall
db 0Fh , 05h
ret
NtWorkerFactoryWorkerReady ENDP
|
; A017072: a(n) = (8*n)^8.
; 0,16777216,4294967296,110075314176,1099511627776,6553600000000,28179280429056,96717311574016,281474976710656,722204136308736,1677721600000000,3596345248055296,7213895789838336,13685690504052736,24759631762948096,42998169600000000,72057594037927936,117033789351264256,184884258895036416,284936905588473856,429496729600000000,634562281237118976,920664383502155776,1313840315232157696,1846757322198614016,2560000000000000000,3503536769037500416,4738381338321616896,6338465731314712576,8392742123471896576,11007531417600000000,14309137159611744256,18446744073709551616,23595621172490797056,29960650073923649536,37780199833600000000,47330370277129322496,58929626493994663936,72943847830649307136,89791815397090000896,109951162777600000000,133964815312812507136,162447943996702457856,196095460708571938816,235690082176551878656,282110990745600000000,336343120699432370176,399487099562283237376,472769874482845188096,557556054479199010816,655360000000000000000,767858691933644783616,896905412873600106496,1044544274124532350976,1213025622610333925376,1404822362521600000000,1622647227216566419456,1869471037565976969216,2148541983608805523456,2463405967062215950336,2817928042905600000000,3216314998934990749696,3663139112860606529536,4163363127196737601536,4722366482869645213696,5345972853145600000000,6040479020157644046336,6812685136986118291456,7669926418924454281216,8620106308238186643456,9671731157401600000000,10833946476472881381376,12116574790945106558976,13530155157086846058496,15085984382462633967616,16796160000000000000000,18673625044646222626816,20732214682334418436096,22986704741655040229376,25452862199305313714176,28147497671065600000000,31088519960728128454656,34294992720080001826816,37787193273718832889856,41586673663155829211136,45716323965337600000000,50200437941394416336896,55064781072099113435136,60336661037197280935936,66045000696445844586496,72220413630873600000000,78895282303453716545536,86103838899054686765056,93882248904212654063616,102268697487944508768256,111303478745497600000000,121029087867608368152576,131490316298518660120576,142734349946674946768896,154810870512712119484416
pow $0,8
mul $0,16777216
|
%ifndef PRINT_INT
%define PRINT_INT
%include "include/printChar.asm"
%include "include/mathPow.asm"
printInt: ;print stuff in si to the screen as a number in the decimal system
;al -> printChar
call lengthInt
.loop:
call printIntDiv
push dx
push bx
sub bx, 1
mov ax, 10
call pow16
pop bx
pop dx
mov cx, ax
mov ax, dx
xor dx, dx
div cx
add al, '0'
push bx
call printChar
pop bx
sub bx, 1
cmp bx, 0
jle .end
jmp .loop
.end:
ret
lengthInt: ;returns length of integer si into bx
mov bx, 0
.loop:
call printIntDiv
cmp ax, 0
je .end
add bx, 1
jmp .loop
.end:
ret
printIntDiv:
mov ax, 10
call pow16
mov cx, ax
mov ax, si
xor dx, dx
div cx
ret
%endif |
// Copyright 2020 The Fuchsia 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/cobalt/bin/app/user_consent_watcher.h"
#include <lib/fit/result.h>
#include <lib/fostr/fidl/fuchsia/settings/formatting.h>
#include <lib/syslog/cpp/macros.h>
#include <zircon/types.h>
#include <optional>
#include "lib/async/cpp/task.h"
namespace cobalt {
UserConsentWatcher::UserConsentWatcher(
async_dispatcher_t *dispatcher, std::shared_ptr<sys::ServiceDirectory> services,
std::function<void(const CobaltServiceInterface::DataCollectionPolicy &)> callback)
: dispatcher_(dispatcher),
services_(services),
callback_(callback),
backoff_(/*initial_delay=*/zx::msec(100), /*retry_factor=*/2u, /*max_delay=*/zx::hour(1)) {}
void UserConsentWatcher::StartWatching() {
privacy_settings_ptr_ = services_->Connect<fuchsia::settings::Privacy>();
privacy_settings_ptr_.set_error_handler([this](zx_status_t status) {
FX_PLOGS(ERROR, status) << "Lost connection to fuchsia.settings.Privacy";
RestartWatching();
});
Watch();
}
void UserConsentWatcher::RestartWatching() {
ResetConsent();
privacy_settings_ptr_.Unbind();
reconnect_task_.Reset([this] { StartWatching(); });
async::PostDelayedTask(
dispatcher_, [reconnect = reconnect_task_.callback()] { reconnect(); }, backoff_.GetNext());
}
void UserConsentWatcher::Watch() {
privacy_settings_ptr_->Watch([this](fuchsia::settings::PrivacySettings settings) {
// Reset the exponential backoff since we successfully watched once.
backoff_.Reset();
privacy_settings_ = std::move(settings);
Update();
// We watch for the next update, following the hanging get pattern.
Watch();
});
}
void UserConsentWatcher::ResetConsent() {
privacy_settings_.clear_user_data_sharing_consent();
Update();
}
void UserConsentWatcher::Update() {
if (!privacy_settings_.has_user_data_sharing_consent()) {
callback_(CobaltServiceInterface::DataCollectionPolicy::DO_NOT_UPLOAD);
} else if (privacy_settings_.user_data_sharing_consent()) {
callback_(CobaltServiceInterface::DataCollectionPolicy::COLLECT_AND_UPLOAD);
} else {
callback_(CobaltServiceInterface::DataCollectionPolicy::DO_NOT_COLLECT);
}
}
} // namespace cobalt
|
// GENERATED FILE - DO NOT EDIT.
// Generated by generate_entry_points.py using data from gl.xml.
//
// Copyright 2020 The ANGLE 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.
//
// entry_points_gles_1_0_autogen.cpp:
// Defines the GLES 1.0 entry points.
#include "libGLESv2/entry_points_gles_1_0_autogen.h"
#include "common/entry_points_enum_autogen.h"
#include "libANGLE/Context.h"
#include "libANGLE/Context.inl.h"
#include "libANGLE/capture_gles_1_0_autogen.h"
#include "libANGLE/entry_points_utils.h"
#include "libANGLE/gl_enum_utils.h"
#include "libANGLE/validationES1.h"
#include "libGLESv2/global_state.h"
namespace gl
{
void GL_APIENTRY AlphaFunc(GLenum func, GLfloat ref)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::AlphaFunc, "glAlphaFunc", "context = %d, func = %s, ref = %f",
CID(context), GLenumToString(GLenumGroup::AlphaFunction, func), ref);
if (context)
{
AlphaTestFunc funcPacked = FromGL<AlphaTestFunc>(func);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateAlphaFunc(context, funcPacked, ref));
if (isCallValid)
{
context->alphaFunc(funcPacked, ref);
}
ANGLE_CAPTURE(AlphaFunc, isCallValid, context, funcPacked, ref);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY AlphaFuncx(GLenum func, GLfixed ref)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::AlphaFuncx, "glAlphaFuncx",
"context = %d, func = %s, ref = 0x%X", CID(context),
GLenumToString(GLenumGroup::AlphaFunction, func), ref);
if (context)
{
AlphaTestFunc funcPacked = FromGL<AlphaTestFunc>(func);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateAlphaFuncx(context, funcPacked, ref));
if (isCallValid)
{
context->alphaFuncx(funcPacked, ref);
}
ANGLE_CAPTURE(AlphaFuncx, isCallValid, context, funcPacked, ref);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ClearColorx(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ClearColorx, "glClearColorx",
"context = %d, red = 0x%X, green = 0x%X, blue = 0x%X, alpha = 0x%X", CID(context), red,
green, blue, alpha);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateClearColorx(context, red, green, blue, alpha));
if (isCallValid)
{
context->clearColorx(red, green, blue, alpha);
}
ANGLE_CAPTURE(ClearColorx, isCallValid, context, red, green, blue, alpha);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ClearDepthx(GLfixed depth)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ClearDepthx, "glClearDepthx", "context = %d, depth = 0x%X",
CID(context), depth);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateClearDepthx(context, depth));
if (isCallValid)
{
context->clearDepthx(depth);
}
ANGLE_CAPTURE(ClearDepthx, isCallValid, context, depth);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ClientActiveTexture(GLenum texture)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ClientActiveTexture, "glClientActiveTexture",
"context = %d, texture = %s", CID(context),
GLenumToString(GLenumGroup::TextureUnit, texture));
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateClientActiveTexture(context, texture));
if (isCallValid)
{
context->clientActiveTexture(texture);
}
ANGLE_CAPTURE(ClientActiveTexture, isCallValid, context, texture);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ClipPlanef(GLenum p, const GLfloat *eqn)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ClipPlanef, "glClipPlanef",
"context = %d, p = %s, eqn = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::ClipPlaneName, p), (uintptr_t)eqn);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateClipPlanef(context, p, eqn));
if (isCallValid)
{
context->clipPlanef(p, eqn);
}
ANGLE_CAPTURE(ClipPlanef, isCallValid, context, p, eqn);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ClipPlanex(GLenum plane, const GLfixed *equation)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ClipPlanex, "glClipPlanex",
"context = %d, plane = %s, equation = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::ClipPlaneName, plane), (uintptr_t)equation);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateClipPlanex(context, plane, equation));
if (isCallValid)
{
context->clipPlanex(plane, equation);
}
ANGLE_CAPTURE(ClipPlanex, isCallValid, context, plane, equation);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Color4f, "glColor4f",
"context = %d, red = %f, green = %f, blue = %f, alpha = %f", CID(context), red, green,
blue, alpha);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateColor4f(context, red, green, blue, alpha));
if (isCallValid)
{
context->color4f(red, green, blue, alpha);
}
ANGLE_CAPTURE(Color4f, isCallValid, context, red, green, blue, alpha);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Color4ub, "glColor4ub",
"context = %d, red = %d, green = %d, blue = %d, alpha = %d", CID(context), red, green,
blue, alpha);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateColor4ub(context, red, green, blue, alpha));
if (isCallValid)
{
context->color4ub(red, green, blue, alpha);
}
ANGLE_CAPTURE(Color4ub, isCallValid, context, red, green, blue, alpha);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Color4x, "glColor4x",
"context = %d, red = 0x%X, green = 0x%X, blue = 0x%X, alpha = 0x%X", CID(context), red,
green, blue, alpha);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateColor4x(context, red, green, blue, alpha));
if (isCallValid)
{
context->color4x(red, green, blue, alpha);
}
ANGLE_CAPTURE(Color4x, isCallValid, context, red, green, blue, alpha);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ColorPointer, "glColorPointer",
"context = %d, size = %d, type = %s, stride = %d, pointer = 0x%016" PRIxPTR "",
CID(context), size, GLenumToString(GLenumGroup::ColorPointerType, type), stride,
(uintptr_t)pointer);
if (context)
{
VertexAttribType typePacked = FromGL<VertexAttribType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateColorPointer(context, size, typePacked, stride, pointer));
if (isCallValid)
{
context->colorPointer(size, typePacked, stride, pointer);
}
ANGLE_CAPTURE(ColorPointer, isCallValid, context, size, typePacked, stride, pointer);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY DepthRangex(GLfixed n, GLfixed f)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::DepthRangex, "glDepthRangex", "context = %d, n = 0x%X, f = 0x%X",
CID(context), n, f);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateDepthRangex(context, n, f));
if (isCallValid)
{
context->depthRangex(n, f);
}
ANGLE_CAPTURE(DepthRangex, isCallValid, context, n, f);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY DisableClientState(GLenum array)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::DisableClientState, "glDisableClientState",
"context = %d, array = %s", CID(context), GLenumToString(GLenumGroup::EnableCap, array));
if (context)
{
ClientVertexArrayType arrayPacked = FromGL<ClientVertexArrayType>(array);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDisableClientState(context, arrayPacked));
if (isCallValid)
{
context->disableClientState(arrayPacked);
}
ANGLE_CAPTURE(DisableClientState, isCallValid, context, arrayPacked);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY EnableClientState(GLenum array)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::EnableClientState, "glEnableClientState",
"context = %d, array = %s", CID(context), GLenumToString(GLenumGroup::EnableCap, array));
if (context)
{
ClientVertexArrayType arrayPacked = FromGL<ClientVertexArrayType>(array);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateEnableClientState(context, arrayPacked));
if (isCallValid)
{
context->enableClientState(arrayPacked);
}
ANGLE_CAPTURE(EnableClientState, isCallValid, context, arrayPacked);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Fogf(GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Fogf, "glFogf", "context = %d, pname = %s, param = %f",
CID(context), GLenumToString(GLenumGroup::FogParameter, pname), param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateFogf(context, pname, param));
if (isCallValid)
{
context->fogf(pname, param);
}
ANGLE_CAPTURE(Fogf, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Fogfv(GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Fogfv, "glFogfv",
"context = %d, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::FogParameter, pname), (uintptr_t)params);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateFogfv(context, pname, params));
if (isCallValid)
{
context->fogfv(pname, params);
}
ANGLE_CAPTURE(Fogfv, isCallValid, context, pname, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Fogx(GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Fogx, "glFogx", "context = %d, pname = %s, param = 0x%X",
CID(context), GLenumToString(GLenumGroup::FogPName, pname), param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateFogx(context, pname, param));
if (isCallValid)
{
context->fogx(pname, param);
}
ANGLE_CAPTURE(Fogx, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Fogxv(GLenum pname, const GLfixed *param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Fogxv, "glFogxv",
"context = %d, pname = %s, param = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::FogPName, pname), (uintptr_t)param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateFogxv(context, pname, param));
if (isCallValid)
{
context->fogxv(pname, param);
}
ANGLE_CAPTURE(Fogxv, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Frustumf(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Frustumf, "glFrustumf",
"context = %d, l = %f, r = %f, b = %f, t = %f, n = %f, f = %f", CID(context), l, r, b, t,
n, f);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateFrustumf(context, l, r, b, t, n, f));
if (isCallValid)
{
context->frustumf(l, r, b, t, n, f);
}
ANGLE_CAPTURE(Frustumf, isCallValid, context, l, r, b, t, n, f);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Frustumx(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Frustumx, "glFrustumx",
"context = %d, l = 0x%X, r = 0x%X, b = 0x%X, t = 0x%X, n = 0x%X, f = 0x%X", CID(context),
l, r, b, t, n, f);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateFrustumx(context, l, r, b, t, n, f));
if (isCallValid)
{
context->frustumx(l, r, b, t, n, f);
}
ANGLE_CAPTURE(Frustumx, isCallValid, context, l, r, b, t, n, f);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetClipPlanef(GLenum plane, GLfloat *equation)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetClipPlanef, "glGetClipPlanef",
"context = %d, plane = %s, equation = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::ClipPlaneName, plane), (uintptr_t)equation);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetClipPlanef(context, plane, equation));
if (isCallValid)
{
context->getClipPlanef(plane, equation);
}
ANGLE_CAPTURE(GetClipPlanef, isCallValid, context, plane, equation);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetClipPlanex(GLenum plane, GLfixed *equation)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetClipPlanex, "glGetClipPlanex",
"context = %d, plane = %s, equation = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::ClipPlaneName, plane), (uintptr_t)equation);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetClipPlanex(context, plane, equation));
if (isCallValid)
{
context->getClipPlanex(plane, equation);
}
ANGLE_CAPTURE(GetClipPlanex, isCallValid, context, plane, equation);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetFixedv(GLenum pname, GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetFixedv, "glGetFixedv",
"context = %d, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::GetPName, pname), (uintptr_t)params);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateGetFixedv(context, pname, params));
if (isCallValid)
{
context->getFixedv(pname, params);
}
ANGLE_CAPTURE(GetFixedv, isCallValid, context, pname, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetLightfv(GLenum light, GLenum pname, GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetLightfv, "glGetLightfv",
"context = %d, light = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), (uintptr_t)params);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetLightfv(context, light, pnamePacked, params));
if (isCallValid)
{
context->getLightfv(light, pnamePacked, params);
}
ANGLE_CAPTURE(GetLightfv, isCallValid, context, light, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetLightxv(GLenum light, GLenum pname, GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetLightxv, "glGetLightxv",
"context = %d, light = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), (uintptr_t)params);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetLightxv(context, light, pnamePacked, params));
if (isCallValid)
{
context->getLightxv(light, pnamePacked, params);
}
ANGLE_CAPTURE(GetLightxv, isCallValid, context, light, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetMaterialfv, "glGetMaterialfv",
"context = %d, face = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), (uintptr_t)params);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetMaterialfv(context, face, pnamePacked, params));
if (isCallValid)
{
context->getMaterialfv(face, pnamePacked, params);
}
ANGLE_CAPTURE(GetMaterialfv, isCallValid, context, face, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetMaterialxv, "glGetMaterialxv",
"context = %d, face = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), (uintptr_t)params);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetMaterialxv(context, face, pnamePacked, params));
if (isCallValid)
{
context->getMaterialxv(face, pnamePacked, params);
}
ANGLE_CAPTURE(GetMaterialxv, isCallValid, context, face, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetTexEnvfv, "glGetTexEnvfv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetTexEnvfv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->getTexEnvfv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(GetTexEnvfv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetTexEnviv(GLenum target, GLenum pname, GLint *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetTexEnviv, "glGetTexEnviv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetTexEnviv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->getTexEnviv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(GetTexEnviv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetTexEnvxv(GLenum target, GLenum pname, GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetTexEnvxv, "glGetTexEnvxv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetTexEnvxv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->getTexEnvxv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(GetTexEnvxv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY GetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::GetTexParameterxv, "glGetTexParameterxv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureTarget, target),
GLenumToString(GLenumGroup::GetTextureParameter, pname), (uintptr_t)params);
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetTexParameterxv(context, targetPacked, pname, params));
if (isCallValid)
{
context->getTexParameterxv(targetPacked, pname, params);
}
ANGLE_CAPTURE(GetTexParameterxv, isCallValid, context, targetPacked, pname, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LightModelf(GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LightModelf, "glLightModelf",
"context = %d, pname = %s, param = %f", CID(context),
GLenumToString(GLenumGroup::LightModelParameter, pname), param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightModelf(context, pname, param));
if (isCallValid)
{
context->lightModelf(pname, param);
}
ANGLE_CAPTURE(LightModelf, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LightModelfv(GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LightModelfv, "glLightModelfv",
"context = %d, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightModelParameter, pname), (uintptr_t)params);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightModelfv(context, pname, params));
if (isCallValid)
{
context->lightModelfv(pname, params);
}
ANGLE_CAPTURE(LightModelfv, isCallValid, context, pname, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LightModelx(GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LightModelx, "glLightModelx",
"context = %d, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::LightModelParameter, pname), param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightModelx(context, pname, param));
if (isCallValid)
{
context->lightModelx(pname, param);
}
ANGLE_CAPTURE(LightModelx, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LightModelxv(GLenum pname, const GLfixed *param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LightModelxv, "glLightModelxv",
"context = %d, pname = %s, param = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightModelParameter, pname), (uintptr_t)param);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightModelxv(context, pname, param));
if (isCallValid)
{
context->lightModelxv(pname, param);
}
ANGLE_CAPTURE(LightModelxv, isCallValid, context, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Lightf(GLenum light, GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Lightf, "glLightf",
"context = %d, light = %s, pname = %s, param = %f", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), param);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightf(context, light, pnamePacked, param));
if (isCallValid)
{
context->lightf(light, pnamePacked, param);
}
ANGLE_CAPTURE(Lightf, isCallValid, context, light, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Lightfv(GLenum light, GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Lightfv, "glLightfv",
"context = %d, light = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), (uintptr_t)params);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightfv(context, light, pnamePacked, params));
if (isCallValid)
{
context->lightfv(light, pnamePacked, params);
}
ANGLE_CAPTURE(Lightfv, isCallValid, context, light, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Lightx(GLenum light, GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Lightx, "glLightx",
"context = %d, light = %s, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), param);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightx(context, light, pnamePacked, param));
if (isCallValid)
{
context->lightx(light, pnamePacked, param);
}
ANGLE_CAPTURE(Lightx, isCallValid, context, light, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Lightxv(GLenum light, GLenum pname, const GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Lightxv, "glLightxv",
"context = %d, light = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::LightName, light),
GLenumToString(GLenumGroup::LightParameter, pname), (uintptr_t)params);
if (context)
{
LightParameter pnamePacked = FromGL<LightParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateLightxv(context, light, pnamePacked, params));
if (isCallValid)
{
context->lightxv(light, pnamePacked, params);
}
ANGLE_CAPTURE(Lightxv, isCallValid, context, light, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LineWidthx(GLfixed width)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LineWidthx, "glLineWidthx", "context = %d, width = 0x%X",
CID(context), width);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateLineWidthx(context, width));
if (isCallValid)
{
context->lineWidthx(width);
}
ANGLE_CAPTURE(LineWidthx, isCallValid, context, width);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LoadIdentity()
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LoadIdentity, "glLoadIdentity", "context = %d", CID(context));
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateLoadIdentity(context));
if (isCallValid)
{
context->loadIdentity();
}
ANGLE_CAPTURE(LoadIdentity, isCallValid, context);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LoadMatrixf(const GLfloat *m)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LoadMatrixf, "glLoadMatrixf",
"context = %d, m = 0x%016" PRIxPTR "", CID(context), (uintptr_t)m);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateLoadMatrixf(context, m));
if (isCallValid)
{
context->loadMatrixf(m);
}
ANGLE_CAPTURE(LoadMatrixf, isCallValid, context, m);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LoadMatrixx(const GLfixed *m)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LoadMatrixx, "glLoadMatrixx",
"context = %d, m = 0x%016" PRIxPTR "", CID(context), (uintptr_t)m);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateLoadMatrixx(context, m));
if (isCallValid)
{
context->loadMatrixx(m);
}
ANGLE_CAPTURE(LoadMatrixx, isCallValid, context, m);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY LogicOp(GLenum opcode)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::LogicOp, "glLogicOp", "context = %d, opcode = %s", CID(context),
GLenumToString(GLenumGroup::LogicOp, opcode));
if (context)
{
LogicalOperation opcodePacked = FromGL<LogicalOperation>(opcode);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateLogicOp(context, opcodePacked));
if (isCallValid)
{
context->logicOp(opcodePacked);
}
ANGLE_CAPTURE(LogicOp, isCallValid, context, opcodePacked);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Materialf(GLenum face, GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Materialf, "glMaterialf",
"context = %d, face = %s, pname = %s, param = %f", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), param);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMaterialf(context, face, pnamePacked, param));
if (isCallValid)
{
context->materialf(face, pnamePacked, param);
}
ANGLE_CAPTURE(Materialf, isCallValid, context, face, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Materialfv(GLenum face, GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Materialfv, "glMaterialfv",
"context = %d, face = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), (uintptr_t)params);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMaterialfv(context, face, pnamePacked, params));
if (isCallValid)
{
context->materialfv(face, pnamePacked, params);
}
ANGLE_CAPTURE(Materialfv, isCallValid, context, face, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Materialx(GLenum face, GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Materialx, "glMaterialx",
"context = %d, face = %s, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), param);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMaterialx(context, face, pnamePacked, param));
if (isCallValid)
{
context->materialx(face, pnamePacked, param);
}
ANGLE_CAPTURE(Materialx, isCallValid, context, face, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Materialxv(GLenum face, GLenum pname, const GLfixed *param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Materialxv, "glMaterialxv",
"context = %d, face = %s, pname = %s, param = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::MaterialFace, face),
GLenumToString(GLenumGroup::MaterialParameter, pname), (uintptr_t)param);
if (context)
{
MaterialParameter pnamePacked = FromGL<MaterialParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMaterialxv(context, face, pnamePacked, param));
if (isCallValid)
{
context->materialxv(face, pnamePacked, param);
}
ANGLE_CAPTURE(Materialxv, isCallValid, context, face, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY MatrixMode(GLenum mode)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::MatrixMode, "glMatrixMode", "context = %d, mode = %s",
CID(context), GLenumToString(GLenumGroup::MatrixMode, mode));
if (context)
{
MatrixType modePacked = FromGL<MatrixType>(mode);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateMatrixMode(context, modePacked));
if (isCallValid)
{
context->matrixMode(modePacked);
}
ANGLE_CAPTURE(MatrixMode, isCallValid, context, modePacked);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY MultMatrixf(const GLfloat *m)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::MultMatrixf, "glMultMatrixf",
"context = %d, m = 0x%016" PRIxPTR "", CID(context), (uintptr_t)m);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateMultMatrixf(context, m));
if (isCallValid)
{
context->multMatrixf(m);
}
ANGLE_CAPTURE(MultMatrixf, isCallValid, context, m);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY MultMatrixx(const GLfixed *m)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::MultMatrixx, "glMultMatrixx",
"context = %d, m = 0x%016" PRIxPTR "", CID(context), (uintptr_t)m);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateMultMatrixx(context, m));
if (isCallValid)
{
context->multMatrixx(m);
}
ANGLE_CAPTURE(MultMatrixx, isCallValid, context, m);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::MultiTexCoord4f, "glMultiTexCoord4f",
"context = %d, target = %s, s = %f, t = %f, r = %f, q = %f", CID(context),
GLenumToString(GLenumGroup::TextureUnit, target), s, t, r, q);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMultiTexCoord4f(context, target, s, t, r, q));
if (isCallValid)
{
context->multiTexCoord4f(target, s, t, r, q);
}
ANGLE_CAPTURE(MultiTexCoord4f, isCallValid, context, target, s, t, r, q);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY MultiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::MultiTexCoord4x, "glMultiTexCoord4x",
"context = %d, texture = %s, s = 0x%X, t = 0x%X, r = 0x%X, q = 0x%X", CID(context),
GLenumToString(GLenumGroup::TextureUnit, texture), s, t, r, q);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateMultiTexCoord4x(context, texture, s, t, r, q));
if (isCallValid)
{
context->multiTexCoord4x(texture, s, t, r, q);
}
ANGLE_CAPTURE(MultiTexCoord4x, isCallValid, context, texture, s, t, r, q);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Normal3f(GLfloat nx, GLfloat ny, GLfloat nz)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Normal3f, "glNormal3f",
"context = %d, nx = %f, ny = %f, nz = %f", CID(context), nx, ny, nz);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateNormal3f(context, nx, ny, nz));
if (isCallValid)
{
context->normal3f(nx, ny, nz);
}
ANGLE_CAPTURE(Normal3f, isCallValid, context, nx, ny, nz);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Normal3x(GLfixed nx, GLfixed ny, GLfixed nz)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Normal3x, "glNormal3x",
"context = %d, nx = 0x%X, ny = 0x%X, nz = 0x%X", CID(context), nx, ny, nz);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateNormal3x(context, nx, ny, nz));
if (isCallValid)
{
context->normal3x(nx, ny, nz);
}
ANGLE_CAPTURE(Normal3x, isCallValid, context, nx, ny, nz);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY NormalPointer(GLenum type, GLsizei stride, const void *pointer)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::NormalPointer, "glNormalPointer",
"context = %d, type = %s, stride = %d, pointer = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::NormalPointerType, type), stride, (uintptr_t)pointer);
if (context)
{
VertexAttribType typePacked = FromGL<VertexAttribType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateNormalPointer(context, typePacked, stride, pointer));
if (isCallValid)
{
context->normalPointer(typePacked, stride, pointer);
}
ANGLE_CAPTURE(NormalPointer, isCallValid, context, typePacked, stride, pointer);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Orthof(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Orthof, "glOrthof",
"context = %d, l = %f, r = %f, b = %f, t = %f, n = %f, f = %f", CID(context), l, r, b, t,
n, f);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateOrthof(context, l, r, b, t, n, f));
if (isCallValid)
{
context->orthof(l, r, b, t, n, f);
}
ANGLE_CAPTURE(Orthof, isCallValid, context, l, r, b, t, n, f);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Orthox(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Orthox, "glOrthox",
"context = %d, l = 0x%X, r = 0x%X, b = 0x%X, t = 0x%X, n = 0x%X, f = 0x%X", CID(context),
l, r, b, t, n, f);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateOrthox(context, l, r, b, t, n, f));
if (isCallValid)
{
context->orthox(l, r, b, t, n, f);
}
ANGLE_CAPTURE(Orthox, isCallValid, context, l, r, b, t, n, f);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointParameterf(GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointParameterf, "glPointParameterf",
"context = %d, pname = %s, param = %f", CID(context),
GLenumToString(GLenumGroup::DefaultGroup, pname), param);
if (context)
{
PointParameter pnamePacked = FromGL<PointParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePointParameterf(context, pnamePacked, param));
if (isCallValid)
{
context->pointParameterf(pnamePacked, param);
}
ANGLE_CAPTURE(PointParameterf, isCallValid, context, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointParameterfv(GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointParameterfv, "glPointParameterfv",
"context = %d, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::DefaultGroup, pname), (uintptr_t)params);
if (context)
{
PointParameter pnamePacked = FromGL<PointParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePointParameterfv(context, pnamePacked, params));
if (isCallValid)
{
context->pointParameterfv(pnamePacked, params);
}
ANGLE_CAPTURE(PointParameterfv, isCallValid, context, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointParameterx(GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointParameterx, "glPointParameterx",
"context = %d, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::DefaultGroup, pname), param);
if (context)
{
PointParameter pnamePacked = FromGL<PointParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePointParameterx(context, pnamePacked, param));
if (isCallValid)
{
context->pointParameterx(pnamePacked, param);
}
ANGLE_CAPTURE(PointParameterx, isCallValid, context, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointParameterxv(GLenum pname, const GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointParameterxv, "glPointParameterxv",
"context = %d, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::DefaultGroup, pname), (uintptr_t)params);
if (context)
{
PointParameter pnamePacked = FromGL<PointParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePointParameterxv(context, pnamePacked, params));
if (isCallValid)
{
context->pointParameterxv(pnamePacked, params);
}
ANGLE_CAPTURE(PointParameterxv, isCallValid, context, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointSize(GLfloat size)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointSize, "glPointSize", "context = %d, size = %f",
CID(context), size);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidatePointSize(context, size));
if (isCallValid)
{
context->pointSize(size);
}
ANGLE_CAPTURE(PointSize, isCallValid, context, size);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PointSizex(GLfixed size)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PointSizex, "glPointSizex", "context = %d, size = 0x%X",
CID(context), size);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidatePointSizex(context, size));
if (isCallValid)
{
context->pointSizex(size);
}
ANGLE_CAPTURE(PointSizex, isCallValid, context, size);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PolygonOffsetx(GLfixed factor, GLfixed units)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PolygonOffsetx, "glPolygonOffsetx",
"context = %d, factor = 0x%X, units = 0x%X", CID(context), factor, units);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePolygonOffsetx(context, factor, units));
if (isCallValid)
{
context->polygonOffsetx(factor, units);
}
ANGLE_CAPTURE(PolygonOffsetx, isCallValid, context, factor, units);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PopMatrix()
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PopMatrix, "glPopMatrix", "context = %d", CID(context));
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidatePopMatrix(context));
if (isCallValid)
{
context->popMatrix();
}
ANGLE_CAPTURE(PopMatrix, isCallValid, context);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY PushMatrix()
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::PushMatrix, "glPushMatrix", "context = %d", CID(context));
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidatePushMatrix(context));
if (isCallValid)
{
context->pushMatrix();
}
ANGLE_CAPTURE(PushMatrix, isCallValid, context);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Rotatef, "glRotatef",
"context = %d, angle = %f, x = %f, y = %f, z = %f", CID(context), angle, x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateRotatef(context, angle, x, y, z));
if (isCallValid)
{
context->rotatef(angle, x, y, z);
}
ANGLE_CAPTURE(Rotatef, isCallValid, context, angle, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Rotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Rotatex, "glRotatex",
"context = %d, angle = 0x%X, x = 0x%X, y = 0x%X, z = 0x%X", CID(context), angle, x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateRotatex(context, angle, x, y, z));
if (isCallValid)
{
context->rotatex(angle, x, y, z);
}
ANGLE_CAPTURE(Rotatex, isCallValid, context, angle, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY SampleCoveragex(GLclampx value, GLboolean invert)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::SampleCoveragex, "glSampleCoveragex",
"context = %d, value = 0x%X, invert = %s", CID(context), value,
GLbooleanToString(invert));
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateSampleCoveragex(context, value, invert));
if (isCallValid)
{
context->sampleCoveragex(value, invert);
}
ANGLE_CAPTURE(SampleCoveragex, isCallValid, context, value, invert);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Scalef(GLfloat x, GLfloat y, GLfloat z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Scalef, "glScalef", "context = %d, x = %f, y = %f, z = %f",
CID(context), x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateScalef(context, x, y, z));
if (isCallValid)
{
context->scalef(x, y, z);
}
ANGLE_CAPTURE(Scalef, isCallValid, context, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Scalex(GLfixed x, GLfixed y, GLfixed z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Scalex, "glScalex", "context = %d, x = 0x%X, y = 0x%X, z = 0x%X",
CID(context), x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateScalex(context, x, y, z));
if (isCallValid)
{
context->scalex(x, y, z);
}
ANGLE_CAPTURE(Scalex, isCallValid, context, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY ShadeModel(GLenum mode)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::ShadeModel, "glShadeModel", "context = %d, mode = %s",
CID(context), GLenumToString(GLenumGroup::ShadingModel, mode));
if (context)
{
ShadingModel modePacked = FromGL<ShadingModel>(mode);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateShadeModel(context, modePacked));
if (isCallValid)
{
context->shadeModel(modePacked);
}
ANGLE_CAPTURE(ShadeModel, isCallValid, context, modePacked);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexCoordPointer, "glTexCoordPointer",
"context = %d, size = %d, type = %s, stride = %d, pointer = 0x%016" PRIxPTR "",
CID(context), size, GLenumToString(GLenumGroup::TexCoordPointerType, type), stride,
(uintptr_t)pointer);
if (context)
{
VertexAttribType typePacked = FromGL<VertexAttribType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexCoordPointer(context, size, typePacked, stride, pointer));
if (isCallValid)
{
context->texCoordPointer(size, typePacked, stride, pointer);
}
ANGLE_CAPTURE(TexCoordPointer, isCallValid, context, size, typePacked, stride, pointer);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnvf(GLenum target, GLenum pname, GLfloat param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnvf, "glTexEnvf",
"context = %d, target = %s, pname = %s, param = %f", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), param);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnvf(context, targetPacked, pnamePacked, param));
if (isCallValid)
{
context->texEnvf(targetPacked, pnamePacked, param);
}
ANGLE_CAPTURE(TexEnvf, isCallValid, context, targetPacked, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnvfv, "glTexEnvfv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnvfv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->texEnvfv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(TexEnvfv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnvi(GLenum target, GLenum pname, GLint param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnvi, "glTexEnvi",
"context = %d, target = %s, pname = %s, param = %d", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), param);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnvi(context, targetPacked, pnamePacked, param));
if (isCallValid)
{
context->texEnvi(targetPacked, pnamePacked, param);
}
ANGLE_CAPTURE(TexEnvi, isCallValid, context, targetPacked, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnviv(GLenum target, GLenum pname, const GLint *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnviv, "glTexEnviv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnviv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->texEnviv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(TexEnviv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnvx(GLenum target, GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnvx, "glTexEnvx",
"context = %d, target = %s, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), param);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnvx(context, targetPacked, pnamePacked, param));
if (isCallValid)
{
context->texEnvx(targetPacked, pnamePacked, param);
}
ANGLE_CAPTURE(TexEnvx, isCallValid, context, targetPacked, pnamePacked, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexEnvxv(GLenum target, GLenum pname, const GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexEnvxv, "glTexEnvxv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureEnvTarget, target),
GLenumToString(GLenumGroup::TextureEnvParameter, pname), (uintptr_t)params);
if (context)
{
TextureEnvTarget targetPacked = FromGL<TextureEnvTarget>(target);
TextureEnvParameter pnamePacked = FromGL<TextureEnvParameter>(pname);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexEnvxv(context, targetPacked, pnamePacked, params));
if (isCallValid)
{
context->texEnvxv(targetPacked, pnamePacked, params);
}
ANGLE_CAPTURE(TexEnvxv, isCallValid, context, targetPacked, pnamePacked, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexParameterx(GLenum target, GLenum pname, GLfixed param)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexParameterx, "glTexParameterx",
"context = %d, target = %s, pname = %s, param = 0x%X", CID(context),
GLenumToString(GLenumGroup::TextureTarget, target),
GLenumToString(GLenumGroup::GetTextureParameter, pname), param);
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexParameterx(context, targetPacked, pname, param));
if (isCallValid)
{
context->texParameterx(targetPacked, pname, param);
}
ANGLE_CAPTURE(TexParameterx, isCallValid, context, targetPacked, pname, param);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY TexParameterxv(GLenum target, GLenum pname, const GLfixed *params)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::TexParameterxv, "glTexParameterxv",
"context = %d, target = %s, pname = %s, params = 0x%016" PRIxPTR "", CID(context),
GLenumToString(GLenumGroup::TextureTarget, target),
GLenumToString(GLenumGroup::GetTextureParameter, pname), (uintptr_t)params);
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexParameterxv(context, targetPacked, pname, params));
if (isCallValid)
{
context->texParameterxv(targetPacked, pname, params);
}
ANGLE_CAPTURE(TexParameterxv, isCallValid, context, targetPacked, pname, params);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Translatef(GLfloat x, GLfloat y, GLfloat z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Translatef, "glTranslatef",
"context = %d, x = %f, y = %f, z = %f", CID(context), x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateTranslatef(context, x, y, z));
if (isCallValid)
{
context->translatef(x, y, z);
}
ANGLE_CAPTURE(Translatef, isCallValid, context, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY Translatex(GLfixed x, GLfixed y, GLfixed z)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::Translatex, "glTranslatex",
"context = %d, x = 0x%X, y = 0x%X, z = 0x%X", CID(context), x, y, z);
if (context)
{
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateTranslatex(context, x, y, z));
if (isCallValid)
{
context->translatex(x, y, z);
}
ANGLE_CAPTURE(Translatex, isCallValid, context, x, y, z);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
void GL_APIENTRY VertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
{
Context *context = GetValidGlobalContext();
EVENT(context, gl::EntryPoint::VertexPointer, "glVertexPointer",
"context = %d, size = %d, type = %s, stride = %d, pointer = 0x%016" PRIxPTR "",
CID(context), size, GLenumToString(GLenumGroup::VertexPointerType, type), stride,
(uintptr_t)pointer);
if (context)
{
VertexAttribType typePacked = FromGL<VertexAttribType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateVertexPointer(context, size, typePacked, stride, pointer));
if (isCallValid)
{
context->vertexPointer(size, typePacked, stride, pointer);
}
ANGLE_CAPTURE(VertexPointer, isCallValid, context, size, typePacked, stride, pointer);
}
else
{
GenerateContextLostErrorOnCurrentGlobalContext();
}
}
} // namespace gl
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.