text stringlengths 1 1.05M |
|---|
; A059028: Row sums of A059026: a(n) = sum( lcm(n,m)/n + lcm(n,m)/m - 1, m = 1..n ).
; Submitted by Jamie Morken(s1)
; 1,3,8,13,27,26,58,57,83,85,156,104,223,180,206,241,393,257,496,327,431,478,738,428,757,681,794,682,1191,632,1366,993,1133,1195,1320,971,1963,1506,1610,1315,2421,1313,2668,1788,1877,2236,3198,1748,3103
add $0,1
sub $1,$0
seq $0,341316 ; Row sums in A341315.
add $1,$0
mov $0,$1
sub $0,1
|
; A172482: a(n) = (1+n)*(9 + 11*n + 4*n^2)/3.
; 3,16,47,104,195,328,511,752,1059,1440,1903,2456,3107,3864,4735,5728,6851,8112,9519,11080,12803,14696,16767,19024,21475,24128,26991,30072,33379,36920,40703,44736,49027,53584,58415,63528,68931,74632,80639,86960,93603,100576,107887,115544,123555,131928,140671,149792,159299,169200,179503,190216,201347,212904,224895,237328,250211,263552,277359,291640,306403,321656,337407,353664,370435,387728,405551,423912,442819,462280,482303,502896,524067,545824,568175,591128,614691,638872,663679,689120,715203,741936,769327,797384,826115,855528,885631,916432,947939,980160,1013103,1046776,1081187,1116344,1152255,1188928,1226371,1264592,1303599,1343400
mul $0,4
add $0,6
mov $1,$0
bin $0,3
add $0,$1
div $0,8
|
db PINSIR ; pokedex id
db 65 ; base hp
db 125 ; base attack
db 100 ; base defense
db 85 ; base speed
db 55 ; base special
db BUG ; species type 1
db BUG ; species type 2
db 45 ; catch rate
db 200 ; base exp yield
INCBIN "pic/gsmon/pinsir.pic",0,1 ; 77, sprite dimensions
dw PinsirPicFront
dw PinsirPicBack
; attacks known at lvl 0
db BIND
db 0
db 0
db 0
db 5 ; growth rate
; learnset
tmlearn 3,6,8
tmlearn 9,10,15
tmlearn 17,18,19,20
tmlearn 28,31,32
tmlearn 34
tmlearn 44
tmlearn 50,51,54
db BANK(PinsirPicFront)
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Epson 24-pin print drivers
FILE: printcomEpsonLQ1Cursor.asm
AUTHOR: Dave Durran, 14 March 1990
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 3/14/90 Initial revision
DESCRIPTION:
This file contains most of the code to implement the epson 24-pin
print driver cursor movement support
$Id: printcomEpsonLQ1Cursor.asm,v 1.1 97/04/18 11:50:25 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include Cursor/cursorDotMatrixCommon.asm
include Cursor/cursorSetCursorAbs72.asm
include Cursor/cursorPrLineFeedExe.asm
include Cursor/cursorPrFormFeed60.asm
include Cursor/cursorConvert180.asm
|
; $Id: bs3-wc16-U8DQ.asm 69111 2017-10-17 14:26:02Z vboxsync $
;; @file
; BS3Kit - 16-bit Watcom C/C++, 64-bit unsigned integer division.
;
;
; Copyright (C) 2007-2017 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
; VirtualBox OSE distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
%include "bs3kit-template-header.mac"
BS3_EXTERN_CMN Bs3UInt64Div
;;
; 64-bit unsigned integer division, SS variant.
;
; @returns ax:bx:cx:dx quotient. (AX is the most significant, DX the least)
; @param ax:bx:cx:dx Dividend.
; @param [ss:si] Divisor
;
; @uses Nothing.
;
global $_?U8DQ
$_?U8DQ:
push es
push ss
pop es
%ifdef BS3_MODEL_FAR_CODE
push cs
%endif
call $_?U8DQE
pop es
%ifdef BS3_MODEL_FAR_CODE
retf
%else
ret
%endif
;;
; 64-bit unsigned integer division, ES variant.
;
; @returns ax:bx:cx:dx quotient. (AX is the most significant, DX the least)
; @param ax:bx:cx:dx Dividend.
; @param [es:si] Divisor
;
; @uses Nothing.
;
global $_?U8DQE
$_?U8DQE:
push ds
push es
;
; Convert to a C __cdecl call - not doing this in assembly.
;
; Set up a frame of sorts, allocating 16 bytes for the result buffer.
push bp
sub sp, 10h
mov bp, sp
; Pointer to the return buffer.
push ss
push bp
add bp, 10h ; Correct bp.
; The divisor.
push word [es:si + 6]
push word [es:si + 4]
push word [es:si + 2]
push word [es:si]
; The dividend.
push ax
push bx
push cx
push dx
call Bs3UInt64Div
; Load the quotient.
mov ax, [bp - 10h + 6]
mov bx, [bp - 10h + 4]
mov cx, [bp - 10h + 2]
mov dx, [bp - 10h]
mov sp, bp
pop bp
pop es
pop ds
%ifdef ASM_MODEL_FAR_CODE
retf
%else
ret
%endif
|
; A059542: Beatty sequence for 1 + 1/log(2).
; 2,4,7,9,12,14,17,19,21,24,26,29,31,34,36,39,41,43,46,48,51,53,56,58,61,63,65,68,70,73,75,78,80,83,85,87,90,92,95,97,100,102,105,107,109,112,114,117,119,122,124,127,129,131,134,136,139,141,144,146,149,151,153,156,158,161,163,166,168,170,173,175,178,180,183,185,188,190,192,195,197,200,202,205,207,210,212,214,217,219,222,224,227,229,232,234,236,239,241,244,246,249,251,254,256,258,261,263,266,268,271,273,276,278,280,283,285,288,290,293,295,298,300,302,305,307,310,312,315,317,319,322,324,327,329,332,334,337,339,341,344,346,349,351,354,356,359,361,363,366,368,371,373,376,378,381,383,385,388,390,393,395,398,400,403,405,407,410,412,415,417,420,422,425,427,429,432,434,437,439,442,444,447,449,451,454,456,459,461,464,466,468,471,473,476,478,481,483,486,488,490,493,495,498,500,503,505,508,510,512,515,517,520,522,525,527,530,532,534,537,539,542,544,547,549,552,554,556,559,561,564,566,569,571,574,576,578,581,583,586,588,591,593,596,598,600,603,605,608,610
mov $2,$0
add $2,1
mov $7,$0
lpb $2,1
mov $0,$7
sub $2,1
sub $0,$2
mov $3,$0
mov $5,2
lpb $5,1
mov $0,$3
sub $5,1
add $0,$5
mov $6,$5
mov $8,$0
mul $8,576
div $8,61
lpb $6,1
mov $4,$8
sub $6,1
lpe
lpe
lpb $3,1
mov $3,0
sub $4,$8
lpe
mov $8,$4
sub $8,7
add $1,$8
lpe
|
C arm/fat/aes-decrypt-internal-2.asm
ifelse(<
Copyright (C) 2015 Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
>)
define(<fat_transform>, <$1_armv6>)
include_src(<arm/v6/aes-decrypt-internal.asm>)
|
; A056520: a(n) = (n + 2)*(2*n^2 - n + 3)/6.
; 1,2,6,15,31,56,92,141,205,286,386,507,651,820,1016,1241,1497,1786,2110,2471,2871,3312,3796,4325,4901,5526,6202,6931,7715,8556,9456,10417,11441,12530,13686,14911,16207,17576,19020,20541,22141,23822,25586,27435,29371,31396,33512,35721,38025,40426,42926,45527,48231,51040,53956,56981,60117,63366,66730,70211,73811,77532,81376,85345,89441,93666,98022,102511,107135,111896,116796,121837,127021,132350,137826,143451,149227,155156,161240,167481,173881,180442,187166,194055,201111,208336,215732,223301,231045,238966,247066,255347,263811,272460,281296,290321,299537,308946,318550,328351,338351,348552,358956,369565,380381,391406,402642,414091,425755,437636,449736,462057,474601,487370,500366,513591,527047,540736,554660,568821,583221,597862,612746,627875,643251,658876,674752,690881,707265,723906,740806,757967,775391,793080,811036,829261,847757,866526,885570,904891,924491,944372,964536,984985,1005721,1026746,1048062,1069671,1091575,1113776,1136276,1159077,1182181,1205590,1229306,1253331,1277667,1302316,1327280,1352561,1378161,1404082,1430326,1456895,1483791,1511016,1538572,1566461,1594685,1623246,1652146,1681387,1710971,1740900,1771176,1801801,1832777,1864106,1895790,1927831,1960231,1992992,2026116,2059605,2093461,2127686,2162282,2197251,2232595,2268316,2304416,2340897,2377761,2415010,2452646,2490671,2529087,2567896,2607100,2646701,2686701,2727102,2767906,2809115,2850731,2892756,2935192,2978041,3021305,3064986,3109086,3153607,3198551,3243920,3289716,3335941,3382597,3429686,3477210,3525171,3573571,3622412,3671696,3721425,3771601,3822226,3873302,3924831,3976815,4029256,4082156,4135517,4189341,4243630,4298386,4353611,4409307,4465476,4522120,4579241,4636841,4694922,4753486,4812535,4872071,4932096,4992612,5053621,5115125,5177126
mul $0,-2
bin $0,3
sub $1,$0
div $1,4
add $1,1
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; gf_6vect_dot_prod_avx(len, vec, *g_tbls, **buffs, **dests);
;;;
%ifidn __OUTPUT_FORMAT__, elf64
%define arg0 rdi
%define arg1 rsi
%define arg2 rdx
%define arg3 rcx
%define arg4 r8
%define arg5 r9
%define tmp r11
%define tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r12 ; must be saved and restored
%define tmp5 r14 ; must be saved and restored
%define tmp6 r15 ; must be saved and restored
%define return rax
%define PS 8
%define LOG_PS 3
%define func(x) x:
%macro FUNC_SAVE 0
push r12
push r13
push r14
push r15
%endmacro
%macro FUNC_RESTORE 0
pop r15
pop r14
pop r13
pop r12
%endmacro
%endif
%ifidn __OUTPUT_FORMAT__, win64
%define arg0 rcx
%define arg1 rdx
%define arg2 r8
%define arg3 r9
%define arg4 r12 ; must be saved, loaded and restored
%define arg5 r15 ; must be saved and restored
%define tmp r11
%define tmp2 r10
%define tmp3 r13 ; must be saved and restored
%define tmp4 r14 ; must be saved and restored
%define tmp5 rdi ; must be saved and restored
%define tmp6 rsi ; must be saved and restored
%define return rax
%define PS 8
%define LOG_PS 3
%define stack_size 10*16 + 7*8 ; must be an odd multiple of 8
%define arg(x) [rsp + stack_size + PS + PS*x]
%define func(x) proc_frame x
%macro FUNC_SAVE 0
alloc_stack stack_size
save_xmm128 xmm6, 0*16
save_xmm128 xmm7, 1*16
save_xmm128 xmm8, 2*16
save_xmm128 xmm9, 3*16
save_xmm128 xmm10, 4*16
save_xmm128 xmm11, 5*16
save_xmm128 xmm12, 6*16
save_xmm128 xmm13, 7*16
save_xmm128 xmm14, 8*16
save_xmm128 xmm15, 9*16
save_reg r12, 10*16 + 0*8
save_reg r13, 10*16 + 1*8
save_reg r14, 10*16 + 2*8
save_reg r15, 10*16 + 3*8
save_reg rdi, 10*16 + 4*8
save_reg rsi, 10*16 + 5*8
end_prolog
mov arg4, arg(4)
%endmacro
%macro FUNC_RESTORE 0
vmovdqa xmm6, [rsp + 0*16]
vmovdqa xmm7, [rsp + 1*16]
vmovdqa xmm8, [rsp + 2*16]
vmovdqa xmm9, [rsp + 3*16]
vmovdqa xmm10, [rsp + 4*16]
vmovdqa xmm11, [rsp + 5*16]
vmovdqa xmm12, [rsp + 6*16]
vmovdqa xmm13, [rsp + 7*16]
vmovdqa xmm14, [rsp + 8*16]
vmovdqa xmm15, [rsp + 9*16]
mov r12, [rsp + 10*16 + 0*8]
mov r13, [rsp + 10*16 + 1*8]
mov r14, [rsp + 10*16 + 2*8]
mov r15, [rsp + 10*16 + 3*8]
mov rdi, [rsp + 10*16 + 4*8]
mov rsi, [rsp + 10*16 + 5*8]
add rsp, stack_size
%endmacro
%endif
%define len arg0
%define vec arg1
%define mul_array arg2
%define src arg3
%define dest arg4
%define ptr arg5
%define vec_i tmp2
%define dest1 tmp3
%define dest2 tmp4
%define vskip1 tmp5
%define vskip3 tmp6
%define pos return
%ifndef EC_ALIGNED_ADDR
;;; Use Un-aligned load/store
%define XLDR vmovdqu
%define XSTR vmovdqu
%else
;;; Use Non-temporal load/stor
%ifdef NO_NT_LDST
%define XLDR vmovdqa
%define XSTR vmovdqa
%else
%define XLDR vmovntdqa
%define XSTR vmovntdq
%endif
%endif
default rel
[bits 64]
section .text
%define xmask0f xmm15
%define xgft1_lo xmm14
%define xgft1_hi xmm13
%define xgft2_lo xmm12
%define xgft2_hi xmm11
%define xgft3_lo xmm10
%define xgft3_hi xmm9
%define x0 xmm0
%define xtmpa xmm1
%define xp1 xmm2
%define xp2 xmm3
%define xp3 xmm4
%define xp4 xmm5
%define xp5 xmm6
%define xp6 xmm7
align 16
global gf_6vect_dot_prod_avx:function
func(gf_6vect_dot_prod_avx)
FUNC_SAVE
sub len, 16
jl .return_fail
xor pos, pos
vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
mov vskip1, vec
imul vskip1, 32
mov vskip3, vec
imul vskip3, 96
sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS
mov dest1, [dest]
mov dest2, [dest+PS]
.loop16:
mov tmp, mul_array
xor vec_i, vec_i
vpxor xp1, xp1
vpxor xp2, xp2
vpxor xp3, xp3
vpxor xp4, xp4
vpxor xp5, xp5
vpxor xp6, xp6
.next_vect:
mov ptr, [src+vec_i]
add vec_i, PS
XLDR x0, [ptr+pos] ;Get next source vector
vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f}
vmovdqu xgft1_hi, [tmp+16] ; " Ax{00}, Ax{10}, ..., Ax{f0}
vmovdqu xgft2_lo, [tmp+vskip1*1] ;Load array Bx{00}, Bx{01}, ..., Bx{0f}
vmovdqu xgft2_hi, [tmp+vskip1*1+16] ; " Bx{00}, Bx{10}, ..., Bx{f0}
vmovdqu xgft3_lo, [tmp+vskip1*2] ;Load array Cx{00}, Cx{01}, ..., Cx{0f}
vmovdqu xgft3_hi, [tmp+vskip1*2+16] ; " Cx{00}, Cx{10}, ..., Cx{f0}
lea ptr, [vskip1 + vskip1*4] ;ptr = vskip5
vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft1_hi, xgft1_lo ;GF add high and low partials
vpxor xp1, xgft1_hi ;xp1 += partial
vpshufb xgft2_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft2_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft2_hi, xgft2_lo ;GF add high and low partials
vpxor xp2, xgft2_hi ;xp2 += partial
vpshufb xgft3_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft3_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft3_hi, xgft3_lo ;GF add high and low partials
vpxor xp3, xgft3_hi ;xp3 += partial
vmovdqu xgft1_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f}
vmovdqu xgft1_hi, [tmp+vskip3+16] ; " Dx{00}, Dx{10}, ..., Dx{f0}
vmovdqu xgft2_lo, [tmp+vskip1*4] ;Load array Ex{00}, Ex{01}, ..., Ex{0f}
vmovdqu xgft2_hi, [tmp+vskip1*4+16] ; " Ex{00}, Ex{10}, ..., Ex{f0}
vmovdqu xgft3_lo, [tmp+ptr] ;Load array Fx{00}, Fx{01}, ..., Fx{0f}
vmovdqu xgft3_hi, [tmp+ptr+16] ; " Fx{00}, Fx{10}, ..., Fx{f0}
add tmp, 32
vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft1_hi, xgft1_lo ;GF add high and low partials
vpxor xp4, xgft1_hi ;xp4 += partial
vpshufb xgft2_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft2_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft2_hi, xgft2_lo ;GF add high and low partials
vpxor xp5, xgft2_hi ;xp5 += partial
vpshufb xgft3_hi, x0 ;Lookup mul table of high nibble
vpshufb xgft3_lo, xtmpa ;Lookup mul table of low nibble
vpxor xgft3_hi, xgft3_lo ;GF add high and low partials
vpxor xp6, xgft3_hi ;xp6 += partial
cmp vec_i, vec
jl .next_vect
mov tmp, [dest+2*PS]
mov ptr, [dest+3*PS]
mov vec_i, [dest+4*PS]
XSTR [dest1+pos], xp1
XSTR [dest2+pos], xp2
XSTR [tmp+pos], xp3
mov tmp, [dest+5*PS]
XSTR [ptr+pos], xp4
XSTR [vec_i+pos], xp5
XSTR [tmp+pos], xp6
add pos, 16 ;Loop on 16 bytes at a time
cmp pos, len
jle .loop16
lea tmp, [len + 16]
cmp pos, tmp
je .return_pass
;; Tail len
mov pos, len ;Overlapped offset length-16
jmp .loop16 ;Do one more overlap pass
.return_pass:
FUNC_RESTORE
mov return, 0
ret
.return_fail:
FUNC_RESTORE
mov return, 1
ret
endproc_frame
section .data
align 16
mask0f: ddq 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
%macro slversion 4
global %1_slver_%2%3%4
global %1_slver
%1_slver:
%1_slver_%2%3%4:
dw 0x%4
db 0x%3, 0x%2
%endmacro
;;; func core, ver, snum
slversion gf_6vect_dot_prod_avx, 02, 03, 0195
|
; A130815: Period 6: repeat [1, 5, 4, -1, -5, -4].
; 1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4,1,5,4,-1,-5,-4
mov $1,1
mov $2,4
lpb $0,1
sub $0,1
add $1,$2
sub $2,$1
lpe
|
; A254030: a(n) = 1*4^n + 2*3^n + 3*2^n + 4*1^n.
; Submitted by Christian Krause
; 10,20,50,146,470,1610,5750,21146,79430,303050,1169750,4554746,17852390,70322090,278050550,1102537946,4381257350,17438542730,69495104150,277204002746,1106488342310,4418973508970,17654960746550,70557055701146,282039886115270,1127594584724810,4508683560353750,18029650107105146,72103348428144230,288367638517054250,1153333290092261750,4612921371662406746,18450450126972157190,73798094441741121290,295181259594291766550,1180691683910688517946,4722666672346397642150,18890366499702679709930
mov $1,3
pow $1,$0
mov $2,2
pow $2,$0
add $2,2
bin $2,2
add $1,$2
mov $0,$1
add $0,1
mul $0,2
|
; A329844: Beatty sequence for (11+sqrt(61))/6.
; 3,6,9,12,15,18,21,25,28,31,34,37,40,43,47,50,53,56,59,62,65,68,72,75,78,81,84,87,90,94,97,100,103,106,109,112,115,119,122,125,128,131,134,137,141,144,147,150,153,156,159,163,166,169,172,175,178,181
mov $3,$0
mul $3,7
add $3,7
mov $1,$3
div $1,52
add $1,3
mov $2,$0
mul $2,3
add $1,$2
|
_wc: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
printf(1, "%d %d %d %s\n", l, w, c, name);
}
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: be 01 00 00 00 mov $0x1,%esi
16: 83 ec 18 sub $0x18,%esp
19: 8b 01 mov (%ecx),%eax
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 83 c3 04 add $0x4,%ebx
int fd, i;
if(argc <= 1){
21: 83 f8 01 cmp $0x1,%eax
{
24: 89 45 e4 mov %eax,-0x1c(%ebp)
if(argc <= 1){
27: 7e 56 jle 7f <main+0x7f>
29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
wc(0, "");
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
30: 83 ec 08 sub $0x8,%esp
33: 6a 00 push $0x0
35: ff 33 pushl (%ebx)
37: e8 d6 03 00 00 call 412 <open>
3c: 83 c4 10 add $0x10,%esp
3f: 85 c0 test %eax,%eax
41: 89 c7 mov %eax,%edi
43: 78 26 js 6b <main+0x6b>
printf(1, "wc: cannot open %s\n", argv[i]);
exit();
}
wc(fd, argv[i]);
45: 83 ec 08 sub $0x8,%esp
48: ff 33 pushl (%ebx)
for(i = 1; i < argc; i++){
4a: 83 c6 01 add $0x1,%esi
wc(fd, argv[i]);
4d: 50 push %eax
4e: 83 c3 04 add $0x4,%ebx
51: e8 4a 00 00 00 call a0 <wc>
close(fd);
56: 89 3c 24 mov %edi,(%esp)
59: e8 9c 03 00 00 call 3fa <close>
for(i = 1; i < argc; i++){
5e: 83 c4 10 add $0x10,%esp
61: 39 75 e4 cmp %esi,-0x1c(%ebp)
64: 75 ca jne 30 <main+0x30>
}
exit();
66: e8 67 03 00 00 call 3d2 <exit>
printf(1, "wc: cannot open %s\n", argv[i]);
6b: 50 push %eax
6c: ff 33 pushl (%ebx)
6e: 68 cb 08 00 00 push $0x8cb
73: 6a 01 push $0x1
75: e8 d6 04 00 00 call 550 <printf>
exit();
7a: e8 53 03 00 00 call 3d2 <exit>
wc(0, "");
7f: 52 push %edx
80: 52 push %edx
81: 68 bd 08 00 00 push $0x8bd
86: 6a 00 push $0x0
88: e8 13 00 00 00 call a0 <wc>
exit();
8d: e8 40 03 00 00 call 3d2 <exit>
92: 66 90 xchg %ax,%ax
94: 66 90 xchg %ax,%ax
96: 66 90 xchg %ax,%ax
98: 66 90 xchg %ax,%ax
9a: 66 90 xchg %ax,%ax
9c: 66 90 xchg %ax,%ax
9e: 66 90 xchg %ax,%ax
000000a0 <wc>:
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 57 push %edi
a4: 56 push %esi
a5: 53 push %ebx
l = w = c = 0;
a6: 31 db xor %ebx,%ebx
{
a8: 83 ec 1c sub $0x1c,%esp
inword = 0;
ab: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
l = w = c = 0;
b2: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
b9: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
while((n = read(fd, buf, sizeof(buf))) > 0){
c0: 83 ec 04 sub $0x4,%esp
c3: 68 00 02 00 00 push $0x200
c8: 68 00 0c 00 00 push $0xc00
cd: ff 75 08 pushl 0x8(%ebp)
d0: e8 15 03 00 00 call 3ea <read>
d5: 83 c4 10 add $0x10,%esp
d8: 83 f8 00 cmp $0x0,%eax
db: 89 c6 mov %eax,%esi
dd: 7e 61 jle 140 <wc+0xa0>
for(i=0; i<n; i++){
df: 31 ff xor %edi,%edi
e1: eb 13 jmp f6 <wc+0x56>
e3: 90 nop
e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
inword = 0;
e8: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
for(i=0; i<n; i++){
ef: 83 c7 01 add $0x1,%edi
f2: 39 fe cmp %edi,%esi
f4: 74 42 je 138 <wc+0x98>
if(buf[i] == '\n')
f6: 0f be 87 00 0c 00 00 movsbl 0xc00(%edi),%eax
l++;
fd: 31 c9 xor %ecx,%ecx
ff: 3c 0a cmp $0xa,%al
101: 0f 94 c1 sete %cl
if(strchr(" \r\t\n\v", buf[i]))
104: 83 ec 08 sub $0x8,%esp
107: 50 push %eax
108: 68 a8 08 00 00 push $0x8a8
l++;
10d: 01 cb add %ecx,%ebx
if(strchr(" \r\t\n\v", buf[i]))
10f: e8 3c 01 00 00 call 250 <strchr>
114: 83 c4 10 add $0x10,%esp
117: 85 c0 test %eax,%eax
119: 75 cd jne e8 <wc+0x48>
else if(!inword){
11b: 8b 55 e4 mov -0x1c(%ebp),%edx
11e: 85 d2 test %edx,%edx
120: 75 cd jne ef <wc+0x4f>
for(i=0; i<n; i++){
122: 83 c7 01 add $0x1,%edi
w++;
125: 83 45 dc 01 addl $0x1,-0x24(%ebp)
inword = 1;
129: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
for(i=0; i<n; i++){
130: 39 fe cmp %edi,%esi
132: 75 c2 jne f6 <wc+0x56>
134: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
138: 01 75 e0 add %esi,-0x20(%ebp)
13b: eb 83 jmp c0 <wc+0x20>
13d: 8d 76 00 lea 0x0(%esi),%esi
if(n < 0){
140: 75 24 jne 166 <wc+0xc6>
printf(1, "%d %d %d %s\n", l, w, c, name);
142: 83 ec 08 sub $0x8,%esp
145: ff 75 0c pushl 0xc(%ebp)
148: ff 75 e0 pushl -0x20(%ebp)
14b: ff 75 dc pushl -0x24(%ebp)
14e: 53 push %ebx
14f: 68 be 08 00 00 push $0x8be
154: 6a 01 push $0x1
156: e8 f5 03 00 00 call 550 <printf>
}
15b: 83 c4 20 add $0x20,%esp
15e: 8d 65 f4 lea -0xc(%ebp),%esp
161: 5b pop %ebx
162: 5e pop %esi
163: 5f pop %edi
164: 5d pop %ebp
165: c3 ret
printf(1, "wc: read error\n");
166: 50 push %eax
167: 50 push %eax
168: 68 ae 08 00 00 push $0x8ae
16d: 6a 01 push $0x1
16f: e8 dc 03 00 00 call 550 <printf>
exit();
174: e8 59 02 00 00 call 3d2 <exit>
179: 66 90 xchg %ax,%ax
17b: 66 90 xchg %ax,%ax
17d: 66 90 xchg %ax,%ax
17f: 90 nop
00000180 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 53 push %ebx
184: 8b 45 08 mov 0x8(%ebp),%eax
187: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
18a: 89 c2 mov %eax,%edx
18c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
190: 83 c1 01 add $0x1,%ecx
193: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
197: 83 c2 01 add $0x1,%edx
19a: 84 db test %bl,%bl
19c: 88 5a ff mov %bl,-0x1(%edx)
19f: 75 ef jne 190 <strcpy+0x10>
;
return os;
}
1a1: 5b pop %ebx
1a2: 5d pop %ebp
1a3: c3 ret
1a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000001b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1b0: 55 push %ebp
1b1: 89 e5 mov %esp,%ebp
1b3: 53 push %ebx
1b4: 8b 55 08 mov 0x8(%ebp),%edx
1b7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
1ba: 0f b6 02 movzbl (%edx),%eax
1bd: 0f b6 19 movzbl (%ecx),%ebx
1c0: 84 c0 test %al,%al
1c2: 75 1c jne 1e0 <strcmp+0x30>
1c4: eb 2a jmp 1f0 <strcmp+0x40>
1c6: 8d 76 00 lea 0x0(%esi),%esi
1c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
1d0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
1d3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
1d6: 83 c1 01 add $0x1,%ecx
1d9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
1dc: 84 c0 test %al,%al
1de: 74 10 je 1f0 <strcmp+0x40>
1e0: 38 d8 cmp %bl,%al
1e2: 74 ec je 1d0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
1e4: 29 d8 sub %ebx,%eax
}
1e6: 5b pop %ebx
1e7: 5d pop %ebp
1e8: c3 ret
1e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1f0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
1f2: 29 d8 sub %ebx,%eax
}
1f4: 5b pop %ebx
1f5: 5d pop %ebp
1f6: c3 ret
1f7: 89 f6 mov %esi,%esi
1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000200 <strlen>:
uint
strlen(char *s)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
206: 80 39 00 cmpb $0x0,(%ecx)
209: 74 15 je 220 <strlen+0x20>
20b: 31 d2 xor %edx,%edx
20d: 8d 76 00 lea 0x0(%esi),%esi
210: 83 c2 01 add $0x1,%edx
213: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
217: 89 d0 mov %edx,%eax
219: 75 f5 jne 210 <strlen+0x10>
;
return n;
}
21b: 5d pop %ebp
21c: c3 ret
21d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
220: 31 c0 xor %eax,%eax
}
222: 5d pop %ebp
223: c3 ret
224: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
22a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000230 <memset>:
void*
memset(void *dst, int c, uint n)
{
230: 55 push %ebp
231: 89 e5 mov %esp,%ebp
233: 57 push %edi
234: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
237: 8b 4d 10 mov 0x10(%ebp),%ecx
23a: 8b 45 0c mov 0xc(%ebp),%eax
23d: 89 d7 mov %edx,%edi
23f: fc cld
240: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
242: 89 d0 mov %edx,%eax
244: 5f pop %edi
245: 5d pop %ebp
246: c3 ret
247: 89 f6 mov %esi,%esi
249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000250 <strchr>:
char*
strchr(const char *s, char c)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 53 push %ebx
254: 8b 45 08 mov 0x8(%ebp),%eax
257: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
25a: 0f b6 10 movzbl (%eax),%edx
25d: 84 d2 test %dl,%dl
25f: 74 1d je 27e <strchr+0x2e>
if(*s == c)
261: 38 d3 cmp %dl,%bl
263: 89 d9 mov %ebx,%ecx
265: 75 0d jne 274 <strchr+0x24>
267: eb 17 jmp 280 <strchr+0x30>
269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
270: 38 ca cmp %cl,%dl
272: 74 0c je 280 <strchr+0x30>
for(; *s; s++)
274: 83 c0 01 add $0x1,%eax
277: 0f b6 10 movzbl (%eax),%edx
27a: 84 d2 test %dl,%dl
27c: 75 f2 jne 270 <strchr+0x20>
return (char*)s;
return 0;
27e: 31 c0 xor %eax,%eax
}
280: 5b pop %ebx
281: 5d pop %ebp
282: c3 ret
283: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
289: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000290 <gets>:
char*
gets(char *buf, int max)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 57 push %edi
294: 56 push %esi
295: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
296: 31 f6 xor %esi,%esi
298: 89 f3 mov %esi,%ebx
{
29a: 83 ec 1c sub $0x1c,%esp
29d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
2a0: eb 2f jmp 2d1 <gets+0x41>
2a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
2a8: 8d 45 e7 lea -0x19(%ebp),%eax
2ab: 83 ec 04 sub $0x4,%esp
2ae: 6a 01 push $0x1
2b0: 50 push %eax
2b1: 6a 00 push $0x0
2b3: e8 32 01 00 00 call 3ea <read>
if(cc < 1)
2b8: 83 c4 10 add $0x10,%esp
2bb: 85 c0 test %eax,%eax
2bd: 7e 1c jle 2db <gets+0x4b>
break;
buf[i++] = c;
2bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
2c3: 83 c7 01 add $0x1,%edi
2c6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
2c9: 3c 0a cmp $0xa,%al
2cb: 74 23 je 2f0 <gets+0x60>
2cd: 3c 0d cmp $0xd,%al
2cf: 74 1f je 2f0 <gets+0x60>
for(i=0; i+1 < max; ){
2d1: 83 c3 01 add $0x1,%ebx
2d4: 3b 5d 0c cmp 0xc(%ebp),%ebx
2d7: 89 fe mov %edi,%esi
2d9: 7c cd jl 2a8 <gets+0x18>
2db: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
2dd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
2e0: c6 03 00 movb $0x0,(%ebx)
}
2e3: 8d 65 f4 lea -0xc(%ebp),%esp
2e6: 5b pop %ebx
2e7: 5e pop %esi
2e8: 5f pop %edi
2e9: 5d pop %ebp
2ea: c3 ret
2eb: 90 nop
2ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2f0: 8b 75 08 mov 0x8(%ebp),%esi
2f3: 8b 45 08 mov 0x8(%ebp),%eax
2f6: 01 de add %ebx,%esi
2f8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
2fa: c6 03 00 movb $0x0,(%ebx)
}
2fd: 8d 65 f4 lea -0xc(%ebp),%esp
300: 5b pop %ebx
301: 5e pop %esi
302: 5f pop %edi
303: 5d pop %ebp
304: c3 ret
305: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
309: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000310 <stat>:
int
stat(char *n, struct stat *st)
{
310: 55 push %ebp
311: 89 e5 mov %esp,%ebp
313: 56 push %esi
314: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
315: 83 ec 08 sub $0x8,%esp
318: 6a 00 push $0x0
31a: ff 75 08 pushl 0x8(%ebp)
31d: e8 f0 00 00 00 call 412 <open>
if(fd < 0)
322: 83 c4 10 add $0x10,%esp
325: 85 c0 test %eax,%eax
327: 78 27 js 350 <stat+0x40>
return -1;
r = fstat(fd, st);
329: 83 ec 08 sub $0x8,%esp
32c: ff 75 0c pushl 0xc(%ebp)
32f: 89 c3 mov %eax,%ebx
331: 50 push %eax
332: e8 f3 00 00 00 call 42a <fstat>
close(fd);
337: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
33a: 89 c6 mov %eax,%esi
close(fd);
33c: e8 b9 00 00 00 call 3fa <close>
return r;
341: 83 c4 10 add $0x10,%esp
}
344: 8d 65 f8 lea -0x8(%ebp),%esp
347: 89 f0 mov %esi,%eax
349: 5b pop %ebx
34a: 5e pop %esi
34b: 5d pop %ebp
34c: c3 ret
34d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
350: be ff ff ff ff mov $0xffffffff,%esi
355: eb ed jmp 344 <stat+0x34>
357: 89 f6 mov %esi,%esi
359: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000360 <atoi>:
int
atoi(const char *s)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 53 push %ebx
364: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
367: 0f be 11 movsbl (%ecx),%edx
36a: 8d 42 d0 lea -0x30(%edx),%eax
36d: 3c 09 cmp $0x9,%al
n = 0;
36f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
374: 77 1f ja 395 <atoi+0x35>
376: 8d 76 00 lea 0x0(%esi),%esi
379: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
380: 8d 04 80 lea (%eax,%eax,4),%eax
383: 83 c1 01 add $0x1,%ecx
386: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
38a: 0f be 11 movsbl (%ecx),%edx
38d: 8d 5a d0 lea -0x30(%edx),%ebx
390: 80 fb 09 cmp $0x9,%bl
393: 76 eb jbe 380 <atoi+0x20>
return n;
}
395: 5b pop %ebx
396: 5d pop %ebp
397: c3 ret
398: 90 nop
399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000003a0 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 56 push %esi
3a4: 53 push %ebx
3a5: 8b 5d 10 mov 0x10(%ebp),%ebx
3a8: 8b 45 08 mov 0x8(%ebp),%eax
3ab: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3ae: 85 db test %ebx,%ebx
3b0: 7e 14 jle 3c6 <memmove+0x26>
3b2: 31 d2 xor %edx,%edx
3b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
3b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
3bc: 88 0c 10 mov %cl,(%eax,%edx,1)
3bf: 83 c2 01 add $0x1,%edx
while(n-- > 0)
3c2: 39 d3 cmp %edx,%ebx
3c4: 75 f2 jne 3b8 <memmove+0x18>
return vdst;
}
3c6: 5b pop %ebx
3c7: 5e pop %esi
3c8: 5d pop %ebp
3c9: c3 ret
000003ca <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3ca: b8 01 00 00 00 mov $0x1,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <exit>:
SYSCALL(exit)
3d2: b8 02 00 00 00 mov $0x2,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <wait>:
SYSCALL(wait)
3da: b8 03 00 00 00 mov $0x3,%eax
3df: cd 40 int $0x40
3e1: c3 ret
000003e2 <pipe>:
SYSCALL(pipe)
3e2: b8 04 00 00 00 mov $0x4,%eax
3e7: cd 40 int $0x40
3e9: c3 ret
000003ea <read>:
SYSCALL(read)
3ea: b8 05 00 00 00 mov $0x5,%eax
3ef: cd 40 int $0x40
3f1: c3 ret
000003f2 <write>:
SYSCALL(write)
3f2: b8 10 00 00 00 mov $0x10,%eax
3f7: cd 40 int $0x40
3f9: c3 ret
000003fa <close>:
SYSCALL(close)
3fa: b8 15 00 00 00 mov $0x15,%eax
3ff: cd 40 int $0x40
401: c3 ret
00000402 <kill>:
SYSCALL(kill)
402: b8 06 00 00 00 mov $0x6,%eax
407: cd 40 int $0x40
409: c3 ret
0000040a <exec>:
SYSCALL(exec)
40a: b8 07 00 00 00 mov $0x7,%eax
40f: cd 40 int $0x40
411: c3 ret
00000412 <open>:
SYSCALL(open)
412: b8 0f 00 00 00 mov $0xf,%eax
417: cd 40 int $0x40
419: c3 ret
0000041a <mknod>:
SYSCALL(mknod)
41a: b8 11 00 00 00 mov $0x11,%eax
41f: cd 40 int $0x40
421: c3 ret
00000422 <unlink>:
SYSCALL(unlink)
422: b8 12 00 00 00 mov $0x12,%eax
427: cd 40 int $0x40
429: c3 ret
0000042a <fstat>:
SYSCALL(fstat)
42a: b8 08 00 00 00 mov $0x8,%eax
42f: cd 40 int $0x40
431: c3 ret
00000432 <link>:
SYSCALL(link)
432: b8 13 00 00 00 mov $0x13,%eax
437: cd 40 int $0x40
439: c3 ret
0000043a <mkdir>:
SYSCALL(mkdir)
43a: b8 14 00 00 00 mov $0x14,%eax
43f: cd 40 int $0x40
441: c3 ret
00000442 <chdir>:
SYSCALL(chdir)
442: b8 09 00 00 00 mov $0x9,%eax
447: cd 40 int $0x40
449: c3 ret
0000044a <dup>:
SYSCALL(dup)
44a: b8 0a 00 00 00 mov $0xa,%eax
44f: cd 40 int $0x40
451: c3 ret
00000452 <getpid>:
SYSCALL(getpid)
452: b8 0b 00 00 00 mov $0xb,%eax
457: cd 40 int $0x40
459: c3 ret
0000045a <sbrk>:
SYSCALL(sbrk)
45a: b8 0c 00 00 00 mov $0xc,%eax
45f: cd 40 int $0x40
461: c3 ret
00000462 <sleep>:
SYSCALL(sleep)
462: b8 0d 00 00 00 mov $0xd,%eax
467: cd 40 int $0x40
469: c3 ret
0000046a <uptime>:
SYSCALL(uptime)
46a: b8 0e 00 00 00 mov $0xe,%eax
46f: cd 40 int $0x40
471: c3 ret
00000472 <cps>:
SYSCALL(cps)
472: b8 16 00 00 00 mov $0x16,%eax
477: cd 40 int $0x40
479: c3 ret
0000047a <chpr>:
SYSCALL(chpr)
47a: b8 17 00 00 00 mov $0x17,%eax
47f: cd 40 int $0x40
481: c3 ret
00000482 <setTickets>:
SYSCALL(setTickets)
482: b8 18 00 00 00 mov $0x18,%eax
487: cd 40 int $0x40
489: c3 ret
0000048a <thread_create>:
SYSCALL(thread_create)
48a: b8 19 00 00 00 mov $0x19,%eax
48f: cd 40 int $0x40
491: c3 ret
00000492 <thread_exit>:
SYSCALL(thread_exit)
492: b8 1a 00 00 00 mov $0x1a,%eax
497: cd 40 int $0x40
499: c3 ret
0000049a <thread_join>:
SYSCALL(thread_join)
49a: b8 1b 00 00 00 mov $0x1b,%eax
49f: cd 40 int $0x40
4a1: c3 ret
000004a2 <gettid>:
SYSCALL(gettid)
4a2: b8 1c 00 00 00 mov $0x1c,%eax
4a7: cd 40 int $0x40
4a9: c3 ret
4aa: 66 90 xchg %ax,%ax
4ac: 66 90 xchg %ax,%ax
4ae: 66 90 xchg %ax,%ax
000004b0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
4b0: 55 push %ebp
4b1: 89 e5 mov %esp,%ebp
4b3: 57 push %edi
4b4: 56 push %esi
4b5: 53 push %ebx
4b6: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
4b9: 85 d2 test %edx,%edx
{
4bb: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
4be: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
4c0: 79 76 jns 538 <printint+0x88>
4c2: f6 45 08 01 testb $0x1,0x8(%ebp)
4c6: 74 70 je 538 <printint+0x88>
x = -xx;
4c8: f7 d8 neg %eax
neg = 1;
4ca: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
4d1: 31 f6 xor %esi,%esi
4d3: 8d 5d d7 lea -0x29(%ebp),%ebx
4d6: eb 0a jmp 4e2 <printint+0x32>
4d8: 90 nop
4d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
4e0: 89 fe mov %edi,%esi
4e2: 31 d2 xor %edx,%edx
4e4: 8d 7e 01 lea 0x1(%esi),%edi
4e7: f7 f1 div %ecx
4e9: 0f b6 92 e8 08 00 00 movzbl 0x8e8(%edx),%edx
}while((x /= base) != 0);
4f0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
4f2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
4f5: 75 e9 jne 4e0 <printint+0x30>
if(neg)
4f7: 8b 45 c4 mov -0x3c(%ebp),%eax
4fa: 85 c0 test %eax,%eax
4fc: 74 08 je 506 <printint+0x56>
buf[i++] = '-';
4fe: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
503: 8d 7e 02 lea 0x2(%esi),%edi
506: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
50a: 8b 7d c0 mov -0x40(%ebp),%edi
50d: 8d 76 00 lea 0x0(%esi),%esi
510: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
513: 83 ec 04 sub $0x4,%esp
516: 83 ee 01 sub $0x1,%esi
519: 6a 01 push $0x1
51b: 53 push %ebx
51c: 57 push %edi
51d: 88 45 d7 mov %al,-0x29(%ebp)
520: e8 cd fe ff ff call 3f2 <write>
while(--i >= 0)
525: 83 c4 10 add $0x10,%esp
528: 39 de cmp %ebx,%esi
52a: 75 e4 jne 510 <printint+0x60>
putc(fd, buf[i]);
}
52c: 8d 65 f4 lea -0xc(%ebp),%esp
52f: 5b pop %ebx
530: 5e pop %esi
531: 5f pop %edi
532: 5d pop %ebp
533: c3 ret
534: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
538: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
53f: eb 90 jmp 4d1 <printint+0x21>
541: eb 0d jmp 550 <printf>
543: 90 nop
544: 90 nop
545: 90 nop
546: 90 nop
547: 90 nop
548: 90 nop
549: 90 nop
54a: 90 nop
54b: 90 nop
54c: 90 nop
54d: 90 nop
54e: 90 nop
54f: 90 nop
00000550 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
550: 55 push %ebp
551: 89 e5 mov %esp,%ebp
553: 57 push %edi
554: 56 push %esi
555: 53 push %ebx
556: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
559: 8b 75 0c mov 0xc(%ebp),%esi
55c: 0f b6 1e movzbl (%esi),%ebx
55f: 84 db test %bl,%bl
561: 0f 84 b3 00 00 00 je 61a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
567: 8d 45 10 lea 0x10(%ebp),%eax
56a: 83 c6 01 add $0x1,%esi
state = 0;
56d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
56f: 89 45 d4 mov %eax,-0x2c(%ebp)
572: eb 2f jmp 5a3 <printf+0x53>
574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
578: 83 f8 25 cmp $0x25,%eax
57b: 0f 84 a7 00 00 00 je 628 <printf+0xd8>
write(fd, &c, 1);
581: 8d 45 e2 lea -0x1e(%ebp),%eax
584: 83 ec 04 sub $0x4,%esp
587: 88 5d e2 mov %bl,-0x1e(%ebp)
58a: 6a 01 push $0x1
58c: 50 push %eax
58d: ff 75 08 pushl 0x8(%ebp)
590: e8 5d fe ff ff call 3f2 <write>
595: 83 c4 10 add $0x10,%esp
598: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
59b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
59f: 84 db test %bl,%bl
5a1: 74 77 je 61a <printf+0xca>
if(state == 0){
5a3: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
5a5: 0f be cb movsbl %bl,%ecx
5a8: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
5ab: 74 cb je 578 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
5ad: 83 ff 25 cmp $0x25,%edi
5b0: 75 e6 jne 598 <printf+0x48>
if(c == 'd'){
5b2: 83 f8 64 cmp $0x64,%eax
5b5: 0f 84 05 01 00 00 je 6c0 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
5bb: 81 e1 f7 00 00 00 and $0xf7,%ecx
5c1: 83 f9 70 cmp $0x70,%ecx
5c4: 74 72 je 638 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
5c6: 83 f8 73 cmp $0x73,%eax
5c9: 0f 84 99 00 00 00 je 668 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
5cf: 83 f8 63 cmp $0x63,%eax
5d2: 0f 84 08 01 00 00 je 6e0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
5d8: 83 f8 25 cmp $0x25,%eax
5db: 0f 84 ef 00 00 00 je 6d0 <printf+0x180>
write(fd, &c, 1);
5e1: 8d 45 e7 lea -0x19(%ebp),%eax
5e4: 83 ec 04 sub $0x4,%esp
5e7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
5eb: 6a 01 push $0x1
5ed: 50 push %eax
5ee: ff 75 08 pushl 0x8(%ebp)
5f1: e8 fc fd ff ff call 3f2 <write>
5f6: 83 c4 0c add $0xc,%esp
5f9: 8d 45 e6 lea -0x1a(%ebp),%eax
5fc: 88 5d e6 mov %bl,-0x1a(%ebp)
5ff: 6a 01 push $0x1
601: 50 push %eax
602: ff 75 08 pushl 0x8(%ebp)
605: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
608: 31 ff xor %edi,%edi
write(fd, &c, 1);
60a: e8 e3 fd ff ff call 3f2 <write>
for(i = 0; fmt[i]; i++){
60f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
613: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
616: 84 db test %bl,%bl
618: 75 89 jne 5a3 <printf+0x53>
}
}
}
61a: 8d 65 f4 lea -0xc(%ebp),%esp
61d: 5b pop %ebx
61e: 5e pop %esi
61f: 5f pop %edi
620: 5d pop %ebp
621: c3 ret
622: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
628: bf 25 00 00 00 mov $0x25,%edi
62d: e9 66 ff ff ff jmp 598 <printf+0x48>
632: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
638: 83 ec 0c sub $0xc,%esp
63b: b9 10 00 00 00 mov $0x10,%ecx
640: 6a 00 push $0x0
642: 8b 7d d4 mov -0x2c(%ebp),%edi
645: 8b 45 08 mov 0x8(%ebp),%eax
648: 8b 17 mov (%edi),%edx
64a: e8 61 fe ff ff call 4b0 <printint>
ap++;
64f: 89 f8 mov %edi,%eax
651: 83 c4 10 add $0x10,%esp
state = 0;
654: 31 ff xor %edi,%edi
ap++;
656: 83 c0 04 add $0x4,%eax
659: 89 45 d4 mov %eax,-0x2c(%ebp)
65c: e9 37 ff ff ff jmp 598 <printf+0x48>
661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
668: 8b 45 d4 mov -0x2c(%ebp),%eax
66b: 8b 08 mov (%eax),%ecx
ap++;
66d: 83 c0 04 add $0x4,%eax
670: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
673: 85 c9 test %ecx,%ecx
675: 0f 84 8e 00 00 00 je 709 <printf+0x1b9>
while(*s != 0){
67b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
67e: 31 ff xor %edi,%edi
s = (char*)*ap;
680: 89 cb mov %ecx,%ebx
while(*s != 0){
682: 84 c0 test %al,%al
684: 0f 84 0e ff ff ff je 598 <printf+0x48>
68a: 89 75 d0 mov %esi,-0x30(%ebp)
68d: 89 de mov %ebx,%esi
68f: 8b 5d 08 mov 0x8(%ebp),%ebx
692: 8d 7d e3 lea -0x1d(%ebp),%edi
695: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
698: 83 ec 04 sub $0x4,%esp
s++;
69b: 83 c6 01 add $0x1,%esi
69e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
6a1: 6a 01 push $0x1
6a3: 57 push %edi
6a4: 53 push %ebx
6a5: e8 48 fd ff ff call 3f2 <write>
while(*s != 0){
6aa: 0f b6 06 movzbl (%esi),%eax
6ad: 83 c4 10 add $0x10,%esp
6b0: 84 c0 test %al,%al
6b2: 75 e4 jne 698 <printf+0x148>
6b4: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
6b7: 31 ff xor %edi,%edi
6b9: e9 da fe ff ff jmp 598 <printf+0x48>
6be: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
6c0: 83 ec 0c sub $0xc,%esp
6c3: b9 0a 00 00 00 mov $0xa,%ecx
6c8: 6a 01 push $0x1
6ca: e9 73 ff ff ff jmp 642 <printf+0xf2>
6cf: 90 nop
write(fd, &c, 1);
6d0: 83 ec 04 sub $0x4,%esp
6d3: 88 5d e5 mov %bl,-0x1b(%ebp)
6d6: 8d 45 e5 lea -0x1b(%ebp),%eax
6d9: 6a 01 push $0x1
6db: e9 21 ff ff ff jmp 601 <printf+0xb1>
putc(fd, *ap);
6e0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
6e3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
6e6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
6e8: 6a 01 push $0x1
ap++;
6ea: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
6ed: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
6f0: 8d 45 e4 lea -0x1c(%ebp),%eax
6f3: 50 push %eax
6f4: ff 75 08 pushl 0x8(%ebp)
6f7: e8 f6 fc ff ff call 3f2 <write>
ap++;
6fc: 89 7d d4 mov %edi,-0x2c(%ebp)
6ff: 83 c4 10 add $0x10,%esp
state = 0;
702: 31 ff xor %edi,%edi
704: e9 8f fe ff ff jmp 598 <printf+0x48>
s = "(null)";
709: bb df 08 00 00 mov $0x8df,%ebx
while(*s != 0){
70e: b8 28 00 00 00 mov $0x28,%eax
713: e9 72 ff ff ff jmp 68a <printf+0x13a>
718: 66 90 xchg %ax,%ax
71a: 66 90 xchg %ax,%ax
71c: 66 90 xchg %ax,%ax
71e: 66 90 xchg %ax,%ax
00000720 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
720: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
721: a1 e0 0b 00 00 mov 0xbe0,%eax
{
726: 89 e5 mov %esp,%ebp
728: 57 push %edi
729: 56 push %esi
72a: 53 push %ebx
72b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
72e: 8d 4b f8 lea -0x8(%ebx),%ecx
731: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
738: 39 c8 cmp %ecx,%eax
73a: 8b 10 mov (%eax),%edx
73c: 73 32 jae 770 <free+0x50>
73e: 39 d1 cmp %edx,%ecx
740: 72 04 jb 746 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
742: 39 d0 cmp %edx,%eax
744: 72 32 jb 778 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
746: 8b 73 fc mov -0x4(%ebx),%esi
749: 8d 3c f1 lea (%ecx,%esi,8),%edi
74c: 39 fa cmp %edi,%edx
74e: 74 30 je 780 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
750: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
753: 8b 50 04 mov 0x4(%eax),%edx
756: 8d 34 d0 lea (%eax,%edx,8),%esi
759: 39 f1 cmp %esi,%ecx
75b: 74 3a je 797 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
75d: 89 08 mov %ecx,(%eax)
freep = p;
75f: a3 e0 0b 00 00 mov %eax,0xbe0
}
764: 5b pop %ebx
765: 5e pop %esi
766: 5f pop %edi
767: 5d pop %ebp
768: c3 ret
769: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
770: 39 d0 cmp %edx,%eax
772: 72 04 jb 778 <free+0x58>
774: 39 d1 cmp %edx,%ecx
776: 72 ce jb 746 <free+0x26>
{
778: 89 d0 mov %edx,%eax
77a: eb bc jmp 738 <free+0x18>
77c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
780: 03 72 04 add 0x4(%edx),%esi
783: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
786: 8b 10 mov (%eax),%edx
788: 8b 12 mov (%edx),%edx
78a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
78d: 8b 50 04 mov 0x4(%eax),%edx
790: 8d 34 d0 lea (%eax,%edx,8),%esi
793: 39 f1 cmp %esi,%ecx
795: 75 c6 jne 75d <free+0x3d>
p->s.size += bp->s.size;
797: 03 53 fc add -0x4(%ebx),%edx
freep = p;
79a: a3 e0 0b 00 00 mov %eax,0xbe0
p->s.size += bp->s.size;
79f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
7a2: 8b 53 f8 mov -0x8(%ebx),%edx
7a5: 89 10 mov %edx,(%eax)
}
7a7: 5b pop %ebx
7a8: 5e pop %esi
7a9: 5f pop %edi
7aa: 5d pop %ebp
7ab: c3 ret
7ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000007b0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
7b0: 55 push %ebp
7b1: 89 e5 mov %esp,%ebp
7b3: 57 push %edi
7b4: 56 push %esi
7b5: 53 push %ebx
7b6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7b9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
7bc: 8b 15 e0 0b 00 00 mov 0xbe0,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
7c2: 8d 78 07 lea 0x7(%eax),%edi
7c5: c1 ef 03 shr $0x3,%edi
7c8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
7cb: 85 d2 test %edx,%edx
7cd: 0f 84 9d 00 00 00 je 870 <malloc+0xc0>
7d3: 8b 02 mov (%edx),%eax
7d5: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
7d8: 39 cf cmp %ecx,%edi
7da: 76 6c jbe 848 <malloc+0x98>
7dc: 81 ff 00 10 00 00 cmp $0x1000,%edi
7e2: bb 00 10 00 00 mov $0x1000,%ebx
7e7: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
7ea: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
7f1: eb 0e jmp 801 <malloc+0x51>
7f3: 90 nop
7f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7f8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
7fa: 8b 48 04 mov 0x4(%eax),%ecx
7fd: 39 f9 cmp %edi,%ecx
7ff: 73 47 jae 848 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
801: 39 05 e0 0b 00 00 cmp %eax,0xbe0
807: 89 c2 mov %eax,%edx
809: 75 ed jne 7f8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
80b: 83 ec 0c sub $0xc,%esp
80e: 56 push %esi
80f: e8 46 fc ff ff call 45a <sbrk>
if(p == (char*)-1)
814: 83 c4 10 add $0x10,%esp
817: 83 f8 ff cmp $0xffffffff,%eax
81a: 74 1c je 838 <malloc+0x88>
hp->s.size = nu;
81c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
81f: 83 ec 0c sub $0xc,%esp
822: 83 c0 08 add $0x8,%eax
825: 50 push %eax
826: e8 f5 fe ff ff call 720 <free>
return freep;
82b: 8b 15 e0 0b 00 00 mov 0xbe0,%edx
if((p = morecore(nunits)) == 0)
831: 83 c4 10 add $0x10,%esp
834: 85 d2 test %edx,%edx
836: 75 c0 jne 7f8 <malloc+0x48>
return 0;
}
}
838: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
83b: 31 c0 xor %eax,%eax
}
83d: 5b pop %ebx
83e: 5e pop %esi
83f: 5f pop %edi
840: 5d pop %ebp
841: c3 ret
842: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
848: 39 cf cmp %ecx,%edi
84a: 74 54 je 8a0 <malloc+0xf0>
p->s.size -= nunits;
84c: 29 f9 sub %edi,%ecx
84e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
851: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
854: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
857: 89 15 e0 0b 00 00 mov %edx,0xbe0
}
85d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
860: 83 c0 08 add $0x8,%eax
}
863: 5b pop %ebx
864: 5e pop %esi
865: 5f pop %edi
866: 5d pop %ebp
867: c3 ret
868: 90 nop
869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
870: c7 05 e0 0b 00 00 e4 movl $0xbe4,0xbe0
877: 0b 00 00
87a: c7 05 e4 0b 00 00 e4 movl $0xbe4,0xbe4
881: 0b 00 00
base.s.size = 0;
884: b8 e4 0b 00 00 mov $0xbe4,%eax
889: c7 05 e8 0b 00 00 00 movl $0x0,0xbe8
890: 00 00 00
893: e9 44 ff ff ff jmp 7dc <malloc+0x2c>
898: 90 nop
899: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
8a0: 8b 08 mov (%eax),%ecx
8a2: 89 0a mov %ecx,(%edx)
8a4: eb b1 jmp 857 <malloc+0xa7>
|
; A196789: Binomial coefficients C(2*n+10,10).
; 1,66,1001,8008,43758,184756,646646,1961256,5311735,13123110,30045015,64512240,131128140,254186856,472733756,847660528,1471442973,2481256778,4076350421,6540715896,10272278170,15820024220,23930713170,35607051480,52179482355,75394027566,107518933731,151473214816,210980549208,290752384208,396704524216,536211932256,718406958841,954526728530,1258315963905,1646492110120,2139280241670,2761025887620,3540894603246,4513667845896,5720645481903,7210666060598,9041256841903,11279926456656,14005614014756,17310309456440,21300860967540,26100986351440,31853506369685,38722819230810,46897636623981,56594002961496,68058620813106,81572506886508,97455004333258,116068178638776,137821625890091,163177723806526,192657357567675,226846154180800,266401260897200,312058705015200,364641374297200,425067659180736,494360799979761,573658984353378,664226242466073,767464189477128,884924667278366,1018323339749716,1169554298222310,1340705736329960,1534076755992935,1752195368913990,1997837760676615,2274048887320496,2584164477130236,2931834513311496,3321048276244908,3756161027103408,4241922417794061,4783506715442026,5386544932973061,6057158960772920,6801997797908170,7628275984984380,8543814344395330,9557083137481880,10677247751972451,11914217037019726,13278694407181203,14782231840815648,16437286902584328,18257282924056176,20256672480820776,22451004309013280,24856993808752105,27492597286684530,30377090094628145,33531148826188520
mul $0,2
mov $1,-11
bin $1,$0
mov $0,$1
|
; A131066: Binomial transform of [1, 1, 6, 6, 6, ...].
; 1,2,9,28,71,162,349,728,1491,3022,6089,12228,24511,49082,98229,196528,393131,786342,1572769,3145628,6291351,12582802,25165709,50331528,100663171,201326462,402653049,805306228,1610612591,3221225322,6442450789,12884901728,25769803611,51539607382,103079214929,206158430028,412316860231,824633720642,1649267441469,3298534883128,6597069766451,13194139533102,26388279066409,52776558133028,105553116266271,211106232532762,422212465065749,844424930131728,1688849860263691,3377699720527622,6755399441055489
mov $1,2
pow $1,$0
sub $0,$1
mul $0,5
sub $1,$0
sub $1,5
|
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "WebServerClientTest.h"
#include <cstdio>
#include <fmt/format.h>
#include <wpi/SmallString.h>
#include <wpinet/raw_uv_ostream.h>
#include <wpinet/uv/util.h>
static constexpr int kTcpConnectAttemptTimeout = 1000;
namespace uv = wpi::uv;
namespace wpilibws {
// Create Web Socket and specify event callbacks
void WebServerClientTest::InitializeWebSocket(const std::string& host, int port,
const std::string& uri) {
fmt::print("Will attempt to connect to: {}:{}{}\n", host, port, uri);
m_websocket = wpi::WebSocket::CreateClient(*m_tcp_client.get(), uri,
fmt::format("{}:{}", host, port));
// Hook up events
m_websocket->open.connect_extended([this](auto conn, auto) {
conn.disconnect();
m_buffers = std::make_unique<BufferPool>();
m_exec = UvExecFunc::Create(m_tcp_client->GetLoop(),
[](auto out, LoopFunc func) {
func();
out.set_value();
});
m_ws_connected = true;
std::fputs("WebServerClientTest: WebSocket Connected\n", stderr);
});
m_websocket->text.connect([this](auto msg, bool) {
wpi::json j;
try {
j = wpi::json::parse(msg);
} catch (const wpi::json::parse_error& e) {
std::string err("JSON parse failed: ");
err += e.what();
fmt::print(stderr, "{}\n", err);
m_websocket->Fail(1003, err);
return;
}
// Save last message received
m_json = j;
});
m_websocket->closed.connect([this](uint16_t, auto) {
if (m_ws_connected) {
std::fputs("WebServerClientTest: Websocket Disconnected\n", stderr);
m_ws_connected = false;
}
});
}
// Create tcp client, specify callbacks, and create timers for loop
bool WebServerClientTest::Initialize() {
m_loop.error.connect(
[](uv::Error err) { fmt::print(stderr, "uv Error: {}\n", err.str()); });
m_tcp_client = uv::Tcp::Create(m_loop);
if (!m_tcp_client) {
std::fputs("ERROR: Could not create TCP Client\n", stderr);
return false;
}
// Hook up TCP client events
m_tcp_client->error.connect(
[this, socket = m_tcp_client.get()](wpi::uv::Error err) {
if (m_tcp_connected) {
m_tcp_connected = false;
m_connect_attempts = 0;
m_loop.Stop();
return;
}
// If we weren't previously connected, attempt a reconnection
m_connect_timer->Start(uv::Timer::Time(kTcpConnectAttemptTimeout));
});
m_tcp_client->closed.connect(
[]() { std::fputs("TCP connection closed\n", stderr); });
// Set up the connection timer
m_connect_timer = uv::Timer::Create(m_loop);
if (!m_connect_timer) {
return false;
}
// Set up the timer to attempt connection
m_connect_timer->timeout.connect([this] { AttemptConnect(); });
m_connect_timer->Start(uv::Timer::Time(0));
std::puts("WebServerClientTest Initialized");
return true;
}
void WebServerClientTest::AttemptConnect() {
m_connect_attempts++;
fmt::print("Test Client Connection Attempt {}\n", m_connect_attempts);
if (m_connect_attempts >= 5) {
std::fputs("Test Client Timeout. Unable to connect\n", stderr);
m_loop.Stop();
return;
}
struct sockaddr_in dest;
uv::NameToAddr("localhost", 3300, &dest);
m_tcp_client->Connect(dest, [this]() {
m_tcp_connected = true;
InitializeWebSocket("localhost", 3300, "/wpilibws");
});
}
void WebServerClientTest::SendMessage(const wpi::json& msg) {
if (msg.empty()) {
std::fputs("Message to send is empty\n", stderr);
return;
}
wpi::SmallVector<uv::Buffer, 4> sendBufs;
wpi::raw_uv_ostream os{sendBufs, [this]() -> uv::Buffer {
std::lock_guard lock(m_buffers_mutex);
return m_buffers->Allocate();
}};
os << msg;
// Call the websocket send function on the uv loop
m_exec->Call([this, sendBufs]() mutable {
m_websocket->SendText(sendBufs, [this](auto bufs, wpi::uv::Error err) {
{
std::lock_guard lock(m_buffers_mutex);
m_buffers->Release(bufs);
}
if (err) {
fmt::print(stderr, "{}\n", err.str());
std::fflush(stderr);
}
});
});
}
const wpi::json& WebServerClientTest::GetLastMessage() {
return m_json;
}
} // namespace wpilibws
|
;==========================================================
; Branch Macros
;==========================================================
//allow branching to absolute file addresses
.macro b_a, addr
b (org() + addr - orga())
.endmacro
.macro beqz_a, reg1, addr
beqz reg1, (org() + addr - orga())
.endmacro
.macro bnez_a, reg1, addr
bnez reg1, (org() + addr - orga())
.endmacro
.macro bne_a, reg1, reg2, addr
bne reg1, reg2, (org() + addr - orga())
.endmacro
.macro beq_a, reg1, reg2, addr
beq reg1, reg2, (org() + addr - orga())
.endmacro |
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x8280, %rsi
lea addresses_UC_ht+0x1c840, %rdi
nop
nop
nop
xor $22766, %r14
mov $46, %rcx
rep movsw
nop
nop
nop
sub %r14, %r14
lea addresses_normal_ht+0xbae0, %r8
nop
nop
sub $29373, %rbx
mov (%r8), %edx
nop
nop
nop
add %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r8
push %rbp
push %rcx
push %rdx
// Store
lea addresses_WT+0x170e0, %r8
nop
nop
nop
nop
nop
sub %r15, %r15
mov $0x5152535455565758, %rdx
movq %rdx, %xmm4
vmovups %ymm4, (%r8)
// Exception!!!
mov (0), %r13
nop
nop
add $4943, %rcx
// Store
lea addresses_WC+0x1d260, %r13
nop
nop
nop
dec %rcx
movw $0x5152, (%r13)
nop
nop
nop
nop
nop
xor %r15, %r15
// Faulty Load
lea addresses_D+0x1b9e0, %r13
nop
nop
and %rbp, %rbp
movb (%r13), %r8b
lea oracles, %rcx
and $0xff, %r8
shlq $12, %r8
mov (%rcx,%r8,1), %r8
pop %rdx
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 7, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'36': 6658}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
; ===============================================================
; Jan 2014
; ===============================================================
;
; int vfscanf_unlocked(FILE *stream, const char *format, void *arg)
;
; See C11 specification.
;
; ===============================================================
IFNDEF CLIB_OPT_SCANF
INCLUDE "config_private.inc"
defc CLIB_OPT_SCANF = __CLIB_OPT_SCANF
defc CLIB_OPT_SCANF_2 = __CLIB_OPT_SCANF_2
ENDIF
SECTION code_clib
SECTION code_stdio
PUBLIC asm_vfscanf_unlocked
PUBLIC asm0_vfscanf_unlocked, asm1_vfscanf_unlocked
EXTERN __stdio_verify_input, __stdio_scanf_sm_format, __stdio_recv_input_eatc
EXTERN __stdio_scanf_sm_format_pct, error_einval_zc
EXTERN __stdio_nextarg_bc, __stdio_length_modifier, error_erange_zc, l_atou
asm_vfscanf_unlocked:
; enter : ix = FILE *
; de = char *format
; bc = void *stack_param = arg
;
; exit : ix = FILE *
; de = char *format (next unexamined char)
; hl = number of items assigned
; de'= number of chars consumed from the stream
; hl'= number of items assigned
;
; success
;
; carry reset
;
; fail
;
; hl will be -1 on eof and stream in error state
; carry set, errno set as below
;
; eacces = stream not open for reading
; eacces = stream is in an error state
; einval = unknown conversion specifier
; einval = error during scanf conversion
; erange = width out of range
;
; more errors may be set by underlying driver
;
; uses : all except ix
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_STDIO & $01
EXTERN __stdio_verify_valid
call __stdio_verify_valid
ret c
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
asm1_vfscanf_unlocked:
call __stdio_verify_input ; check that input from stream is ok
ret c ; if input is not possible
asm0_vfscanf_unlocked:
IF (CLIB_OPT_SCANF != 0) || ((CLIB_OPT_SCANF_2 != 0) && __SDCC)
ld hl,-40
add hl,sp
ld sp,hl ; create forty bytes of workspace
push bc ; save stack_param
ENDIF
exx
ld de,0 ; de = num chars read from stream = 0
ld l,e
ld h,d ; hl = num items assigned = 0
exx
;******************************
; * FORMAT STRING LOOP ********
; de = char *format
; stack = WORKSPACE_40, stack_param
format_loop_scanf:
; MATCH STREAM CHARS UNTIL '%' OR '\0'
ld hl,__stdio_scanf_sm_format ; format string state machine
exx
ld bc,$ffff ; match as many chars as we can
call __stdio_recv_input_eatc
exx
percent_join_scanf:
ld a,(de)
; stream error while traversing format string characters
; must not terminate processing because there are converters
; like %n that must be filled in at EOF.
; jr c, possible_error_scanf
; a = next char of format string
; de = char *format (address of next char)
; stack = WORKSPACE_40, stack_param
cp '%'
jr z, possible_conversion_0_scanf
or a
jr nz, mismatch_error_scanf
; reached end of format string
exit_success_scanf:
IF (CLIB_OPT_SCANF != 0) || ((CLIB_OPT_SCANF_2 != 0) && __SDCC)
; stack = WORKSPACE_40, stack_param
ld hl,42
add hl,sp
ld sp,hl ; repair stack
ENDIF
exx
push hl
exx
pop hl ; hl = num items assigned
or a ; indicate success
ret
mismatch_error_scanf:
call error_einval_zc
exit_failure_scanf:
IF (CLIB_OPT_SCANF != 0) || ((CLIB_OPT_SCANF_2 != 0) && _SDCC)
; stack = WORKSPACE_40, stack_param
ld hl,42
add hl,sp
ld sp,hl ; repair stack
ENDIF
exx
push hl
exx
pop hl ; hl = num items assigned
scf ; indicate failure
ret
;possible_error_scanf:
;
; ; stream error occurred
; ; if end of format string reached no one cares
;
; or a
; jr z, exit_success_scanf
;
; jr exit_failure_scanf
possible_conversion_0_scanf:
; format contains %, check for %%
inc de
ld a,(de)
cp '%'
jr nz, possible_conversion_1_scanf
; format contains %% so must consume % from stream
stream_consume_pct_scanf:
ld b,1
ld hl,__stdio_scanf_sm_format_pct ; enter format state machine at percent
exx
ld bc,$ffff ; match as many chars as we can
call __stdio_recv_input_eatc
exx
djnz percent_join_scanf ; if % was seen on stream
jr mismatch_error_scanf
IF (CLIB_OPT_SCANF != 0) || ((CLIB_OPT_SCANF_2 != 0) && __SDCC)
error_format_width_scanf:
; stack = WORKSPACE_40, stack_param, void *p
pop hl
call error_erange_zc
jr exit_failure_scanf
assignment_suppressed_scanf:
inc de ; consume the '*'
ld bc,0 ; void *p = 0
jr suppressed_rejoin_scanf
ENDIF
possible_conversion_1_scanf:
; only one % in format string
or a
jr z, stream_consume_pct_scanf ; if format string ends in %
IF (CLIB_OPT_SCANF = 0) && ((CLIB_OPT_SCANF_2 = 0) || __SCCZ80)
; completely disable % logic
; scanf can only match format chars to the input stream
; de = address char after % in char *format
jr mismatch_error_scanf
ELSE
; regular % processing
;*******************************
; * PROCESS CONVERSION SPECIFIER
; a = next char to examine
; de = char *format (address of next char to examine)
; stack = WORKSPACE_40, stack_param
; CHECK FOR ASSIGNMENT SUPPRESSION
cp '*'
jr z, assignment_suppressed_scanf
; read void *p from stack params
pop hl
call __stdio_nextarg_bc ; bc = void *p
push hl
suppressed_rejoin_scanf:
push bc
; de = char *format (address of next char to examine)
; stack = WORKSPACE_40, stack_param, void *p
; READ OPTIONAL WIDTH
call l_atou
jr c, error_format_width_scanf ; if overflow
push hl ; save width (0 = default)
; READ OPTIONAL LENGTH MODIFIER
call __stdio_length_modifier
; de = char *format (address of next char to examine)
; c = length modifier id
; stack = WORKSPACE_40, stack_param, void *p, width
; SET UP REGISTERS FOR CONVERTERS
ld hl,6
add hl,sp ; hl = void *buffer
ld a,c
and $30 ; long modifiers activated ?
sub $10
ld a,(de) ; a = conversion specifier
inc de
push de
exx
pop bc ; bc'= char *format (for %[)
exx
pop bc ; bc = width
ex de,hl ; de = void *buffer
ex (sp),hl ; hl = void *p
; a = conversion char
; bc = width (0 for default)
; de = void *buffer
; hl = void *p (0 for assignment suppression)
; bc'= char *format
; nc flag set if long modifiers present
; stack = WORKSPACE_40, stack_param, char *format
; CONVERSION SPECIFIER
; identify conversion "B[cdiInopsux"
; long modifies "Bdinopux" not "[cIs"
jr nc, spec_long_scanf
; no long modifier
IF CLIB_OPT_SCANF & $200000
cp '['
jr z, _scanf_bkt ; special treatment for '%['
ENDIF
call spec_unmodified_scanf
; RETURN FROM CONVERSION
; stack = WORKSPACE_40, stack_param, char *format
; carry set on error
spec_return_scanf:
pop de ; de = char *format
jp nc, format_loop_scanf
jr exit_failure_scanf
spec_unmodified_scanf:
IF CLIB_OPT_SCANF & $01
cp 'd'
EXTERN __stdio_scanf_d
jp z, __stdio_scanf_d
ENDIF
IF CLIB_OPT_SCANF & $02
cp 'u'
EXTERN __stdio_scanf_u
jp z, __stdio_scanf_u
ENDIF
IF CLIB_OPT_SCANF & $40
cp 'i'
EXTERN __stdio_scanf_i
jp z, __stdio_scanf_i
ENDIF
IF CLIB_OPT_SCANF & $c0
cp 'x'
EXTERN __stdio_scanf_x
jp z, __stdio_scanf_x
ENDIF
IF CLIB_OPT_SCANF & $10
cp 'o'
EXTERN __stdio_scanf_o
jp z, __stdio_scanf_o
ENDIF
IF CLIB_OPT_SCANF & $80
cp 'p'
EXTERN __stdio_scanf_p
jp z, __stdio_scanf_p
ENDIF
IF CLIB_OPT_SCANF & $20
cp 'n'
EXTERN __stdio_scanf_n
jp z, __stdio_scanf_n
ENDIF
IF CLIB_OPT_SCANF & $100
cp 'B'
EXTERN __stdio_scanf_bb
jp z, __stdio_scanf_bb
ENDIF
spec_constant_scanf:
IF CLIB_OPT_SCANF & $200
cp 's'
EXTERN __stdio_scanf_s
jp z, __stdio_scanf_s
ENDIF
IF CLIB_OPT_SCANF & $400
cp 'c'
EXTERN __stdio_scanf_c
jp z, __stdio_scanf_c
ENDIF
IF CLIB_OPT_SCANF & $800
cp 'I'
EXTERN __stdio_scanf_ii
jp z, __stdio_scanf_ii
ENDIF
; UNRECOGNIZED CONVERSION
; stack = WORKSPACE_40, stack_param, char *format, return
pop hl ; junk return address
pop de ; de = char *format
dec de ; move back to unknown conversion char
jp mismatch_error_scanf
spec_long_scanf:
jr nz, longlong_spec_scanf
long_spec_scanf:
; long modifier
call __spec_long_scanf
jr spec_return_scanf
__spec_long_scanf:
IF CLIB_OPT_SCANF & $1000
cp 'd'
EXTERN __stdio_scanf_ld
jp z, __stdio_scanf_ld
ENDIF
IF CLIB_OPT_SCANF & $2000
cp 'u'
EXTERN __stdio_scanf_lu
jp z, __stdio_scanf_lu
ENDIF
IF CLIB_OPT_SCANF & $40000
cp 'i'
EXTERN __stdio_scanf_li
jp z, __stdio_scanf_li
ENDIF
IF CLIB_OPT_SCANF & $c000
cp 'x'
EXTERN __stdio_scanf_lx
jp z, __stdio_scanf_lx
ENDIF
IF CLIB_OPT_SCANF & $10000
cp 'o'
EXTERN __stdio_scanf_lo
jp z, __stdio_scanf_lo
ENDIF
IF CLIB_OPT_SCANF & $80000
cp 'p'
EXTERN __stdio_scanf_lp
jp z, __stdio_scanf_lp
ENDIF
IF CLIB_OPT_SCANF & $20000
cp 'n'
EXTERN __stdio_scanf_ln
jp z, __stdio_scanf_ln
ENDIF
IF CLIB_OPT_SCANF & $100000
cp 'B'
EXTERN __stdio_scanf_lbb
jp z, __stdio_scanf_lbb
ENDIF
jr spec_constant_scanf
IF CLIB_OPT_SCANF & $200000
_scanf_bkt:
; special treatment for %[
; bc' communicates the format pointer
EXTERN __stdio_scanf_bkt
call __stdio_scanf_bkt
; bc'= char *format
; stack = WORKSPACE_40, stack_param, char *format (invalid)
; carry set on error
pop bc ; junk invalid format
exx
push bc ; replace with valid one
exx
jr spec_return_scanf
ENDIF
longlong_spec_scanf:
call __spec_longlong_scanf
jp spec_return_scanf
__spec_longlong_scanf:
IF CLIB_OPT_SCANF_2 && __SDCC
IF CLIB_OPT_SCANF_2 & $01
cp 'd'
EXTERN __stdio_scanf_lld
jp z, __stdio_scanf_lld
ENDIF
IF CLIB_OPT_SCANF_2 & $02
cp 'u'
EXTERN __stdio_scanf_llu
jp z, __stdio_scanf_llu
ENDIF
IF CLIB_OPT_SCANF_2 & $40
cp 'i'
EXTERN __stdio_scanf_lli
jp z, __stdio_scanf_lli
ENDIF
IF CLIB_OPT_SCANF_2 & $0c
cp 'x'
EXTERN __stdio_scanf_llx
jp z, __stdio_scanf_llx
ENDIF
IF CLIB_OPT_SCANF_2 & $10
cp 'o'
EXTERN __stdio_scanf_llo
jp z, __stdio_scanf_llo
ENDIF
ENDIF
jr spec_constant_scanf
ENDIF
|
; Program 5.2
; Looping - NASM (64-bit)
; Copyright (c) 2017 Hall & Slonka
SECTION .text
global _main
_main:
xor rax, rax
mov rcx, 5
myLoop:
inc rax
loop myLoop
mov rax, 60
xor rdi, rdi
syscall
|
; A336853: a(n) = A003961(n) - n, where A003961 is the prime shift towards larger primes.
; 0,1,2,5,2,9,4,19,16,11,2,33,4,19,20,65,2,57,4,43,34,17,6,111,24,25,98,71,2,75,6,211,32,23,42,189,4,31,46,149,2,123,4,73,130,41,6,357,72,97,44,101,6,321,36,241,58,35,2,255,6,49,212,665,54,129,4,103,76,161,2,603,6,49,170,131,66,177,4,487,544,47,6,411,48,55,68,263,8,435,96,169,92,65,66,1119,4,265,226,341,2,183,4,355,280,71,2,1017,4,163,94,779,14,231,88,163,308,65,90,825,48,79,92,209,218,699,4,2059,106,227,6,453,120,79,740,377,2,297,10,553,124,77,78,1881,72,91,458,221,2,585,6,469,322,275,104,609,6,91,136,1541,158,1713,4,223,290,101,6,1317,120,229,404,251,6,291,364,877,128,113,2,1395,10,379,152,599,102,369,60,289,1186,293,2,3453,4,109,400,893,2,777,12,1123,154,107,138,651,96,115,518,1169,90,945,12,319,152,113,114,3159,190,121,176,599,102,393,4,2449,1000,155,2,807,4,379,484,605,6,1041,136,313,178,389,2,2595,10,265,2882,359,602,399,144,751,196,779
mov $2,$0
cal $0,3961 ; Completely multiplicative with a(prime(k)) = prime(k+1).
sub $0,$2
mov $1,$0
sub $1,1
|
_test_sleep: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
int total;
}ttable;
void func(void *arg_ptr);
int main(int argc, char *argv[]){
1000: 55 push %ebp
1001: 89 e5 mov %esp,%ebp
1003: 83 e4 f0 and $0xfffffff0,%esp
1006: 83 ec 20 sub $0x20,%esp
struct thread * t;
int i;
printf(1,"init ttable\n");
1009: c7 44 24 04 f4 1b 00 movl $0x1bf4,0x4(%esp)
1010: 00
1011: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1018: e8 c8 05 00 00 call 15e5 <printf>
lock_init(&ttable.lock);
101d: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
1024: e8 9d 09 00 00 call 19c6 <lock_init>
ttable.total = 0;
1029: c7 05 04 1e 00 00 00 movl $0x0,0x1e04
1030: 00 00 00
lock_acquire(&ttable.lock);
1033: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
103a: e8 95 09 00 00 call 19d4 <lock_acquire>
for(t=ttable.threads;t < &ttable.threads[64];t++){
103f: c7 44 24 14 04 1d 00 movl $0x1d04,0x14(%esp)
1046: 00
1047: eb 0f jmp 1058 <main+0x58>
t->tid = 0;
1049: 8b 44 24 14 mov 0x14(%esp),%eax
104d: c7 00 00 00 00 00 movl $0x0,(%eax)
printf(1,"init ttable\n");
lock_init(&ttable.lock);
ttable.total = 0;
lock_acquire(&ttable.lock);
for(t=ttable.threads;t < &ttable.threads[64];t++){
1053: 83 44 24 14 04 addl $0x4,0x14(%esp)
1058: b8 04 1e 00 00 mov $0x1e04,%eax
105d: 39 44 24 14 cmp %eax,0x14(%esp)
1061: 72 e6 jb 1049 <main+0x49>
t->tid = 0;
}
lock_release(&ttable.lock);
1063: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
106a: e8 84 09 00 00 call 19f3 <lock_release>
printf(1,"testing thread sleep and wakeup \n\n\n");
106f: c7 44 24 04 04 1c 00 movl $0x1c04,0x4(%esp)
1076: 00
1077: c7 04 24 01 00 00 00 movl $0x1,(%esp)
107e: e8 62 05 00 00 call 15e5 <printf>
void *stack = thread_create(func,0);
1083: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
108a: 00
108b: c7 04 24 6c 11 00 00 movl $0x116c,(%esp)
1092: e8 77 09 00 00 call 1a0e <thread_create>
1097: 89 44 24 1c mov %eax,0x1c(%esp)
thread_create(func,0);
109b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
10a2: 00
10a3: c7 04 24 6c 11 00 00 movl $0x116c,(%esp)
10aa: e8 5f 09 00 00 call 1a0e <thread_create>
thread_create(func,0);
10af: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
10b6: 00
10b7: c7 04 24 6c 11 00 00 movl $0x116c,(%esp)
10be: e8 4b 09 00 00 call 1a0e <thread_create>
i=0;
10c3: c7 44 24 18 00 00 00 movl $0x0,0x18(%esp)
10ca: 00
while(i++ < 1000000);
10cb: 81 7c 24 18 3f 42 0f cmpl $0xf423f,0x18(%esp)
10d2: 00
10d3: 0f 9e c0 setle %al
10d6: 83 44 24 18 01 addl $0x1,0x18(%esp)
10db: 84 c0 test %al,%al
10dd: 75 ec jne 10cb <main+0xcb>
//find that thread
lock_acquire(&ttable.lock);
10df: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
10e6: e8 e9 08 00 00 call 19d4 <lock_acquire>
for(t=ttable.threads;t < &ttable.threads[64];t++){
10eb: c7 44 24 14 04 1d 00 movl $0x1d04,0x14(%esp)
10f2: 00
10f3: eb 40 jmp 1135 <main+0x135>
if(t->tid != 0){
10f5: 8b 44 24 14 mov 0x14(%esp),%eax
10f9: 8b 00 mov (%eax),%eax
10fb: 85 c0 test %eax,%eax
10fd: 74 31 je 1130 <main+0x130>
printf(1,"found one... %d, wake up lazy boy !!!\n",t->tid);
10ff: 8b 44 24 14 mov 0x14(%esp),%eax
1103: 8b 00 mov (%eax),%eax
1105: 89 44 24 08 mov %eax,0x8(%esp)
1109: c7 44 24 04 28 1c 00 movl $0x1c28,0x4(%esp)
1110: 00
1111: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1118: e8 c8 04 00 00 call 15e5 <printf>
twakeup(t->tid);
111d: 8b 44 24 14 mov 0x14(%esp),%eax
1121: 8b 00 mov (%eax),%eax
1123: 89 04 24 mov %eax,(%esp)
1126: e8 d9 03 00 00 call 1504 <twakeup>
i++;
112b: 83 44 24 18 01 addl $0x1,0x18(%esp)
i=0;
while(i++ < 1000000);
//find that thread
lock_acquire(&ttable.lock);
for(t=ttable.threads;t < &ttable.threads[64];t++){
1130: 83 44 24 14 04 addl $0x4,0x14(%esp)
1135: b8 04 1e 00 00 mov $0x1e04,%eax
113a: 39 44 24 14 cmp %eax,0x14(%esp)
113e: 72 b5 jb 10f5 <main+0xf5>
printf(1,"found one... %d, wake up lazy boy !!!\n",t->tid);
twakeup(t->tid);
i++;
}
}
lock_release(&ttable.lock);
1140: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
1147: e8 a7 08 00 00 call 19f3 <lock_release>
wait();
114c: e8 03 03 00 00 call 1454 <wait>
wait();
1151: e8 fe 02 00 00 call 1454 <wait>
wait();
1156: e8 f9 02 00 00 call 1454 <wait>
free(stack);
115b: 8b 44 24 1c mov 0x1c(%esp),%eax
115f: 89 04 24 mov %eax,(%esp)
1162: e8 35 06 00 00 call 179c <free>
exit();
1167: e8 e0 02 00 00 call 144c <exit>
0000116c <func>:
}
void func(void *arg_ptr){
116c: 55 push %ebp
116d: 89 e5 mov %esp,%ebp
116f: 83 ec 28 sub $0x28,%esp
int tid;
tid = getpid();
1172: e8 55 03 00 00 call 14cc <getpid>
1177: 89 45 f4 mov %eax,-0xc(%ebp)
lock_acquire(&ttable.lock);
117a: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
1181: e8 4e 08 00 00 call 19d4 <lock_acquire>
(ttable.threads[ttable.total]).tid = tid;
1186: a1 04 1e 00 00 mov 0x1e04,%eax
118b: 8b 55 f4 mov -0xc(%ebp),%edx
118e: 89 14 85 04 1d 00 00 mov %edx,0x1d04(,%eax,4)
ttable.total++;
1195: a1 04 1e 00 00 mov 0x1e04,%eax
119a: 83 c0 01 add $0x1,%eax
119d: a3 04 1e 00 00 mov %eax,0x1e04
lock_release(&ttable.lock);
11a2: c7 04 24 00 1d 00 00 movl $0x1d00,(%esp)
11a9: e8 45 08 00 00 call 19f3 <lock_release>
printf(1,"I am thread %d, is about to sleep\n",tid);
11ae: 8b 45 f4 mov -0xc(%ebp),%eax
11b1: 89 44 24 08 mov %eax,0x8(%esp)
11b5: c7 44 24 04 54 1c 00 movl $0x1c54,0x4(%esp)
11bc: 00
11bd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
11c4: e8 1c 04 00 00 call 15e5 <printf>
tsleep();
11c9: e8 2e 03 00 00 call 14fc <tsleep>
printf(1,"I am wake up!\n");
11ce: c7 44 24 04 77 1c 00 movl $0x1c77,0x4(%esp)
11d5: 00
11d6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
11dd: e8 03 04 00 00 call 15e5 <printf>
texit();
11e2: e8 0d 03 00 00 call 14f4 <texit>
11e7: 90 nop
000011e8 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
11e8: 55 push %ebp
11e9: 89 e5 mov %esp,%ebp
11eb: 57 push %edi
11ec: 53 push %ebx
asm volatile("cld; rep stosb" :
11ed: 8b 4d 08 mov 0x8(%ebp),%ecx
11f0: 8b 55 10 mov 0x10(%ebp),%edx
11f3: 8b 45 0c mov 0xc(%ebp),%eax
11f6: 89 cb mov %ecx,%ebx
11f8: 89 df mov %ebx,%edi
11fa: 89 d1 mov %edx,%ecx
11fc: fc cld
11fd: f3 aa rep stos %al,%es:(%edi)
11ff: 89 ca mov %ecx,%edx
1201: 89 fb mov %edi,%ebx
1203: 89 5d 08 mov %ebx,0x8(%ebp)
1206: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1209: 5b pop %ebx
120a: 5f pop %edi
120b: 5d pop %ebp
120c: c3 ret
0000120d <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
120d: 55 push %ebp
120e: 89 e5 mov %esp,%ebp
1210: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
1213: 8b 45 08 mov 0x8(%ebp),%eax
1216: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1219: 8b 45 0c mov 0xc(%ebp),%eax
121c: 0f b6 10 movzbl (%eax),%edx
121f: 8b 45 08 mov 0x8(%ebp),%eax
1222: 88 10 mov %dl,(%eax)
1224: 8b 45 08 mov 0x8(%ebp),%eax
1227: 0f b6 00 movzbl (%eax),%eax
122a: 84 c0 test %al,%al
122c: 0f 95 c0 setne %al
122f: 83 45 08 01 addl $0x1,0x8(%ebp)
1233: 83 45 0c 01 addl $0x1,0xc(%ebp)
1237: 84 c0 test %al,%al
1239: 75 de jne 1219 <strcpy+0xc>
;
return os;
123b: 8b 45 fc mov -0x4(%ebp),%eax
}
123e: c9 leave
123f: c3 ret
00001240 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1240: 55 push %ebp
1241: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
1243: eb 08 jmp 124d <strcmp+0xd>
p++, q++;
1245: 83 45 08 01 addl $0x1,0x8(%ebp)
1249: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
124d: 8b 45 08 mov 0x8(%ebp),%eax
1250: 0f b6 00 movzbl (%eax),%eax
1253: 84 c0 test %al,%al
1255: 74 10 je 1267 <strcmp+0x27>
1257: 8b 45 08 mov 0x8(%ebp),%eax
125a: 0f b6 10 movzbl (%eax),%edx
125d: 8b 45 0c mov 0xc(%ebp),%eax
1260: 0f b6 00 movzbl (%eax),%eax
1263: 38 c2 cmp %al,%dl
1265: 74 de je 1245 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1267: 8b 45 08 mov 0x8(%ebp),%eax
126a: 0f b6 00 movzbl (%eax),%eax
126d: 0f b6 d0 movzbl %al,%edx
1270: 8b 45 0c mov 0xc(%ebp),%eax
1273: 0f b6 00 movzbl (%eax),%eax
1276: 0f b6 c0 movzbl %al,%eax
1279: 89 d1 mov %edx,%ecx
127b: 29 c1 sub %eax,%ecx
127d: 89 c8 mov %ecx,%eax
}
127f: 5d pop %ebp
1280: c3 ret
00001281 <strlen>:
uint
strlen(char *s)
{
1281: 55 push %ebp
1282: 89 e5 mov %esp,%ebp
1284: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1287: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
128e: eb 04 jmp 1294 <strlen+0x13>
1290: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1294: 8b 45 fc mov -0x4(%ebp),%eax
1297: 03 45 08 add 0x8(%ebp),%eax
129a: 0f b6 00 movzbl (%eax),%eax
129d: 84 c0 test %al,%al
129f: 75 ef jne 1290 <strlen+0xf>
;
return n;
12a1: 8b 45 fc mov -0x4(%ebp),%eax
}
12a4: c9 leave
12a5: c3 ret
000012a6 <memset>:
void*
memset(void *dst, int c, uint n)
{
12a6: 55 push %ebp
12a7: 89 e5 mov %esp,%ebp
12a9: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
12ac: 8b 45 10 mov 0x10(%ebp),%eax
12af: 89 44 24 08 mov %eax,0x8(%esp)
12b3: 8b 45 0c mov 0xc(%ebp),%eax
12b6: 89 44 24 04 mov %eax,0x4(%esp)
12ba: 8b 45 08 mov 0x8(%ebp),%eax
12bd: 89 04 24 mov %eax,(%esp)
12c0: e8 23 ff ff ff call 11e8 <stosb>
return dst;
12c5: 8b 45 08 mov 0x8(%ebp),%eax
}
12c8: c9 leave
12c9: c3 ret
000012ca <strchr>:
char*
strchr(const char *s, char c)
{
12ca: 55 push %ebp
12cb: 89 e5 mov %esp,%ebp
12cd: 83 ec 04 sub $0x4,%esp
12d0: 8b 45 0c mov 0xc(%ebp),%eax
12d3: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
12d6: eb 14 jmp 12ec <strchr+0x22>
if(*s == c)
12d8: 8b 45 08 mov 0x8(%ebp),%eax
12db: 0f b6 00 movzbl (%eax),%eax
12de: 3a 45 fc cmp -0x4(%ebp),%al
12e1: 75 05 jne 12e8 <strchr+0x1e>
return (char*)s;
12e3: 8b 45 08 mov 0x8(%ebp),%eax
12e6: eb 13 jmp 12fb <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
12e8: 83 45 08 01 addl $0x1,0x8(%ebp)
12ec: 8b 45 08 mov 0x8(%ebp),%eax
12ef: 0f b6 00 movzbl (%eax),%eax
12f2: 84 c0 test %al,%al
12f4: 75 e2 jne 12d8 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
12f6: b8 00 00 00 00 mov $0x0,%eax
}
12fb: c9 leave
12fc: c3 ret
000012fd <gets>:
char*
gets(char *buf, int max)
{
12fd: 55 push %ebp
12fe: 89 e5 mov %esp,%ebp
1300: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
1303: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
130a: eb 44 jmp 1350 <gets+0x53>
cc = read(0, &c, 1);
130c: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1313: 00
1314: 8d 45 ef lea -0x11(%ebp),%eax
1317: 89 44 24 04 mov %eax,0x4(%esp)
131b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1322: e8 3d 01 00 00 call 1464 <read>
1327: 89 45 f4 mov %eax,-0xc(%ebp)
if(cc < 1)
132a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
132e: 7e 2d jle 135d <gets+0x60>
break;
buf[i++] = c;
1330: 8b 45 f0 mov -0x10(%ebp),%eax
1333: 03 45 08 add 0x8(%ebp),%eax
1336: 0f b6 55 ef movzbl -0x11(%ebp),%edx
133a: 88 10 mov %dl,(%eax)
133c: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(c == '\n' || c == '\r')
1340: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1344: 3c 0a cmp $0xa,%al
1346: 74 16 je 135e <gets+0x61>
1348: 0f b6 45 ef movzbl -0x11(%ebp),%eax
134c: 3c 0d cmp $0xd,%al
134e: 74 0e je 135e <gets+0x61>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1350: 8b 45 f0 mov -0x10(%ebp),%eax
1353: 83 c0 01 add $0x1,%eax
1356: 3b 45 0c cmp 0xc(%ebp),%eax
1359: 7c b1 jl 130c <gets+0xf>
135b: eb 01 jmp 135e <gets+0x61>
cc = read(0, &c, 1);
if(cc < 1)
break;
135d: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
135e: 8b 45 f0 mov -0x10(%ebp),%eax
1361: 03 45 08 add 0x8(%ebp),%eax
1364: c6 00 00 movb $0x0,(%eax)
return buf;
1367: 8b 45 08 mov 0x8(%ebp),%eax
}
136a: c9 leave
136b: c3 ret
0000136c <stat>:
int
stat(char *n, struct stat *st)
{
136c: 55 push %ebp
136d: 89 e5 mov %esp,%ebp
136f: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1372: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1379: 00
137a: 8b 45 08 mov 0x8(%ebp),%eax
137d: 89 04 24 mov %eax,(%esp)
1380: e8 07 01 00 00 call 148c <open>
1385: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd < 0)
1388: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
138c: 79 07 jns 1395 <stat+0x29>
return -1;
138e: b8 ff ff ff ff mov $0xffffffff,%eax
1393: eb 23 jmp 13b8 <stat+0x4c>
r = fstat(fd, st);
1395: 8b 45 0c mov 0xc(%ebp),%eax
1398: 89 44 24 04 mov %eax,0x4(%esp)
139c: 8b 45 f0 mov -0x10(%ebp),%eax
139f: 89 04 24 mov %eax,(%esp)
13a2: e8 fd 00 00 00 call 14a4 <fstat>
13a7: 89 45 f4 mov %eax,-0xc(%ebp)
close(fd);
13aa: 8b 45 f0 mov -0x10(%ebp),%eax
13ad: 89 04 24 mov %eax,(%esp)
13b0: e8 bf 00 00 00 call 1474 <close>
return r;
13b5: 8b 45 f4 mov -0xc(%ebp),%eax
}
13b8: c9 leave
13b9: c3 ret
000013ba <atoi>:
int
atoi(const char *s)
{
13ba: 55 push %ebp
13bb: 89 e5 mov %esp,%ebp
13bd: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
13c0: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
13c7: eb 24 jmp 13ed <atoi+0x33>
n = n*10 + *s++ - '0';
13c9: 8b 55 fc mov -0x4(%ebp),%edx
13cc: 89 d0 mov %edx,%eax
13ce: c1 e0 02 shl $0x2,%eax
13d1: 01 d0 add %edx,%eax
13d3: 01 c0 add %eax,%eax
13d5: 89 c2 mov %eax,%edx
13d7: 8b 45 08 mov 0x8(%ebp),%eax
13da: 0f b6 00 movzbl (%eax),%eax
13dd: 0f be c0 movsbl %al,%eax
13e0: 8d 04 02 lea (%edx,%eax,1),%eax
13e3: 83 e8 30 sub $0x30,%eax
13e6: 89 45 fc mov %eax,-0x4(%ebp)
13e9: 83 45 08 01 addl $0x1,0x8(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
13ed: 8b 45 08 mov 0x8(%ebp),%eax
13f0: 0f b6 00 movzbl (%eax),%eax
13f3: 3c 2f cmp $0x2f,%al
13f5: 7e 0a jle 1401 <atoi+0x47>
13f7: 8b 45 08 mov 0x8(%ebp),%eax
13fa: 0f b6 00 movzbl (%eax),%eax
13fd: 3c 39 cmp $0x39,%al
13ff: 7e c8 jle 13c9 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
1401: 8b 45 fc mov -0x4(%ebp),%eax
}
1404: c9 leave
1405: c3 ret
00001406 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1406: 55 push %ebp
1407: 89 e5 mov %esp,%ebp
1409: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
140c: 8b 45 08 mov 0x8(%ebp),%eax
140f: 89 45 f8 mov %eax,-0x8(%ebp)
src = vsrc;
1412: 8b 45 0c mov 0xc(%ebp),%eax
1415: 89 45 fc mov %eax,-0x4(%ebp)
while(n-- > 0)
1418: eb 13 jmp 142d <memmove+0x27>
*dst++ = *src++;
141a: 8b 45 fc mov -0x4(%ebp),%eax
141d: 0f b6 10 movzbl (%eax),%edx
1420: 8b 45 f8 mov -0x8(%ebp),%eax
1423: 88 10 mov %dl,(%eax)
1425: 83 45 f8 01 addl $0x1,-0x8(%ebp)
1429: 83 45 fc 01 addl $0x1,-0x4(%ebp)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
142d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
1431: 0f 9f c0 setg %al
1434: 83 6d 10 01 subl $0x1,0x10(%ebp)
1438: 84 c0 test %al,%al
143a: 75 de jne 141a <memmove+0x14>
*dst++ = *src++;
return vdst;
143c: 8b 45 08 mov 0x8(%ebp),%eax
}
143f: c9 leave
1440: c3 ret
1441: 90 nop
1442: 90 nop
1443: 90 nop
00001444 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
1444: b8 01 00 00 00 mov $0x1,%eax
1449: cd 40 int $0x40
144b: c3 ret
0000144c <exit>:
SYSCALL(exit)
144c: b8 02 00 00 00 mov $0x2,%eax
1451: cd 40 int $0x40
1453: c3 ret
00001454 <wait>:
SYSCALL(wait)
1454: b8 03 00 00 00 mov $0x3,%eax
1459: cd 40 int $0x40
145b: c3 ret
0000145c <pipe>:
SYSCALL(pipe)
145c: b8 04 00 00 00 mov $0x4,%eax
1461: cd 40 int $0x40
1463: c3 ret
00001464 <read>:
SYSCALL(read)
1464: b8 05 00 00 00 mov $0x5,%eax
1469: cd 40 int $0x40
146b: c3 ret
0000146c <write>:
SYSCALL(write)
146c: b8 10 00 00 00 mov $0x10,%eax
1471: cd 40 int $0x40
1473: c3 ret
00001474 <close>:
SYSCALL(close)
1474: b8 15 00 00 00 mov $0x15,%eax
1479: cd 40 int $0x40
147b: c3 ret
0000147c <kill>:
SYSCALL(kill)
147c: b8 06 00 00 00 mov $0x6,%eax
1481: cd 40 int $0x40
1483: c3 ret
00001484 <exec>:
SYSCALL(exec)
1484: b8 07 00 00 00 mov $0x7,%eax
1489: cd 40 int $0x40
148b: c3 ret
0000148c <open>:
SYSCALL(open)
148c: b8 0f 00 00 00 mov $0xf,%eax
1491: cd 40 int $0x40
1493: c3 ret
00001494 <mknod>:
SYSCALL(mknod)
1494: b8 11 00 00 00 mov $0x11,%eax
1499: cd 40 int $0x40
149b: c3 ret
0000149c <unlink>:
SYSCALL(unlink)
149c: b8 12 00 00 00 mov $0x12,%eax
14a1: cd 40 int $0x40
14a3: c3 ret
000014a4 <fstat>:
SYSCALL(fstat)
14a4: b8 08 00 00 00 mov $0x8,%eax
14a9: cd 40 int $0x40
14ab: c3 ret
000014ac <link>:
SYSCALL(link)
14ac: b8 13 00 00 00 mov $0x13,%eax
14b1: cd 40 int $0x40
14b3: c3 ret
000014b4 <mkdir>:
SYSCALL(mkdir)
14b4: b8 14 00 00 00 mov $0x14,%eax
14b9: cd 40 int $0x40
14bb: c3 ret
000014bc <chdir>:
SYSCALL(chdir)
14bc: b8 09 00 00 00 mov $0x9,%eax
14c1: cd 40 int $0x40
14c3: c3 ret
000014c4 <dup>:
SYSCALL(dup)
14c4: b8 0a 00 00 00 mov $0xa,%eax
14c9: cd 40 int $0x40
14cb: c3 ret
000014cc <getpid>:
SYSCALL(getpid)
14cc: b8 0b 00 00 00 mov $0xb,%eax
14d1: cd 40 int $0x40
14d3: c3 ret
000014d4 <sbrk>:
SYSCALL(sbrk)
14d4: b8 0c 00 00 00 mov $0xc,%eax
14d9: cd 40 int $0x40
14db: c3 ret
000014dc <sleep>:
SYSCALL(sleep)
14dc: b8 0d 00 00 00 mov $0xd,%eax
14e1: cd 40 int $0x40
14e3: c3 ret
000014e4 <uptime>:
SYSCALL(uptime)
14e4: b8 0e 00 00 00 mov $0xe,%eax
14e9: cd 40 int $0x40
14eb: c3 ret
000014ec <clone>:
SYSCALL(clone)
14ec: b8 16 00 00 00 mov $0x16,%eax
14f1: cd 40 int $0x40
14f3: c3 ret
000014f4 <texit>:
SYSCALL(texit)
14f4: b8 17 00 00 00 mov $0x17,%eax
14f9: cd 40 int $0x40
14fb: c3 ret
000014fc <tsleep>:
SYSCALL(tsleep)
14fc: b8 18 00 00 00 mov $0x18,%eax
1501: cd 40 int $0x40
1503: c3 ret
00001504 <twakeup>:
SYSCALL(twakeup)
1504: b8 19 00 00 00 mov $0x19,%eax
1509: cd 40 int $0x40
150b: c3 ret
0000150c <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
150c: 55 push %ebp
150d: 89 e5 mov %esp,%ebp
150f: 83 ec 28 sub $0x28,%esp
1512: 8b 45 0c mov 0xc(%ebp),%eax
1515: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
1518: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
151f: 00
1520: 8d 45 f4 lea -0xc(%ebp),%eax
1523: 89 44 24 04 mov %eax,0x4(%esp)
1527: 8b 45 08 mov 0x8(%ebp),%eax
152a: 89 04 24 mov %eax,(%esp)
152d: e8 3a ff ff ff call 146c <write>
}
1532: c9 leave
1533: c3 ret
00001534 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
1534: 55 push %ebp
1535: 89 e5 mov %esp,%ebp
1537: 53 push %ebx
1538: 83 ec 44 sub $0x44,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
153b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
1542: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
1546: 74 17 je 155f <printint+0x2b>
1548: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
154c: 79 11 jns 155f <printint+0x2b>
neg = 1;
154e: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
1555: 8b 45 0c mov 0xc(%ebp),%eax
1558: f7 d8 neg %eax
155a: 89 45 f4 mov %eax,-0xc(%ebp)
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
155d: eb 06 jmp 1565 <printint+0x31>
neg = 1;
x = -xx;
} else {
x = xx;
155f: 8b 45 0c mov 0xc(%ebp),%eax
1562: 89 45 f4 mov %eax,-0xc(%ebp)
}
i = 0;
1565: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
do{
buf[i++] = digits[x % base];
156c: 8b 4d ec mov -0x14(%ebp),%ecx
156f: 8b 5d 10 mov 0x10(%ebp),%ebx
1572: 8b 45 f4 mov -0xc(%ebp),%eax
1575: ba 00 00 00 00 mov $0x0,%edx
157a: f7 f3 div %ebx
157c: 89 d0 mov %edx,%eax
157e: 0f b6 80 bc 1c 00 00 movzbl 0x1cbc(%eax),%eax
1585: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
1589: 83 45 ec 01 addl $0x1,-0x14(%ebp)
}while((x /= base) != 0);
158d: 8b 45 10 mov 0x10(%ebp),%eax
1590: 89 45 d4 mov %eax,-0x2c(%ebp)
1593: 8b 45 f4 mov -0xc(%ebp),%eax
1596: ba 00 00 00 00 mov $0x0,%edx
159b: f7 75 d4 divl -0x2c(%ebp)
159e: 89 45 f4 mov %eax,-0xc(%ebp)
15a1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
15a5: 75 c5 jne 156c <printint+0x38>
if(neg)
15a7: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
15ab: 74 28 je 15d5 <printint+0xa1>
buf[i++] = '-';
15ad: 8b 45 ec mov -0x14(%ebp),%eax
15b0: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
15b5: 83 45 ec 01 addl $0x1,-0x14(%ebp)
while(--i >= 0)
15b9: eb 1a jmp 15d5 <printint+0xa1>
putc(fd, buf[i]);
15bb: 8b 45 ec mov -0x14(%ebp),%eax
15be: 0f b6 44 05 dc movzbl -0x24(%ebp,%eax,1),%eax
15c3: 0f be c0 movsbl %al,%eax
15c6: 89 44 24 04 mov %eax,0x4(%esp)
15ca: 8b 45 08 mov 0x8(%ebp),%eax
15cd: 89 04 24 mov %eax,(%esp)
15d0: e8 37 ff ff ff call 150c <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
15d5: 83 6d ec 01 subl $0x1,-0x14(%ebp)
15d9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
15dd: 79 dc jns 15bb <printint+0x87>
putc(fd, buf[i]);
}
15df: 83 c4 44 add $0x44,%esp
15e2: 5b pop %ebx
15e3: 5d pop %ebp
15e4: c3 ret
000015e5 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
15e5: 55 push %ebp
15e6: 89 e5 mov %esp,%ebp
15e8: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
15eb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
ap = (uint*)(void*)&fmt + 1;
15f2: 8d 45 0c lea 0xc(%ebp),%eax
15f5: 83 c0 04 add $0x4,%eax
15f8: 89 45 f4 mov %eax,-0xc(%ebp)
for(i = 0; fmt[i]; i++){
15fb: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
1602: e9 7e 01 00 00 jmp 1785 <printf+0x1a0>
c = fmt[i] & 0xff;
1607: 8b 55 0c mov 0xc(%ebp),%edx
160a: 8b 45 ec mov -0x14(%ebp),%eax
160d: 8d 04 02 lea (%edx,%eax,1),%eax
1610: 0f b6 00 movzbl (%eax),%eax
1613: 0f be c0 movsbl %al,%eax
1616: 25 ff 00 00 00 and $0xff,%eax
161b: 89 45 e8 mov %eax,-0x18(%ebp)
if(state == 0){
161e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1622: 75 2c jne 1650 <printf+0x6b>
if(c == '%'){
1624: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1628: 75 0c jne 1636 <printf+0x51>
state = '%';
162a: c7 45 f0 25 00 00 00 movl $0x25,-0x10(%ebp)
1631: e9 4b 01 00 00 jmp 1781 <printf+0x19c>
} else {
putc(fd, c);
1636: 8b 45 e8 mov -0x18(%ebp),%eax
1639: 0f be c0 movsbl %al,%eax
163c: 89 44 24 04 mov %eax,0x4(%esp)
1640: 8b 45 08 mov 0x8(%ebp),%eax
1643: 89 04 24 mov %eax,(%esp)
1646: e8 c1 fe ff ff call 150c <putc>
164b: e9 31 01 00 00 jmp 1781 <printf+0x19c>
}
} else if(state == '%'){
1650: 83 7d f0 25 cmpl $0x25,-0x10(%ebp)
1654: 0f 85 27 01 00 00 jne 1781 <printf+0x19c>
if(c == 'd'){
165a: 83 7d e8 64 cmpl $0x64,-0x18(%ebp)
165e: 75 2d jne 168d <printf+0xa8>
printint(fd, *ap, 10, 1);
1660: 8b 45 f4 mov -0xc(%ebp),%eax
1663: 8b 00 mov (%eax),%eax
1665: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
166c: 00
166d: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1674: 00
1675: 89 44 24 04 mov %eax,0x4(%esp)
1679: 8b 45 08 mov 0x8(%ebp),%eax
167c: 89 04 24 mov %eax,(%esp)
167f: e8 b0 fe ff ff call 1534 <printint>
ap++;
1684: 83 45 f4 04 addl $0x4,-0xc(%ebp)
1688: e9 ed 00 00 00 jmp 177a <printf+0x195>
} else if(c == 'x' || c == 'p'){
168d: 83 7d e8 78 cmpl $0x78,-0x18(%ebp)
1691: 74 06 je 1699 <printf+0xb4>
1693: 83 7d e8 70 cmpl $0x70,-0x18(%ebp)
1697: 75 2d jne 16c6 <printf+0xe1>
printint(fd, *ap, 16, 0);
1699: 8b 45 f4 mov -0xc(%ebp),%eax
169c: 8b 00 mov (%eax),%eax
169e: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
16a5: 00
16a6: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
16ad: 00
16ae: 89 44 24 04 mov %eax,0x4(%esp)
16b2: 8b 45 08 mov 0x8(%ebp),%eax
16b5: 89 04 24 mov %eax,(%esp)
16b8: e8 77 fe ff ff call 1534 <printint>
ap++;
16bd: 83 45 f4 04 addl $0x4,-0xc(%ebp)
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
16c1: e9 b4 00 00 00 jmp 177a <printf+0x195>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
16c6: 83 7d e8 73 cmpl $0x73,-0x18(%ebp)
16ca: 75 46 jne 1712 <printf+0x12d>
s = (char*)*ap;
16cc: 8b 45 f4 mov -0xc(%ebp),%eax
16cf: 8b 00 mov (%eax),%eax
16d1: 89 45 e4 mov %eax,-0x1c(%ebp)
ap++;
16d4: 83 45 f4 04 addl $0x4,-0xc(%ebp)
if(s == 0)
16d8: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
16dc: 75 27 jne 1705 <printf+0x120>
s = "(null)";
16de: c7 45 e4 86 1c 00 00 movl $0x1c86,-0x1c(%ebp)
while(*s != 0){
16e5: eb 1f jmp 1706 <printf+0x121>
putc(fd, *s);
16e7: 8b 45 e4 mov -0x1c(%ebp),%eax
16ea: 0f b6 00 movzbl (%eax),%eax
16ed: 0f be c0 movsbl %al,%eax
16f0: 89 44 24 04 mov %eax,0x4(%esp)
16f4: 8b 45 08 mov 0x8(%ebp),%eax
16f7: 89 04 24 mov %eax,(%esp)
16fa: e8 0d fe ff ff call 150c <putc>
s++;
16ff: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
1703: eb 01 jmp 1706 <printf+0x121>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1705: 90 nop
1706: 8b 45 e4 mov -0x1c(%ebp),%eax
1709: 0f b6 00 movzbl (%eax),%eax
170c: 84 c0 test %al,%al
170e: 75 d7 jne 16e7 <printf+0x102>
1710: eb 68 jmp 177a <printf+0x195>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
1712: 83 7d e8 63 cmpl $0x63,-0x18(%ebp)
1716: 75 1d jne 1735 <printf+0x150>
putc(fd, *ap);
1718: 8b 45 f4 mov -0xc(%ebp),%eax
171b: 8b 00 mov (%eax),%eax
171d: 0f be c0 movsbl %al,%eax
1720: 89 44 24 04 mov %eax,0x4(%esp)
1724: 8b 45 08 mov 0x8(%ebp),%eax
1727: 89 04 24 mov %eax,(%esp)
172a: e8 dd fd ff ff call 150c <putc>
ap++;
172f: 83 45 f4 04 addl $0x4,-0xc(%ebp)
1733: eb 45 jmp 177a <printf+0x195>
} else if(c == '%'){
1735: 83 7d e8 25 cmpl $0x25,-0x18(%ebp)
1739: 75 17 jne 1752 <printf+0x16d>
putc(fd, c);
173b: 8b 45 e8 mov -0x18(%ebp),%eax
173e: 0f be c0 movsbl %al,%eax
1741: 89 44 24 04 mov %eax,0x4(%esp)
1745: 8b 45 08 mov 0x8(%ebp),%eax
1748: 89 04 24 mov %eax,(%esp)
174b: e8 bc fd ff ff call 150c <putc>
1750: eb 28 jmp 177a <printf+0x195>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
1752: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
1759: 00
175a: 8b 45 08 mov 0x8(%ebp),%eax
175d: 89 04 24 mov %eax,(%esp)
1760: e8 a7 fd ff ff call 150c <putc>
putc(fd, c);
1765: 8b 45 e8 mov -0x18(%ebp),%eax
1768: 0f be c0 movsbl %al,%eax
176b: 89 44 24 04 mov %eax,0x4(%esp)
176f: 8b 45 08 mov 0x8(%ebp),%eax
1772: 89 04 24 mov %eax,(%esp)
1775: e8 92 fd ff ff call 150c <putc>
}
state = 0;
177a: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1781: 83 45 ec 01 addl $0x1,-0x14(%ebp)
1785: 8b 55 0c mov 0xc(%ebp),%edx
1788: 8b 45 ec mov -0x14(%ebp),%eax
178b: 8d 04 02 lea (%edx,%eax,1),%eax
178e: 0f b6 00 movzbl (%eax),%eax
1791: 84 c0 test %al,%al
1793: 0f 85 6e fe ff ff jne 1607 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
1799: c9 leave
179a: c3 ret
179b: 90 nop
0000179c <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
179c: 55 push %ebp
179d: 89 e5 mov %esp,%ebp
179f: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
17a2: 8b 45 08 mov 0x8(%ebp),%eax
17a5: 83 e8 08 sub $0x8,%eax
17a8: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
17ab: a1 e8 1c 00 00 mov 0x1ce8,%eax
17b0: 89 45 fc mov %eax,-0x4(%ebp)
17b3: eb 24 jmp 17d9 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
17b5: 8b 45 fc mov -0x4(%ebp),%eax
17b8: 8b 00 mov (%eax),%eax
17ba: 3b 45 fc cmp -0x4(%ebp),%eax
17bd: 77 12 ja 17d1 <free+0x35>
17bf: 8b 45 f8 mov -0x8(%ebp),%eax
17c2: 3b 45 fc cmp -0x4(%ebp),%eax
17c5: 77 24 ja 17eb <free+0x4f>
17c7: 8b 45 fc mov -0x4(%ebp),%eax
17ca: 8b 00 mov (%eax),%eax
17cc: 3b 45 f8 cmp -0x8(%ebp),%eax
17cf: 77 1a ja 17eb <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
17d1: 8b 45 fc mov -0x4(%ebp),%eax
17d4: 8b 00 mov (%eax),%eax
17d6: 89 45 fc mov %eax,-0x4(%ebp)
17d9: 8b 45 f8 mov -0x8(%ebp),%eax
17dc: 3b 45 fc cmp -0x4(%ebp),%eax
17df: 76 d4 jbe 17b5 <free+0x19>
17e1: 8b 45 fc mov -0x4(%ebp),%eax
17e4: 8b 00 mov (%eax),%eax
17e6: 3b 45 f8 cmp -0x8(%ebp),%eax
17e9: 76 ca jbe 17b5 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
17eb: 8b 45 f8 mov -0x8(%ebp),%eax
17ee: 8b 40 04 mov 0x4(%eax),%eax
17f1: c1 e0 03 shl $0x3,%eax
17f4: 89 c2 mov %eax,%edx
17f6: 03 55 f8 add -0x8(%ebp),%edx
17f9: 8b 45 fc mov -0x4(%ebp),%eax
17fc: 8b 00 mov (%eax),%eax
17fe: 39 c2 cmp %eax,%edx
1800: 75 24 jne 1826 <free+0x8a>
bp->s.size += p->s.ptr->s.size;
1802: 8b 45 f8 mov -0x8(%ebp),%eax
1805: 8b 50 04 mov 0x4(%eax),%edx
1808: 8b 45 fc mov -0x4(%ebp),%eax
180b: 8b 00 mov (%eax),%eax
180d: 8b 40 04 mov 0x4(%eax),%eax
1810: 01 c2 add %eax,%edx
1812: 8b 45 f8 mov -0x8(%ebp),%eax
1815: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
1818: 8b 45 fc mov -0x4(%ebp),%eax
181b: 8b 00 mov (%eax),%eax
181d: 8b 10 mov (%eax),%edx
181f: 8b 45 f8 mov -0x8(%ebp),%eax
1822: 89 10 mov %edx,(%eax)
1824: eb 0a jmp 1830 <free+0x94>
} else
bp->s.ptr = p->s.ptr;
1826: 8b 45 fc mov -0x4(%ebp),%eax
1829: 8b 10 mov (%eax),%edx
182b: 8b 45 f8 mov -0x8(%ebp),%eax
182e: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
1830: 8b 45 fc mov -0x4(%ebp),%eax
1833: 8b 40 04 mov 0x4(%eax),%eax
1836: c1 e0 03 shl $0x3,%eax
1839: 03 45 fc add -0x4(%ebp),%eax
183c: 3b 45 f8 cmp -0x8(%ebp),%eax
183f: 75 20 jne 1861 <free+0xc5>
p->s.size += bp->s.size;
1841: 8b 45 fc mov -0x4(%ebp),%eax
1844: 8b 50 04 mov 0x4(%eax),%edx
1847: 8b 45 f8 mov -0x8(%ebp),%eax
184a: 8b 40 04 mov 0x4(%eax),%eax
184d: 01 c2 add %eax,%edx
184f: 8b 45 fc mov -0x4(%ebp),%eax
1852: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1855: 8b 45 f8 mov -0x8(%ebp),%eax
1858: 8b 10 mov (%eax),%edx
185a: 8b 45 fc mov -0x4(%ebp),%eax
185d: 89 10 mov %edx,(%eax)
185f: eb 08 jmp 1869 <free+0xcd>
} else
p->s.ptr = bp;
1861: 8b 45 fc mov -0x4(%ebp),%eax
1864: 8b 55 f8 mov -0x8(%ebp),%edx
1867: 89 10 mov %edx,(%eax)
freep = p;
1869: 8b 45 fc mov -0x4(%ebp),%eax
186c: a3 e8 1c 00 00 mov %eax,0x1ce8
}
1871: c9 leave
1872: c3 ret
00001873 <morecore>:
static Header*
morecore(uint nu)
{
1873: 55 push %ebp
1874: 89 e5 mov %esp,%ebp
1876: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
1879: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
1880: 77 07 ja 1889 <morecore+0x16>
nu = 4096;
1882: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
1889: 8b 45 08 mov 0x8(%ebp),%eax
188c: c1 e0 03 shl $0x3,%eax
188f: 89 04 24 mov %eax,(%esp)
1892: e8 3d fc ff ff call 14d4 <sbrk>
1897: 89 45 f0 mov %eax,-0x10(%ebp)
if(p == (char*)-1)
189a: 83 7d f0 ff cmpl $0xffffffff,-0x10(%ebp)
189e: 75 07 jne 18a7 <morecore+0x34>
return 0;
18a0: b8 00 00 00 00 mov $0x0,%eax
18a5: eb 22 jmp 18c9 <morecore+0x56>
hp = (Header*)p;
18a7: 8b 45 f0 mov -0x10(%ebp),%eax
18aa: 89 45 f4 mov %eax,-0xc(%ebp)
hp->s.size = nu;
18ad: 8b 45 f4 mov -0xc(%ebp),%eax
18b0: 8b 55 08 mov 0x8(%ebp),%edx
18b3: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
18b6: 8b 45 f4 mov -0xc(%ebp),%eax
18b9: 83 c0 08 add $0x8,%eax
18bc: 89 04 24 mov %eax,(%esp)
18bf: e8 d8 fe ff ff call 179c <free>
return freep;
18c4: a1 e8 1c 00 00 mov 0x1ce8,%eax
}
18c9: c9 leave
18ca: c3 ret
000018cb <malloc>:
void*
malloc(uint nbytes)
{
18cb: 55 push %ebp
18cc: 89 e5 mov %esp,%ebp
18ce: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
18d1: 8b 45 08 mov 0x8(%ebp),%eax
18d4: 83 c0 07 add $0x7,%eax
18d7: c1 e8 03 shr $0x3,%eax
18da: 83 c0 01 add $0x1,%eax
18dd: 89 45 f4 mov %eax,-0xc(%ebp)
if((prevp = freep) == 0){
18e0: a1 e8 1c 00 00 mov 0x1ce8,%eax
18e5: 89 45 f0 mov %eax,-0x10(%ebp)
18e8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
18ec: 75 23 jne 1911 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
18ee: c7 45 f0 e0 1c 00 00 movl $0x1ce0,-0x10(%ebp)
18f5: 8b 45 f0 mov -0x10(%ebp),%eax
18f8: a3 e8 1c 00 00 mov %eax,0x1ce8
18fd: a1 e8 1c 00 00 mov 0x1ce8,%eax
1902: a3 e0 1c 00 00 mov %eax,0x1ce0
base.s.size = 0;
1907: c7 05 e4 1c 00 00 00 movl $0x0,0x1ce4
190e: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1911: 8b 45 f0 mov -0x10(%ebp),%eax
1914: 8b 00 mov (%eax),%eax
1916: 89 45 ec mov %eax,-0x14(%ebp)
if(p->s.size >= nunits){
1919: 8b 45 ec mov -0x14(%ebp),%eax
191c: 8b 40 04 mov 0x4(%eax),%eax
191f: 3b 45 f4 cmp -0xc(%ebp),%eax
1922: 72 4d jb 1971 <malloc+0xa6>
if(p->s.size == nunits)
1924: 8b 45 ec mov -0x14(%ebp),%eax
1927: 8b 40 04 mov 0x4(%eax),%eax
192a: 3b 45 f4 cmp -0xc(%ebp),%eax
192d: 75 0c jne 193b <malloc+0x70>
prevp->s.ptr = p->s.ptr;
192f: 8b 45 ec mov -0x14(%ebp),%eax
1932: 8b 10 mov (%eax),%edx
1934: 8b 45 f0 mov -0x10(%ebp),%eax
1937: 89 10 mov %edx,(%eax)
1939: eb 26 jmp 1961 <malloc+0x96>
else {
p->s.size -= nunits;
193b: 8b 45 ec mov -0x14(%ebp),%eax
193e: 8b 40 04 mov 0x4(%eax),%eax
1941: 89 c2 mov %eax,%edx
1943: 2b 55 f4 sub -0xc(%ebp),%edx
1946: 8b 45 ec mov -0x14(%ebp),%eax
1949: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
194c: 8b 45 ec mov -0x14(%ebp),%eax
194f: 8b 40 04 mov 0x4(%eax),%eax
1952: c1 e0 03 shl $0x3,%eax
1955: 01 45 ec add %eax,-0x14(%ebp)
p->s.size = nunits;
1958: 8b 45 ec mov -0x14(%ebp),%eax
195b: 8b 55 f4 mov -0xc(%ebp),%edx
195e: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
1961: 8b 45 f0 mov -0x10(%ebp),%eax
1964: a3 e8 1c 00 00 mov %eax,0x1ce8
return (void*)(p + 1);
1969: 8b 45 ec mov -0x14(%ebp),%eax
196c: 83 c0 08 add $0x8,%eax
196f: eb 38 jmp 19a9 <malloc+0xde>
}
if(p == freep)
1971: a1 e8 1c 00 00 mov 0x1ce8,%eax
1976: 39 45 ec cmp %eax,-0x14(%ebp)
1979: 75 1b jne 1996 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
197b: 8b 45 f4 mov -0xc(%ebp),%eax
197e: 89 04 24 mov %eax,(%esp)
1981: e8 ed fe ff ff call 1873 <morecore>
1986: 89 45 ec mov %eax,-0x14(%ebp)
1989: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
198d: 75 07 jne 1996 <malloc+0xcb>
return 0;
198f: b8 00 00 00 00 mov $0x0,%eax
1994: eb 13 jmp 19a9 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1996: 8b 45 ec mov -0x14(%ebp),%eax
1999: 89 45 f0 mov %eax,-0x10(%ebp)
199c: 8b 45 ec mov -0x14(%ebp),%eax
199f: 8b 00 mov (%eax),%eax
19a1: 89 45 ec mov %eax,-0x14(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
19a4: e9 70 ff ff ff jmp 1919 <malloc+0x4e>
}
19a9: c9 leave
19aa: c3 ret
19ab: 90 nop
000019ac <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
19ac: 55 push %ebp
19ad: 89 e5 mov %esp,%ebp
19af: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
19b2: 8b 55 08 mov 0x8(%ebp),%edx
19b5: 8b 45 0c mov 0xc(%ebp),%eax
19b8: 8b 4d 08 mov 0x8(%ebp),%ecx
19bb: f0 87 02 lock xchg %eax,(%edx)
19be: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
19c1: 8b 45 fc mov -0x4(%ebp),%eax
}
19c4: c9 leave
19c5: c3 ret
000019c6 <lock_init>:
#include "mmu.h"
#include "spinlock.h"
#include "x86.h"
#include "proc.h"
void lock_init(lock_t *lock){
19c6: 55 push %ebp
19c7: 89 e5 mov %esp,%ebp
lock->locked = 0;
19c9: 8b 45 08 mov 0x8(%ebp),%eax
19cc: c7 00 00 00 00 00 movl $0x0,(%eax)
}
19d2: 5d pop %ebp
19d3: c3 ret
000019d4 <lock_acquire>:
void lock_acquire(lock_t *lock){
19d4: 55 push %ebp
19d5: 89 e5 mov %esp,%ebp
19d7: 83 ec 08 sub $0x8,%esp
while(xchg(&lock->locked,1) != 0);
19da: 8b 45 08 mov 0x8(%ebp),%eax
19dd: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
19e4: 00
19e5: 89 04 24 mov %eax,(%esp)
19e8: e8 bf ff ff ff call 19ac <xchg>
19ed: 85 c0 test %eax,%eax
19ef: 75 e9 jne 19da <lock_acquire+0x6>
}
19f1: c9 leave
19f2: c3 ret
000019f3 <lock_release>:
void lock_release(lock_t *lock){
19f3: 55 push %ebp
19f4: 89 e5 mov %esp,%ebp
19f6: 83 ec 08 sub $0x8,%esp
xchg(&lock->locked,0);
19f9: 8b 45 08 mov 0x8(%ebp),%eax
19fc: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1a03: 00
1a04: 89 04 24 mov %eax,(%esp)
1a07: e8 a0 ff ff ff call 19ac <xchg>
}
1a0c: c9 leave
1a0d: c3 ret
00001a0e <thread_create>:
void *thread_create(void(*start_routine)(void*), void *arg){
1a0e: 55 push %ebp
1a0f: 89 e5 mov %esp,%ebp
1a11: 83 ec 28 sub $0x28,%esp
int tid;
void * stack = malloc(2 * 4096);
1a14: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
1a1b: e8 ab fe ff ff call 18cb <malloc>
1a20: 89 45 f0 mov %eax,-0x10(%ebp)
void *garbage_stack = stack;
1a23: 8b 45 f0 mov -0x10(%ebp),%eax
1a26: 89 45 f4 mov %eax,-0xc(%ebp)
// printf(1,"start routine addr : %d\n",(uint)start_routine);
if((uint)stack % 4096){
1a29: 8b 45 f0 mov -0x10(%ebp),%eax
1a2c: 25 ff 0f 00 00 and $0xfff,%eax
1a31: 85 c0 test %eax,%eax
1a33: 74 15 je 1a4a <thread_create+0x3c>
stack = stack + (4096 - (uint)stack % 4096);
1a35: 8b 45 f0 mov -0x10(%ebp),%eax
1a38: 89 c2 mov %eax,%edx
1a3a: 81 e2 ff 0f 00 00 and $0xfff,%edx
1a40: b8 00 10 00 00 mov $0x1000,%eax
1a45: 29 d0 sub %edx,%eax
1a47: 01 45 f0 add %eax,-0x10(%ebp)
}
if (stack == 0){
1a4a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a4e: 75 1b jne 1a6b <thread_create+0x5d>
printf(1,"malloc fail \n");
1a50: c7 44 24 04 8d 1c 00 movl $0x1c8d,0x4(%esp)
1a57: 00
1a58: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1a5f: e8 81 fb ff ff call 15e5 <printf>
return 0;
1a64: b8 00 00 00 00 mov $0x0,%eax
1a69: eb 6f jmp 1ada <thread_create+0xcc>
}
tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg);
1a6b: 8b 4d 0c mov 0xc(%ebp),%ecx
1a6e: 8b 55 08 mov 0x8(%ebp),%edx
1a71: 8b 45 f0 mov -0x10(%ebp),%eax
1a74: 89 4c 24 0c mov %ecx,0xc(%esp)
1a78: 89 54 24 08 mov %edx,0x8(%esp)
1a7c: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp)
1a83: 00
1a84: 89 04 24 mov %eax,(%esp)
1a87: e8 60 fa ff ff call 14ec <clone>
1a8c: 89 45 ec mov %eax,-0x14(%ebp)
if(tid < 0){
1a8f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1a93: 79 1b jns 1ab0 <thread_create+0xa2>
printf(1,"clone fails\n");
1a95: c7 44 24 04 9b 1c 00 movl $0x1c9b,0x4(%esp)
1a9c: 00
1a9d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1aa4: e8 3c fb ff ff call 15e5 <printf>
return 0;
1aa9: b8 00 00 00 00 mov $0x0,%eax
1aae: eb 2a jmp 1ada <thread_create+0xcc>
}
if(tid > 0){
1ab0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1ab4: 7e 05 jle 1abb <thread_create+0xad>
//store threads on thread table
return garbage_stack;
1ab6: 8b 45 f4 mov -0xc(%ebp),%eax
1ab9: eb 1f jmp 1ada <thread_create+0xcc>
}
if(tid == 0){
1abb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1abf: 75 14 jne 1ad5 <thread_create+0xc7>
printf(1,"tid = 0 return \n");
1ac1: c7 44 24 04 a8 1c 00 movl $0x1ca8,0x4(%esp)
1ac8: 00
1ac9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1ad0: e8 10 fb ff ff call 15e5 <printf>
}
// wait();
// free(garbage_stack);
return 0;
1ad5: b8 00 00 00 00 mov $0x0,%eax
}
1ada: c9 leave
1adb: c3 ret
00001adc <init_q>:
#include "queue.h"
#include "types.h"
#include "user.h"
void init_q(struct queue *q){
1adc: 55 push %ebp
1add: 89 e5 mov %esp,%ebp
q->size = 0;
1adf: 8b 45 08 mov 0x8(%ebp),%eax
1ae2: c7 00 00 00 00 00 movl $0x0,(%eax)
q->head = 0;
1ae8: 8b 45 08 mov 0x8(%ebp),%eax
1aeb: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1af2: 8b 45 08 mov 0x8(%ebp),%eax
1af5: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
1afc: 5d pop %ebp
1afd: c3 ret
00001afe <add_q>:
void add_q(struct queue *q, int v){
1afe: 55 push %ebp
1aff: 89 e5 mov %esp,%ebp
1b01: 83 ec 28 sub $0x28,%esp
struct node * n = malloc(sizeof(struct node));
1b04: c7 04 24 08 00 00 00 movl $0x8,(%esp)
1b0b: e8 bb fd ff ff call 18cb <malloc>
1b10: 89 45 f4 mov %eax,-0xc(%ebp)
n->next = 0;
1b13: 8b 45 f4 mov -0xc(%ebp),%eax
1b16: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->value = v;
1b1d: 8b 45 f4 mov -0xc(%ebp),%eax
1b20: 8b 55 0c mov 0xc(%ebp),%edx
1b23: 89 10 mov %edx,(%eax)
if(q->head == 0){
1b25: 8b 45 08 mov 0x8(%ebp),%eax
1b28: 8b 40 04 mov 0x4(%eax),%eax
1b2b: 85 c0 test %eax,%eax
1b2d: 75 0b jne 1b3a <add_q+0x3c>
q->head = n;
1b2f: 8b 45 08 mov 0x8(%ebp),%eax
1b32: 8b 55 f4 mov -0xc(%ebp),%edx
1b35: 89 50 04 mov %edx,0x4(%eax)
1b38: eb 0c jmp 1b46 <add_q+0x48>
}else{
q->tail->next = n;
1b3a: 8b 45 08 mov 0x8(%ebp),%eax
1b3d: 8b 40 08 mov 0x8(%eax),%eax
1b40: 8b 55 f4 mov -0xc(%ebp),%edx
1b43: 89 50 04 mov %edx,0x4(%eax)
}
q->tail = n;
1b46: 8b 45 08 mov 0x8(%ebp),%eax
1b49: 8b 55 f4 mov -0xc(%ebp),%edx
1b4c: 89 50 08 mov %edx,0x8(%eax)
q->size++;
1b4f: 8b 45 08 mov 0x8(%ebp),%eax
1b52: 8b 00 mov (%eax),%eax
1b54: 8d 50 01 lea 0x1(%eax),%edx
1b57: 8b 45 08 mov 0x8(%ebp),%eax
1b5a: 89 10 mov %edx,(%eax)
}
1b5c: c9 leave
1b5d: c3 ret
00001b5e <empty_q>:
int empty_q(struct queue *q){
1b5e: 55 push %ebp
1b5f: 89 e5 mov %esp,%ebp
if(q->size == 0)
1b61: 8b 45 08 mov 0x8(%ebp),%eax
1b64: 8b 00 mov (%eax),%eax
1b66: 85 c0 test %eax,%eax
1b68: 75 07 jne 1b71 <empty_q+0x13>
return 1;
1b6a: b8 01 00 00 00 mov $0x1,%eax
1b6f: eb 05 jmp 1b76 <empty_q+0x18>
else
return 0;
1b71: b8 00 00 00 00 mov $0x0,%eax
}
1b76: 5d pop %ebp
1b77: c3 ret
00001b78 <pop_q>:
int pop_q(struct queue *q){
1b78: 55 push %ebp
1b79: 89 e5 mov %esp,%ebp
1b7b: 83 ec 28 sub $0x28,%esp
int val;
struct node *destroy;
if(!empty_q(q)){
1b7e: 8b 45 08 mov 0x8(%ebp),%eax
1b81: 89 04 24 mov %eax,(%esp)
1b84: e8 d5 ff ff ff call 1b5e <empty_q>
1b89: 85 c0 test %eax,%eax
1b8b: 75 5d jne 1bea <pop_q+0x72>
val = q->head->value;
1b8d: 8b 45 08 mov 0x8(%ebp),%eax
1b90: 8b 40 04 mov 0x4(%eax),%eax
1b93: 8b 00 mov (%eax),%eax
1b95: 89 45 f0 mov %eax,-0x10(%ebp)
destroy = q->head;
1b98: 8b 45 08 mov 0x8(%ebp),%eax
1b9b: 8b 40 04 mov 0x4(%eax),%eax
1b9e: 89 45 f4 mov %eax,-0xc(%ebp)
q->head = q->head->next;
1ba1: 8b 45 08 mov 0x8(%ebp),%eax
1ba4: 8b 40 04 mov 0x4(%eax),%eax
1ba7: 8b 50 04 mov 0x4(%eax),%edx
1baa: 8b 45 08 mov 0x8(%ebp),%eax
1bad: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
1bb0: 8b 45 f4 mov -0xc(%ebp),%eax
1bb3: 89 04 24 mov %eax,(%esp)
1bb6: e8 e1 fb ff ff call 179c <free>
q->size--;
1bbb: 8b 45 08 mov 0x8(%ebp),%eax
1bbe: 8b 00 mov (%eax),%eax
1bc0: 8d 50 ff lea -0x1(%eax),%edx
1bc3: 8b 45 08 mov 0x8(%ebp),%eax
1bc6: 89 10 mov %edx,(%eax)
if(q->size == 0){
1bc8: 8b 45 08 mov 0x8(%ebp),%eax
1bcb: 8b 00 mov (%eax),%eax
1bcd: 85 c0 test %eax,%eax
1bcf: 75 14 jne 1be5 <pop_q+0x6d>
q->head = 0;
1bd1: 8b 45 08 mov 0x8(%ebp),%eax
1bd4: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1bdb: 8b 45 08 mov 0x8(%ebp),%eax
1bde: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
1be5: 8b 45 f0 mov -0x10(%ebp),%eax
1be8: eb 05 jmp 1bef <pop_q+0x77>
}
return -1;
1bea: b8 ff ff ff ff mov $0xffffffff,%eax
}
1bef: c9 leave
1bf0: c3 ret
|
; A138799: Values of T(j) corresponding to least possible T(k) with T(k)-T(j)=n, where T(i)>0 are the triangular numbers A000217.
; Submitted by Jamie Morken(s1.)
; 1,3,6,1,15,3,28,1,45,10,3,15,1,6,120,28,3,36,1,15,6,55,21,3,10,1,378,91,6,105,496,3,21,1,55,153,28,6,15,190,3,210,1,10,45,253,105,6,28,15,3,325,1,36,10,21,78,406,6,435,91,3,2016,1,105,528,10,36,21,595,6,630
seq $0,138798 ; Values of j corresponding to least possible k>0 with T(k)-T(j)=n, where T(i)>0 are the triangular numbers A000217.
mul $0,2
add $0,1
pow $0,2
div $0,8
|
title "Irql Processing"
;++
;
; Copyright (c) 1989 Microsoft Corporation
;
; Module Name:
;
; ixirql.asm
;
; Abstract:
;
; This module implements the code necessary to raise and lower i386
; Irql and dispatch software interrupts with the 8259 PIC.
;
; Author:
;
; Shie-Lin Tzong (shielint) 8-Jan-1990
;
; Environment:
;
; Kernel mode only.
;
; Revision History:
;
; John Vert (jvert) 27-Nov-1991
; Moved from kernel into HAL
;
;--
.586p
.xlist
include hal386.inc
include callconv.inc ; calling convention macros
include i386\ix8259.inc
include i386\kimacro.inc
include mac386.inc
.list
EXTRNP _KeBugCheckEx,5,IMPORT
EXTRNP _KeSetEventBoostPriority, 2, IMPORT
EXTRNP _KeWaitForSingleObject,5, IMPORT
extrn _HalpApcInterrupt:near
extrn _HalpDispatchInterrupt:near
extrn _KiUnexpectedInterrupt:near
extrn _HalpBusType:DWORD
extrn _HalpApcInterrupt2ndEntry:NEAR
extrn _HalpDispatchInterrupt2ndEntry:NEAR
ifdef NT_UP
LOCK_ADD equ add
LOCK_DEC equ dec
LOCK_CMPXCHG equ cmpxchg
else
LOCK_ADD equ lock add
LOCK_DEC equ lock dec
LOCK_CMPXCHG equ lock cmpxchg
endif
;
; Initialization control words equates for the PICs
;
ICW1_ICW4_NEEDED equ 01H
ICW1_CASCADE equ 00H
ICW1_INTERVAL8 equ 00H
ICW1_LEVEL_TRIG equ 08H
ICW1_EDGE_TRIG equ 00H
ICW1_ICW equ 10H
ICW4_8086_MODE equ 001H
ICW4_NORM_EOI equ 000H
ICW4_NON_BUF_MODE equ 000H
ICW4_SPEC_FULLY_NESTED equ 010H
ICW4_NOT_SPEC_FULLY_NESTED equ 000H
OCW2_NON_SPECIFIC_EOI equ 020H
OCW2_SPECIFIC_EOI equ 060H
OCW2_SET_PRIORITY equ 0c0H
PIC_SLAVE_IRQ equ 2
PIC1_BASE equ 30H
PIC2_BASE equ 38H
;
; Interrupt flag bit maks for EFLAGS
;
EFLAGS_IF equ 200H
EFLAGS_SHIFT equ 9
_DATA SEGMENT DWORD PUBLIC 'DATA'
;
; PICsInitializationString - Master PIC initialization command string
;
PS2PICsInitializationString dw PIC1_PORT0
;
; Master PIC initialization command
;
db ICW1_ICW + ICW1_LEVEL_TRIG + ICW1_INTERVAL8 +\
ICW1_CASCADE + ICW1_ICW4_NEEDED
db PIC1_BASE
db 1 SHL PIC_SLAVE_IRQ
db ICW4_NOT_SPEC_FULLY_NESTED + \
ICW4_NON_BUF_MODE + \
ICW4_NORM_EOI + \
ICW4_8086_MODE
;
; Slave PIC initialization command strings
;
dw PIC2_PORT0
db ICW1_ICW + ICW1_LEVEL_TRIG + ICW1_INTERVAL8 +\
ICW1_CASCADE + ICW1_ICW4_NEEDED
db PIC2_BASE
db PIC_SLAVE_IRQ
db ICW4_NOT_SPEC_FULLY_NESTED + \
ICW4_NON_BUF_MODE + \
ICW4_NORM_EOI + \
ICW4_8086_MODE
dw 0 ; end of string
PICsInitializationString dw PIC1_PORT0
;
; Master PIC initialization command
;
db ICW1_ICW + ICW1_EDGE_TRIG + ICW1_INTERVAL8 +\
ICW1_CASCADE + ICW1_ICW4_NEEDED
db PIC1_BASE
db 1 SHL PIC_SLAVE_IRQ
db ICW4_NOT_SPEC_FULLY_NESTED + \
ICW4_NON_BUF_MODE + \
ICW4_NORM_EOI + \
ICW4_8086_MODE
; Slave PIC initialization command strings
;
dw PIC2_PORT0
db ICW1_ICW + ICW1_EDGE_TRIG + ICW1_INTERVAL8 +\
ICW1_CASCADE + ICW1_ICW4_NEEDED
db PIC2_BASE
db PIC_SLAVE_IRQ
db ICW4_NOT_SPEC_FULLY_NESTED + \
ICW4_NON_BUF_MODE + \
ICW4_NORM_EOI + \
ICW4_8086_MODE
dw 0 ; end of string
align 4
public KiI8259MaskTable
KiI8259MaskTable label dword
dd 00000000000000000000000000000000B ; irql 0
dd 00000000000000000000000000000000B ; irql 1
dd 00000000000000000000000000000000B ; irql 2
dd 00000000000000000000000000000000B ; irql 3
dd 11111111100000000000000000000000B ; irql 4
dd 11111111110000000000000000000000B ; irql 5
dd 11111111111000000000000000000000B ; irql 6
dd 11111111111100000000000000000000B ; irql 7
dd 11111111111110000000000000000000B ; irql 8
dd 11111111111111000000000000000000B ; irql 9
dd 11111111111111100000000000000000B ; irql 10
dd 11111111111111110000000000000000B ; irql 11
dd 11111111111111111000000000000000B ; irql 12
dd 11111111111111111100000000000000B ; irql 13
dd 11111111111111111110000000000000B ; irql 14
dd 11111111111111111111000000000000B ; irql 15
dd 11111111111111111111100000000000B ; irql 16
dd 11111111111111111111110000000000B ; irql 17
dd 11111111111111111111111000000000B ; irql 18
dd 11111111111111111111111000000000B ; irql 19
dd 11111111111111111111111010000000B ; irql 20
dd 11111111111111111111111011000000B ; irql 21
dd 11111111111111111111111011100000B ; irql 22
dd 11111111111111111111111011110000B ; irql 23
dd 11111111111111111111111011111000B ; irql 24
dd 11111111111111111111111011111000B ; irql 25
dd 11111111111111111111111011111010B ; irql 26
dd 11111111111111111111111111111010B ; irql 27
dd 11111111111111111111111111111011B ; irql 28
dd 11111111111111111111111111111011B ; irql 29
dd 11111111111111111111111111111011B ; irql 30
dd 11111111111111111111111111111011B ; irql 31
align 4
;
; The following tables define the addresses of software interrupt routers
;
;
; Use this table if there is NO machine state frame on stack already
;
public SWInterruptHandlerTable
SWInterruptHandlerTable label dword
dd offset FLAT:_KiUnexpectedInterrupt ; irql 0
dd offset FLAT:_HalpApcInterrupt ; irql 1
dd offset FLAT:_HalpDispatchInterrupt ; irql 2
;
; Use this table if there is a machine state frame on stack already
;
public SWInterruptHandlerTable2
SWInterruptHandlerTable2 label dword
dd offset FLAT:_KiUnexpectedInterrupt ; irql 0
dd offset FLAT:_HalpApcInterrupt2ndEntry ; irql 1
dd offset FLAT:_HalpDispatchInterrupt2ndEntry ; irql 2
;
; The following table picks up the highest pending software irq level
; from software irr
;
public SWInterruptLookUpTable
SWInterruptLookUpTable label byte
db 0 ; SWIRR=0, so highest pending SW irql= 0
db 0 ; SWIRR=1, so highest pending SW irql= 0
db 1 ; SWIRR=2, so highest pending SW irql= 1
db 1 ; SWIRR=3, so highest pending SW irql= 1
db 2 ; SWIRR=4, so highest pending SW irql= 2
db 2 ; SWIRR=5, so highest pending SW irql= 2
db 2 ; SWIRR=6, so highest pending SW irql= 2
db 2 ; SWIRR=7, so highest pending SW irql= 2
_DATA ENDS
_TEXT SEGMENT PARA PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:FLAT, FS:NOTHING, GS:NOTHING
PAGE
subttl "Raise Irql"
;++
;
; KIRQL
; FASTCALL
; KfRaiseIrql (
; IN KIRQL NewIrql
; )
;
; Routine Description:
;
; This routine is used to raise IRQL to the specified value.
; Also, a mask will be used to mask off all the lower lever 8259
; interrupts.
;
; Arguments:
;
; (cl) = NewIrql - the new irql to be raised to
;
; Return Value:
;
; OldIrql - the addr of a variable which old irql should be stored
;
;--
cPublicFastCall KfRaiseIrql,1
cPublicFpo 0,0
mov eax, PCR[PcIrql] ; get current irql
movzx ecx, cl ; 32bit extend NewIrql
if DBG
cmp eax,ecx ; old > new?
ja short Kri99 ; raising to a lower IRQL is BAD
endif
cmp ecx,DISPATCH_LEVEL ; software level?
jbe short kri10 ; Skip setting 8259 masks
mov edx, eax ; Save OldIrql
pushfd
cli ; disable interrupt
mov PCR[PcIrql], cl ; set the new irql
mov eax, KiI8259MaskTable[ecx*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
popfd
mov eax, edx ; (al) = OldIrql
fstRET KfRaiseIrql
align 4
kri10:
;
; Note it is very important that we set the old irql AFTER we raise to
; the new irql. Otherwise, if there is an interrupt in between and the
; OldIrql is not a local variable, the caller will get the wrong OldIrql.
; The bottom line is that raising irql and returning the old irql has to be
; atomic to the caller.
;
mov PCR[PcIrql], ecx
fstRET KfRaiseIrql
if DBG
Kri99: mov dword ptr PCR[PcIrql],0 ; avoid recursive error
stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,eax,ecx,0,9>
; never returns (but need the following for the debugger)
fstRET KfRaiseIrql
endif
fstENDP KfRaiseIrql
;++
;
; VOID
; KIRQL
; KeRaiseIrqlToDpcLevel (
; )
;
; Routine Description:
;
; This routine is used to raise IRQL to DPC level.
;
; Arguments:
;
; Return Value:
;
; OldIrql - the addr of a variable which old irql should be stored
;
;--
cPublicProc _KeRaiseIrqlToDpcLevel,0
cPublicFpo 0, 0
mov eax, PCR[PcIrql] ; (eax) = Old Irql
mov dword ptr PCR[PcIrql], DISPATCH_LEVEL ; set new irql
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
if DBG
cmp eax, DISPATCH_LEVEL ; old > new?
ja short Krid99 ; yes, go bugcheck
endif
stdRET _KeRaiseIrqlToDpcLevel
if DBG
cPublicFpo 0,1
Krid99: stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,eax,DISPATCH_LEVEL,0,1>
; never returns (but need the following for the debugger)
stdRET _KeRaiseIrqlToDpcLevel
endif
stdENDP _KeRaiseIrqlToDpcLevel
;++
;
; VOID
; KIRQL
; KeRaiseIrqlToSynchLevel (
; )
;
; Routine Description:
;
; This routine is used to raise IRQL to SYNC level.
;
; Arguments:
;
; Return Value:
;
; OldIrql - the addr of a variable which old irql should be stored
;
;--
cPublicProc _KeRaiseIrqlToSynchLevel,0
cPublicFpo 0, 0
pushfd
cli ; disable interrupt
mov eax, KiI8259MaskTable[SYNCH_LEVEL*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
mov eax, PCR[PcIrql] ; (eax) = Old irql
mov dword ptr PCR[PcIrql], SYNCH_LEVEL ; set new irql
popfd
if DBG
cmp eax, SYNCH_LEVEL
ja short Kris99
endif
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
stdRET _KeRaiseIrqlToSynchLevel
if DBG
cPublicFpo 0,1
Kris99: stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,eax,SYNCH_LEVEL,0,2>
stdRET _KeRaiseIrqlToSynchLevel
endif
stdENDP _KeRaiseIrqlToSynchLevel
page ,132
subttl "Lower irql"
;++
;
; VOID
; FASTCALL
; KfLowerIrql (
; IN KIRQL NewIrql
; )
;
; Routine Description:
;
; This routine is used to lower IRQL to the specified value.
; The IRQL and PIRQL will be updated accordingly. Also, this
; routine checks to see if any software interrupt should be
; generated. The following condition will cause software
; interrupt to be simulated:
; any software interrupt which has higher priority than
; current IRQL's is pending.
;
; NOTE: This routine simulates software interrupt as long as
; any pending SW interrupt level is higher than the current
; IRQL, even when interrupts are disabled.
;
; On a UP system, HalEndSystenInterrupt is treated as a
; LowerIrql.
;
; Arguments:
;
; (cl) = NewIrql - the new irql to be set.
;
; Return Value:
;
; None.
;
;--
cPublicFastCall KfLowerIrql ,1
cPublicFpo 0,1
pushfd ; save caller's eflags
movzx ecx, cl ; zero extend irql
if DBG
cmp ecx,PCR[PcIrql]
ja short Kli99
endif
cmp dword ptr PCR[PcIrql],DISPATCH_LEVEL ; Software level?
cli
jbe short kli02 ; no, go set 8259 hw
mov eax, KiI8259MaskTable[ecx*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
kli02:
mov PCR[PcIrql], ecx ; set the new irql
mov eax, PCR[PcIRR] ; get SW interrupt request register
mov al, SWInterruptLookUpTable[eax] ; get the highest pending
; software interrupt level
cmp al, cl ; Is highest SW int level > irql?
ja Kli10 ; yes, go simulate interrupt
kil03: popfd ; restore flags, including ints
cPublicFpo 0,0
fstRET KfLowerIrql
if DBG
Kli99:
mov eax, dword ptr PCR[PcIrql]; old irql for debugging
mov dword ptr PCR[PcIrql],HIGH_LEVEL ; avoid recursive error
stdCall _KeBugCheckEx,<IRQL_NOT_LESS_OR_EQUAL,eax,ecx,0,3>
; never returns
endif
;
; When we come to Kli10, (eax) = soft interrupt index
;
; Note Do NOT:
;
; popfd
; jmp SWInterruptHandlerTable[eax*4]
;
; We want to make sure interrupts are off after entering SWInterrupt
; Handler.
;
align 4
cPublicFpo 1,1
Kli10: call SWInterruptHandlerTable[eax*4] ; SIMULATE INTERRUPT
popfd ; restore flags, including ints
cPublicFpo 1,0
fstRET KfLowerIrql ; cRetURN
fstENDP KfLowerIrql
;++
;
; KIRQL
; FASTCALL
; KfAcquireSpinLock (
; IN PKSPIN_LOCK SpinLock,
; )
;
; Routine Description:
;
; This function raises to DISPATCH_LEVEL and then acquires a the
; kernel spin lock.
;
; In a UP hal spinlock serialization is accomplished by raising the
; IRQL to DISPATCH_LEVEL. The SpinLock is not used; however, for
; debugging purposes if the UP hal is compiled with the NT_UP flag
; not set (ie, MP) we take the SpinLock.
;
; Arguments:
;
; (ecx) = SpinLock - Supplies a pointer to an kernel spin lock.
;
; Return Value:
;
; OldIrql
;
;--
cPublicFastCall KfAcquireSpinLock,1
cPublicFpo 0,0
mov eax, PCR[PcIrql] ; (eax) = Old Irql
mov dword ptr PCR[PcIrql], DISPATCH_LEVEL ; set new irql
ifndef NT_UP
asl10: ACQUIRE_SPINLOCK ecx,<short asl20>
endif
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
if DBG
cmp eax, DISPATCH_LEVEL ; old > new?
ja short asl99 ; yes, go bugcheck
endif
fstRET KfAcquireSpinLock
ifndef NT_UP
asl20: SPIN_ON_SPINLOCK ecx,<short asl10>
endif
if DBG
cPublicFpo 2, 1
asl99:
stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,ecx,DISPATCH_LEVEL,0,4>
endif
fstRET KfAcquireSpinLock
fstENDP KfAcquireSpinLock
;++
;
; KIRQL
; FASTCALL
; KeAcquireSpinLockRaiseToSynch (
; IN PKSPIN_LOCK SpinLock,
; )
;
; Routine Description:
;
; This function acquires the SpinLock at SYNCH_LEVEL. The function
; is optmized for hoter locks (the lock is tested before acquired.
; Any spin should occur at OldIrql; however, since this is a UP hal
; we don't have the code for it)
;
; In a UP hal spinlock serialization is accomplished by raising the
; IRQL to SYNCH_LEVEL. The SpinLock is not used; however, for
; debugging purposes if the UP hal is compiled with the NT_UP flag
; not set (ie, MP) we take the SpinLock.
;
; Arguments:
;
; (ecx) = SpinLock - Supplies a pointer to an kernel spin lock.
;
; Return Value:
;
; OldIrql
;
;--
cPublicFastCall KeAcquireSpinLockRaiseToSynch,1
cPublicFpo 0,0
push ecx
mov ecx, SYNCH_LEVEL
fstCall KfRaiseIrql ; Raise to SYNCH_LEVEL
pop ecx
ifndef NT_UP
asls10: ACQUIRE_SPINLOCK ecx,<short asls20>
endif
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
if DBG
cmp al, SYNCH_LEVEL ; old > new?
ja short asls99 ; yes, go bugcheck
endif
fstRET KeAcquireSpinLockRaiseToSynch
ifndef NT_UP
asls20: SPIN_ON_SPINLOCK ecx,<short asls10>
endif
if DBG
cPublicFpo 2, 1
asls99:
stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,eax,DISPATCH_LEVEL,0,5>
; never returns
endif
fstRET KeAcquireSpinLockRaiseToSynch
fstENDP KeAcquireSpinLockRaiseToSynch
PAGE
SUBTTL "Release Kernel Spin Lock"
;++
;
; VOID
; FASTCALL
; KfReleaseSpinLock (
; IN PKSPIN_LOCK SpinLock,
; IN KIRQL NewIrql
; )
;
; Routine Description:
;
; This function releases a kernel spin lock and lowers to the new irql
;
; In a UP hal spinlock serialization is accomplished by raising the
; IRQL to DISPATCH_LEVEL. The SpinLock is not used; however, for
; debugging purposes if the UP hal is compiled with the NT_UP flag
; not set (ie, MP) we use the SpinLock.
;
;
; Arguments:
;
; (ecx) = SpinLock - Supplies a pointer to an executive spin lock.
; (dl) = NewIrql - New irql value to set
;
; Return Value:
;
; None.
;
;--
align 16
cPublicFastCall KfReleaseSpinLock ,2
cPublicFpo 0,1
pushfd
ifndef NT_UP
RELEASE_SPINLOCK ecx ; release it
endif
movzx ecx, dl ; (ecx) = NewIrql
cmp dword ptr PCR[PcIrql],DISPATCH_LEVEL ; Software level?
cli
jbe short rsl02 ; no, go set 8259 hw
mov eax, KiI8259MaskTable[ecx*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
rsl02:
mov PCR[PcIrql], ecx
mov eax, PCR[PcIRR] ; get SW interrupt request register
mov al, SWInterruptLookUpTable[eax] ; get the highest pending
; software interrupt level
cmp al, cl ; Is highest SW int level > irql?
ja short rsl20 ; yes, go simulate interrupt
popfd
fstRet KfReleaseSpinLock ; all done
align 4
rsl20: call SWInterruptHandlerTable[eax*4] ; SIMULATE INTERRUPT
popfd ; restore flags, including ints
cPublicFpo 2,0
fstRET KfReleaseSpinLock ; all done
fstENDP KfReleaseSpinLock
;++
;
; VOID
; FASTCALL
; ExAcquireFastMutex (
; IN PFAST_MUTEX FastMutex
; )
;
; Routine description:
;
; This function acquire ownership of the FastMutex
;
; Arguments:
;
; (ecx) = FastMutex - Supplies a pointer to the fast mutex
;
; Return Value:
;
; None.
;
;--
cPublicFastCall ExAcquireFastMutex,1
cPublicFpo 0,1
push ecx ; Save FastMutex
mov ecx, APC_LEVEL
fstCall KfRaiseIrql ; Raise to APC_LEVEL
pop ecx ; (ecx) = FastMutex
cPublicFpo 0,0
if DBG
pushfd
cli ; prevent swapcontext while
; snapping current thread.
mov edx, PCR[PcPrcb]
mov edx, [edx].PbCurrentThread ; (edx) = Current Thread
popfd
cmp [ecx].FmOwner, edx ; Already owned by this thread?
je short afm98 ; Yes, error
endif
LOCK_DEC dword ptr [ecx].FmCount ; Get count
jz short afm_ret ; The owner? Yes, Done
inc dword ptr [ecx].FmContention
cPublicFpo 0,2
push ecx ; Save FastMutex
push eax ; Save OldIrql
add ecx, FmEvent ; Wait on Event
stdCall _KeWaitForSingleObject,<ecx,WrExecutive,0,0,0>
pop eax
pop ecx
cPublicFpo 0,0
if DBG
pushfd
cli ; prevent swapcontext while
; snapping current thread.
mov edx, PCR[PcPrcb]
mov edx, [edx].PbCurrentThread ; (edx) = Current Thread
popfd
endif
afm_ret:
if DBG
mov [ecx].FmOwner, edx ; save owner in fast mutex
else
;
; Use esp to track the owning thread for debugging purposes.
; !thread from kd will find the owning thread. Note that the
; owner isn't cleared on release, check if the mutex is owned
; first.
;
mov dword ptr [ecx].FmOwner, esp
endif
mov byte ptr [ecx].FmOldIrql, al ; (al) = OldIrql
fstRet ExAcquireFastMutex
if DBG
; KeBugCheckEx(MUTEX_ALREADY_OWNED, FastMutex, CurrentThread, 0, 6)
; (never returns)
afm98: stdcall _KeBugCheckEx,<MUTEX_ALREADY_OWNED,ecx,edx,0,6>
fstRet ExAcquireFastMutex
endif
fstENDP ExAcquireFastMutex
;++
;
; BOOLEAN
; FASTCALL
; ExTryToAcquireFastMutex (
; IN PFAST_MUTEX FastMutex
; )
;
; Routine description:
;
; This function acquire ownership of the FastMutex
;
; Arguments:
;
; (ecx) = FastMutex - Supplies a pointer to the fast mutex
;
; Return Value:
;
; Returns TRUE if the FAST_MUTEX was acquired; otherwise FALSE
;
;--
cPublicFastCall ExTryToAcquireFastMutex,1
cPublicFpo 0,1
push ecx ; Save FAST_MUTEX
mov ecx, APC_LEVEL
fstCall KfRaiseIrql ; (al) = OldIrql
pop ecx ; (ecx) = FAST_MUTEX
cPublicFpo 0,0
push eax ; Save OldIrql
mov edx, 0 ; Value to set
mov eax, 1 ; Value to compare against
LOCK_CMPXCHG dword ptr [ecx].FmCount, edx ; Attempt to acquire
jnz short tam20 ; didn't get it
pop dword ptr [ecx].FmOldIrql
if DBG
pushfd
cli ; prevent swapcontext while
; snapping current thread.
mov edx, PCR[PcPrcb]
mov edx, [edx].PbCurrentThread ; (edx) = Current Thread
popfd
mov [ecx].FmOwner, edx ; Save in Fast Mutex
else
;
; Use esp to track the owning thread for debugging purposes.
; !thread from kd will find the owning thread. Note that the
; owner isn't cleared on release, check if the mutex is owned
; first.
;
mov dword ptr [ecx].FmOwner, esp
endif
mov eax, 1 ; return TRUE
fstRet ExTryToAcquireFastMutex
tam20:
pop ecx ; (ecx) = OldIrql
fstCall KfLowerIrql ; restore OldIrql
xor eax, eax ; return FALSE
YIELD
fstRet ExTryToAcquireFastMutex ; all done
fstENDP ExTryToAcquireFastMutex
;++
;
; VOID
; FASTCALL
; ExReleaseFastMutex (
; IN PFAST_MUTEX FastMutex
; )
;
; Routine description:
;
; This function releases ownership of the FastMutex
;
; Arguments:
;
; (ecx) = FastMutex - Supplies a pointer to the fast mutex
;
; Return Value:
;
; None.
;
;--
cPublicFastCall ExReleaseFastMutex,1
cPublicFpo 0,0
if DBG
pushfd
cli ; prevent swapcontext while
; snapping current thread.
mov edx, PCR[PcPrcb]
mov edx, [edx].PbCurrentThread ; (edx) = CurrentThread
popfd
cmp [ecx].FmOwner, edx ; Owner == CurrentThread?
jne short rfm_threaderror ; No, bugcheck
or byte ptr [ecx].FmOwner, 1 ; not the owner anymore
endif
mov al, byte ptr [ecx].FmOldIrql ; (cl) = OldIrql
LOCK_ADD dword ptr [ecx].FmCount, 1 ; Remove our count
xchg ecx, eax ; (cl) = OldIrql
js short rfm05 ; if < 0, set event
jnz @KfLowerIrql@4 ; if != 0, don't set event
rfm05: add eax, FmEvent
push ecx
stdCall _KeSetEventBoostPriority, <eax, 0>
pop ecx
jmp @KfLowerIrql@4
if DBG
; KeBugCheck(THREAD_NOT_MUTEX_OWNER, FastMutex, Thread, Owner, 7)
; (never returns)
rfm_threaderror:
stdCall _KeBugCheckEx,<THREAD_NOT_MUTEX_OWNER,ecx,edx,[ecx].FmOwner,7>
int 3
endif
fstENDP ExReleaseFastMutex
page ,132
subttl "Acquire Queued SpinLock"
;++
;
; KIRQL
; KeAcquireQueuedSpinLock (
; IN KSPIN_LOCK_QUEUE_NUMBER Number
; )
;
; KIRQL
; KeAcquireQueuedSpinLockRaiseToSynch (
; IN KSPIN_LOCK_QUEUE_NUMBER Number
; )
;
; VOID
; KeAcquireInStackQueuedSpinLock (
; IN PKSPIN_LOCK SpinLock,
; IN PKLOCK_QUEUE_HANDLE LockHandle
; )
;
; VOID
; KeAcquireInStackQueuedSpinLockRaiseToSynch (
; IN PKSPIN_LOCK SpinLock,
; IN PKLOCK_QUEUE_HANDLE LockHandle
; )
;
; Routine Description:
;
; This function raises the current IRQL to DISPATCH/SYNCH level
; and acquires the specified queued spinlock.
;
; Arguments:
;
; Number (ecx) - Supplies the queued spinlock number.
;
; Return Value:
;
; The previous IRQL is returned as the function value.
;
;
; Routine Description:
;
; The Kx versions use a LOCK_QUEUE_HANDLE structure rather than
; LOCK_QUEUE structures in the PRCB. Old IRQL is stored in the
; LOCK_QUEUE_HANDLE.
;
; Arguments:
;
; SpinLock (ecx) Address of Actual Lock.
; LockHandle (edx) Address of lock context.
;
; Return Value:
;
; None. Actually returns OldIrql because common code is used
; for all implementations.
;
;--
; compile time assert sizeof(KSPIN_LOCK_QUEUE) == 8
.errnz (LOCK_QUEUE_HEADER_SIZE - 8)
align 16
; VOID
; KeAcquireInStackQueuedSpinLock (
; IN PKSPIN_LOCK SpinLock,
; IN PKLOCK_QUEUE_HANDLE LockHandle
; )
;
cPublicFastCall KeAcquireInStackQueuedSpinLock,2
cPublicFpo 0,0
ifndef NT_UP
mov [edx].LqhLock, ecx ; save spin lock in lock handle
mov dword ptr [edx].LqhNext, 0 ; zero next pointer
endif
push DISPATCH_LEVEL ; raise to DISPATCH_LEVEL
aqsl0:
pop ecx
push edx ; save LockHandle
fstCall KfRaiseIrql
pop edx ; restore lock handle
mov [edx].LqhOldIrql, al ; save old IRQL in lock handle
ifndef NT_UP
jmp short aqslrs10 ; continue in common code
else
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
fstRET KeAcquireInStackQueuedSpinLock
endif
fstENDP KeAcquireInStackQueuedSpinLock
; VOID
; KeAcquireInStackQueuedSpinLockRaiseToSynch (
; IN PKSPIN_LOCK SpinLock,
; IN PKLOCK_QUEUE_HANDLE LockHandle
; )
cPublicFastCall KeAcquireInStackQueuedSpinLockRaiseToSynch,2
cPublicFpo 0,0
ifndef NT_UP
mov [edx].LqhLock, ecx ; save spin lock in lock handle
mov dword ptr [edx].LqhNext, 0 ; zero next pointer
endif
push SYNCH_LEVEL ; raise to SYNCH_LEVEL
jmp short aqsl0
fstENDP KeAcquireInStackQueuedSpinLockRaiseToSynch
; KIRQL
; KeAcquireQueuedSpinLockRaiseToSynch (
; IN KSPIN_LOCK_QUEUE_NUMBER Number
; )
cPublicFastCall KeAcquireQueuedSpinLockRaiseToSynch,1
cPublicFpo 0,0
push ecx
mov ecx, SYNCH_LEVEL ; Raise to SYNCH_LEVEL
fstCall KfRaiseIrql
pop ecx
ifndef NT_UP
jmp short aqslrs ; continue in common code
else
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
fstRET KeAcquireQueuedSpinLockRaiseToSynch
endif
fstENDP KeAcquireQueuedSpinLockRaiseToSynch
; KIRQL
; KeAcquireQueuedSpinLock (
; IN KSPIN_LOCK_QUEUE_NUMBER Number
; )
cPublicFastCall KeAcquireQueuedSpinLock,1
cPublicFpo 0,0
; Get old IRQL and raise to DISPATCH_LEVEL
mov eax, PCR[PcIrql]
mov dword ptr PCR[PcIrql], DISPATCH_LEVEL
if DBG
cmp eax, DISPATCH_LEVEL
ja short aqsl
endif
ifndef NT_UP
aqslrs:
; Get address of Lock Queue entry
mov edx, PCR[PcPrcb] ; get address of PRCB
lea edx, [edx+ecx*8].PbLockQueue ; get &PRCB->LockQueue[Number]
; Get address of the actual lock.
aqslrs10:
mov ecx, [edx].LqLock
push eax ; save return value (old IRQL)
mov eax, edx ; save Lock Queue entry address
; Exchange the value of the lock with the address of this
; Lock Queue entry.
xchg [ecx], edx
cmp edx, 0 ; check if lock is held
jnz short @f ; jiff held
; note: the actual lock address will be word aligned, we use
; the bottom two bits as indicators, bit 0 is LOCK_QUEUE_WAIT,
; bit 1 is LOCK_QUEUE_OWNER.
or ecx, LOCK_QUEUE_OWNER ; mark self as lock owner
mov [eax].LqLock, ecx
; lock has been acquired, return.
aqsl20: pop eax ; restore return value
endif
ifdef IRQL_METRICS
inc HalRaiseIrqlCount
endif
fstRET KeAcquireQueuedSpinLock
ifndef NT_UP
@@:
; The lock is already held by another processor. Set the wait
; bit in this processor's Lock Queue entry, then set the next
; field in the Lock Queue entry of the last processor to attempt
; to acquire the lock (this is the address returned by the xchg
; above) to point to THIS processor's lock queue entry.
or ecx, LOCK_QUEUE_WAIT ; set lock bit
mov [eax].LqLock, ecx
mov [edx].LqNext, eax ; set previous acquirer's
; next field.
; Wait.
@@:
YIELD ; fire avoidance.
test [eax].LqLock, LOCK_QUEUE_WAIT ; check if still waiting
jz short aqsl20 ; jif lock acquired
jmp short @b ; else, continue waiting
endif
if DBG
aqsl: mov edx, DISPATCH_LEVEL
stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,eax,edx,ecx,8>
int 3
; never returns
endif
fstENDP KeAcquireQueuedSpinLock
page ,132
subttl "Release Queued SpinLock"
;++
;
; VOID
; KeReleaseInStackQueuedSpinLock (
; IN PKLOCK_QUEUE_HANDLE LockHandle
; )
;
; Routine Description:
;
; This function releases a queued spinlock and lowers the IRQL to
; its previous value.
;
; This differs from KeReleaseQueuedSpinLock in that this version
; uses a caller supplied lock context where that one uses a
; predefined lock context in the processor's PRCB.
;
; This version sets up a compatible register context and uses
; KeReleaseQueuedSpinLock to do the actual work.
;
; Arguments:
;
; LockHandle (ecx) - Address of Lock Queue Handle structure.
;
; Return Value:
;
; None.
;
;--
cPublicFastCall KeReleaseInStackQueuedSpinLock,1
cPublicFpo 0,0
ifndef NT_UP
movzx edx, byte ptr [ecx].LqhOldIrql ; get old irql
lea eax, [ecx].LqhNext ; get address of lock struct
jmp short rqsl10 ; continue in common code
else
movzx ecx, byte ptr [ecx].LqhOldIrql ; get old irql
jmp @KfLowerIrql@4 ; returns directly to our caller
endif
fstENDP KeReleaseInStackQueuedSpinLock
;++
;
; VOID
; KeReleaseQueuedSpinLock (
; IN KSPIN_LOCK_QUEUE_NUMBER Number,
; IN KIRQL OldIrql
; )
;
; Routine Description:
;
; This function releases a queued spinlock and lowers the IRQL to
; its previous value.
;
; Arguments:
;
; Number (ecx) - Supplies the queued spinlock number.
; OldIrql (dl) - Supplies the IRQL value to lower to.
;
; Return Value:
;
; None.
;
;--
cPublicFastCall KeReleaseQueuedSpinLock,2
cPublicFpo 0,0
.errnz (LOCK_QUEUE_OWNER - 2) ; error if not bit 1 for btr
ifndef NT_UP
; Get address of Lock Queue entry
mov eax, PCR[PcPrcb] ; get address of PRCB
lea eax, [eax+ecx*8].PbLockQueue ; get &PRCB->LockQueue[Number]
rqsl10:
push ebx ; need another register
cPublicFpo 0,1
; Clear the lock field in the Lock Queue entry.
mov ebx, [eax].LqNext
mov ecx, [eax].LqLock
; Quick check: If Lock Queue entry's Next field is not NULL,
; there is another waiter. Don't bother with ANY atomic ops
; in this case.
;
; Note: test clears CF and sets ZF appropriately, the following
; btr sets CF appropriately for the owner check.
test ebx, ebx
; clear the "I am owner" bit in the Lock entry.
btr ecx, 1 ; clear owner bit.
if DBG
jnc short rqsl98 ; bugcheck if was not set
; tests CF
endif
mov [eax].LqLock, ecx ; clear lock bit in queue entry
jnz short rqsl40 ; jif another processor waits
; tests ZF
; ebx contains zero here which will be used to set the new owner NULL
push eax ; save &PRCB->LockQueue[Number]
cPublicFpo 0,2
; Use compare exchange to attempt to clear the actual lock.
; If there are still no processors waiting for the lock when
; the compare exchange happens, the old contents of the lock
; should be the address of this lock entry (eax).
lock cmpxchg [ecx], ebx ; store 0 if no waiters
pop eax ; restore lock queue address
cPublicFpo 0,1
jnz short rqsl60 ; jif store failed
; The lock has been released. Lower IRQL and return to caller.
rqsl20:
pop ebx ; restore ebx
cPublicFpo 0,0
endif
movzx ecx, dl ; IRQL is 1st param KfLowerIrql
jmp @KfLowerIrql@4 ; returns directly to our caller
fstRET KeReleaseQueuedSpinLock
ifndef NT_UP
; Another processor is waiting on this lock. Hand the lock
; to that processor by getting the address of its LockQueue
; entry, turning ON its owner bit and OFF its wait bit.
rqsl40: xor [ebx].LqLock, (LOCK_QUEUE_OWNER+LOCK_QUEUE_WAIT)
; Done, the other processor now owns the lock, clear the next
; field in my LockQueue entry (to preserve the order for entering
; the queue again) and proceed to lower IRQL and return.
mov [eax].LqNext, 0
jmp short rqsl20
; We get here if another processor is attempting to acquire
; the lock but had not yet updated the next field in this
; processor's Queued Lock Next field. Wait for the next
; field to be updated.
rqsl60: mov ebx, [eax].LqNext
test ebx, ebx ; check if still 0
jnz short rqsl40 ; jif Next field now set.
YIELD ; wait a bit
jmp short rqsl60 ; continue waiting
if DBG
cPublicFpo 0,1
rqsl98: stdCall _KeBugCheckEx,<SPIN_LOCK_NOT_OWNED,ecx,eax,0,1>
int 3 ; so stacktrace works
endif
endif
fstENDP KeReleaseQueuedSpinLock
page ,132
subttl "Try to Acquire Queued SpinLock"
;++
;
; LOGICAL
; KeTryToAcquireQueuedSpinLock (
; IN KSPIN_LOCK_QUEUE_NUMBER Number,
; OUT PKIRQL OldIrql
; )
;
; LOGICAL
; KeTryToAcquireQueuedSpinLockRaiseToSynch (
; IN KSPIN_LOCK_QUEUE_NUMBER Number,
; OUT PKIRQL OldIrql
; )
;
; Routine Description:
;
; This function raises the current IRQL to DISPATCH/SYNCH level
; and attempts to acquire the specified queued spinlock. If the
; spinlock is already owned by another thread, IRQL is restored
; to its previous value and FALSE is returned.
;
; Arguments:
;
; Number (ecx) - Supplies the queued spinlock number.
; OldIrql (edx) - A pointer to the variable to receive the old
; IRQL.
;
; Return Value:
;
; TRUE if the lock was acquired, FALSE otherwise.
; N.B. ZF is set if FALSE returned, clear otherwise.
;
;--
align 16
cPublicFastCall KeTryToAcquireQueuedSpinLockRaiseToSynch,2
ifndef NT_UP
cPublicFpo 0,3
pushfd
else
cPublicFpo 0,2
endif
push edx
push SYNCH_LEVEL
jmp short taqsl10
fstENDP KeTryToAcquireQueuedSpinLockRaiseToSynch
cPublicFastCall KeTryToAcquireQueuedSpinLock,2
ifndef NT_UP
cPublicFpo 0,3
pushfd
else
cPublicFpo 0,2
endif
push edx
push DISPATCH_LEVEL
taqsl10:
ifndef NT_UP
; Attempt to get the lock with interrupts disabled, raising
; the priority in the interrupt controller only if acquisition
; is successful.
; Get address of Lock Queue entry
cli ; disable interrupts
mov edx, PCR[PcPrcb] ; get address of PRCB
lea edx, [edx+ecx*8].PbLockQueue ; get &PRCB->LockQueue[Number]
; Get address of the actual lock.
mov ecx, [edx].LqLock
cmp dword ptr [ecx], 0 ; check if already taken
jnz short taqsl60 ; jif already taken
xor eax, eax ; comparison value (not locked)
; Store the Lock Queue entry address in the lock ONLY if the
; current lock value is 0.
lock cmpxchg [ecx], edx
jnz short taqsl60
; Lock has been acquired.
; note: the actual lock address will be word aligned, we use
; the bottom two bits as indicators, bit 0 is LOCK_QUEUE_WAIT,
; bit 1 is LOCK_QUEUE_OWNER.
or ecx, LOCK_QUEUE_OWNER ; mark self as lock owner
mov [edx].LqLock, ecx
endif
pop ecx ; IRQL to ecx for RaiseIrql
ifndef NT_UP
cPublicFpo 0,2
else
cPublicFpo 0,1
endif
fstCall KfRaiseIrql ; Raise IRQL
pop edx
mov [edx], al ; save OldIrql
ifndef NT_UP
popfd ; restore interrupt state
endif
xor eax, eax
or eax, 1 ; return TRUE
fstRET KeTryToAcquireQueuedSpinLock
ifndef NT_UP
taqsl60:
; The lock is already held by another processor. Indicate
; failure to the caller.
pop eax ; pop new IRQL off stack
pop edx ; pop saved OldIrql address
popfd ; restore interrupt state
xor eax, eax ; return FALSE
fstRET KeTryToAcquireQueuedSpinLock
endif
fstENDP KeTryToAcquireQueuedSpinLock
page ,132
subttl "End System Interrupt"
;++
;
; VOID
; HalpEndSystemInterrupt
; IN KIRQL NewIrql,
; IN ULONG Vector
; )
;
; Routine Description:
;
; This routine is used to lower IRQL to the specified value.
; The IRQL and PIRQL will be updated accordingly. Also, this
; routine checks to see if any software interrupt should be
; generated. The following condition will cause software
; interrupt to be simulated:
; any software interrupt which has higher priority than
; current IRQL's is pending.
;
; NOTE: This routine simulates software interrupt as long as
; any pending SW interrupt level is higher than the current
; IRQL, even when interrupts are disabled.
;
; Arguments:
;
; NewIrql - the new irql to be set.
;
; Vector - Vector number of the interrupt
;
; Note that esp+12 is the beginning of interrupt/trap frame and upon
; entering to this routine the interrupts are off.
;
; Return Value:
;
; None.
;
;--
HeiNewIrql equ [esp + 4]
cPublicProc _HalEndSystemInterrupt ,2
cPublicFpo 2, 0
movzx ecx, byte ptr HeiNewIrql; get new irql value
cmp dword ptr PCR[PcIrql],DISPATCH_LEVEL ; Software level?
jbe short Hei02 ; no, go set 8259 hw
mov eax, KiI8259MaskTable[ecx*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
Hei02:
mov PCR[PcIrql], ecx ; set the new irql
mov eax, PCR[PcIRR] ; get SW interrupt request register
mov al, SWInterruptLookUpTable[eax] ; get the highest pending
; software interrupt level
cmp al, cl ; Is highest SW int level > irql?
ja short Hei10 ; yes, go simulate interrupt
stdRET _HalEndSystemInterrupt ; cRetURN
; When we come to Hei10, (eax) = soft interrupt index
Hei10: add esp, 12 ; esp = trap frame
jmp SWInterruptHandlerTable2[eax*4] ; SIMULATE INTERRUPT
; to the appropriate handler
stdENDP _HalEndSystemInterrupt
;++
;
; VOID
; HalpEndSoftwareInterrupt
; IN KIRQL NewIrql,
; )
;
; Routine Description:
;
; This routine is used to lower IRQL from software interrupt
; level to the specified value.
; The IRQL and PIRQL will be updated accordingly. Also, this
; routine checks to see if any software interrupt should be
; generated. The following condition will cause software
; interrupt to be simulated:
; any software interrupt which has higher priority than
; current IRQL's is pending.
;
; NOTE: This routine simulates software interrupt as long as
; any pending SW interrupt level is higher than the current
; IRQL, even when interrupts are disabled.
;
; Arguments:
;
; NewIrql - the new irql to be set.
;
; Note that esp+8 is the beginning of interrupt/trap frame and upon
; entering to this routine the interrupts are off.
;
; Return Value:
;
; None.
;
;--
HesNewIrql equ [esp + 4]
cPublicProc _HalpEndSoftwareInterrupt ,1
cPublicFpo 1, 0
movzx ecx, byte ptr HesNewIrql; get new irql value
cmp dword ptr PCR[PcIrql],DISPATCH_LEVEL ; Software level?
jbe short Hes02 ; no, go set 8259 hw
mov eax, KiI8259MaskTable[ecx*4]; get pic masks for the new irql
or eax, PCR[PcIDR] ; mask irqs which are disabled
SET_8259_MASK ; set 8259 masks
Hes02:
mov PCR[PcIrql], ecx ; set the new irql
mov eax, PCR[PcIRR] ; get SW interrupt request register
mov al, SWInterruptLookUpTable[eax] ; get the highest pending
; software interrupt level
cmp al, cl ; Is highest SW int level > irql?
ja short Hes10 ; yes, go simulate interrupt
stdRET _HalpEndSoftwareInterrupt ; cRetURN
; When we come to Hes10, (eax) = soft interrupt index
Hes10: add esp, 8
jmp SWInterruptHandlerTable2[eax*4] ; SIMULATE INTERRUPT
; to the appropriate handler
stdENDP _HalpEndSoftwareInterrupt
page ,132
subttl "Get current irql"
;++
;
; KIRQL
; KeGetCurrentIrql (VOID)
;
; Routine Description:
;
; This routine returns to current IRQL.
;
; Arguments:
;
; None.
;
; Return Value:
;
; The current IRQL.
;
;--
cPublicProc _KeGetCurrentIrql ,0
cPublicFpo 0, 0
mov eax, dword ptr PCR[PcIrql] ; Current irql is in the PCR
stdRET _KeGetCurrentIrql
stdENDP _KeGetCurrentIrql
;++
;
; KIRQL
; HalpDisableAllInterrupts (VOID)
;
; Routine Description:
;
; This routine is called during a system crash. The hal needs all
; interrupts disabled.
;
; Arguments:
;
; None.
;
; Return Value:
;
; None - all interrupts are masked off
;
;--
cPublicProc _HalpDisableAllInterrupts,0
cPublicFpo 0, 0
;
; Raising to HIGH_LEVEL disables interrupts for the microchannel HAL
;
mov ecx, HIGH_LEVEL
fstCall KfRaiseIrql
stdRET _HalpDisableAllInterrupts
stdENDP _HalpDisableAllInterrupts
;++
;
; VOID
; HalpReenableInterrupts (
; IN KIRQL Irql
; )
;
; Routine Description:
;
; Restores irql level.
;
; Arguments:
;
; Irql - Irql state to restore to.
;
; Return Value:
;
; None
;
;--
HriNewIrql equ [esp + 4]
cPublicProc _HalpReenableInterrupts,1
cPublicFpo 1, 0
movzx ecx, byte ptr HriNewIrql
fstCall KfLowerIrql
stdRET _HalpReenableInterrupts
stdENDP _HalpReenableInterrupts
page ,132
subttl "Interrupt Controller Chip Initialization"
;++
;
; VOID
; HalpInitializePICs (
; BOOLEAN EnableInterrupts
; )
;
; Routine Description:
;
; This routine sends the 8259 PIC initialization commands and
; masks all the interrupts on 8259s.
;
; Arguments:
;
; EnableInterrupts - If this is true, then this function will
; explicitly enable interrupts at the end,
; as it always did in the past. If this
; is false, then it will preserve the interrupt
; flag.
;
; Return Value:
;
; None.
;
;--
EnableInterrupts equ [esp + 0ch]
cPublicProc _HalpInitializePICs ,1
push esi ; save caller's esi
pushfd
cli ; disable interrupt
lea esi, PICsInitializationString
test _HalpBusType, MACHINE_TYPE_MCA
jz short Hip00
; Is this a PS2 or PS700 series machine?
in al, 07fh ; get PD700 ID byte
and al, 0F0h ; Mask high nibble
cmp al, 0A0h ; Is the ID Ax?
jz short Hip00
cmp al, 090h ; Or an 9X?
jz short Hip00 ; Yes, it's a 700
lea esi, PS2PICsInitializationString
Hip00:
lodsw ; (AX) = PIC port 0 address
Hip10: movzx edx, ax
outsb ; output ICW1
IODelay
inc edx ; (DX) = PIC port 1 address
outsb ; output ICW2
IODelay
outsb ; output ICW3
IODelay
outsb ; output ICW4
IODelay
mov al, 0FFH ; mask all 8259 irqs
out dx,al ; write mask to PIC
lodsw
cmp ax, 0 ; end of init string?
jne short Hip10 ; go init next PIC
mov al, EnableInterrupts
.if (al != 0)
or [esp], EFLAGS_INTERRUPT_MASK ; enable interrupts
.endif
popfd
pop esi ; restore caller's esi
stdRET _HalpInitializePICs
stdENDP _HalpInitializePICs
_TEXT ends
end
|
#include <iostream>
#include <string>
using namespace std;
int board[8][8] = {
{ 2,3,4,4,4,4,3,2 },
{ 3,4,6,6,6,6,4,3 },
{ 4,6,8,8,8,8,6,4 },
{ 4,6,8,8,8,8,6,4 },
{ 4,6,8,8,8,8,6,4 },
{ 4,6,8,8,8,8,6,4 },
{ 3,4,6,6,6,6,4,3 },
{ 2,3,4,4,4,4,3,2 } };
int main() {
int a;
string s;
cin >> a;
for (int i = 0; i < a; i++) {
cin >> s;
cout << board[s[0] - 'a'][s[1] - '1'] << endl;
}
return 0;
}
|
// Std. Includes
#include <string>
// GLEW
#define GLEW_STATIC
#include <GL/glew.h>
// GLFW
#include <GLFW/glfw3.h>
// GL includes
#include "Shader.h"
#include "Camera.h"
// GLM Mathemtics
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
// Other Libs
#include <SOIL/SOIL.h>
// Properties
GLuint screenWidth = 800, screenHeight = 600;
// Function prototypes
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
void Do_Movement();
GLuint loadTexture(GLchar* path);
// Camera
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
bool keys[1024];
GLfloat lastX = 400, lastY = 300;
bool firstMouse = true;
GLfloat deltaTime = 0.0f;
GLfloat lastFrame = 0.0f;
// The MAIN function, from here we start our application and run our Game loop
int main()
{
// Init GLFW
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow* window = glfwCreateWindow(screenWidth, screenHeight, "LearnOpenGL", nullptr, nullptr); // Windowed
glfwMakeContextCurrent(window);
// Set the required callback functions
glfwSetKeyCallback(window, key_callback);
glfwSetCursorPosCallback(window, mouse_callback);
glfwSetScrollCallback(window, scroll_callback);
// Options
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
// Initialize GLEW to setup the OpenGL Function pointers
glewExperimental = GL_TRUE;
glewInit();
// Define the viewport dimensions
glViewport(0, 0, screenWidth, screenHeight);
// Setup some OpenGL options
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS); // Set to always pass the depth test (same effect as glDisable(GL_DEPTH_TEST))
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// Setup and compile our shaders
Shader shader("./advanced.vs", "./advanced.frag");
Shader shaderSingleColor("./advanced.vs", "./shaderSingleColor.frag");
#pragma region "object_initialization"
// Set the object data (buffers, vertex attributes)
GLfloat cubeVertices[] = {
// Positions // Texture Coords
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f
};
GLfloat planeVertices[] = {
// Positions // Texture Coords (note we set these higher than 1 that together with GL_REPEAT as texture wrapping mode will cause the floor texture to repeat)
5.0f, -0.5f, 5.0f, 2.0f, 0.0f,
-5.0f, -0.5f, 5.0f, 0.0f, 0.0f,
-5.0f, -0.5f, -5.0f, 0.0f, 2.0f,
5.0f, -0.5f, 5.0f, 2.0f, 0.0f,
-5.0f, -0.5f, -5.0f, 0.0f, 2.0f,
5.0f, -0.5f, -5.0f, 2.0f, 2.0f
};
// Setup cube VAO
GLuint cubeVAO, cubeVBO;
glGenVertexArrays(1, &cubeVAO);
glGenBuffers(1, &cubeVBO);
glBindVertexArray(cubeVAO);
glBindBuffer(GL_ARRAY_BUFFER, cubeVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), &cubeVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
glBindVertexArray(0);
// Setup plane VAO
GLuint planeVAO, planeVBO;
glGenVertexArrays(1, &planeVAO);
glGenBuffers(1, &planeVBO);
glBindVertexArray(planeVAO);
glBindBuffer(GL_ARRAY_BUFFER, planeVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(planeVertices), &planeVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
glBindVertexArray(0);
// Load textures
GLuint cubeTexture = loadTexture("./container.jpg");
GLuint floorTexture = loadTexture("./wall.jpg");
#pragma endregion
// Game loop
while(!glfwWindowShouldClose(window))
{
// Set frame time
GLfloat currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
// Check and call events
glfwPollEvents();
Do_Movement();
// Clear the colorbuffer
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// Set uniforms
shaderSingleColor.Use();
glm::mat4 model;
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(camera.Zoom, (float)screenWidth/(float)screenHeight, 0.1f, 100.0f);
glUniformMatrix4fv(glGetUniformLocation(shaderSingleColor.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));
glUniformMatrix4fv(glGetUniformLocation(shaderSingleColor.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
shader.Use();
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "view"), 1, GL_FALSE, glm::value_ptr(view));
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
// Draw floor as normal, we only care about the containers. The floor should NOT fill the stencil buffer so we set its mask to 0x00
glStencilMask(0x00);
// Floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
model = glm::mat4();
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
// == =============
// 1st. Render pass, draw objects as normal, filling the stencil buffer
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilMask(0xFF);
// Cubes
glBindVertexArray(cubeVAO);
glBindTexture(GL_TEXTURE_2D, cubeTexture);
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glDrawArrays(GL_TRIANGLES, 0, 36);
glBindVertexArray(0);
// == =============
// 2nd. Render pass, now draw slightly scaled versions of the objects, this time disabling stencil writing.
// Because stencil buffer is now filled with several 1s. The parts of the buffer that are 1 are now not drawn, thus only drawing
// the objects' size differences, making it look like borders.
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
glStencilMask(0x00);
glDisable(GL_DEPTH_TEST);
shaderSingleColor.Use();
GLfloat scale = 1.1;
// Cubes
glBindVertexArray(cubeVAO);
//glBindTexture(GL_TEXTURE_2D, cubeTexture); // no need
model = glm::mat4();
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
model = glm::scale(model, glm::vec3(scale, scale, scale));
glUniformMatrix4fv(glGetUniformLocation(shaderSingleColor.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
model = glm::scale(model, glm::vec3(scale, scale, scale));
glUniformMatrix4fv(glGetUniformLocation(shaderSingleColor.Program, "model"), 1, GL_FALSE, glm::value_ptr(model));
glDrawArrays(GL_TRIANGLES, 0, 36);
glBindVertexArray(0);
glStencilMask(0xFF);
glEnable(GL_DEPTH_TEST);
// Swap the buffers
glfwSwapBuffers(window);
}
glfwTerminate();
return 0;
}
// This function loads a texture from file. Note: texture loading functions like these are usually
// managed by a 'Resource Manager' that manages all resources (like textures, models, audio).
// For learning purposes we'll just define it as a utility function.
GLuint loadTexture(GLchar* path)
{
//Generate texture ID and load texture data
GLuint textureID;
glGenTextures(1, &textureID);
int width,height;
unsigned char* image = SOIL_load_image(path, &width, &height, 0, SOIL_LOAD_RGB);
// Assign texture to ID
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glGenerateMipmap(GL_TEXTURE_2D);
// Parameters
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
SOIL_free_image_data(image);
return textureID;
}
#pragma region "User input"
// Moves/alters the camera positions based on user input
void Do_Movement()
{
// Camera controls
if(keys[GLFW_KEY_W])
camera.ProcessKeyboard(FORWARD, deltaTime);
if(keys[GLFW_KEY_S])
camera.ProcessKeyboard(BACKWARD, deltaTime);
if(keys[GLFW_KEY_A])
camera.ProcessKeyboard(LEFT, deltaTime);
if(keys[GLFW_KEY_D])
camera.ProcessKeyboard(RIGHT, deltaTime);
}
// Is called whenever a key is pressed/released via GLFW
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
{
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
if(action == GLFW_PRESS)
keys[key] = true;
else if(action == GLFW_RELEASE)
keys[key] = false;
}
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
{
if(firstMouse)
{
lastX = xpos;
lastY = ypos;
firstMouse = false;
}
GLfloat xoffset = xpos - lastX;
GLfloat yoffset = lastY - ypos;
lastX = xpos;
lastY = ypos;
camera.ProcessMouseMovement(xoffset, yoffset);
}
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
camera.ProcessMouseScroll(yoffset);
}
#pragma endregion
|
; A111733: a(n) = a(n-1) + a(n-2) + 7 where a(0) = a(1) = 1.
; 1,1,9,17,33,57,97,161,265,433,705,1145,1857,3009,4873,7889,12769,20665,33441,54113,87561,141681,229249,370937,600193,971137,1571337,2542481,4113825,6656313,10770145,17426465,28196617,45623089,73819713,119442809
sub $0,1
mov $1,1
mov $2,1
lpb $0,1
sub $0,1
mov $3,$2
mov $2,$1
add $1,$3
lpe
sub $1,1
mul $1,8
add $1,1
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Stack.asm
;
; Abstract:
;
; Switch the stack from temporary memory to permenent memory.
;
;------------------------------------------------------------------------------
.586p
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; SecSwitchStack (
; UINT32 TemporaryMemoryBase,
; UINT32 PermenentMemoryBase
; );
;------------------------------------------------------------------------------
SecSwitchStack PROC
;
; Save three register: eax, ebx, ecx
;
push eax
push ebx
push ecx
push edx
;
; !!CAUTION!! this function address's is pushed into stack after
; migration of whole temporary memory, so need save it to permenent
; memory at first!
;
mov ebx, [esp + 20] ; Save the first parameter
mov ecx, [esp + 24] ; Save the second parameter
;
; Save this function's return address into permenent memory at first.
; Then, Fixup the esp point to permenent memory
;
mov eax, esp
sub eax, ebx
add eax, ecx
mov edx, dword ptr [esp] ; copy pushed register's value to permenent memory
mov dword ptr [eax], edx
mov edx, dword ptr [esp + 4]
mov dword ptr [eax + 4], edx
mov edx, dword ptr [esp + 8]
mov dword ptr [eax + 8], edx
mov edx, dword ptr [esp + 12]
mov dword ptr [eax + 12], edx
mov edx, dword ptr [esp + 16] ; Update this function's return address into permenent memory
mov dword ptr [eax + 16], edx
mov esp, eax ; From now, esp is pointed to permenent memory
;
; Fixup the ebp point to permenent memory
;
mov eax, ebp
sub eax, ebx
add eax, ecx
mov ebp, eax ; From now, ebp is pointed to permenent memory
;
; Fixup callee's ebp point for PeiDispatch
;
mov eax, dword ptr [ebp]
sub eax, ebx
add eax, ecx
mov dword ptr [ebp], eax ; From now, Temporary's PPI caller's stack is in permenent memory
pop edx
pop ecx
pop ebx
pop eax
ret
SecSwitchStack ENDP
END
|
;*******************************************************************************
;memcpy.asm - contains memcpy and memmove routines
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
; memcpy() copies a source memory buffer to a destination buffer.
; Overlapping buffers are not treated specially, so propogation may occur.
; memmove() copies a source memory buffer to a destination buffer.
; Overlapping buffers are treated specially, to avoid propogation.
;
;*******************************************************************************
include hal.inc
;***
;memcpy - Copy source buffer to destination buffer
;
;Purpose:
; memcpy() copies a source memory buffer to a destination memory buffer.
; This routine does NOT recognize overlapping buffers, and thus can lead
; to propogation.
; For cases where propogation must be avoided, memmove() must be used.
;
; Algorithm:
;
; void * memcpy(void * dst, void * src, size_t count)
; {
; void * ret = dst;
;
; /*
; * copy from lower addresses to higher addresses
; */
; while (count--)
; *dst++ = *src++;
;
; return(ret);
; }
;
;memmove - Copy source buffer to destination buffer
;
;Purpose:
; memmove() copies a source memory buffer to a destination memory buffer.
; This routine recognize overlapping buffers to avoid propogation.
; For cases where propogation is not a problem, memcpy() can be used.
;
; Algorithm:
;
; void * memmove(void * dst, void * src, size_t count)
; {
; void * ret = dst;
;
; if (dst <= src || dst >= (src + count)) {
; /*
; * Non-Overlapping Buffers
; * copy from lower addresses to higher addresses
; */
; while (count--)
; *dst++ = *src++;
; }
; else {
; /*
; * Overlapping Buffers
; * copy from higher addresses to lower addresses
; */
; dst += count - 1;
; src += count - 1;
;
; while (count--)
; *dst-- = *src--;
; }
;
; return(ret);
; }
;
;
;Entry:
; void *dst = pointer to destination buffer
; const void *src = pointer to source buffer
; size_t count = number of bytes to copy
;
;Exit:
; Returns a pointer to the destination buffer in AX/DX:AX
;
;Uses:
; CX, DX
;
;Exceptions:
;*******************************************************************************
% public memcpy
memcpy proc NEAR C \
dst:ptr byte, \
src:ptr byte, \
count:DWORD
; destination pointer
; source pointer
; number of bytes to copy
; push ebp ;U - save old frame pointer
; mov ebp, esp ;V - set new frame pointer
push edi ;U - save edi
push esi ;V - save esi
mov esi,[src] ;U - esi = source
mov ecx,[count] ;V - ecx = number of bytes to move
mov edi,[dst] ;U - edi = dest
;
; Check for overlapping buffers:
; If (dst <= src) Or (dst >= src + Count) Then
; Do normal (Upwards) Copy
; Else
; Do Downwards Copy to avoid propagation
;
mov eax,ecx ;V - eax = byte count...
mov edx,ecx ;U - edx = byte count...
add eax,esi ;V - eax = point past source end
cmp edi,esi ;U - dst <= src ?
jbe short CopyUp ;V - yes, copy toward higher addresses
cmp edi,eax ;U - dst < (src + count) ?
jb CopyDown ;V - yes, copy toward lower addresses
;
; Copy toward higher addresses.
;
;
; The algorithm for forward moves is to align the destination to a dword
; boundary and so we can move dwords with an aligned destination. This
; occurs in 3 steps.
;
; - move x = ((4 - Dest & 3) & 3) bytes
; - move y = ((L-x) >> 2) dwords
; - move (L - x - y*4) bytes
;
CopyUp:
test edi,11b ;U - destination dword aligned?
jnz short CopyLeadUp ;V - if we are not dword aligned already, align
shr ecx,2 ;U - shift down to dword count
and edx,11b ;V - trailing byte count
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindUp ;V - if so, then jump
rep movsd ;N - move all of our dwords
jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
;
; Code to do optimal memory copies for non-dword-aligned destinations.
;
; The following length check is done for two reasons:
;
; 1. to ensure that the actual move length is greater than any possiale
; alignment move, and
;
; 2. to skip the multiple move logic for small moves where it would
; be faster to move the bytes with one instruction.
;
align @WordSize
CopyLeadUp:
mov eax,edi ;U - get destination offset
mov edx,11b ;V - prepare for mask
sub ecx,4 ;U - check for really short string - sub for adjust
jb short ByteCopyUp ;V - branch to just copy bytes
and eax,11b ;U - get offset within first dword
add ecx,eax ;V - update size after leading bytes copied
jmp dword ptr LeadUpVec[eax*4-4] ;N - process leading bytes
align @WordSize
ByteCopyUp:
jmp dword ptr TrailUpVec[ecx*4+16] ;N - process just bytes
align @WordSize
CopyUnwindUp:
jmp dword ptr UnwindUpVec[ecx*4] ;N - unwind dword copy
align @WordSize
LeadUpVec dd LeadUp1, LeadUp2, LeadUp3
align @WordSize
LeadUp1:
and edx,ecx ;U - trailing byte count
mov al,[esi] ;V - get first byte from source
mov [edi],al ;U - write second byte to destination
mov al,[esi+1] ;V - get second byte from source
mov [edi+1],al ;U - write second byte to destination
mov al,[esi+2] ;V - get third byte from source
shr ecx,2 ;U - shift down to dword count
mov [edi+2],al ;V - write third byte to destination
add esi,3 ;U - advance source pointer
add edi,3 ;V - advance destination pointer
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindUp ;V - if so, then jump
rep movsd ;N - move all of our dwords
jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
align @WordSize
LeadUp2:
and edx,ecx ;U - trailing byte count
mov al,[esi] ;V - get first byte from source
mov [edi],al ;U - write second byte to destination
mov al,[esi+1] ;V - get second byte from source
shr ecx,2 ;U - shift down to dword count
mov [edi+1],al ;V - write second byte to destination
add esi,2 ;U - advance source pointer
add edi,2 ;V - advance destination pointer
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindUp ;V - if so, then jump
rep movsd ;N - move all of our dwords
jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
align @WordSize
LeadUp3:
and edx,ecx ;U - trailing byte count
mov al,[esi] ;V - get first byte from source
mov [edi],al ;U - write second byte to destination
add esi,1 ;V - advance source pointer
shr ecx,2 ;U - shift down to dword count
add edi,1 ;V - advance destination pointer
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindUp ;V - if so, then jump
rep movsd ;N - move all of our dwords
jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
align @WordSize
UnwindUpVec dd UnwindUp0, UnwindUp1, UnwindUp2, UnwindUp3
dd UnwindUp4, UnwindUp5, UnwindUp6, UnwindUp7
UnwindUp7:
mov eax,[esi+ecx*4-28] ;U - get dword from source
;V - spare
mov [edi+ecx*4-28],eax ;U - put dword into destination
UnwindUp6:
mov eax,[esi+ecx*4-24] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-24],eax ;U - put dword into destination
UnwindUp5:
mov eax,[esi+ecx*4-20] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-20],eax ;U - put dword into destination
UnwindUp4:
mov eax,[esi+ecx*4-16] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-16],eax ;U - put dword into destination
UnwindUp3:
mov eax,[esi+ecx*4-12] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-12],eax ;U - put dword into destination
UnwindUp2:
mov eax,[esi+ecx*4-8] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-8],eax ;U - put dword into destination
UnwindUp1:
mov eax,[esi+ecx*4-4] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4-4],eax ;U - put dword into destination
lea eax,[ecx*4] ;V - compute update for pointer
add esi,eax ;U - update source pointer
add edi,eax ;V - update destination pointer
UnwindUp0:
jmp dword ptr TrailUpVec[edx*4] ;N - process trailing bytes
;-----------------------------------------------------------------------------
align @WordSize
TrailUpVec dd TrailUp0, TrailUp1, TrailUp2, TrailUp3
align @WordSize
TrailUp0:
mov eax,[dst] ;U - return pointer to destination
pop esi ;V - restore esi
pop edi ;U - restore edi
;V - spare
ret
align @WordSize
TrailUp1:
mov al,[esi] ;U - get byte from source
;V - spare
mov [edi],al ;U - put byte in destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
align @WordSize
TrailUp2:
mov al,[esi] ;U - get first byte from source
;V - spare
mov [edi],al ;U - put first byte into destination
mov al,[esi+1] ;V - get second byte from source
mov [edi+1],al ;U - put second byte into destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
align @WordSize
TrailUp3:
mov al,[esi] ;U - get first byte from source
;V - spare
mov [edi],al ;U - put first byte into destination
mov al,[esi+1] ;V - get second byte from source
mov [edi+1],al ;U - put second byte into destination
mov al,[esi+2] ;V - get third byte from source
mov [edi+2],al ;U - put third byte into destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
;
; Copy down to avoid propogation in overlapping buffers.
;
align @WordSize
CopyDown:
lea esi,[esi+ecx-4] ;U - point to 4 bytes before src buffer end
lea edi,[edi+ecx-4] ;V - point to 4 bytes before dest buffer end
;
; See if the destination start is dword aligned
;
test edi,11b ;U - test if dword aligned
jnz short CopyLeadDown ;V - if not, jump
shr ecx,2 ;U - shift down to dword count
and edx,11b ;V - trailing byte count
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindDown ;V - if so, then jump
std ;N - set direction flag
rep movsd ;N - move all of our dwords
cld ;N - clear direction flag back
jmp dword ptr TrailDownVec[edx*4] ;N - process trailing bytes
align @WordSize
CopyUnwindDown:
neg ecx ;U - negate dword count for table merging
;V - spare
jmp dword ptr UnwindDownVec[ecx*4+28] ;N - unwind copy
align @WordSize
CopyLeadDown:
mov eax,edi ;U - get destination offset
mov edx,11b ;V - prepare for mask
cmp ecx,4 ;U - check for really short string
jb short ByteCopyDown ;V - branch to just copy bytes
and eax,11b ;U - get offset within first dword
sub ecx,eax ;U - to update size after lead copied
jmp dword ptr LeadDownVec[eax*4-4] ;N - process leading bytes
align @WordSize
ByteCopyDown:
jmp dword ptr TrailDownVec[ecx*4] ;N - process just bytes
align @WordSize
LeadDownVec dd LeadDown1, LeadDown2, LeadDown3
align @WordSize
LeadDown1:
mov al,[esi+3] ;U - load first byte
and edx,ecx ;V - trailing byte count
mov [edi+3],al ;U - write out first byte
sub esi,1 ;V - point to last src dword
shr ecx,2 ;U - shift down to dword count
sub edi,1 ;V - point to last dest dword
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindDown ;V - if so, then jump
std ;N - set direction flag
rep movsd ;N - move all of our dwords
cld ;N - clear direction flag
jmp dword ptr TrailDownVec[edx*4] ;N - process trailing bytes
align @WordSize
LeadDown2:
mov al,[esi+3] ;U - load first byte
and edx,ecx ;V - trailing byte count
mov [edi+3],al ;U - write out first byte
mov al,[esi+2] ;V - get second byte from source
shr ecx,2 ;U - shift down to dword count
mov [edi+2],al ;V - write second byte to destination
sub esi,2 ;U - point to last src dword
sub edi,2 ;V - point to last dest dword
cmp ecx,8 ;U - test if small enough for unwind copy
jb short CopyUnwindDown ;V - if so, then jump
std ;N - set direction flag
rep movsd ;N - move all of our dwords
cld ;N - clear direction flag
jmp dword ptr TrailDownVec[edx*4] ;N - process trailing bytes
align @WordSize
LeadDown3:
mov al,[esi+3] ;U - load first byte
and edx,ecx ;V - trailing byte count
mov [edi+3],al ;U - write out first byte
mov al,[esi+2] ;V - get second byte from source
mov [edi+2],al ;U - write second byte to destination
mov al,[esi+1] ;V - get third byte from source
shr ecx,2 ;U - shift down to dword count
mov [edi+1],al ;V - write third byte to destination
sub esi,3 ;U - point to last src dword
sub edi,3 ;V - point to last dest dword
cmp ecx,8 ;U - test if small enough for unwind copy
jb CopyUnwindDown ;V - if so, then jump
std ;N - set direction flag
rep movsd ;N - move all of our dwords
cld ;N - clear direction flag
jmp dword ptr TrailDownVec[edx*4] ;N - process trailing bytes
;------------------------------------------------------------------
align @WordSize
UnwindDownVec dd UnwindDown7, UnwindDown6, UnwindDown5, UnwindDown4
dd UnwindDown3, UnwindDown2, UnwindDown1, UnwindDown0
UnwindDown7:
mov eax,[esi+ecx*4+28] ;U - get dword from source
;V - spare
mov [edi+ecx*4+28],eax ;U - put dword into destination
UnwindDown6:
mov eax,[esi+ecx*4+24] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+24],eax ;U - put dword into destination
UnwindDown5:
mov eax,[esi+ecx*4+20] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+20],eax ;U - put dword into destination
UnwindDown4:
mov eax,[esi+ecx*4+16] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+16],eax ;U - put dword into destination
UnwindDown3:
mov eax,[esi+ecx*4+12] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+12],eax ;U - put dword into destination
UnwindDown2:
mov eax,[esi+ecx*4+8] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+8],eax ;U - put dword into destination
UnwindDown1:
mov eax,[esi+ecx*4+4] ;U(entry)/V(not) - get dword from source
;V(entry) - spare
mov [edi+ecx*4+4],eax ;U - put dword into destination
lea eax,[ecx*4] ;V - compute update for pointer
add esi,eax ;U - update source pointer
add edi,eax ;V - update destination pointer
UnwindDown0:
jmp dword ptr TrailDownVec[edx*4] ;N - process trailing bytes
;-----------------------------------------------------------------------------
align @WordSize
TrailDownVec dd TrailDown0, TrailDown1, TrailDown2, TrailDown3
align @WordSize
TrailDown0:
mov eax,[dst] ;U - return pointer to destination
;V - spare
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
align @WordSize
TrailDown1:
mov al,[esi+3] ;U - get byte from source
;V - spare
mov [edi+3],al ;U - put byte in destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
align @WordSize
TrailDown2:
mov al,[esi+3] ;U - get first byte from source
;V - spare
mov [edi+3],al ;U - put first byte into destination
mov al,[esi+2] ;V - get second byte from source
mov [edi+2],al ;U - put second byte into destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
align @WordSize
TrailDown3:
mov al,[esi+3] ;U - get first byte from source
;V - spare
mov [edi+3],al ;U - put first byte into destination
mov al,[esi+2] ;V - get second byte from source
mov [edi+2],al ;U - put second byte into destination
mov al,[esi+1] ;V - get third byte from source
mov [edi+1],al ;U - put third byte into destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
ret
memcpy endp
memmove proc NEAR C\
dst:ptr byte, \
src:ptr byte, \
count:DWORD
jmp memcpy
memmove endp
end
|
; A181134: Sum of 13th powers: a(n) = Sum_{j=0..n} j^13.
; Submitted by Christian Krause
; 0,1,8193,1602516,68711380,1289414505,14350108521,111239118928,660994932816,3202860761145,13202860761145,47725572905076,154718778284148,457593884876401,1251308658130545,3197503726489920,7701103353860416,17605681386766353,38428646252437521,80481629714694580,162401629714694580,316874007453814041,599684065336896793,1103720427273364176,1980208765738722000,3470324885123487625,5951477758327224201,10004032911346200468,16506144333844148116,26766773046802750305,42710003046802750305,67127549344247792896
add $0,1
lpb $0
sub $0,1
mov $2,$0
pow $2,13
add $1,$2
lpe
mov $0,$1
|
//
// Copyright 2020 gRPC authors.
//
// 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.
//
// This filter reads GRPC_ARG_SERVICE_CONFIG and populates ServiceConfigCallData
// in the call context per call for direct channels.
#include <grpc/support/port_platform.h>
#include <new>
#include <string>
#include <utility>
#include "absl/types/optional.h"
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/channel/context.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/service_config/service_config.h"
#include "src/core/lib/service_config/service_config_call_data.h"
#include "src/core/lib/service_config/service_config_impl.h"
#include "src/core/lib/service_config/service_config_parser.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
namespace grpc_core {
namespace {
class ServiceConfigChannelArgChannelData {
public:
explicit ServiceConfigChannelArgChannelData(
const grpc_channel_element_args* args) {
const char* service_config_str = grpc_channel_args_find_string(
args->channel_args, GRPC_ARG_SERVICE_CONFIG);
if (service_config_str != nullptr) {
grpc_error_handle service_config_error = GRPC_ERROR_NONE;
auto service_config = ServiceConfigImpl::Create(
args->channel_args, service_config_str, &service_config_error);
if (GRPC_ERROR_IS_NONE(service_config_error)) {
service_config_ = std::move(service_config);
} else {
gpr_log(GPR_ERROR, "%s",
grpc_error_std_string(service_config_error).c_str());
}
GRPC_ERROR_UNREF(service_config_error);
}
}
RefCountedPtr<ServiceConfig> service_config() const {
return service_config_;
}
private:
RefCountedPtr<ServiceConfig> service_config_;
};
class ServiceConfigChannelArgCallData {
public:
ServiceConfigChannelArgCallData(
RefCountedPtr<ServiceConfig> service_config,
const ServiceConfigParser::ParsedConfigVector* method_config,
const grpc_call_element_args* args)
: call_context_(args->context),
service_config_call_data_(std::move(service_config), method_config,
/*call_attributes=*/{}) {
GPR_DEBUG_ASSERT(args->context != nullptr);
// No need to set the destroy function, since it will be cleaned up
// when this filter is destroyed in the filter stack.
args->context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value =
&service_config_call_data_;
}
~ServiceConfigChannelArgCallData() {
// Remove the entry from call context, just in case anyone above us
// tries to look at it during call stack destruction.
call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value = nullptr;
}
private:
grpc_call_context_element* call_context_;
ServiceConfigCallData service_config_call_data_;
};
grpc_error_handle ServiceConfigChannelArgInitCallElem(
grpc_call_element* elem, const grpc_call_element_args* args) {
auto* chand =
static_cast<ServiceConfigChannelArgChannelData*>(elem->channel_data);
auto* calld = static_cast<ServiceConfigChannelArgCallData*>(elem->call_data);
RefCountedPtr<ServiceConfig> service_config = chand->service_config();
const ServiceConfigParser::ParsedConfigVector* method_config = nullptr;
if (service_config != nullptr) {
method_config = service_config->GetMethodParsedConfigVector(args->path);
}
new (calld) ServiceConfigChannelArgCallData(std::move(service_config),
method_config, args);
return GRPC_ERROR_NONE;
}
void ServiceConfigChannelArgDestroyCallElem(
grpc_call_element* elem, const grpc_call_final_info* /* final_info */,
grpc_closure* /* then_schedule_closure */) {
ServiceConfigChannelArgCallData* calld =
static_cast<ServiceConfigChannelArgCallData*>(elem->call_data);
calld->~ServiceConfigChannelArgCallData();
}
grpc_error_handle ServiceConfigChannelArgInitChannelElem(
grpc_channel_element* elem, grpc_channel_element_args* args) {
ServiceConfigChannelArgChannelData* chand =
static_cast<ServiceConfigChannelArgChannelData*>(elem->channel_data);
new (chand) ServiceConfigChannelArgChannelData(args);
return GRPC_ERROR_NONE;
}
void ServiceConfigChannelArgDestroyChannelElem(grpc_channel_element* elem) {
ServiceConfigChannelArgChannelData* chand =
static_cast<ServiceConfigChannelArgChannelData*>(elem->channel_data);
chand->~ServiceConfigChannelArgChannelData();
}
const grpc_channel_filter ServiceConfigChannelArgFilter = {
grpc_call_next_op,
nullptr,
grpc_channel_next_op,
sizeof(ServiceConfigChannelArgCallData),
ServiceConfigChannelArgInitCallElem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
ServiceConfigChannelArgDestroyCallElem,
sizeof(ServiceConfigChannelArgChannelData),
ServiceConfigChannelArgInitChannelElem,
grpc_channel_stack_no_post_init,
ServiceConfigChannelArgDestroyChannelElem,
grpc_channel_next_get_info,
"service_config_channel_arg"};
} // namespace
void RegisterServiceConfigChannelArgFilter(
CoreConfiguration::Builder* builder) {
builder->channel_init()->RegisterStage(
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
[](ChannelStackBuilder* builder) {
auto channel_args = builder->channel_args();
if (channel_args.WantMinimalStack() ||
!channel_args.GetString(GRPC_ARG_SERVICE_CONFIG).has_value()) {
return true;
}
builder->PrependFilter(&ServiceConfigChannelArgFilter);
return true;
});
}
} // namespace grpc_core
|
; A002802: a(n) = (2*n+3)!/(6*n!*(n+1)!).
; 1,10,70,420,2310,12012,60060,291720,1385670,6466460,29745716,135207800,608435100,2714556600,12021607800,52895074320,231415950150,1007340018300,4365140079300,18839025605400,81007810103220,347176329013800,1483389769422600,6320530321887600,26862253868022300,113895956400414552,481867507847907720,2034551699802277040,8574182163452453240,36070697377282734320,151496928984587484144,635309702193431385120,2660359377934993925190,11125139216819065505340,46463816729067861816420,193820492641254509291352,807585386005227122047300,3361301336346080453926600,13975937135333702940010600,58053892716001535289274800,240923654771406371450490420,998951739296075198697155400,4138514348512311537459643800,17131524512446312875995734800,70862215028755203259800539400,292897155452188173473842229520,1209792598606864194783261382800,4993612002760247952935164005600,20598649511386022805857551523100,84916881659183196056800518523800,349857552435834767754018136318056,1440589921794613749575368796603760,5928581601231679661714017739869320,24385486586198229551955771080971920,100251444854370499269151503332884560,411942300674322415178695268240580192
add $0,2
mov $1,$0
mul $0,2
bin $0,$1
bin $1,2
mul $1,$0
mov $0,$1
div $0,6
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CMountPointReader.h"
#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#include "CReadFile.h"
#include "os.h"
namespace irr
{
namespace io
{
//! Constructor
CArchiveLoaderMount::CArchiveLoaderMount( io::IFileSystem* fs)
: FileSystem(fs)
{
#ifdef _DEBUG
setDebugName("CArchiveLoaderMount");
#endif
}
//! returns true if the file maybe is able to be loaded by this class
bool CArchiveLoaderMount::isALoadableFileFormat(const io::path& filename) const
{
bool ret = false;
io::path fname(filename);
deletePathFromFilename(fname);
if (!fname.size())
{
ret = true;
}
return ret;
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderMount::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
{
return fileType == EFAT_FOLDER;
}
//! Check if the file might be loaded by this class
bool CArchiveLoaderMount::isALoadableFileFormat(io::IReadFile* file) const
{
return false;
}
//! Creates an archive from the filename
IFileArchive* CArchiveLoaderMount::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
EFileSystemType current = FileSystem->setFileListSystem(FILESYSTEM_NATIVE);
io::path save = FileSystem->getWorkingDirectory();
io::path fullPath = FileSystem->getAbsolutePath(filename);
FileSystem->flattenFilename(fullPath);
if ( FileSystem->changeWorkingDirectoryTo ( fullPath ) )
{
archive = new CMountPointReader(FileSystem, fullPath, ignoreCase, ignorePaths);
}
FileSystem->changeWorkingDirectoryTo(save);
FileSystem->setFileListSystem(current);
return archive;
}
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
IFileArchive* CArchiveLoaderMount::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
return 0;
}
//! compatible Folder Architecture
CMountPointReader::CMountPointReader(IFileSystem * parent, const io::path& basename, bool ignoreCase, bool ignorePaths)
: CFileList(basename, ignoreCase, ignorePaths), Parent(parent)
{
//! ensure CFileList path ends in a slash
if (Path.lastChar() != '/' )
Path.append('/');
const io::path work = Parent->getWorkingDirectory();
Parent->changeWorkingDirectoryTo(basename);
buildDirectory();
Parent->changeWorkingDirectoryTo(work);
sort();
}
//! returns the list of files
const IFileList* CMountPointReader::getFileList() const
{
return this;
}
void CMountPointReader::buildDirectory()
{
IFileList * list = Parent->createFileList();
if (!list)
return;
const u32 size = list->getFileCount();
for (u32 i=0; i < size; ++i)
{
io::path full = list->getFullFileName(i);
full = full.subString(Path.size(), full.size() - Path.size());
if (!list->isDirectory(i))
{
addItem(full, list->getFileOffset(i), list->getFileSize(i), false, RealFileNames.size());
RealFileNames.push_back(list->getFullFileName(i));
}
else
{
const io::path rel = list->getFileName(i);
io::path pwd = Parent->getWorkingDirectory();
if (pwd.lastChar() != '/')
pwd.append('/');
pwd.append(rel);
if ( rel != "." && rel != ".." )
{
addItem(full, 0, 0, true, 0);
Parent->changeWorkingDirectoryTo(pwd);
buildDirectory();
Parent->changeWorkingDirectoryTo("..");
}
}
}
list->drop();
}
//! opens a file by index
IReadFile* CMountPointReader::createAndOpenFile(u32 index)
{
if (index >= Files.size())
return 0;
return createReadFile(RealFileNames[Files[index].ID]);
}
//! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename)
{
s32 index = findFile(filename, false);
if (index != -1)
return createAndOpenFile(index);
else
return 0;
}
} // io
} // irr
#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
|
SFX_Push_Boulder_1_Ch1:
unknownnoise0x20 4, 162, 35
unknownnoise0x20 8, 241, 52
unknownnoise0x20 15, 0, 0
unknownnoise0x20 2, 247, 36
unknownnoise0x20 2, 247, 52
unknownnoise0x20 4, 247, 68
unknownnoise0x20 8, 244, 85
unknownnoise0x20 8, 241, 68
endchannel
|
; ===============================================================
; Dec 2013
; ===============================================================
;
; void *balloc_firstfit(unsigned char queue, unsigned char num)
;
; Allocate a block from the first queue in [queue, queue+num-1]
; that has a block available.
;
; ===============================================================
SECTION code_clib
SECTION code_alloc_balloc
PUBLIC asm_balloc_firstfit
EXTERN __balloc_array, error_zc
asm_balloc_firstfit:
; enter : l = queue
; h = num
;
; exit : success
;
; hl = ptr to allocated block
; carry reset
;
; fail
;
; hl = 0
; carry set
;
; uses : af, bc, de, hl
ld a,h
or a
jp z, error_zc ; zero queues to search
ld h,0
add hl,hl
ld de,(__balloc_array)
add hl,de ; forward_list *q
ld b,a
loop:
ld e,(hl)
inc hl
ld d,(hl) ; de = first block in this queue
inc hl
ld a,d
or e
jr nz, found_block
djnz loop
jp error_zc
found_block:
ex de,hl
; hl = & block
; de = & queue + 2b
; carry reset
inc hl
dec de
ldd ; copy link to next block from block to q
ld a,(hl)
ld (de),a
ret
|
/*
* Copyright © 2013 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "vice.h"
#include "vteutils.h"
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <glib.h>
/* Temporary define until glibc release catches up */
#ifdef __linux__
#include <sys/ioctl.h>
#include <linux/fs.h>
#ifndef O_TMPFILE
#ifndef __O_TMPFILE
#define __O_TMPFILE 020000000
#endif
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
#endif
#endif /* __linux__ */
int
_vte_mkstemp (void)
{
int fd;
gchar *file_name;
#ifdef O_TMPFILE
fd = open (g_get_tmp_dir (),
O_TMPFILE | O_EXCL | O_RDWR | O_NOATIME | O_CLOEXEC,
0600);
if (fd != -1)
goto done;
/* Try again with g_file_open_tmp */
#endif
fd = g_file_open_tmp ("vteXXXXXX", &file_name, NULL);
if (fd == -1)
return -1;
unlink (file_name);
g_free (file_name);
#ifdef O_NOATIME
do { } while (fcntl (fd, F_SETFL, O_NOATIME) == -1 && errno == EINTR);
#endif
#ifdef O_TMPFILE
done:
#endif
#ifdef __linux__
{
/* Mark the tmpfile as no-cow on file systems that support it.
*
* (Note that the definition of the ioctls make you think @flags would
* be long instead of int, but it turns out that this is not the case;
* see http://lwn.net/Articles/575846/ ).
*/
int flags;
if (ioctl (fd, FS_IOC_GETFLAGS, &flags) == 0) {
flags |= FS_SECRM_FL | FS_NOATIME_FL | FS_NOCOMP_FL | FS_NOCOW_FL | FS_NODUMP_FL;
ioctl (fd, FS_IOC_SETFLAGS, &flags);
}
}
#endif /* __linux__ */
return fd;
}
|
.size 8000
.text@48
inc a
ldff(45), a
xor a, a
ldff(41), a
ldff(c), a
jp l1000
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 03
call lwaitly_b
ld c, 41
lbegin_waitm0:
ldff a, (c)
and a, b
jrnz lbegin_waitm0
ld a, 80
ldff(68), a
ld a, ff
ld c, 69
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
xor a, a
ldff(c), a
ldff(c), a
ld a, 40
ldff(41), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ei
ld a, b
inc a
inc a
ldff(45), a
ld c, 0f
.text@1000
l1000:
nop
.text@10cb
ld a, 40
ldff(41), a
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
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/shape_inference.h"
#include <stddef.h>
#include <algorithm>
#include <numeric>
#include <set>
#include <string>
#include "tensorflow/compiler/xla/shape_util.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/compiler/xla/util.h"
#include "tensorflow/compiler/xla/window_util.h"
#include "tensorflow/compiler/xla/xla_data.pb.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/gtl/flatset.h"
#include "tensorflow/core/lib/math/math_util.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/protobuf.h"
namespace xla {
namespace {
// Return the UnaryOperation proto enum value associated with the given HLO
// opcode.
UnaryOperation OpcodeToUnaryOperation(HloOpcode opcode) {
switch (opcode) {
case HloOpcode::kAbs:
return UNOP_ABS;
case HloOpcode::kCeil:
return UNOP_CEIL;
case HloOpcode::kCos:
return UNOP_COS;
case HloOpcode::kExp:
return UNOP_EXP;
case HloOpcode::kFloor:
return UNOP_FLOOR;
case HloOpcode::kImag:
return UNOP_IMAG;
case HloOpcode::kIsFinite:
return UNOP_IS_FINITE;
case HloOpcode::kLog:
return UNOP_LOG;
case HloOpcode::kNot:
return UNOP_NOT;
case HloOpcode::kNegate:
return UNOP_NEGATE;
case HloOpcode::kReal:
return UNOP_REAL;
case HloOpcode::kRoundNearestAfz:
return UNOP_ROUND_NEAREST_AFZ;
case HloOpcode::kSign:
return UNOP_SIGN;
case HloOpcode::kSin:
return UNOP_SIN;
case HloOpcode::kSort:
return UNOP_SORT;
case HloOpcode::kTanh:
return UNOP_TANH;
default:
LOG(FATAL) << "Unhandled opcode for conversion to unary operation: "
<< opcode;
}
}
// Return the BinaryOperation proto enum value associated with the given HLO
// opcode.
BinaryOperation OpcodeToBinaryOperation(HloOpcode opcode) {
switch (opcode) {
case HloOpcode::kAtan2:
return BINOP_ATAN2;
case HloOpcode::kComplex:
return BINOP_COMPLEX;
case HloOpcode::kMultiply:
return BINOP_MUL;
case HloOpcode::kAdd:
return BINOP_ADD;
case HloOpcode::kSubtract:
return BINOP_SUB;
case HloOpcode::kDivide:
return BINOP_DIV;
case HloOpcode::kEq:
return BINOP_EQ;
case HloOpcode::kGe:
return BINOP_GE;
case HloOpcode::kGt:
return BINOP_GT;
case HloOpcode::kLe:
return BINOP_LE;
case HloOpcode::kLt:
return BINOP_LT;
case HloOpcode::kNe:
return BINOP_NE;
case HloOpcode::kMaximum:
return BINOP_MAX;
case HloOpcode::kMinimum:
return BINOP_MIN;
case HloOpcode::kPower:
return BINOP_POW;
case HloOpcode::kRemainder:
return BINOP_REM;
case HloOpcode::kOr:
return BINOP_OR;
case HloOpcode::kAnd:
return BINOP_AND;
case HloOpcode::kShiftLeft:
return BINOP_SHIFT_LEFT;
case HloOpcode::kShiftRightArithmetic:
return BINOP_SHIFT_RIGHT_ARITHMETIC;
case HloOpcode::kShiftRightLogical:
return BINOP_SHIFT_RIGHT_LOGICAL;
default:
LOG(FATAL) << "unhandled opcode " << opcode;
}
}
// Return the TernaryOperation proto enum value associated with the given HLO
// opcode.
TernaryOperation OpcodeToTernaryOperation(HloOpcode opcode) {
switch (opcode) {
case HloOpcode::kClamp:
return TRIOP_CLAMP;
case HloOpcode::kSelect:
return TRIOP_SELECT;
default:
LOG(FATAL) << "unhandled opcode " << opcode;
}
}
// Return the VariadicOperation proto enum value associated with the given HLO
// opcode.
VariadicOperation OpcodeToVariadicOperation(HloOpcode opcode) {
switch (opcode) {
case HloOpcode::kTuple:
return VAROP_TUPLE;
default:
LOG(FATAL) << "unhandled opcode " << opcode;
}
}
// Returns true if no element is present in slice more than once.
bool AllUnique(tensorflow::gtl::ArraySlice<int64> slice) {
return std::set<int64>(slice.begin(), slice.end()).size() == slice.size();
}
tensorflow::Status ExpectNotTupleOrOpaque(const Shape& shape,
tensorflow::StringPiece op_type) {
if (ShapeUtil::IsTuple(shape)) {
return InvalidArgument("Expected non-tuple argument for %s. Got: %s",
op_type.ToString().c_str(),
ShapeUtil::HumanString(shape).c_str());
} else if (ShapeUtil::IsOpaque(shape)) {
return InvalidArgument("Expected non-opaque argument for %s. Got: %s",
op_type.ToString().c_str(),
ShapeUtil::HumanString(shape).c_str());
} else {
return tensorflow::Status::OK();
}
}
tensorflow::Status VerifyReducerShape(const ProgramShape& reducer_shape,
const Shape& init_value_shape,
const PrimitiveType& input_element_type) {
if (reducer_shape.parameters_size() != 2) {
return InvalidArgument(
"Reduction function must take 2 parameters, but "
"takes %d parameter(s).",
reducer_shape.parameters_size());
}
const Shape& accumulator_shape = reducer_shape.result();
if (ShapeUtil::Rank(accumulator_shape) != 0) {
return Unimplemented(
"Reduction function currently must have rank-0 result.");
}
// Check that the accumulator can be passed in as the first argument.
// Note: comparing here and below with Compatible since we don't care about
// layout in scalars - see b/26668201 for a longer-term vision.
if (!ShapeUtil::Compatible(accumulator_shape, reducer_shape.parameters(0))) {
return InvalidArgument(
"Reduction function's first parameter shape differs from the "
"result shape: %s vs %s",
ShapeUtil::HumanString(reducer_shape.parameters(0)).c_str(),
ShapeUtil::HumanString(accumulator_shape).c_str());
}
// Check that init_value's shape is suitable for reducer_shape.
if (!ShapeUtil::Compatible(accumulator_shape, init_value_shape)) {
return InvalidArgument(
"Reduction function's accumulator shape differs from the "
"init_value shape: %s vs %s",
ShapeUtil::HumanString(accumulator_shape).c_str(),
ShapeUtil::HumanString(init_value_shape).c_str());
}
// Check that the inputs can be passed in as the second argument.
const Shape& input_element_shape =
ShapeUtil::MakeShape(input_element_type, {});
if (!ShapeUtil::Compatible(input_element_shape,
reducer_shape.parameters(1))) {
return InvalidArgument(
"Reduction function's second parameter shape differs from the "
"input type element type: %s vs %s",
ShapeUtil::HumanString(reducer_shape.parameters(1)).c_str(),
ShapeUtil::HumanString(input_element_shape).c_str());
}
// Currently the accumulator and inputs must be the same type,
// though that restriction could be relaxed.
if (!ShapeUtil::Compatible(accumulator_shape, reducer_shape.parameters(1))) {
return InvalidArgument(
"Reduction function's second parameter shape currently must "
"match the result shape. Got %s vs %s",
ShapeUtil::HumanString(reducer_shape.parameters(1)).c_str(),
ShapeUtil::HumanString(accumulator_shape).c_str());
}
return tensorflow::Status::OK();
}
StatusOr<Shape> InferWindowOutputShape(const Shape& base_shape,
const Window& window,
PrimitiveType element_type,
bool allow_negative_padding) {
if (window.dimensions_size() != ShapeUtil::Rank(base_shape)) {
return InvalidArgument(
"Window has dimension %d but base shape has dimension %lld.",
window.dimensions_size(), ShapeUtil::Rank(base_shape));
}
std::vector<int64> output_dimensions(window.dimensions_size());
for (int64 i = 0; i < window.dimensions_size(); ++i) {
const auto& dim = window.dimensions(i);
if (dim.size() <= 0) {
return InvalidArgument("Window has a non-positive dimension. Window: %s",
window.DebugString().c_str());
}
if (dim.stride() <= 0) {
return InvalidArgument("Window has a non-positive stride. Window: %s",
window.DebugString().c_str());
}
if (!allow_negative_padding && dim.padding_low() < 0) {
return InvalidArgument("Window has a negative low padding. Window: %s",
window.DebugString().c_str());
}
if (!allow_negative_padding && dim.padding_high() < 0) {
return InvalidArgument("Window has a negative high padding. Window: %s",
window.DebugString().c_str());
}
if (dim.base_dilation() < 1) {
return InvalidArgument(
"Window has a non-positive base area dilation factor. Window: %s",
window.DebugString().c_str());
}
if (dim.window_dilation() < 1) {
return InvalidArgument(
"Window has a non-positive window dilation factor. Window: %s",
window.DebugString().c_str());
}
const int64 dilated_base = window_util::DilatedBound(
ShapeUtil::GetDimension(base_shape, i), dim.base_dilation());
const int64 padded_dilated_base =
dim.padding_low() + dilated_base + dim.padding_high();
const int64 dilated_window =
window_util::DilatedBound(dim.size(), dim.window_dilation());
output_dimensions[i] = window_util::StridedBound(
padded_dilated_base, dilated_window, dim.stride());
}
return ShapeUtil::MakeShape(element_type, output_dimensions);
}
} // namespace
/* static */ StatusOr<Shape> ShapeInference::InferUnaryOpShape(
HloOpcode opcode, const HloInstruction* operand) {
// There is no copy operation at the proto level, so handle copy explicitly.
if (opcode == HloOpcode::kCopy) {
return operand->shape();
}
return InferUnaryOpShape(OpcodeToUnaryOperation(opcode), operand->shape());
}
/* static */ StatusOr<Shape> ShapeInference::InferUnaryOpShape(
UnaryOperation operation, const Shape& arg) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(arg, "operand of unary operation"));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(arg));
switch (operation) {
case UNOP_FLOOR:
case UNOP_CEIL:
if (!ShapeUtil::ElementIsFloating(arg)) {
return InvalidArgument(
"expected element type in shape to be floating for floor/ceil "
"operation; got %s",
PrimitiveType_Name(arg.element_type()).c_str());
}
return arg;
case UNOP_COS:
case UNOP_SIN:
case UNOP_EXP:
case UNOP_LOG:
case UNOP_TANH:
if (!ShapeUtil::ElementIsFloating(arg) &&
!ShapeUtil::ElementIsComplex(arg)) {
return InvalidArgument(
"expected element type in shape to be floating or complex for "
"sin/cos/exp/log/tanh operation; got %s",
PrimitiveType_Name(arg.element_type()).c_str());
}
return arg;
case UNOP_REAL:
case UNOP_IMAG:
if (!ShapeUtil::ElementIsComplex(arg)) {
return InvalidArgument(
"expected element type in shape to be complex for real/imag "
"operation; got %s",
PrimitiveType_Name(arg.element_type()).c_str());
}
return ShapeUtil::ChangeElementType(arg, F32);
case UNOP_ABS:
if (ShapeUtil::ElementIsComplex(arg)) {
return ShapeUtil::ChangeElementType(
arg, primitive_util::ComplexComponentType(arg.element_type()));
}
return arg;
case UNOP_NEGATE:
case UNOP_ROUND_NEAREST_AFZ:
case UNOP_SIGN:
case UNOP_SORT:
return arg;
case UNOP_NOT:
if (arg.element_type() != PRED &&
!primitive_util::IsIntegralType(arg.element_type())) {
return InvalidArgument(
"expected pred or an integral element type in argument to not "
"operation; got %s",
PrimitiveType_Name(arg.element_type()).c_str());
}
return arg;
case UNOP_IS_FINITE:
if (!ShapeUtil::ElementIsFloating(arg)) {
return InvalidArgument(
"expected element type in shape to be floating point for IsFinite "
"operation; got %s",
PrimitiveType_Name(arg.element_type()).c_str());
}
return ShapeUtil::ChangeElementType(arg, PRED);
default:
return InvalidArgument(
"Unknown operation for unary shape inference: \"%s\".",
UnaryOperation_Name(operation).c_str());
}
}
/* static */ StatusOr<Shape> ShapeInference::InferConcatOpShape(
tensorflow::gtl::ArraySlice<const Shape*> arg_shapes,
const int64 dimension) {
if (arg_shapes.empty()) {
return InvalidArgument("Concatenate expects at least one argument");
}
if (dimension < 0 || dimension >= ShapeUtil::Rank(*arg_shapes[0])) {
return InvalidArgument("dimension to concatenate along out of bounds: %lld",
dimension);
}
const Shape* arg_shape = nullptr;
for (const Shape* shape : arg_shapes) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(*shape, "operand of concatenation"));
if (!arg_shape) {
arg_shape = shape;
continue;
}
if (ShapeUtil::Rank(*arg_shape) != ShapeUtil::Rank(*shape)) {
return InvalidArgument(
"Cannot concatenate arrays with different ranks: %lld (%s) vs %lld "
"(%s)",
ShapeUtil::Rank(*arg_shape),
ShapeUtil::HumanString(*arg_shape).c_str(), ShapeUtil::Rank(*shape),
ShapeUtil::HumanString(*shape).c_str());
}
if (arg_shape->element_type() != shape->element_type()) {
return InvalidArgument(
"cannot concatenate arrays with different element types: %s vs %s",
PrimitiveType_Name(arg_shape->element_type()).c_str(),
PrimitiveType_Name(shape->element_type()).c_str());
}
for (int64 dimension_number = 0;
dimension_number < ShapeUtil::Rank(*arg_shape); ++dimension_number) {
if (arg_shape->dimensions(dimension_number) !=
shape->dimensions(dimension_number)) {
if (dimension_number == dimension) {
continue; // It's okay to differ in the dimension we're
// concatenating.
}
return InvalidArgument(
"cannot concatenate arrays that differ in dimensions other than "
"the one being concatenated (the other array dimensions must be "
"the same): %s vs %s in dimension %lld",
ShapeUtil::HumanString(*arg_shape).c_str(),
ShapeUtil::HumanString(*shape).c_str(), dimension);
}
}
}
std::vector<int64> new_dimensions(arg_shape->dimensions().begin(),
arg_shape->dimensions().end());
for (size_t i = 1; i < arg_shapes.size(); ++i) {
new_dimensions[dimension] += arg_shapes[i]->dimensions(dimension);
}
return ShapeUtil::MakeShape(arg_shape->element_type(), new_dimensions);
}
/* static */ StatusOr<Shape> ShapeInference::InferConvertShape(
const Shape& operand_shape, PrimitiveType new_element_type) {
auto old_element_type = operand_shape.element_type();
if (primitive_util::IsComplexType(old_element_type) &&
!primitive_util::IsComplexType(new_element_type)) {
return Unimplemented(
"Unsupported conversion from complex to real type: %s => %s",
ShapeUtil::HumanString(operand_shape).c_str(),
PrimitiveType_Name(new_element_type).c_str());
}
if (ShapeUtil::IsTuple(operand_shape) || new_element_type == TUPLE) {
// Note: we may want to support tuple conversions via this operation in the
// future, by recursing into the tuple elements to check all sub-conversions
// are valid. For now we just reject them, though.
return InvalidArgument(
"cannot convert from or to tuple type; requested conversion: %s => %s",
ShapeUtil::HumanString(operand_shape).c_str(),
PrimitiveType_Name(new_element_type).c_str());
}
return ShapeUtil::ChangeElementType(operand_shape, new_element_type);
}
/* static */ StatusOr<Shape> ShapeInference::InferBitcastConvertShape(
const Shape& operand_shape, PrimitiveType new_element_type) {
auto old_element_type = operand_shape.element_type();
if (primitive_util::IsComplexType(old_element_type) !=
primitive_util::IsComplexType(new_element_type)) {
return Unimplemented(
"Unsupported conversion between real and complex types: %s => %s",
ShapeUtil::HumanString(operand_shape).c_str(),
PrimitiveType_Name(new_element_type).c_str());
}
if (ShapeUtil::IsTuple(operand_shape) || new_element_type == TUPLE) {
// Note: we may want to support tuple conversions via this operation in the
// future, by recursing into the tuple elements to check all sub-conversions
// are valid. For now we just reject them, though.
return InvalidArgument(
"cannot convert from or to tuple type; requested conversion: %s => %s",
ShapeUtil::HumanString(operand_shape).c_str(),
PrimitiveType_Name(new_element_type).c_str());
}
if (primitive_util::BitWidth(old_element_type) !=
primitive_util::BitWidth(new_element_type)) {
return InvalidArgument(
"cannot bitcast types with different bit-widths: %s => %s",
PrimitiveType_Name(old_element_type).c_str(),
PrimitiveType_Name(new_element_type).c_str());
}
return ShapeUtil::ChangeElementType(operand_shape, new_element_type);
}
/* static */ StatusOr<Shape> ShapeInference::InferReducePrecisionShape(
const Shape& operand_shape, const int exponent_bits,
const int mantissa_bits) {
if (!ShapeUtil::ElementIsFloating(operand_shape)) {
return InvalidArgument(
"expected element type in shape to be floating point for "
"ReducePrecision operation; got %s",
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (exponent_bits < 1) {
// One exponent bit is necessary to distinguish 0 from infinity. Having
// no exponent bits doesn't produce a sensible number, so we require at
// least one.
return InvalidArgument("expected exponent_bits >= 1; got %d",
exponent_bits);
}
if (mantissa_bits < 0) {
// A number with no mantissa bits is still meaningful, however.
return InvalidArgument("expected non-negative mantissa_bits; got %d",
mantissa_bits);
}
return operand_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferPadShape(
const Shape& operand_shape, const Shape& padding_value_shape,
const PaddingConfig& padding_config) {
if (ShapeUtil::IsTuple(operand_shape)) {
return InvalidArgument(
"pad operation does not support tuple-shape operands");
}
if (!ShapeUtil::IsScalar(padding_value_shape)) {
return InvalidArgument(
"pad operation does not support non-scalar padding values");
}
if (ShapeUtil::Rank(operand_shape) != padding_config.dimensions_size()) {
return InvalidArgument(
"The rank of the operand and the padding configuration do not match: "
"%s vs %s",
ShapeUtil::HumanString(operand_shape).c_str(),
padding_config.ShortDebugString().c_str());
}
if (operand_shape.element_type() != padding_value_shape.element_type()) {
return InvalidArgument(
"the element types of the operands to pad do not match");
}
std::vector<int64> dimensions(ShapeUtil::Rank(operand_shape));
for (int64 i = 0; i < operand_shape.dimensions_size(); ++i) {
dimensions[i] = operand_shape.dimensions(i) +
padding_config.dimensions(i).edge_padding_low() +
padding_config.dimensions(i).edge_padding_high() +
std::max<int64>(operand_shape.dimensions(i) - 1, 0LL) *
padding_config.dimensions(i).interior_padding();
}
return ShapeUtil::MakeShape(operand_shape.element_type(), dimensions);
}
// Current DotDimensionNumbers Requirements:
//
// Contracting Dimensions:
// *) Exactly one contracting dimension on both lhs and rhs.
// *) Contracting dimension size must be the same on both lhs and rhs.
// *) Contracting dimension numbers do not need to be the same (i.e. transposes
// are passed on to emitter implementations).
//
// Batch Dimensions:
// *) Same number of batch dimensions on both lhs and rhs.
// *) Same batch dimension numbers (and sizes) on both lhs and rhs.
// *) Batch dimension numbers must be ordered before contracting and
// non-contracting/non-batch dimension numbers.
//
// Non-Contracting-Non-Batch Dimensions:
// *) Can be 0 (matrix-vector) or 1 (matrix-matrix).
//
namespace {
Status ValidateDotDimensionNumbers(
const Shape& lhs, const Shape& rhs,
const DotDimensionNumbers& dimension_numbers) {
// Check that dimension numbers are in range.
auto dims_in_range =
[](const int64 rank, tensorflow::gtl::ArraySlice<int64> contracting_dims,
tensorflow::gtl::ArraySlice<int64> batch_dims) -> bool {
auto in_range = [&rank](int64 i) -> bool { return 0 <= i && i < rank; };
return std::all_of(contracting_dims.begin(), contracting_dims.end(),
in_range) &&
std::all_of(batch_dims.begin(), batch_dims.end(), in_range);
};
tensorflow::gtl::ArraySlice<int64> lhs_contracting_dimensions =
AsInt64Slice(dimension_numbers.lhs_contracting_dimensions());
tensorflow::gtl::ArraySlice<int64> rhs_contracting_dimensions =
AsInt64Slice(dimension_numbers.rhs_contracting_dimensions());
tensorflow::gtl::ArraySlice<int64> lhs_batch_dimensions =
AsInt64Slice(dimension_numbers.lhs_batch_dimensions());
tensorflow::gtl::ArraySlice<int64> rhs_batch_dimensions =
AsInt64Slice(dimension_numbers.rhs_batch_dimensions());
if (!dims_in_range(ShapeUtil::Rank(lhs), lhs_contracting_dimensions,
lhs_batch_dimensions) ||
!dims_in_range(ShapeUtil::Rank(rhs), rhs_contracting_dimensions,
rhs_batch_dimensions)) {
return InvalidArgument("A dimension number is out of range in dot: %s",
dimension_numbers.DebugString().c_str());
}
// Check that dimension numbers are unique.
auto dims_unique = [](tensorflow::gtl::ArraySlice<int64> contracting_dims,
tensorflow::gtl::ArraySlice<int64> batch_dims) -> bool {
tensorflow::gtl::FlatSet<int64> dim_set;
auto is_unique = [&dim_set](int64 i) -> bool {
return dim_set.insert(i).second;
};
return std::all_of(contracting_dims.begin(), contracting_dims.end(),
is_unique) &&
std::all_of(batch_dims.begin(), batch_dims.end(), is_unique);
};
if (!dims_unique(lhs_contracting_dimensions, lhs_batch_dimensions) ||
!dims_unique(rhs_contracting_dimensions, rhs_batch_dimensions)) {
return InvalidArgument("A dimension number is not unique in dot: %s",
dimension_numbers.DebugString().c_str());
}
// Check that the count of non-contracting-non-batch dimensions is in {0, 1}.
const int64 lhs_non_contracting_non_batch_dims =
ShapeUtil::Rank(lhs) -
dimension_numbers.lhs_contracting_dimensions_size() -
dimension_numbers.lhs_batch_dimensions_size();
const int64 rhs_non_contracting_non_batch_dims =
ShapeUtil::Rank(rhs) -
dimension_numbers.rhs_contracting_dimensions_size() -
dimension_numbers.rhs_batch_dimensions_size();
if (lhs_non_contracting_non_batch_dims < 0 ||
lhs_non_contracting_non_batch_dims > 1 ||
rhs_non_contracting_non_batch_dims < 0 ||
rhs_non_contracting_non_batch_dims > 1) {
return InvalidArgument(
"batch and contracting dimension number mismatch "
"with rank ");
}
// Check that batch dimension numbers are ordered before all others, and
// that they are monotonically increasing.
std::vector<int64> batch_dim_numbers(lhs_batch_dimensions.size());
std::iota(batch_dim_numbers.begin(), batch_dim_numbers.end(), 0);
if (!std::equal(batch_dim_numbers.begin(), batch_dim_numbers.end(),
lhs_batch_dimensions.begin()) ||
!std::equal(batch_dim_numbers.begin(), batch_dim_numbers.end(),
rhs_batch_dimensions.begin())) {
return InvalidArgument(
"batch dimension numbers must precede non-batch dimensions and be"
"monotonically increasing.");
}
return Status::OK();
}
} // namespace
/* static */ StatusOr<Shape> ShapeInference::InferDotOpShape(
const Shape& lhs, const Shape& rhs,
const DotDimensionNumbers& dimension_numbers) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(lhs, "lhs of dot"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(rhs, "rhs of dot"));
auto fail = [lhs, rhs](const string& addendum) -> Status {
string message = tensorflow::strings::Printf(
"cannot infer shape for dot operation: %s <dot> %s",
ShapeUtil::HumanString(lhs).c_str(),
ShapeUtil::HumanString(rhs).c_str());
if (!addendum.empty()) {
message += ": " + addendum;
}
return InvalidArgument("%s", message.c_str());
};
// Check if both element types are the same.
if (lhs.element_type() != rhs.element_type()) {
return fail("element types do not match");
}
if ((ShapeUtil::Rank(lhs) < 1) || (ShapeUtil::Rank(rhs) < 1)) {
return fail("dot only supports rank 1 or above.");
}
// Validate basic properties of dot dimension numbers.
TF_RETURN_IF_ERROR(ValidateDotDimensionNumbers(lhs, rhs, dimension_numbers));
// Check that there is only one contracting dimension for both lhs and rhs.
if (dimension_numbers.lhs_contracting_dimensions_size() !=
dimension_numbers.rhs_contracting_dimensions_size() ||
dimension_numbers.lhs_contracting_dimensions_size() != 1) {
return fail("must specify one contracting dimension for both lhs and rhs.");
}
// Check that contracting dimension sizes match.
const int64 lhs_contracting_dimension =
dimension_numbers.lhs_contracting_dimensions(0);
const int64 rhs_contracting_dimension =
dimension_numbers.rhs_contracting_dimensions(0);
if (lhs.dimensions(lhs_contracting_dimension) !=
rhs.dimensions(rhs_contracting_dimension)) {
return fail("contracting dimension sizes do not match.");
}
// Check that number of batch dimensions match.
if (dimension_numbers.lhs_batch_dimensions_size() !=
dimension_numbers.rhs_batch_dimensions_size()) {
return fail("must the same number of batch dimensions for lhs and rhs.");
}
// Check that batch dimension numbers and sizes match.
for (int64 i = 0; i < dimension_numbers.lhs_batch_dimensions_size(); ++i) {
if (dimension_numbers.lhs_batch_dimensions(i) !=
dimension_numbers.rhs_batch_dimensions(i) ||
lhs.dimensions(dimension_numbers.lhs_batch_dimensions(i)) !=
rhs.dimensions(dimension_numbers.rhs_batch_dimensions(i))) {
return fail("batch dimension numbers and sizes must match for lhs/rhs.");
}
}
// The ranks of lhs and rhs are decremented by 1 respectively due to the
// contraction, and added for the rank of the result. When an input tensor is
// a scalar, its contribution to the rank of the result is 0.
// Generate the result dimensions in order, rhs dimensions followed by lhs
// dimensions except the contracted and batch dimensions.
std::vector<int64> dimensions;
std::unordered_set<int64> rhs_batch_dims(
dimension_numbers.rhs_batch_dimensions().begin(),
dimension_numbers.rhs_batch_dimensions().end());
for (int64 i = 0; i < ShapeUtil::Rank(lhs); i++) {
if (i != lhs_contracting_dimension) {
dimensions.push_back(lhs.dimensions(i));
}
}
for (int64 i = 0; i < ShapeUtil::Rank(rhs); i++) {
if (i != rhs_contracting_dimension && rhs_batch_dims.count(i) == 0) {
dimensions.push_back(rhs.dimensions(i));
}
}
Shape result = ShapeUtil::MakeShape(lhs.element_type(), dimensions);
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(result));
VLOG(2) << "inferred dot shape: " << ShapeUtil::HumanString(result);
return result;
}
/* static */ StatusOr<Shape>
ShapeInference::InferDegenerateDimensionBroadcastShape(
BinaryOperation operation, const Shape& lhs, const Shape& rhs) {
TF_RET_CHECK(ShapeUtil::Rank(lhs) == ShapeUtil::Rank(rhs));
// The shapes have to be compatible. That is, if some dimension d has a
// different size in the two shapes, one of them has to be 1 (a "degenerate"
// dimension). In that case, the output shape has the non-1 dimension size
// from the lhs/rhs pair in every index.
std::vector<int64> output_dimensions(ShapeUtil::Rank(lhs));
for (int64 i = 0; i < ShapeUtil::Rank(lhs); ++i) {
if (lhs.dimensions(i) == rhs.dimensions(i)) {
output_dimensions[i] = lhs.dimensions(i);
} else if (lhs.dimensions(i) == 1) {
output_dimensions[i] = rhs.dimensions(i);
} else if (rhs.dimensions(i) == 1) {
output_dimensions[i] = lhs.dimensions(i);
} else {
return InvalidArgument("binary op %s with incompatible shapes: %s and %s",
BinaryOperation_Name(operation).c_str(),
ShapeUtil::HumanString(lhs).c_str(),
ShapeUtil::HumanString(rhs).c_str());
}
}
return ShapeUtil::MakeShape(lhs.element_type(), output_dimensions);
}
/* static */ StatusOr<Shape> ShapeInference::InferInDimBroadcastShape(
BinaryOperation operation, const Shape& smaller_shape,
const Shape& larger_shape,
tensorflow::gtl::ArraySlice<int64> broadcast_dimensions) {
if (broadcast_dimensions.empty() && !ShapeUtil::IsScalar(smaller_shape)) {
// Reject "magic" inference for binops on different shapes, requiring
// the user to provide an explicit broadcast dimension in this case.
// See b/25177275 for more details.
return InvalidArgument("automatic shape inference not supported: %s and %s",
ShapeUtil::HumanString(smaller_shape).c_str(),
ShapeUtil::HumanString(larger_shape).c_str());
} else if (broadcast_dimensions.size() != ShapeUtil::Rank(smaller_shape)) {
return InvalidArgument(
"size of broadcast_dimensions has to match lower-rank operand's "
"rank; "
" lower-rank operand's rank is %lld, size of broadcast_dimensions is "
"%zu",
ShapeUtil::Rank(smaller_shape), broadcast_dimensions.size());
}
// broadcast_dimensions is a sequence of dimensions; its length is equal to
// the rank of the lower-rank operand. The lower-rank operand's dimensions
// have to be compatible with the higher-rank operand's dimensions at indices
// specified by broadcast_dimensions. Here compatible means the dimension
// sizes are equal or in one of the shapes the dimension size is
// one. Examples:
//
// smaller_shape larger_shape broadcast_dimensions output_shape
// [] [2, 3] {} [2, 3]
// [3] [4, 3] {1} [4, 3]
// [2, 3] [2, 3, 4] {0, 1} [2, 3, 4]
// [2, 1] [2, 3, 4] {0, 2} [2, 3, 1]
// [2, 3] [2, 1, 4] {0, 1} [2, 3, 4]
//
// The column output_shape may not be the final shape of the XLA
// operation. After the "InDim" broadcasting implemented in this function
// expands the rank, degenerate-dimension broadcasting (implemented in
// InferDegenerateDimensionBroadcastShape) broadcasts dimensions of size one
// up to match the dimension size of the other operand. For example, consider
// the row in the table above with a smaller_shape of [2, 1]. The shape
// returned by this function is [2, 3, 1] (output_shape) however, the result
// shape of the XLA operation is [2, 3, 4] after degenerate-dimension
// broadcasting.
//
// Invalid broadcasts:
//
// smaller_shape=[3], larger_shape=[4, 3], broadcast_dimensions={0}
// Reason: Dimension zero** of larger_shape (size 4) is not compatible with
// dimension zero of smaller_shape(size 3). **Zero here comes from the value
// in broadcast_dimensions.
//
// smaller_shape=[2, 1], larger_shape=[2, 3, 4], broadcast_dimensions={1, 2}
// Reason: Dimension one of larger_shape (size 3) is not compatible with
// dimension zero of smaller_shape(size 2)
// The output shape is initially the larger_shape. Sizes of dimensions
// specified in broadcast_dimensions are then changed to match the
// corresponding dimension size in smaller_shape.
Shape output_shape(larger_shape);
for (int i = 0; i < smaller_shape.dimensions_size(); ++i) {
int64 dimension_to_match = broadcast_dimensions.at(i);
if (dimension_to_match < 0) {
return InvalidArgument(
"broadcast dimension number (%lld) cannot be negative",
dimension_to_match);
}
if (dimension_to_match >= larger_shape.dimensions_size()) {
return InvalidArgument(
"broadcast dimension number (%lld) too large; higher-rank "
"operand has rank %d",
dimension_to_match, larger_shape.dimensions_size());
}
int64 small_dimension_size = smaller_shape.dimensions(i);
int64 large_dimension_size = larger_shape.dimensions(dimension_to_match);
// Dimension sizes must be compatible: match or be degenerate (degenerate
// case is handled by degenerate dimension broadcasting which occurs after
// InDim broadcasting).
if (small_dimension_size != large_dimension_size &&
small_dimension_size != 1 && large_dimension_size != 1) {
return InvalidArgument(
"broadcast dimension %d mismatch: %lld != %lld; %s and %s", i,
small_dimension_size, large_dimension_size,
ShapeUtil::HumanString(smaller_shape).c_str(),
ShapeUtil::HumanString(larger_shape).c_str());
}
// Make sure the broadcast dimensions are listed in a strictly increasing
// order.
if (i > 0 && broadcast_dimensions.at(i - 1) >= dimension_to_match) {
return InvalidArgument(
"broadcast dimensions order is wrong: %lld comes after %lld",
dimension_to_match, broadcast_dimensions.at(i - 1));
}
output_shape.set_dimensions(dimension_to_match, small_dimension_size);
}
return output_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferElementwiseBinaryOpShape(
BinaryOperation operation, const Shape& lhs, const Shape& rhs,
tensorflow::gtl::ArraySlice<int64> broadcast_dimensions) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(lhs, "lhs of elementwise binary operation"));
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(rhs, "rhs of elementwise binary operation"));
if (!ShapeUtil::SameElementType(lhs, rhs)) {
return InvalidArgument(
"binary op %s with different element types: %s and %s",
BinaryOperation_Name(operation).c_str(),
ShapeUtil::HumanString(lhs).c_str(),
ShapeUtil::HumanString(rhs).c_str());
}
if (ShapeUtil::Rank(lhs) == ShapeUtil::Rank(rhs)) {
std::vector<int64> identity_dims(ShapeUtil::Rank(lhs));
std::iota(identity_dims.begin(), identity_dims.end(), 0);
if (!broadcast_dimensions.empty() &&
broadcast_dimensions != identity_dims) {
return InvalidArgument(
"broadcast dimensions field must either be not set or be the "
"identity on binary operations with operands of the same rank");
}
}
if (ShapeUtil::Compatible(lhs, rhs)) {
// If the shapes are the same other than layout, the output shape is the
// same (elementwise op).
return lhs;
}
if (ShapeUtil::Rank(lhs) == ShapeUtil::Rank(rhs)) {
return InferDegenerateDimensionBroadcastShape(operation, lhs, rhs);
} else {
// Ranks do not match, so perform InDim broadcasting using
// broadcast_dimensions. Scalar broadcasting is a special case of this.
const Shape& larger_shape =
ShapeUtil::Rank(lhs) > ShapeUtil::Rank(rhs) ? lhs : rhs;
const Shape& smaller_shape =
ShapeUtil::Rank(lhs) > ShapeUtil::Rank(rhs) ? rhs : lhs;
// After InDim broadcasting, perform degenerate dimensions broadcasting.
TF_ASSIGN_OR_RETURN(
Shape indim_broadcast_shape,
InferInDimBroadcastShape(operation, smaller_shape, larger_shape,
broadcast_dimensions));
return InferDegenerateDimensionBroadcastShape(
operation, indim_broadcast_shape, larger_shape);
}
}
/* static */ StatusOr<Shape> ShapeInference::InferBinaryOpShape(
HloOpcode opcode, const HloInstruction* lhs, const HloInstruction* rhs) {
return InferBinaryOpShape(OpcodeToBinaryOperation(opcode), lhs->shape(),
rhs->shape(), /*broadcast_dimensions=*/{});
}
/* static */ StatusOr<Shape> ShapeInference::InferBinaryOpShape(
BinaryOperation operation, const Shape& lhs, const Shape& rhs,
tensorflow::gtl::ArraySlice<int64> broadcast_dimensions) {
VLOG(2) << tensorflow::strings::Printf(
"inferring shape for <%s>(%s, %s) with broadcast_dimensions={%s}",
BinaryOperation_Name(operation).c_str(),
ShapeUtil::HumanString(lhs).c_str(), ShapeUtil::HumanString(rhs).c_str(),
tensorflow::str_util::Join(broadcast_dimensions, ", ").c_str());
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(lhs));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(rhs));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
lhs, tensorflow::strings::StrCat("lhs of binary operation ",
BinaryOperation_Name(operation))));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
rhs, tensorflow::strings::StrCat("rhs of binary operation ",
BinaryOperation_Name(operation))));
switch (operation) {
case BINOP_MAX:
case BINOP_MIN:
case BINOP_SUB:
case BINOP_ADD:
case BINOP_ATAN2:
case BINOP_POW:
case BINOP_DIV:
case BINOP_REM:
case BINOP_MUL:
case BINOP_SHIFT_LEFT:
case BINOP_SHIFT_RIGHT_ARITHMETIC:
case BINOP_SHIFT_RIGHT_LOGICAL:
return InferElementwiseBinaryOpShape(operation, lhs, rhs,
broadcast_dimensions);
case BINOP_COMPLEX: {
if (!ShapeUtil::ElementIsFloating(lhs)) {
return InvalidArgument(
"expected element type in shape to be floating for complex compose "
"operation; got %s",
PrimitiveType_Name(lhs.element_type()).c_str());
}
TF_ASSIGN_OR_RETURN(const Shape& shape,
InferElementwiseBinaryOpShape(operation, lhs, rhs,
broadcast_dimensions));
if (lhs.element_type() == F32) {
return ShapeUtil::ChangeElementType(shape, C64);
} else {
return Unimplemented("complex component type not supported");
}
}
case BINOP_AND:
case BINOP_OR:
if (lhs.element_type() != PRED &&
!primitive_util::IsIntegralType(lhs.element_type())) {
return InvalidArgument(
"expected pred or integral type in argument to and/or operation; "
"got %s",
PrimitiveType_Name(lhs.element_type()).c_str());
}
return InferElementwiseBinaryOpShape(operation, lhs, rhs,
broadcast_dimensions);
case BINOP_EQ:
case BINOP_GE:
case BINOP_GT:
case BINOP_LE:
case BINOP_LT:
case BINOP_NE: {
TF_ASSIGN_OR_RETURN(const Shape& shape,
InferElementwiseBinaryOpShape(operation, lhs, rhs,
broadcast_dimensions));
return ShapeUtil::ChangeElementType(shape, PRED);
}
default:
return Unimplemented(
"not yet implemented; infer binary op shape: %s; lhs: %s; rhs: %s",
BinaryOperation_Name(operation).c_str(),
lhs.ShortDebugString().c_str(), rhs.ShortDebugString().c_str());
}
}
/* static */ StatusOr<Shape> ShapeInference::InferTernaryOpShape(
HloOpcode opcode, const HloInstruction* lhs, const HloInstruction* rhs,
const HloInstruction* ehs) {
return InferTernaryOpShape(OpcodeToTernaryOperation(opcode), lhs->shape(),
rhs->shape(), ehs->shape());
}
/* static */ StatusOr<Shape> ShapeInference::InferTernaryOpShape(
TernaryOperation operation, const Shape& lhs, const Shape& rhs,
const Shape& ehs) {
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(lhs));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(rhs));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(ehs));
switch (operation) {
case TRIOP_CLAMP:
return InferClampShape(lhs, rhs, ehs);
case TRIOP_SELECT:
return InferSelectShape(lhs, rhs, ehs);
default:
return InvalidArgument("unknown operation %s",
TernaryOperation_Name(operation).c_str());
}
}
/* static */ StatusOr<Shape> ShapeInference::InferVariadicOpShape(
HloOpcode opcode,
tensorflow::gtl::ArraySlice<const HloInstruction*> operands) {
std::vector<const Shape*> operand_shapes;
for (const HloInstruction* operand : operands) {
operand_shapes.push_back(&operand->shape());
}
return InferVariadicOpShape(OpcodeToVariadicOperation(opcode),
operand_shapes);
}
/* static */ StatusOr<Shape> ShapeInference::InferVariadicOpShape(
VariadicOperation operation,
tensorflow::gtl::ArraySlice<const Shape*> operand_shapes) {
for (const Shape* shape : operand_shapes) {
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(*shape));
}
switch (operation) {
case VAROP_TUPLE: {
Shape result = ShapeUtil::MakeTupleShape({});
for (const Shape* shape : operand_shapes) {
ShapeUtil::AppendShapeToTuple(*shape, &result);
}
return result;
}
default:
return InvalidArgument("unknown operation %s",
VariadicOperation_Name(operation).c_str());
}
}
/* static */ StatusOr<Shape> ShapeInference::InferMapShape(
tensorflow::gtl::ArraySlice<const Shape*> arg_shapes,
const ProgramShape& to_apply,
tensorflow::gtl::ArraySlice<int64> dimensions) {
if (arg_shapes.empty()) {
return InvalidArgument("Map expects at least one argument");
}
// All arguments must have the same shape.
const Shape* arg_shape = arg_shapes[0];
for (size_t i = 1; i < arg_shapes.size(); ++i) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(*arg_shapes[i], "operand of map"));
if (ShapeUtil::Compatible(*arg_shapes[i], *arg_shape)) {
continue;
}
if (!ShapeUtil::IsTuple(*arg_shapes[i]) &&
!ShapeUtil::IsTuple(*arg_shape) &&
ShapeUtil::SameElementType(*arg_shapes[i], *arg_shape)) {
if (ShapeUtil::IsScalar(*arg_shapes[i])) {
continue;
}
if (ShapeUtil::IsScalar(*arg_shape)) {
arg_shape = arg_shapes[i];
continue;
}
}
std::vector<string> pieces;
for (const Shape* shape : arg_shapes) {
pieces.push_back(ShapeUtil::HumanString(*shape));
}
return InvalidArgument(
"Map operation requires all operands to have the same shape; got: "
"%s",
tensorflow::str_util::Join(pieces, ", ").c_str());
}
// Check that dimensions.size == arg_shape.dimensions_size() (we currently
// only support mapping across all dimensions: i.e. scalar map functions).
if (dimensions.size() != arg_shape->dimensions_size()) {
return InvalidArgument(
"Map applied to a subset of dimensions currently not supported: "
"arg_dimension_size: %d, requested_map_dimensions_size: %zu",
arg_shape->dimensions_size(), dimensions.size());
}
// Check that requested map dimensions numbers are monotonically increasing.
for (int i = 0; i < dimensions.size(); ++i) {
if (dimensions[i] != i) {
return InvalidArgument(
"Map requires monotonically increasing dimension numbers, found: %s ",
tensorflow::str_util::Join(dimensions, ", ").c_str());
}
}
// The applied function's arity equals the number of arguments.
if (arg_shapes.size() != to_apply.parameters_size()) {
return InvalidArgument(
"Map applied function arity must match number of arguments; got: "
"arity: %d, arguments: %zu",
to_apply.parameters_size(), arg_shapes.size());
}
// The parameters should all be scalars, and the output too.
const Shape& output_shape = to_apply.result();
if (!ShapeUtil::IsScalar(output_shape)) {
return InvalidArgument(
"mapped computation's result has to be a scalar; "
"got: %s",
ShapeUtil::HumanString(output_shape).c_str());
}
for (int i = 0; i < to_apply.parameters_size(); ++i) {
const Shape& parameter_shape = to_apply.parameters(i);
if (!ShapeUtil::IsScalar(parameter_shape)) {
return InvalidArgument(
"mapped computation's parameter has to be a scalar; "
"got parameter %d shape: %s",
i, ShapeUtil::HumanString(parameter_shape).c_str());
}
if (parameter_shape.element_type() != arg_shape->element_type()) {
return InvalidArgument(
"mapped computation's parameter type has to match argument element "
"type; got parameter %d shape: %s, argument shape: %s",
i, ShapeUtil::HumanString(parameter_shape).c_str(),
ShapeUtil::HumanString(*arg_shape).c_str());
}
}
return ShapeUtil::MakeShape(output_shape.element_type(),
AsInt64Slice(arg_shape->dimensions()));
}
/* static */ StatusOr<Shape> ShapeInference::InferBatchNormTrainingShape(
const Shape& operand_shape, const Shape& scale_shape,
const Shape& offset_shape, int64 feature_index) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of batch norm training"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
offset_shape, "offset input of batch norm training"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
scale_shape, "scale input of batch norm training"));
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(operand_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(offset_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(scale_shape) ==
tensorflow::Status::OK());
if (feature_index >= ShapeUtil::Rank(operand_shape)) {
return InvalidArgument(
"Expected feature_index of batch-norm-training to be "
"smaller than the rank of operand_shape; "
"got feature_index %lld, and rank %lld",
feature_index, ShapeUtil::Rank(operand_shape));
}
if (feature_index < 0) {
return InvalidArgument(
"Expected feature_index of batch-norm-training to "
"be a non-negative number, got %lld",
feature_index);
}
if (ShapeUtil::Rank(operand_shape) < 1) {
return InvalidArgument(
"Expected the rank of operand to "
"batch-norm-training to be at least 1; got %lld",
ShapeUtil::Rank(operand_shape));
}
if (ShapeUtil::Rank(offset_shape) != 1) {
return InvalidArgument(
"Offset input of batch-norm-training must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(offset_shape));
}
if (ShapeUtil::Rank(scale_shape) != 1) {
return InvalidArgument(
"Scale input of batch-norm-training must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(scale_shape));
}
if (!ShapeUtil::ElementIsFloating(operand_shape)) {
return InvalidArgument(
"The operand to batch-norm-training must have a floating point "
"element type, but the shape is %s",
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(offset_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-training, "
"but the shape of offset factor is %s "
"and the shape of operand is %s",
PrimitiveType_Name(offset_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(scale_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-training, "
"but the shape of scale factor is %s "
"and the shape of operand is %s",
PrimitiveType_Name(scale_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
const int64 feature_count = operand_shape.dimensions(feature_index);
Shape output_shape_for_mean_and_var =
ShapeUtil::MakeShape(operand_shape.element_type(), {feature_count});
if (ShapeUtil::GetDimension(offset_shape, 0) != feature_count) {
return InvalidArgument(
"The size of offset factor should be the same as feature count,"
"but the size of offset factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(offset_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(scale_shape, 0) != feature_count) {
return InvalidArgument(
"The size of scale factor should be the same as feature count,"
"but the size of scale factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(scale_shape, 0), feature_count);
}
return ShapeUtil::MakeTupleShape({operand_shape,
output_shape_for_mean_and_var,
output_shape_for_mean_and_var});
}
/* static */ StatusOr<Shape> ShapeInference::InferBatchNormInferenceShape(
const Shape& operand_shape, const Shape& scale_shape,
const Shape& offset_shape, const Shape& mean_shape,
const Shape& variance_shape, int64 feature_index) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of batch norm inference"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
offset_shape, "offset input of batch norm inference"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
scale_shape, "scale input of batch norm inference"));
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(operand_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(offset_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(scale_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(mean_shape) ==
tensorflow::Status::OK());
TF_RET_CHECK(ShapeUtil::ValidateShapeWithOptionalLayout(variance_shape) ==
tensorflow::Status::OK());
if (feature_index >= ShapeUtil::Rank(operand_shape)) {
return InvalidArgument(
"Expected feature_index of batch-norm-inference to be "
"smaller than the rank of operand_shape; "
"got feature_index %lld, and rank %lld",
feature_index, ShapeUtil::Rank(operand_shape));
}
if (feature_index < 0) {
return InvalidArgument(
"Expected feature_index of batch-norm-inference to "
"be a non-negative number, got %lld",
feature_index);
}
if (ShapeUtil::Rank(operand_shape) < 1) {
return InvalidArgument(
"Expected the rank of operand to "
"batch-norm-inference to be at least 1; got %lld",
ShapeUtil::Rank(operand_shape));
}
if (ShapeUtil::Rank(offset_shape) != 1) {
return InvalidArgument(
"Offset input of batch-norm-inference must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(offset_shape));
}
if (ShapeUtil::Rank(scale_shape) != 1) {
return InvalidArgument(
"Scale input of batch-norm-inference must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(scale_shape));
}
if (!ShapeUtil::ElementIsFloating(operand_shape)) {
return InvalidArgument(
"The operand to batch-norm-inference must have a floating point "
"element type, but the shape is %s",
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(offset_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for "
"batch-norm-inference, "
"but the shape of offset factor is %s "
"and the shape of operand is %s",
PrimitiveType_Name(offset_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(scale_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for "
"batch-norm-inference, "
"but the shape of scale factor is %s "
"and the shape of operand is %s",
PrimitiveType_Name(scale_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(mean_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for "
"batch-norm-inference, "
"but the shape of mean is %s "
"and the shape of operand is %s",
PrimitiveType_Name(mean_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(variance_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for "
"batch-norm-inference, "
"but the shape of variance is %s "
"and the shape of operand is %s",
PrimitiveType_Name(mean_shape.element_type()).c_str(),
PrimitiveType_Name(variance_shape.element_type()).c_str());
}
const int64 feature_count = operand_shape.dimensions(feature_index);
Shape output_shape_for_mean_and_var =
ShapeUtil::MakeShape(operand_shape.element_type(), {feature_count});
if (ShapeUtil::GetDimension(offset_shape, 0) != feature_count) {
return InvalidArgument(
"The size of offset factor should be the same as feature count,"
"but the size of offset factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(offset_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(scale_shape, 0) != feature_count) {
return InvalidArgument(
"The size of scale factor should be the same as feature count,"
"but the size of scale factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(scale_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(mean_shape, 0) != feature_count) {
return InvalidArgument(
"The size of mean should be the same as feature count,"
"but the size of mean is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(mean_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(variance_shape, 0) != feature_count) {
return InvalidArgument(
"The size of variance should be the same as feature count,"
"but the size of variance is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(variance_shape, 0), feature_count);
}
return operand_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferBatchNormGradShape(
const Shape& operand_shape, const Shape& scale_shape,
const Shape& mean_shape, const Shape& var_shape,
const Shape& output_grad_shape, int64 feature_index) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of batch norm grad"));
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(scale_shape, "scale input of batch norm grad"));
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(mean_shape, "mean input of batch norm grad"));
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(var_shape, "var input of batch norm grad"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
output_grad_shape, "output_grad input of batch norm grad"));
TF_RETURN_IF_ERROR(ShapeUtil::ValidateShapeWithOptionalLayout(operand_shape));
TF_RETURN_IF_ERROR(ShapeUtil::ValidateShapeWithOptionalLayout(mean_shape));
TF_RETURN_IF_ERROR(ShapeUtil::ValidateShapeWithOptionalLayout(scale_shape));
TF_RETURN_IF_ERROR(ShapeUtil::ValidateShapeWithOptionalLayout(var_shape));
TF_RETURN_IF_ERROR(
ShapeUtil::ValidateShapeWithOptionalLayout(output_grad_shape));
if (feature_index >= ShapeUtil::Rank(operand_shape)) {
return InvalidArgument(
"Expected feature_index of batch-norm-grad to be "
"smaller than the rank of operand_shape; "
"got feature_index %lld, and rank %lld",
feature_index, ShapeUtil::Rank(operand_shape));
}
if (ShapeUtil::Rank(operand_shape) != ShapeUtil::Rank(output_grad_shape)) {
return InvalidArgument(
"Expected operand_shape of batch-norm-grad to have the same rank as"
" output_grad_shape; got rank(oprand_shape) %lld, and"
" rank(output_grad_shape) %lld",
ShapeUtil::Rank(operand_shape), ShapeUtil::Rank(output_grad_shape));
}
if (ShapeUtil::Rank(mean_shape) != 1) {
return InvalidArgument(
"Mean input of batch-norm-grad must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(mean_shape));
}
if (ShapeUtil::Rank(scale_shape) != 1) {
return InvalidArgument(
"Scale input of batch-norm-grad must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(scale_shape));
}
if (ShapeUtil::Rank(var_shape) != 1) {
return InvalidArgument(
"Var input of batch-norm-grad must have"
" rank 1, but has rank %lld.",
ShapeUtil::Rank(var_shape));
}
if (!ShapeUtil::ElementIsFloating(operand_shape)) {
return InvalidArgument(
"The operand to batch-norm-grad must have a floating point "
"element type, but the shape is %s",
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::ElementIsFloating(output_grad_shape)) {
return InvalidArgument(
"The output_grad to batch-norm-grad must have a floating point "
"element type, but the shape is %s",
PrimitiveType_Name(output_grad_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(output_grad_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-grad, "
"but the element type of output_grad is %s "
"and the element type of operand is %s",
PrimitiveType_Name(output_grad_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(scale_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-grad, "
"but the element type of scale factor is %s "
"and the element type of operand is %s",
PrimitiveType_Name(scale_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(mean_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-grad, "
"but the element type of mean is %s "
"and the element type of operand is %s",
PrimitiveType_Name(mean_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
if (!ShapeUtil::SameElementType(var_shape, operand_shape)) {
return InvalidArgument(
"The inputs should have the same element type for batch-norm-grad, "
"but the element type of mean is %s "
"and the element type of operand is %s",
PrimitiveType_Name(mean_shape.element_type()).c_str(),
PrimitiveType_Name(operand_shape.element_type()).c_str());
}
const int64 feature_count = operand_shape.dimensions(feature_index);
Shape feature_shape =
ShapeUtil::MakeShape(operand_shape.element_type(), {feature_count});
if (ShapeUtil::GetDimension(mean_shape, 0) != feature_count) {
return InvalidArgument(
"The size of mean should be the same as feature count,"
"but the size of offset factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(mean_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(scale_shape, 0) != feature_count) {
return InvalidArgument(
"The size of scale factor should be the same as feature count,"
"but the size of scale factor is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(scale_shape, 0), feature_count);
}
if (ShapeUtil::GetDimension(var_shape, 0) != feature_count) {
return InvalidArgument(
"The size of variance should be the same as feature count,"
"but the size of variance is %lld "
"and the feature count is %lld",
ShapeUtil::GetDimension(var_shape, 0), feature_count);
}
// Verify operand_shape and output_grad_shape have same bounds.
for (int64 i = 0; i < ShapeUtil::Rank(operand_shape); ++i) {
if (ShapeUtil::GetDimension(operand_shape, i) !=
ShapeUtil::GetDimension(output_grad_shape, i)) {
return InvalidArgument(
"The bounds of operand shape should be the same as output_grad's,"
"but the bound of operand_shape at dimension %lld is %lld "
"and the bound of output_grad_shape is %lld",
i, ShapeUtil::GetDimension(operand_shape, i),
ShapeUtil::GetDimension(output_grad_shape, i));
}
}
return ShapeUtil::MakeTupleShape(
{operand_shape, feature_shape, feature_shape});
}
/* static */ StatusOr<Shape> ShapeInference::InferConvolveShape(
const Shape& lhs, const Shape& rhs, const Window& window,
const ConvolutionDimensionNumbers& dnums) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(lhs, "lhs of convolution"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(rhs, "rhs of convolution"));
if (!ShapeUtil::SameElementType(lhs, rhs)) {
return InvalidArgument(
"Convolution with different element types: %s and %s",
ShapeUtil::HumanString(lhs).c_str(),
ShapeUtil::HumanString(rhs).c_str());
}
if (dnums.input_spatial_dimensions_size() !=
dnums.kernel_spatial_dimensions_size()) {
return InvalidArgument(
"Both arguments to convolution must have same number of dimensions.\n"
"Window: %s",
window.DebugString().c_str());
}
const int num_spatial_dims = dnums.input_spatial_dimensions_size();
if (window.dimensions_size() != num_spatial_dims) {
return InvalidArgument(
"Window must have same number of dimensions as dimension numbers.\n"
"Window: %s\nDimension numbers: %s",
window.DebugString().c_str(), dnums.DebugString().c_str());
}
const int num_dims = num_spatial_dims + 2;
if (ShapeUtil::Rank(lhs) != num_dims) {
return InvalidArgument(
"The LHS argument to a convolution should have rank %d.\n"
"lhs: %s",
num_dims, ShapeUtil::HumanString(lhs).c_str());
}
if (ShapeUtil::Rank(rhs) != num_dims) {
return InvalidArgument(
"The RHS argument to a convolution should have rank %d.\n"
"lhs: %s",
num_dims, ShapeUtil::HumanString(lhs).c_str());
}
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(lhs));
TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(rhs));
// Verifies that the input and window dimensions are a permutation of
// the dimension numbers.
std::vector<int64> input_dnums(num_dims);
input_dnums[0] = dnums.input_batch_dimension();
input_dnums[1] = dnums.input_feature_dimension();
std::copy(dnums.input_spatial_dimensions().begin(),
dnums.input_spatial_dimensions().end(), input_dnums.begin() + 2);
std::sort(input_dnums.begin(), input_dnums.end());
std::vector<int64> window_dnums(num_dims);
window_dnums[0] = dnums.kernel_input_feature_dimension();
window_dnums[1] = dnums.kernel_output_feature_dimension();
std::copy(dnums.kernel_spatial_dimensions().begin(),
dnums.kernel_spatial_dimensions().end(), window_dnums.begin() + 2);
std::sort(window_dnums.begin(), window_dnums.end());
std::vector<int64> output_dnums(num_dims);
output_dnums[0] = dnums.output_batch_dimension();
output_dnums[1] = dnums.output_feature_dimension();
std::copy(dnums.output_spatial_dimensions().begin(),
dnums.output_spatial_dimensions().end(), output_dnums.begin() + 2);
std::sort(output_dnums.begin(), output_dnums.end());
std::vector<int64> expected_dnums(num_dims);
std::iota(expected_dnums.begin(), expected_dnums.end(), 0);
const auto in_range = [num_dims](int64 i) { return 0 <= i && i < num_dims; };
if (!std::all_of(input_dnums.begin(), input_dnums.end(), in_range) ||
!std::all_of(window_dnums.begin(), window_dnums.end(), in_range) ||
!std::all_of(output_dnums.begin(), output_dnums.end(), in_range)) {
return InvalidArgument(
"A dimension number is out of range in convolution: %s",
dnums.DebugString().c_str());
}
if (input_dnums != expected_dnums) {
return InvalidArgument(
"Input dimensions of convolution must contain each dimension exactly "
"once: %s",
dnums.DebugString().c_str());
}
if (window_dnums != expected_dnums) {
return InvalidArgument(
"Window dimensions of convolution must contain each dimension exactly "
"once: %s",
dnums.DebugString().c_str());
}
if (output_dnums != expected_dnums) {
return InvalidArgument(
"Output dimensions of convolution must contain each dimension exactly "
"once: %s",
dnums.DebugString().c_str());
}
std::vector<int64> input_spatial_dims(num_spatial_dims);
for (int i = 0; i < num_spatial_dims; ++i) {
input_spatial_dims[i] = lhs.dimensions(dnums.input_spatial_dimensions(i));
}
const int64 input_features = lhs.dimensions(dnums.input_feature_dimension());
const int64 input_batch = lhs.dimensions(dnums.input_batch_dimension());
std::vector<int64> kernel_spatial_dims(num_spatial_dims);
for (int i = 0; i < num_spatial_dims; ++i) {
kernel_spatial_dims[i] = rhs.dimensions(dnums.kernel_spatial_dimensions(i));
}
const int64 kernel_input_features =
rhs.dimensions(dnums.kernel_input_feature_dimension());
const int64 kernel_output_features =
rhs.dimensions(dnums.kernel_output_feature_dimension());
if (input_features != kernel_input_features) {
return InvalidArgument(
"Expected LHS feature dimension (value %lld) to match RHS "
"input feature dimension (value %lld); got <conv>(%s, %s)\n"
"Dimension numbers: {%s}",
input_features, kernel_input_features,
ShapeUtil::HumanString(lhs).c_str(),
ShapeUtil::HumanString(rhs).c_str(), dnums.DebugString().c_str());
}
std::vector<int64> window_dims(num_spatial_dims);
for (int i = 0; i < num_spatial_dims; ++i) {
window_dims[i] = window.dimensions(i).size();
}
if (kernel_spatial_dims != window_dims) {
return InvalidArgument(
"Window dimensions do not match RHS shape:\n\t"
"RHS shape: %s\n\t"
"Window: {%s}\n\t"
"Dimension numbers: {%s}",
ShapeUtil::HumanString(rhs).c_str(), window.ShortDebugString().c_str(),
dnums.ShortDebugString().c_str());
}
Shape base_shape =
ShapeUtil::MakeShape(lhs.element_type(), input_spatial_dims);
TF_ASSIGN_OR_RETURN(
Shape window_output_shape,
InferWindowOutputShape(base_shape, window, lhs.element_type(),
/*allow_negative_padding=*/true));
std::vector<int64> dimensions(num_dims);
dimensions[dnums.output_batch_dimension()] = input_batch;
dimensions[dnums.output_feature_dimension()] = kernel_output_features;
for (int i = 0; i < num_spatial_dims; ++i) {
dimensions[dnums.output_spatial_dimensions(i)] =
window_output_shape.dimensions(i);
}
return ShapeUtil::MakeShape(lhs.element_type(), dimensions);
}
/* static */ StatusOr<Shape> ShapeInference::InferFftShape(
const Shape& in, const FftType fft_type,
const tensorflow::gtl::ArraySlice<int64> fft_length) {
const int64 fft_rank = fft_length.size();
if (fft_rank < 1 || fft_rank > 3) {
return InvalidArgument("FFT only supports ranks 1-3, but got %lld",
fft_rank);
}
switch (fft_type) {
case FFT:
case IFFT:
if (in.element_type() != C64) {
return InvalidArgument("%s requires C64 input type, found %s",
FftType_Name(fft_type).c_str(),
PrimitiveType_Name(in.element_type()).c_str());
}
return in;
case RFFT: {
if (in.element_type() != F32) {
return InvalidArgument("RFFT requires F32 input type, found %s",
PrimitiveType_Name(in.element_type()).c_str());
}
for (int i = 0; i < fft_rank; i++) {
if (in.dimensions(in.dimensions_size() - fft_rank + i) !=
fft_length[i]) {
return InvalidArgument(
"RFFT requires innermost dimensions match fft_length but "
"dimension %lld is %lld and should be %lld",
in.dimensions_size() - fft_rank + i,
in.dimensions(in.dimensions_size() - fft_rank + i),
fft_length[i]);
}
}
Shape result = ShapeUtil::ChangeElementType(in, C64);
result.set_dimensions(result.dimensions_size() - 1,
fft_length[fft_rank - 1] / 2 + 1);
return result;
}
case IRFFT: {
if (in.element_type() != C64) {
return InvalidArgument("IRFFT requires C64 input type, found %s",
PrimitiveType_Name(in.element_type()).c_str());
}
Shape result = ShapeUtil::ChangeElementType(in, F32);
for (int i = 0; i < fft_rank - 1; i++) {
if (in.dimensions(in.dimensions_size() - fft_rank + i) !=
fft_length[i]) {
return InvalidArgument(
"IRFFT requires all but one innermost dimensions match "
"fft_length, but dimension %lld is %lld and should be %lld",
in.dimensions_size() - fft_rank + i,
in.dimensions(in.dimensions_size() - fft_rank + i),
fft_length[i]);
}
}
if (in.dimensions(in.dimensions_size() - 1) !=
fft_length[fft_rank - 1] / 2 + 1) {
return InvalidArgument(
"IRFFT requires innermost dimension matches fft_length/2+1, but "
"dimension %d is %lld and should be %lld",
in.dimensions_size() - 1, in.dimensions(in.dimensions_size() - 1),
fft_length[fft_rank - 1] / 2 + 1);
}
result.set_dimensions(result.dimensions_size() - 1,
fft_length[fft_rank - 1]);
return result;
}
default:
LOG(FATAL) << "Unexpected fft_type: " << fft_type;
}
}
/* static */ StatusOr<Shape> ShapeInference::InferCrossReplicaSumShape(
tensorflow::gtl::ArraySlice<const Shape*> operand_shapes) {
for (const Shape* operand_shape : operand_shapes) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(*operand_shape, "operand of cross replica sum"));
}
if (operand_shapes.size() == 1) {
return *operand_shapes[0];
}
std::vector<Shape> operand_shape_values;
for (const Shape* operand_shape : operand_shapes) {
operand_shape_values.push_back(*operand_shape);
}
return ShapeUtil::MakeTupleShape(operand_shape_values);
}
/* static */ StatusOr<Shape> ShapeInference::InferReduceShape(
const Shape& arg, const Shape& init_value,
tensorflow::gtl::ArraySlice<int64> dimensions_to_reduce,
const ProgramShape& to_apply) {
// Check that the dimension to reduce are in-bounds for the given shape.
for (int64 dimension : dimensions_to_reduce) {
if (dimension >= ShapeUtil::Rank(arg) || dimension < 0) {
return InvalidArgument(
"attempting to reduce out-of-bounds dimension %lld in shape %s",
dimension, ShapeUtil::HumanString(arg).c_str());
}
}
TF_RETURN_IF_ERROR(
VerifyReducerShape(to_apply, init_value, arg.element_type()));
std::set<int64> dimensions_to_reduce_set(dimensions_to_reduce.begin(),
dimensions_to_reduce.end());
std::vector<int64> new_dimensions;
for (int i = 0; i < ShapeUtil::Rank(arg); ++i) {
if (dimensions_to_reduce_set.find(i) == dimensions_to_reduce_set.end()) {
new_dimensions.push_back(arg.dimensions(i));
}
}
return ShapeUtil::MakeShape(to_apply.result().element_type(), new_dimensions);
}
/* static */ StatusOr<Shape> ShapeInference::InferReduceWindowShape(
const Shape& operand_shape, const Shape& init_value_shape,
const Window& window, const ProgramShape& to_apply_shape) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of reduce-window"));
TF_RETURN_IF_ERROR(VerifyReducerShape(to_apply_shape, init_value_shape,
operand_shape.element_type()));
return InferWindowOutputShape(operand_shape, window,
init_value_shape.element_type(),
/*allow_negative_padding=*/false);
}
/* static */ StatusOr<Shape> ShapeInference::InferSelectAndScatterShape(
const Shape& operand_shape, const ProgramShape& select_shape,
const Window& window, const Shape& source_shape,
const Shape& init_value_shape, const ProgramShape& scatter_shape) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of select-and-scatter"));
// Check if the select function has a proper shape of (T,T) -> PRED.
if (select_shape.parameters_size() != 2) {
return InvalidArgument(
"select function must take 2 parameters, but "
"takes %d parameter(s).",
select_shape.parameters_size());
}
const Shape& select_result_shape = select_shape.result();
if (!ShapeUtil::Compatible(select_result_shape,
ShapeUtil::MakeShape(PRED, {}))) {
return Unimplemented("select function must have rank-0 PRED result.");
}
const Shape& operand_element_shape =
ShapeUtil::MakeShape(operand_shape.element_type(), {});
if (!ShapeUtil::Compatible(operand_element_shape,
select_shape.parameters(0))) {
return InvalidArgument(
"select function's first parameter shape currently must "
"match the operand element shape. Got %s vs %s",
ShapeUtil::HumanString(select_shape.parameters(0)).c_str(),
ShapeUtil::HumanString(operand_element_shape).c_str());
}
if (!ShapeUtil::Compatible(operand_element_shape,
select_shape.parameters(1))) {
return InvalidArgument(
"select function's second parameter shape currently must "
"match the operand element shape. Got %s vs %s",
ShapeUtil::HumanString(select_shape.parameters(1)).c_str(),
ShapeUtil::HumanString(operand_element_shape).c_str());
}
// Check if the scatter function has a proper shape as a reduction.
TF_RETURN_IF_ERROR(VerifyReducerShape(scatter_shape, init_value_shape,
source_shape.element_type()));
// Check if the result shape of window operation matches the source shape.
TF_ASSIGN_OR_RETURN(const Shape& window_result_shape,
InferWindowOutputShape(operand_shape, window,
operand_shape.element_type(),
/*allow_negative_padding=*/false));
if (!ShapeUtil::Compatible(source_shape, window_result_shape)) {
return InvalidArgument(
"source shape does not match the shape of window-reduced operand: "
"source(%s), window-reduced operand(%s)",
ShapeUtil::HumanString(source_shape).c_str(),
ShapeUtil::HumanString(window_result_shape).c_str());
}
return operand_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferSliceShape(
const Shape& arg, tensorflow::gtl::ArraySlice<int64> starts,
tensorflow::gtl::ArraySlice<int64> limits,
tensorflow::gtl::ArraySlice<int64> strides) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(arg, "operand of slice"));
VLOG(2) << tensorflow::strings::Printf(
"slicing shape %s starts={%s} limits={%s}",
ShapeUtil::HumanString(arg).c_str(),
tensorflow::str_util::Join(starts, ", ").c_str(),
tensorflow::str_util::Join(limits, ", ").c_str());
if (starts.size() != limits.size()) {
return InvalidArgument("slice start and limit sizes differ: %zu vs %zu",
starts.size(), limits.size());
}
if (starts.size() != strides.size()) {
return InvalidArgument("slice start and strides sizes differ: %zu vs %zu",
starts.size(), strides.size());
}
if (starts.size() != ShapeUtil::Rank(arg)) {
return InvalidArgument(
"slice index count does not match argument rank: %zu vs %lld",
starts.size(), ShapeUtil::Rank(arg));
}
std::vector<int64> sizes;
for (int64 dimension = 0; dimension < starts.size(); ++dimension) {
int64 start_index = starts[dimension];
int64 limit_index = limits[dimension];
int64 stride = strides[dimension];
if (start_index < 0) {
return InvalidArgument("negative start index to slice: %lld",
start_index);
}
if (limit_index > arg.dimensions(dimension)) {
return InvalidArgument(
"limit index (%lld) must be less than or equal to dimension "
"size (%lld)",
limit_index, arg.dimensions(dimension));
}
VLOG(2) << tensorflow::strings::Printf("starts[%lld] = %lld", dimension,
start_index);
VLOG(2) << tensorflow::strings::Printf("limits[%lld] = %lld", dimension,
limit_index);
if (start_index > limit_index) {
return InvalidArgument(
"limit index (%lld) must be greater or equal to "
"start index (%lld) in slice with positive stride",
limit_index, start_index);
}
if (stride <= 0) {
return InvalidArgument("stride (%lld) must be positive", stride);
}
sizes.push_back((limit_index - start_index + stride - 1) / stride);
}
return ShapeUtil::MakeShape(arg.element_type(), sizes);
}
/* static */ StatusOr<Shape> ShapeInference::InferDynamicSliceShape(
const Shape& operand_shape, const Shape& start_indices_shape,
tensorflow::gtl::ArraySlice<int64> slice_sizes) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of dynamic slice"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(start_indices_shape,
"start indices of dynamic slice"));
VLOG(2) << tensorflow::strings::Printf(
"slicing shape %s at dynamic start_indices %s with slice_sizes={%s}",
ShapeUtil::HumanString(operand_shape).c_str(),
ShapeUtil::HumanString(start_indices_shape).c_str(),
tensorflow::str_util::Join(slice_sizes, ", ").c_str());
if (ShapeUtil::Rank(start_indices_shape) != 1) {
return InvalidArgument(
"dynamic slice start indices of rank %lld must be rank1.",
ShapeUtil::Rank(start_indices_shape));
}
if (!ShapeUtil::ElementIsIntegral(start_indices_shape)) {
return InvalidArgument(
"dynamic slice start indices must be of integral type.");
}
const int64 start_num_dims = start_indices_shape.dimensions(0);
if (ShapeUtil::Rank(operand_shape) != start_num_dims) {
return InvalidArgument(
"dynamic slice start number of dimensions %lld (%s) must match rank "
"%lld of slice input (%s)",
start_num_dims, ShapeUtil::HumanString(start_indices_shape).c_str(),
ShapeUtil::Rank(operand_shape),
ShapeUtil::HumanString(operand_shape).c_str());
}
if (slice_sizes.size() != ShapeUtil::Rank(operand_shape)) {
return InvalidArgument(
"dynamic slice index count does not match argument rank: %zu vs %lld",
slice_sizes.size(), ShapeUtil::Rank(operand_shape));
}
for (int64 dim = 0; dim < slice_sizes.size(); ++dim) {
const int64 input_dim_size = operand_shape.dimensions(dim);
const int64 slice_dim_size = slice_sizes[dim];
if (slice_dim_size < 0) {
return InvalidArgument("negative size index to dynamic slice: %lld",
slice_dim_size);
}
if (slice_dim_size > input_dim_size) {
return InvalidArgument(
"slice dim size %lld greater than dynamic slice dimension: %lld",
slice_dim_size, input_dim_size);
}
VLOG(2) << tensorflow::strings::Printf("slice_sizes[%lld] = %lld", dim,
slice_dim_size);
}
return ShapeUtil::MakeShape(operand_shape.element_type(), slice_sizes);
}
/* static */ StatusOr<Shape> ShapeInference::InferDynamicUpdateSliceShape(
const Shape& operand_shape, const Shape& update_shape,
const Shape& start_indices_shape) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of dynamic update slice"));
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(update_shape, "update of dynamic update slice"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(
start_indices_shape, "start indices of dynamic update slice"));
VLOG(2) << tensorflow::strings::Printf(
"updating slice of shape %s at dynamic start_indices %s with update "
"shape %s",
ShapeUtil::HumanString(operand_shape).c_str(),
ShapeUtil::HumanString(start_indices_shape).c_str(),
ShapeUtil::HumanString(update_shape).c_str());
if (ShapeUtil::Rank(start_indices_shape) != 1) {
return InvalidArgument(
"dynamic update slice start indices of rank %lld must be rank1.",
ShapeUtil::Rank(start_indices_shape));
}
if (!ShapeUtil::ElementIsIntegral(start_indices_shape)) {
return InvalidArgument(
"dynamic update slice start indices must be of integral type.");
}
const int64 start_num_dims = start_indices_shape.dimensions(0);
if (ShapeUtil::Rank(operand_shape) != start_num_dims) {
return InvalidArgument(
"dynamic slice start number of dimensions %lld (%s) must match rank "
"%lld of slice input (%s)",
start_num_dims, ShapeUtil::HumanString(start_indices_shape).c_str(),
ShapeUtil::Rank(operand_shape),
ShapeUtil::HumanString(operand_shape).c_str());
}
if (ShapeUtil::Rank(update_shape) != ShapeUtil::Rank(operand_shape)) {
return InvalidArgument(
"dynamic update slice update rank does not match argument rank: "
"%lld vs %lld",
ShapeUtil::Rank(update_shape), ShapeUtil::Rank(operand_shape));
}
if (operand_shape.element_type() != update_shape.element_type()) {
return InvalidArgument(
"dynamic update slice update element type does not match argument. "
"operand.element_type: %s vs update.element_type: %s",
PrimitiveType_Name(operand_shape.element_type()).c_str(),
PrimitiveType_Name(update_shape.element_type()).c_str());
}
for (int64 dim = 0; dim < ShapeUtil::Rank(operand_shape); ++dim) {
const int64 input_dim_size = operand_shape.dimensions(dim);
const int64 update_dim_size = update_shape.dimensions(dim);
if (update_dim_size < 0) {
return InvalidArgument(
"size index %lld to dynamic update slice must be >= 0",
update_dim_size);
}
if (update_dim_size > input_dim_size) {
return InvalidArgument(
"update dim size %lld greater than dynamic slice dimension: %lld",
update_dim_size, input_dim_size);
}
VLOG(2) << tensorflow::strings::Printf("update_sizes[%lld] = %lld", dim,
update_dim_size);
}
return operand_shape;
}
/*static */ StatusOr<Shape> ShapeInference::InferReverseShape(
const Shape& operand_shape, tensorflow::gtl::ArraySlice<int64> dimensions) {
TF_RETURN_IF_ERROR(
ExpectNotTupleOrOpaque(operand_shape, "operand of reverse"));
if (!AllUnique(dimensions)) {
return InvalidArgument("a dimension number is duplicated in reverse");
}
for (int64 dimension : dimensions) {
if (dimension >= ShapeUtil::Rank(operand_shape) || dimension < 0) {
return InvalidArgument(
"one of the reverse dimensions (%lld) is out-of-bounds in shape %s",
dimension, ShapeUtil::HumanString(operand_shape).c_str());
}
}
return operand_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferGetTupleElementShape(
const Shape& arg, int64 index) {
if (!ShapeUtil::IsTuple(arg)) {
return InvalidArgument(
"cannot infer shape: attempting to index into non-tuple: %s",
ShapeUtil::HumanString(arg).c_str());
}
if (index >= arg.tuple_shapes_size()) {
return InvalidArgument(
"cannot infer shape: attempt to index out of tuple bounds: %lld "
">= %d in shape %s",
index, arg.tuple_shapes_size(), ShapeUtil::HumanString(arg).c_str());
}
return arg.tuple_shapes(index);
}
/* static */ StatusOr<Shape> ShapeInference::InferWhileShape(
const ProgramShape& condition, const ProgramShape& body,
const Shape& init) {
// Check the number of parameters for given computations.
if (condition.parameters_size() != 1) {
return InvalidArgument("condition must take 1 arguments; got %d",
condition.parameters_size());
}
if (body.parameters_size() != 1) {
return InvalidArgument("body must take 1 arguments; got %d",
body.parameters_size());
}
auto shape_string = [&]() {
return tensorflow::strings::Printf(
"condition: %s; body: %s; init: %s",
ShapeUtil::HumanString(condition).c_str(),
ShapeUtil::HumanString(body).c_str(),
ShapeUtil::HumanString(init).c_str());
};
// Check the shapes of computation parameters and return types.
if (!ShapeUtil::ShapeIs(condition.result(), PRED, {})) {
return InvalidArgument("condition must return a boolean; got %s",
shape_string().c_str());
}
if (!ShapeUtil::Compatible(body.result(), condition.parameters(0)) ||
!ShapeUtil::Compatible(body.result(), body.parameters(0)) ||
!ShapeUtil::Compatible(body.result(), init)) {
return InvalidArgument(
"the parameter of condition and body, the result of the body, and init "
"must all have the same shape; got %s",
shape_string().c_str());
}
return init;
}
/* static */ StatusOr<Shape> ShapeInference::InferConditionalShape(
const Shape& predicate, const Shape& true_operand,
const Shape& false_operand, const ProgramShape& true_computation,
const ProgramShape& false_computation) {
if (!ShapeUtil::ShapeIs(predicate, PRED, {})) {
return InvalidArgument("predicate must be a boolean; got %s.",
ShapeUtil::HumanString(predicate).c_str());
}
if (true_computation.parameters_size() != 1) {
return InvalidArgument("true_computation must take 1 argument; got %d.",
true_computation.parameters_size());
}
if (!ShapeUtil::Compatible(true_computation.parameters(0), true_operand)) {
auto true_shape_string = [&]() {
return tensorflow::strings::Printf(
"true_operand: %s; true_computation: %s",
ShapeUtil::HumanString(true_operand).c_str(),
ShapeUtil::HumanString(true_computation).c_str());
};
return InvalidArgument(
"true_operand must match the shape of the only parameter of "
"true_computation: got %s.",
true_shape_string().c_str());
}
if (false_computation.parameters_size() != 1) {
return InvalidArgument("false_computation must take 1 argument; got %d.",
false_computation.parameters_size());
}
if (!ShapeUtil::Compatible(false_computation.parameters(0), false_operand)) {
auto false_shape_string = [&]() {
return tensorflow::strings::Printf(
"false_operand: %s; false_computation: %s",
ShapeUtil::HumanString(false_operand).c_str(),
ShapeUtil::HumanString(false_computation).c_str());
};
return InvalidArgument(
"false_operand must match the shape of the only parameter of "
"false_computation: got %s.",
false_shape_string().c_str());
}
if (!ShapeUtil::Compatible(true_computation.result(),
false_computation.result())) {
auto shape_string = [&]() {
return tensorflow::strings::Printf(
"true_computation result: %s; false_computation result: %s.",
ShapeUtil::HumanString(true_computation.result()).c_str(),
ShapeUtil::HumanString(false_computation.result()).c_str());
};
return InvalidArgument(
"the result of true_computation and false_computation must have the "
"same shape: got %s.",
shape_string().c_str());
}
return true_computation.result();
}
/* static */ StatusOr<Shape> ShapeInference::InferBroadcastShape(
const Shape& operand, tensorflow::gtl::ArraySlice<int64> broadcast_sizes) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(operand, "operand of broadcast"));
for (int64 size : broadcast_sizes) {
if (size < 0) {
return InvalidArgument("Broadcast with negative dimension size %lld.",
size);
}
}
std::vector<int64> dimensions(operand.dimensions_size() +
broadcast_sizes.size());
std::copy(broadcast_sizes.begin(), broadcast_sizes.end(), dimensions.begin());
std::copy(operand.dimensions().begin(), operand.dimensions().end(),
dimensions.begin() + broadcast_sizes.size());
return ShapeUtil::MakeShape(operand.element_type(), dimensions);
}
/* static */ StatusOr<Shape> ShapeInference::InferReshapeShape(
const Shape& operand, tensorflow::gtl::ArraySlice<int64> dimensions,
tensorflow::gtl::ArraySlice<int64> new_sizes) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(operand, "reshape"));
Shape inferred_shape =
ShapeUtil::MakeShape(operand.element_type(), new_sizes);
VLOG(3) << "Reshape inferred shape: "
<< ShapeUtil::HumanString(inferred_shape);
if (ShapeUtil::ElementsIn(operand) != ShapeUtil::ElementsIn(inferred_shape)) {
return InvalidArgument(
"reshape operation has mismatched element counts: from=%lld (%s) "
"to=%lld (%s)",
ShapeUtil::ElementsIn(operand), ShapeUtil::HumanString(operand).c_str(),
ShapeUtil::ElementsIn(inferred_shape),
ShapeUtil::HumanString(inferred_shape).c_str());
}
std::vector<int64> indices(ShapeUtil::Rank(operand));
std::iota(indices.begin(), indices.end(), 0);
if (dimensions.size() != ShapeUtil::Rank(operand) ||
!std::is_permutation(dimensions.begin(), dimensions.end(),
indices.begin())) {
return InvalidArgument(
"Reshape dimensions [%s] are not a permutation of the operand "
"dimensions (operand shape is %s).",
tensorflow::str_util::Join(dimensions, ",").c_str(),
ShapeUtil::HumanString(operand).c_str());
}
return inferred_shape;
}
/* static */ StatusOr<Shape> ShapeInference::InferTransposeShape(
const Shape& operand, tensorflow::gtl::ArraySlice<int64> dimensions) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(operand, "transpose"));
std::vector<int64> indices(ShapeUtil::Rank(operand));
std::iota(indices.begin(), indices.end(), 0);
if (dimensions.size() != ShapeUtil::Rank(operand) ||
!std::is_permutation(dimensions.begin(), dimensions.end(),
indices.begin())) {
return InvalidArgument(
"Transpose dimensions not a permutation of the operand dimensions.");
}
// Permute(dimensions,input) computes output[dimensions[i]]=input[i]. However,
// we need output[i]=input[dimensions[i]] which is
// Permute(Inverse(dimensions),input).
return ShapeUtil::PermuteDimensions(InversePermutation(dimensions), operand);
}
// TODO (b/36794510): Make broadcast semantics more consistent, by supporting id:413 gh:414
// "degenerate" cases, as with binary elementwise ops.
/* static */ StatusOr<Shape> ShapeInference::InferClampShape(
const Shape& min, const Shape& operand, const Shape& max) {
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(min, "clamp min"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(operand, "clamp operand"));
TF_RETURN_IF_ERROR(ExpectNotTupleOrOpaque(max, "clamp max"));
if (!ShapeUtil::SameElementType(min, operand) ||
!ShapeUtil::SameElementType(max, operand)) {
return InvalidArgument("clamp op with different operand types: %s, %s, %s",
ShapeUtil::HumanString(min).c_str(),
ShapeUtil::HumanString(operand).c_str(),
ShapeUtil::HumanString(max).c_str());
}
if (((ShapeUtil::Compatible(min, operand) || ShapeUtil::IsScalar(min)) &&
(ShapeUtil::Compatible(max, operand) || ShapeUtil::IsScalar(max)))) {
return operand;
}
if (ShapeUtil::IsScalar(operand)) {
if (ShapeUtil::Compatible(min, max)) {
return min;
} else if (ShapeUtil::IsScalar(min)) {
return max;
} else if (ShapeUtil::IsScalar(max)) {
return min;
}
}
return Unimplemented(
"not yet implemented: %s, %s <clamp> %s", min.ShortDebugString().c_str(),
max.ShortDebugString().c_str(), operand.ShortDebugString().c_str());
}
// TODO (b/36794510): Make broadcast semantics more consistent, by supporting id:415 gh:416
// "degenerate" cases, as with binary elementwise ops, as well as scalar
// broadcast from all operands, not just the predicate.
/* static */ StatusOr<Shape> ShapeInference::InferSelectShape(
const Shape& pred, const Shape& on_true, const Shape& on_false) {
if (!ShapeUtil::Compatible(on_true, on_false)) {
return InvalidArgument(
"operands to select must be the same shape; got %s and %s",
ShapeUtil::HumanString(on_true).c_str(),
ShapeUtil::HumanString(on_false).c_str());
}
if (pred.element_type() != PRED) {
return InvalidArgument(
"select's pred operand must have PRED element type; got %s",
ShapeUtil::HumanString(pred).c_str());
}
if (ShapeUtil::SameDimensions(pred, on_true) || ShapeUtil::Rank(pred) == 0) {
// By this stage we know that pred's element type is PRED. Therefore, this
// check restricts pred to be a PRED scalar, or a PRED array with the same
// dimensions as on_true and on_false.
return on_true;
} else {
return Unimplemented(
"select operation with non-scalar predicate with dimensionality "
" different from the other operands: %s",
ShapeUtil::HumanString(pred).c_str());
}
}
/* static */ StatusOr<Shape> ShapeInference::InferCallShape(
tensorflow::gtl::ArraySlice<const Shape*> arg_shapes,
const ProgramShape& to_apply) {
// The applied function's arity equals the number of arguments.
if (arg_shapes.size() != to_apply.parameters_size()) {
string computation_signature = ShapeUtil::HumanString(to_apply);
string argument_shapes = tensorflow::str_util::Join(
arg_shapes, ", ", [](string* out, const Shape* shape) {
tensorflow::strings::StrAppend(out, ShapeUtil::HumanString(*shape));
});
return InvalidArgument(
"Call applied function arity must match number of arguments; got: "
"arity: %d, arguments: %zu; computation signature: %s; argument "
"shapes: [%s]",
to_apply.parameters_size(), arg_shapes.size(),
computation_signature.c_str(), argument_shapes.c_str());
}
// All arguments must be compatible with the program shape.
for (int i = 0; i < arg_shapes.size(); ++i) {
const Shape& arg_shape = *arg_shapes[i];
const Shape& param_shape = to_apply.parameters(i);
if (!ShapeUtil::Compatible(arg_shape, param_shape)) {
return InvalidArgument(
"Call parameter must match argument; got parameter %d shape: %s, "
"argument shape: %s",
i, ShapeUtil::HumanString(param_shape).c_str(),
ShapeUtil::HumanString(arg_shape).c_str());
}
}
return to_apply.result();
}
} // namespace xla
|
//
// LimitedNodeList.cpp
// libraries/networking/src
//
// Created by Stephen Birarda on 2/15/13.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "LimitedNodeList.h"
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <QtCore/QDataStream>
#include <QtCore/QDebug>
#include <QtCore/QJsonDocument>
#include <QtCore/QThread>
#include <QtCore/QUrl>
#include <QtNetwork/QTcpSocket>
#include <QtNetwork/QHostInfo>
#include <LogHandler.h>
#include <shared/NetworkUtils.h>
#include <NumericalConstants.h>
#include <SettingHandle.h>
#include <SharedUtil.h>
#include <UUID.h>
#include "AccountManager.h"
#include "AssetClient.h"
#include "Assignment.h"
#include "HifiSockAddr.h"
#include "NetworkLogging.h"
#include "udt/Packet.h"
static Setting::Handle<quint16> LIMITED_NODELIST_LOCAL_PORT("LimitedNodeList.LocalPort", 0);
const std::set<NodeType_t> SOLO_NODE_TYPES = {
NodeType::AvatarMixer,
NodeType::AudioMixer,
NodeType::AssetServer,
NodeType::EntityServer,
NodeType::MessagesMixer,
NodeType::EntityScriptServer
};
LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
_nodeSocket(this),
_packetReceiver(new PacketReceiver(this))
{
qRegisterMetaType<ConnectionStep>("ConnectionStep");
auto port = (socketListenPort != INVALID_PORT) ? socketListenPort : LIMITED_NODELIST_LOCAL_PORT.get();
_nodeSocket.bind(QHostAddress::AnyIPv4, port);
qCDebug(networking) << "NodeList socket is listening on" << _nodeSocket.localPort();
if (dtlsListenPort != INVALID_PORT) {
// only create the DTLS socket during constructor if a custom port is passed
_dtlsSocket = new QUdpSocket(this);
_dtlsSocket->bind(QHostAddress::AnyIPv4, dtlsListenPort);
qCDebug(networking) << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort();
}
// check for local socket updates every so often
const int LOCAL_SOCKET_UPDATE_INTERVAL_MSECS = 5 * 1000;
QTimer* localSocketUpdate = new QTimer(this);
connect(localSocketUpdate, &QTimer::timeout, this, &LimitedNodeList::updateLocalSocket);
localSocketUpdate->start(LOCAL_SOCKET_UPDATE_INTERVAL_MSECS);
QTimer* silentNodeTimer = new QTimer(this);
connect(silentNodeTimer, &QTimer::timeout, this, &LimitedNodeList::removeSilentNodes);
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
// check the local socket right now
updateLocalSocket();
// set &PacketReceiver::handleVerifiedPacket as the verified packet callback for the udt::Socket
_nodeSocket.setPacketHandler([this](std::unique_ptr<udt::Packet> packet) {
_packetReceiver->handleVerifiedPacket(std::move(packet));
});
_nodeSocket.setMessageHandler([this](std::unique_ptr<udt::Packet> packet) {
_packetReceiver->handleVerifiedMessagePacket(std::move(packet));
});
_nodeSocket.setMessageFailureHandler([this](HifiSockAddr from,
udt::Packet::MessageNumber messageNumber) {
_packetReceiver->handleMessageFailure(from, messageNumber);
});
// set our isPacketVerified method as the verify operator for the udt::Socket
using std::placeholders::_1;
_nodeSocket.setPacketFilterOperator(std::bind(&LimitedNodeList::isPacketVerified, this, _1));
// set our socketBelongsToNode method as the connection creation filter operator for the udt::Socket
_nodeSocket.setConnectionCreationFilterOperator(std::bind(&LimitedNodeList::sockAddrBelongsToNode, this, _1));
// handle when a socket connection has its receiver side reset - might need to emit clientConnectionToNodeReset
connect(&_nodeSocket, &udt::Socket::clientHandshakeRequestComplete, this, &LimitedNodeList::clientConnectionToSockAddrReset);
_packetStatTimer.start();
if (_stunSockAddr.getAddress().isNull()) {
// we don't know the stun server socket yet, add it to unfiltered once known
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::addSTUNHandlerToUnfiltered);
} else {
// we know the stun server socket, add it to unfiltered now
addSTUNHandlerToUnfiltered();
}
}
QUuid LimitedNodeList::getSessionUUID() const {
QReadLocker lock { &_sessionUUIDLock };
return _sessionUUID;
}
void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) {
QUuid oldUUID;
{
QWriteLocker lock { &_sessionUUIDLock };
oldUUID = _sessionUUID;
_sessionUUID = sessionUUID;
}
if (sessionUUID != oldUUID) {
qCDebug(networking) << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID)
<< "to" << uuidStringWithoutCurlyBraces(sessionUUID);
emit uuidChanged(sessionUUID, oldUUID);
}
}
void LimitedNodeList::setPermissions(const NodePermissions& newPermissions) {
NodePermissions originalPermissions = _permissions;
_permissions = newPermissions;
if (originalPermissions.can(NodePermissions::Permission::canAdjustLocks) !=
newPermissions.can(NodePermissions::Permission::canAdjustLocks)) {
emit isAllowedEditorChanged(_permissions.can(NodePermissions::Permission::canAdjustLocks));
}
if (originalPermissions.can(NodePermissions::Permission::canRezPermanentEntities) !=
newPermissions.can(NodePermissions::Permission::canRezPermanentEntities)) {
emit canRezChanged(_permissions.can(NodePermissions::Permission::canRezPermanentEntities));
}
if (originalPermissions.can(NodePermissions::Permission::canRezTemporaryEntities) !=
newPermissions.can(NodePermissions::Permission::canRezTemporaryEntities)) {
emit canRezTmpChanged(_permissions.can(NodePermissions::Permission::canRezTemporaryEntities));
}
if (originalPermissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities) !=
newPermissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities)) {
emit canRezCertifiedChanged(_permissions.can(NodePermissions::Permission::canRezPermanentCertifiedEntities));
}
if (originalPermissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities) !=
newPermissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities)) {
emit canRezTmpCertifiedChanged(_permissions.can(NodePermissions::Permission::canRezTemporaryCertifiedEntities));
}
if (originalPermissions.can(NodePermissions::Permission::canWriteToAssetServer) !=
newPermissions.can(NodePermissions::Permission::canWriteToAssetServer)) {
emit canWriteAssetsChanged(_permissions.can(NodePermissions::Permission::canWriteToAssetServer));
}
if (originalPermissions.can(NodePermissions::Permission::canKick) !=
newPermissions.can(NodePermissions::Permission::canKick)) {
emit canKickChanged(_permissions.can(NodePermissions::Permission::canKick));
}
if (originalPermissions.can(NodePermissions::Permission::canReplaceDomainContent) !=
newPermissions.can(NodePermissions::Permission::canReplaceDomainContent)) {
emit canReplaceContentChanged(_permissions.can(NodePermissions::Permission::canReplaceDomainContent));
}
}
void LimitedNodeList::setSocketLocalPort(quint16 socketLocalPort) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setSocketLocalPort", Qt::QueuedConnection,
Q_ARG(quint16, socketLocalPort));
return;
}
if (_nodeSocket.localPort() != socketLocalPort) {
_nodeSocket.rebind(socketLocalPort);
LIMITED_NODELIST_LOCAL_PORT.set(socketLocalPort);
}
}
QUdpSocket& LimitedNodeList::getDTLSSocket() {
if (!_dtlsSocket) {
// DTLS socket getter called but no DTLS socket exists, create it now
_dtlsSocket = new QUdpSocket(this);
_dtlsSocket->bind(QHostAddress::AnyIPv4, 0, QAbstractSocket::DontShareAddress);
// we're using DTLS and our socket is good to go, so make the required DTLS changes
// DTLS requires that IP_DONTFRAG be set
// This is not accessible on some platforms (OS X) so we need to make sure DTLS still works without it
qCDebug(networking) << "LimitedNodeList DTLS socket is listening on" << _dtlsSocket->localPort();
}
return *_dtlsSocket;
}
bool LimitedNodeList::isPacketVerifiedWithSource(const udt::Packet& packet, Node* sourceNode) {
// We track bandwidth when doing packet verification to avoid needing to do a node lookup
// later when we already do it in packetSourceAndHashMatchAndTrackBandwidth. A node lookup
// incurs a lock, so it is ideal to avoid needing to do it 2+ times for each packet
// received.
return packetVersionMatch(packet) && packetSourceAndHashMatchAndTrackBandwidth(packet, sourceNode);
}
bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
PacketType headerType = NLPacket::typeInHeader(packet);
PacketVersion headerVersion = NLPacket::versionInHeader(packet);
if (headerVersion != versionForPacketType(headerType)) {
static QMultiHash<QUuid, PacketType> sourcedVersionDebugSuppressMap;
static QMultiHash<HifiSockAddr, PacketType> versionDebugSuppressMap;
bool hasBeenOutput = false;
QString senderString;
const HifiSockAddr& senderSockAddr = packet.getSenderSockAddr();
QUuid sourceID;
if (PacketTypeEnum::getNonSourcedPackets().contains(headerType)) {
hasBeenOutput = versionDebugSuppressMap.contains(senderSockAddr, headerType);
if (!hasBeenOutput) {
versionDebugSuppressMap.insert(senderSockAddr, headerType);
senderString = QString("%1:%2").arg(senderSockAddr.getAddress().toString()).arg(senderSockAddr.getPort());
}
} else {
sourceID = NLPacket::sourceIDInHeader(packet);
hasBeenOutput = sourcedVersionDebugSuppressMap.contains(sourceID, headerType);
if (!hasBeenOutput) {
sourcedVersionDebugSuppressMap.insert(sourceID, headerType);
senderString = uuidStringWithoutCurlyBraces(sourceID.toString());
}
}
if (!hasBeenOutput) {
qCDebug(networking) << "Packet version mismatch on" << headerType << "- Sender"
<< senderString << "sent" << qPrintable(QString::number(headerVersion)) << "but"
<< qPrintable(QString::number(versionForPacketType(headerType))) << "expected.";
emit packetVersionMismatch(headerType, senderSockAddr, sourceID);
}
return false;
} else {
return true;
}
}
bool LimitedNodeList::packetSourceAndHashMatchAndTrackBandwidth(const udt::Packet& packet, Node* sourceNode) {
PacketType headerType = NLPacket::typeInHeader(packet);
if (PacketTypeEnum::getNonSourcedPackets().contains(headerType)) {
if (PacketTypeEnum::getReplicatedPacketMapping().key(headerType) != PacketType::Unknown) {
// this is a replicated packet type - make sure the socket that sent it to us matches
// one from one of our current upstream nodes
NodeType_t sendingNodeType { NodeType::Unassigned };
eachNodeBreakable([&packet, &sendingNodeType](const SharedNodePointer& node){
if (NodeType::isUpstream(node->getType()) && node->getPublicSocket() == packet.getSenderSockAddr()) {
sendingNodeType = node->getType();
return false;
} else {
return true;
}
});
if (sendingNodeType != NodeType::Unassigned) {
emit dataReceived(sendingNodeType, packet.getPayloadSize());
return true;
} else {
static const QString UNSOLICITED_REPLICATED_REGEX =
"Replicated packet of type \\d+ \\([\\sa-zA-Z:]+\\) received from unknown upstream";
static QString repeatedMessage
= LogHandler::getInstance().addRepeatedMessageRegex(UNSOLICITED_REPLICATED_REGEX);
qCDebug(networking) << "Replicated packet of type" << headerType
<< "received from unknown upstream" << packet.getSenderSockAddr();
return false;
}
} else {
emit dataReceived(NodeType::Unassigned, packet.getPayloadSize());
return true;
}
} else {
QUuid sourceID = NLPacket::sourceIDInHeader(packet);
// check if we were passed a sourceNode hint or if we need to look it up
if (!sourceNode) {
// figure out which node this is from
SharedNodePointer matchingNode = nodeWithUUID(sourceID);
sourceNode = matchingNode.data();
}
if (!sourceNode &&
sourceID == getDomainUUID() &&
packet.getSenderSockAddr() == getDomainSockAddr() &&
PacketTypeEnum::getDomainSourcedPackets().contains(headerType)) {
// This is a packet sourced by the domain server
emit dataReceived(NodeType::Unassigned, packet.getPayloadSize());
return true;
}
if (sourceNode) {
bool verifiedPacket = !PacketTypeEnum::getNonVerifiedPackets().contains(headerType);
bool ignoreVerification = isDomainServer() && PacketTypeEnum::getDomainIgnoredVerificationPackets().contains(headerType);
if (verifiedPacket && !ignoreVerification) {
QByteArray packetHeaderHash = NLPacket::verificationHashInHeader(packet);
QByteArray expectedHash = NLPacket::hashForPacketAndSecret(packet, sourceNode->getConnectionSecret());
// check if the md5 hash in the header matches the hash we would expect
if (packetHeaderHash != expectedHash) {
static QMultiMap<QUuid, PacketType> hashDebugSuppressMap;
if (!hashDebugSuppressMap.contains(sourceID, headerType)) {
qCDebug(networking) << packetHeaderHash << expectedHash;
qCDebug(networking) << "Packet hash mismatch on" << headerType << "- Sender" << sourceID;
hashDebugSuppressMap.insert(sourceID, headerType);
}
return false;
}
}
// No matter if this packet is handled or not, we update the timestamp for the last time we heard
// from this sending node
sourceNode->setLastHeardMicrostamp(usecTimestampNow());
emit dataReceived(sourceNode->getType(), packet.getPayloadSize());
return true;
} else {
static const QString UNKNOWN_REGEX = "Packet of type \\d+ \\([\\sa-zA-Z:]+\\) received from unknown node with UUID";
static QString repeatedMessage
= LogHandler::getInstance().addRepeatedMessageRegex(UNKNOWN_REGEX);
qCDebug(networking) << "Packet of type" << headerType
<< "received from unknown node with UUID" << uuidStringWithoutCurlyBraces(sourceID);
}
}
return false;
}
void LimitedNodeList::collectPacketStats(const NLPacket& packet) {
// stat collection for packets
++_numCollectedPackets;
_numCollectedBytes += packet.getDataSize();
}
void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret) {
if (!PacketTypeEnum::getNonSourcedPackets().contains(packet.getType())) {
packet.writeSourceID(getSessionUUID());
}
if (!connectionSecret.isNull()
&& !PacketTypeEnum::getNonSourcedPackets().contains(packet.getType())
&& !PacketTypeEnum::getNonVerifiedPackets().contains(packet.getType())) {
packet.writeVerificationHashGivenSecret(connectionSecret);
}
}
static const qint64 ERROR_SENDING_PACKET_BYTES = -1;
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) {
Q_ASSERT(!packet.isPartOfMessage());
if (!destinationNode.getActiveSocket()) {
return 0;
}
emit dataSent(destinationNode.getType(), packet.getDataSize());
destinationNode.recordBytesSent(packet.getDataSize());
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret());
}
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr,
const QUuid& connectionSecret) {
Q_ASSERT(!packet.isPartOfMessage());
Q_ASSERT_X(!packet.isReliable(), "LimitedNodeList::sendUnreliablePacket",
"Trying to send a reliable packet unreliably.");
collectPacketStats(packet);
fillPacketHeader(packet, connectionSecret);
return _nodeSocket.writePacket(packet, sockAddr);
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode) {
Q_ASSERT(!packet->isPartOfMessage());
auto activeSocket = destinationNode.getActiveSocket();
if (activeSocket) {
emit dataSent(destinationNode.getType(), packet->getDataSize());
destinationNode.recordBytesSent(packet->getDataSize());
return sendPacket(std::move(packet), *activeSocket, destinationNode.getConnectionSecret());
} else {
qCDebug(networking) << "LimitedNodeList::sendPacket called without active socket for node" << destinationNode << "- not sending";
return ERROR_SENDING_PACKET_BYTES;
}
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr,
const QUuid& connectionSecret) {
Q_ASSERT(!packet->isPartOfMessage());
if (packet->isReliable()) {
collectPacketStats(*packet);
fillPacketHeader(*packet, connectionSecret);
auto size = packet->getDataSize();
_nodeSocket.writePacket(std::move(packet), sockAddr);
return size;
} else {
return sendUnreliablePacket(*packet, sockAddr, connectionSecret);
}
}
qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetList, const Node& destinationNode) {
auto activeSocket = destinationNode.getActiveSocket();
if (activeSocket) {
qint64 bytesSent = 0;
auto connectionSecret = destinationNode.getConnectionSecret();
// close the last packet in the list
packetList.closeCurrentPacket();
while (!packetList._packets.empty()) {
bytesSent += sendPacket(packetList.takeFront<NLPacket>(), *activeSocket, connectionSecret);
}
emit dataSent(destinationNode.getType(), bytesSent);
return bytesSent;
} else {
qCDebug(networking) << "LimitedNodeList::sendPacketList called without active socket for node" << destinationNode
<< " - not sending.";
return ERROR_SENDING_PACKET_BYTES;
}
}
qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr,
const QUuid& connectionSecret) {
qint64 bytesSent = 0;
// close the last packet in the list
packetList.closeCurrentPacket();
while (!packetList._packets.empty()) {
bytesSent += sendPacket(packetList.takeFront<NLPacket>(), sockAddr, connectionSecret);
}
return bytesSent;
}
qint64 LimitedNodeList::sendPacketList(std::unique_ptr<NLPacketList> packetList, const HifiSockAddr& sockAddr) {
// close the last packet in the list
packetList->closeCurrentPacket();
for (std::unique_ptr<udt::Packet>& packet : packetList->_packets) {
NLPacket* nlPacket = static_cast<NLPacket*>(packet.get());
collectPacketStats(*nlPacket);
fillPacketHeader(*nlPacket);
}
return _nodeSocket.writePacketList(std::move(packetList), sockAddr);
}
qint64 LimitedNodeList::sendPacketList(std::unique_ptr<NLPacketList> packetList, const Node& destinationNode) {
auto activeSocket = destinationNode.getActiveSocket();
if (activeSocket) {
// close the last packet in the list
packetList->closeCurrentPacket();
for (std::unique_ptr<udt::Packet>& packet : packetList->_packets) {
NLPacket* nlPacket = static_cast<NLPacket*>(packet.get());
collectPacketStats(*nlPacket);
fillPacketHeader(*nlPacket, destinationNode.getConnectionSecret());
}
return _nodeSocket.writePacketList(std::move(packetList), *activeSocket);
} else {
qCDebug(networking) << "LimitedNodeList::sendPacketList called without active socket for node "
<< destinationNode.getUUID() << ". Not sending.";
return ERROR_SENDING_PACKET_BYTES;
}
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
const HifiSockAddr& overridenSockAddr) {
if (overridenSockAddr.isNull() && !destinationNode.getActiveSocket()) {
qCDebug(networking) << "LimitedNodeList::sendPacket called without active socket for node"
<< destinationNode.getUUID() << ". Not sending.";
return ERROR_SENDING_PACKET_BYTES;
}
// use the node's active socket as the destination socket if there is no overriden socket address
auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket()
: overridenSockAddr;
return sendPacket(std::move(packet), destinationSockAddr, destinationNode.getConnectionSecret());
}
int LimitedNodeList::updateNodeWithDataFromPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
NodeData* linkedData = getOrCreateLinkedData(sendingNode);
if (linkedData) {
QMutexLocker linkedDataLocker(&linkedData->getMutex());
return linkedData->parseData(*message);
}
return 0;
}
NodeData* LimitedNodeList::getOrCreateLinkedData(SharedNodePointer node) {
QMutexLocker locker(&node->getMutex());
NodeData* linkedData = node->getLinkedData();
if (!linkedData && linkedDataCreateCallback) {
linkedDataCreateCallback(node.data());
}
return node->getLinkedData();
}
SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
QReadLocker readLocker(&_nodeMutex);
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
}
void LimitedNodeList::eraseAllNodes() {
QSet<SharedNodePointer> killedNodes;
{
// iterate the current nodes - grab them so we can emit that they are dying
// and then remove them from the hash
QWriteLocker writeLocker(&_nodeMutex);
if (_nodeHash.size() > 0) {
qCDebug(networking) << "LimitedNodeList::eraseAllNodes() removing all nodes from NodeList.";
auto it = _nodeHash.begin();
while (it != _nodeHash.end()) {
killedNodes.insert(it->second);
it = _nodeHash.unsafe_erase(it);
}
}
}
foreach(const SharedNodePointer& killedNode, killedNodes) {
handleNodeKill(killedNode);
}
}
void LimitedNodeList::reset() {
eraseAllNodes();
// we need to make sure any socket connections are gone so wait on that here
_nodeSocket.clearConnections();
}
bool LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
QReadLocker readLocker(&_nodeMutex);
NodeHash::iterator it = _nodeHash.find(nodeUUID);
if (it != _nodeHash.end()) {
SharedNodePointer matchingNode = it->second;
readLocker.unlock();
{
QWriteLocker writeLocker(&_nodeMutex);
_nodeHash.unsafe_erase(it);
}
handleNodeKill(matchingNode);
return true;
}
return false;
}
void LimitedNodeList::processKillNode(ReceivedMessage& message) {
// read the node id
QUuid nodeUUID = QUuid::fromRfc4122(message.readWithoutCopy(NUM_BYTES_RFC4122_UUID));
// kill the node with this UUID, if it exists
killNodeWithUUID(nodeUUID);
}
void LimitedNodeList::handleNodeKill(const SharedNodePointer& node) {
qCDebug(networking) << "Killed" << *node;
node->stopPingTimer();
emit nodeKilled(node);
if (auto activeSocket = node->getActiveSocket()) {
_nodeSocket.cleanupConnection(*activeSocket);
}
}
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
bool isReplicated, bool isUpstream,
const QUuid& connectionSecret, const NodePermissions& permissions) {
QReadLocker readLocker(&_nodeMutex);
NodeHash::const_iterator it = _nodeHash.find(uuid);
if (it != _nodeHash.end()) {
SharedNodePointer& matchingNode = it->second;
matchingNode->setPublicSocket(publicSocket);
matchingNode->setLocalSocket(localSocket);
matchingNode->setPermissions(permissions);
matchingNode->setConnectionSecret(connectionSecret);
matchingNode->setIsReplicated(isReplicated);
matchingNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
return matchingNode;
} else {
// we didn't have this node, so add them
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
newNode->setIsReplicated(isReplicated);
newNode->setIsUpstream(isUpstream || NodeType::isUpstream(nodeType));
newNode->setConnectionSecret(connectionSecret);
newNode->setPermissions(permissions);
// move the newly constructed node to the LNL thread
newNode->moveToThread(thread());
if (nodeType == NodeType::AudioMixer) {
LimitedNodeList::flagTimeForConnectionStep(LimitedNodeList::AddedAudioMixer);
}
SharedNodePointer newNodePointer(newNode, &QObject::deleteLater);
// if this is a solo node type, we assume that the DS has replaced its assignment and we should kill the previous node
if (SOLO_NODE_TYPES.count(newNode->getType())) {
// while we still have the read lock, see if there is a previous solo node we'll need to remove
auto previousSoloIt = std::find_if(_nodeHash.cbegin(), _nodeHash.cend(), [newNode](const UUIDNodePair& nodePair){
return nodePair.second->getType() == newNode->getType();
});
if (previousSoloIt != _nodeHash.cend()) {
// we have a previous solo node, switch to a write lock so we can remove it
readLocker.unlock();
QWriteLocker writeLocker(&_nodeMutex);
auto oldSoloNode = previousSoloIt->second;
_nodeHash.unsafe_erase(previousSoloIt);
handleNodeKill(oldSoloNode);
// convert the current lock back to a read lock for insertion of new node
writeLocker.unlock();
readLocker.relock();
}
}
// insert the new node and release our read lock
#if defined(Q_OS_ANDROID) || (defined(__clang__) && defined(Q_OS_LINUX))
_nodeHash.insert(UUIDNodePair(newNode->getUUID(), newNodePointer));
#else
_nodeHash.emplace(newNode->getUUID(), newNodePointer);
#endif
readLocker.unlock();
qCDebug(networking) << "Added" << *newNode;
auto weakPtr = newNodePointer.toWeakRef(); // We don't want the lambdas to hold a strong ref
emit nodeAdded(newNodePointer);
if (newNodePointer->getActiveSocket()) {
emit nodeActivated(newNodePointer);
} else {
connect(newNodePointer.data(), &NetworkPeer::socketActivated, this, [this, weakPtr] {
auto sharedPtr = weakPtr.lock();
if (sharedPtr) {
emit nodeActivated(sharedPtr);
disconnect(sharedPtr.data(), &NetworkPeer::socketActivated, this, 0);
}
});
}
// Signal when a socket changes, so we can start the hole punch over.
connect(newNodePointer.data(), &NetworkPeer::socketUpdated, this, [this, weakPtr] {
emit nodeSocketUpdated(weakPtr);
});
return newNodePointer;
}
}
std::unique_ptr<NLPacket> LimitedNodeList::constructPingPacket(PingType_t pingType) {
int packetSize = sizeof(PingType_t) + sizeof(quint64);
auto pingPacket = NLPacket::create(PacketType::Ping, packetSize);
pingPacket->writePrimitive(pingType);
pingPacket->writePrimitive(usecTimestampNow());
return pingPacket;
}
std::unique_ptr<NLPacket> LimitedNodeList::constructPingReplyPacket(ReceivedMessage& message) {
PingType_t typeFromOriginalPing;
quint64 timeFromOriginalPing;
message.readPrimitive(&typeFromOriginalPing);
message.readPrimitive(&timeFromOriginalPing);
int packetSize = sizeof(PingType_t) + sizeof(quint64) + sizeof(quint64);
auto replyPacket = NLPacket::create(PacketType::PingReply, packetSize);
replyPacket->writePrimitive(typeFromOriginalPing);
replyPacket->writePrimitive(timeFromOriginalPing);
replyPacket->writePrimitive(usecTimestampNow());
return replyPacket;
}
std::unique_ptr<NLPacket> LimitedNodeList::constructICEPingPacket(PingType_t pingType, const QUuid& iceID) {
int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t);
auto icePingPacket = NLPacket::create(PacketType::ICEPing, packetSize);
icePingPacket->write(iceID.toRfc4122());
icePingPacket->writePrimitive(pingType);
return icePingPacket;
}
std::unique_ptr<NLPacket> LimitedNodeList::constructICEPingReplyPacket(ReceivedMessage& message, const QUuid& iceID) {
// pull out the ping type so we can reply back with that
PingType_t pingType;
memcpy(&pingType, message.getRawMessage() + NUM_BYTES_RFC4122_UUID, sizeof(PingType_t));
int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t);
auto icePingReplyPacket = NLPacket::create(PacketType::ICEPingReply, packetSize);
// pack the ICE ID and then the ping type
icePingReplyPacket->write(iceID.toRfc4122());
icePingReplyPacket->writePrimitive(pingType);
return icePingReplyPacket;
}
unsigned int LimitedNodeList::broadcastToNodes(std::unique_ptr<NLPacket> packet, const NodeSet& destinationNodeTypes) {
unsigned int n = 0;
eachNode([&](const SharedNodePointer& node){
if (node && destinationNodeTypes.contains(node->getType())) {
sendUnreliablePacket(*packet, *node);
++n;
}
});
return n;
}
SharedNodePointer LimitedNodeList::soloNodeOfType(NodeType_t nodeType) {
return nodeMatchingPredicate([&](const SharedNodePointer& node){
return node->getType() == nodeType;
});
}
void LimitedNodeList::getPacketStats(float& packetsInPerSecond, float& bytesInPerSecond, float& packetsOutPerSecond, float& bytesOutPerSecond) {
packetsInPerSecond = (float) getPacketReceiver().getInPacketCount() / ((float) _packetStatTimer.elapsed() / 1000.0f);
bytesInPerSecond = (float) getPacketReceiver().getInByteCount() / ((float) _packetStatTimer.elapsed() / 1000.0f);
packetsOutPerSecond = (float) _numCollectedPackets / ((float) _packetStatTimer.elapsed() / 1000.0f);
bytesOutPerSecond = (float) _numCollectedBytes / ((float) _packetStatTimer.elapsed() / 1000.0f);
}
void LimitedNodeList::resetPacketStats() {
getPacketReceiver().resetCounters();
_numCollectedPackets = 0;
_numCollectedBytes = 0;
_packetStatTimer.restart();
}
void LimitedNodeList::removeSilentNodes() {
QSet<SharedNodePointer> killedNodes;
eachNodeHashIterator([&](NodeHash::iterator& it){
SharedNodePointer node = it->second;
node->getMutex().lock();
if (!node->isForcedNeverSilent()
&& (usecTimestampNow() - node->getLastHeardMicrostamp()) > (NODE_SILENCE_THRESHOLD_MSECS * USECS_PER_MSEC)) {
// call the NodeHash erase to get rid of this node
it = _nodeHash.unsafe_erase(it);
killedNodes.insert(node);
} else {
// we didn't erase this node, push the iterator forwards
++it;
}
node->getMutex().unlock();
});
foreach(const SharedNodePointer& killedNode, killedNodes) {
handleNodeKill(killedNode);
}
}
const uint32_t RFC_5389_MAGIC_COOKIE = 0x2112A442;
const int NUM_BYTES_STUN_HEADER = 20;
void LimitedNodeList::makeSTUNRequestPacket(char* stunRequestPacket) {
int packetIndex = 0;
const uint32_t RFC_5389_MAGIC_COOKIE_NETWORK_ORDER = htonl(RFC_5389_MAGIC_COOKIE);
// leading zeros + message type
const uint16_t REQUEST_MESSAGE_TYPE = htons(0x0001);
memcpy(stunRequestPacket + packetIndex, &REQUEST_MESSAGE_TYPE, sizeof(REQUEST_MESSAGE_TYPE));
packetIndex += sizeof(REQUEST_MESSAGE_TYPE);
// message length (no additional attributes are included)
uint16_t messageLength = 0;
memcpy(stunRequestPacket + packetIndex, &messageLength, sizeof(messageLength));
packetIndex += sizeof(messageLength);
memcpy(stunRequestPacket + packetIndex, &RFC_5389_MAGIC_COOKIE_NETWORK_ORDER, sizeof(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER));
packetIndex += sizeof(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER);
// transaction ID (random 12-byte unsigned integer)
const uint NUM_TRANSACTION_ID_BYTES = 12;
QUuid randomUUID = QUuid::createUuid();
memcpy(stunRequestPacket + packetIndex, randomUUID.toRfc4122().data(), NUM_TRANSACTION_ID_BYTES);
}
void LimitedNodeList::sendSTUNRequest() {
if (!_stunSockAddr.getAddress().isNull()) {
const int NUM_INITIAL_STUN_REQUESTS_BEFORE_FAIL = 10;
if (!_hasCompletedInitialSTUN) {
qCDebug(networking) << "Sending intial stun request to" << STUN_SERVER_HOSTNAME;
if (_numInitialSTUNRequests > NUM_INITIAL_STUN_REQUESTS_BEFORE_FAIL) {
// we're still trying to do our initial STUN we're over the fail threshold
stopInitialSTUNUpdate(false);
}
++_numInitialSTUNRequests;
}
char stunRequestPacket[NUM_BYTES_STUN_HEADER];
makeSTUNRequestPacket(stunRequestPacket);
flagTimeForConnectionStep(ConnectionStep::SendSTUNRequest);
_nodeSocket.writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr);
}
}
bool LimitedNodeList::parseSTUNResponse(udt::BasePacket* packet,
QHostAddress& newPublicAddress, uint16_t& newPublicPort) {
// check the cookie to make sure this is actually a STUN response
// and read the first attribute and make sure it is a XOR_MAPPED_ADDRESS
const int NUM_BYTES_MESSAGE_TYPE_AND_LENGTH = 4;
const uint16_t XOR_MAPPED_ADDRESS_TYPE = htons(0x0020);
const uint32_t RFC_5389_MAGIC_COOKIE_NETWORK_ORDER = htonl(RFC_5389_MAGIC_COOKIE);
int attributeStartIndex = NUM_BYTES_STUN_HEADER;
if (memcmp(packet->getData() + NUM_BYTES_MESSAGE_TYPE_AND_LENGTH,
&RFC_5389_MAGIC_COOKIE_NETWORK_ORDER,
sizeof(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER)) != 0) {
return false;
}
// enumerate the attributes to find XOR_MAPPED_ADDRESS_TYPE
while (attributeStartIndex < packet->getDataSize()) {
if (memcmp(packet->getData() + attributeStartIndex, &XOR_MAPPED_ADDRESS_TYPE, sizeof(XOR_MAPPED_ADDRESS_TYPE)) == 0) {
const int NUM_BYTES_STUN_ATTR_TYPE_AND_LENGTH = 4;
const int NUM_BYTES_FAMILY_ALIGN = 1;
const uint8_t IPV4_FAMILY_NETWORK_ORDER = htons(0x01) >> 8;
int byteIndex = attributeStartIndex + NUM_BYTES_STUN_ATTR_TYPE_AND_LENGTH + NUM_BYTES_FAMILY_ALIGN;
uint8_t addressFamily = 0;
memcpy(&addressFamily, packet->getData() + byteIndex, sizeof(addressFamily));
byteIndex += sizeof(addressFamily);
if (addressFamily == IPV4_FAMILY_NETWORK_ORDER) {
// grab the X-Port
uint16_t xorMappedPort = 0;
memcpy(&xorMappedPort, packet->getData() + byteIndex, sizeof(xorMappedPort));
newPublicPort = ntohs(xorMappedPort) ^ (ntohl(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER) >> 16);
byteIndex += sizeof(xorMappedPort);
// grab the X-Address
uint32_t xorMappedAddress = 0;
memcpy(&xorMappedAddress, packet->getData() + byteIndex, sizeof(xorMappedAddress));
uint32_t stunAddress = ntohl(xorMappedAddress) ^ ntohl(RFC_5389_MAGIC_COOKIE_NETWORK_ORDER);
// QHostAddress newPublicAddress(stunAddress);
newPublicAddress = QHostAddress(stunAddress);
return true;
}
} else {
// push forward attributeStartIndex by the length of this attribute
const int NUM_BYTES_ATTRIBUTE_TYPE = 2;
uint16_t attributeLength = 0;
memcpy(&attributeLength, packet->getData() + attributeStartIndex + NUM_BYTES_ATTRIBUTE_TYPE,
sizeof(attributeLength));
attributeLength = ntohs(attributeLength);
attributeStartIndex += NUM_BYTES_MESSAGE_TYPE_AND_LENGTH + attributeLength;
}
}
return false;
}
void LimitedNodeList::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet) {
uint16_t newPublicPort;
QHostAddress newPublicAddress;
if (parseSTUNResponse(packet.get(), newPublicAddress, newPublicPort)) {
if (newPublicAddress != _publicSockAddr.getAddress() || newPublicPort != _publicSockAddr.getPort()) {
_publicSockAddr = HifiSockAddr(newPublicAddress, newPublicPort);
qCDebug(networking, "New public socket received from STUN server is %s:%hu",
_publicSockAddr.getAddress().toString().toLocal8Bit().constData(),
_publicSockAddr.getPort());
if (!_hasCompletedInitialSTUN) {
// if we're here we have definitely completed our initial STUN sequence
stopInitialSTUNUpdate(true);
}
emit publicSockAddrChanged(_publicSockAddr);
flagTimeForConnectionStep(ConnectionStep::SetPublicSocketFromSTUN);
}
}
}
void LimitedNodeList::startSTUNPublicSocketUpdate() {
if (!_initialSTUNTimer ) {
// setup our initial STUN timer here so we can quickly find out our public IP address
_initialSTUNTimer = new QTimer { this };
connect(_initialSTUNTimer.data(), &QTimer::timeout, this, &LimitedNodeList::sendSTUNRequest);
const int STUN_INITIAL_UPDATE_INTERVAL_MSECS = 250;
_initialSTUNTimer->setInterval(STUN_INITIAL_UPDATE_INTERVAL_MSECS); // 250ms, Qt::CoarseTimer acceptable
// if we don't know the STUN IP yet we need to wait until it is known to start STUN requests
if (_stunSockAddr.getAddress().isNull()) {
// if we fail to lookup the socket then timeout the STUN address lookup
connect(&_stunSockAddr, &HifiSockAddr::lookupFailed, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
// immediately send a STUN request once we know the socket
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::sendSTUNRequest);
// start the initial STUN timer once we know the socket
connect(&_stunSockAddr, SIGNAL(lookupCompleted()), _initialSTUNTimer, SLOT(start()));
// in case we just completely fail to lookup the stun socket - add a 10s single shot that will trigger the fail case
const quint64 STUN_DNS_LOOKUP_TIMEOUT_MSECS = 10 * 1000;
QTimer* lookupTimeoutTimer = new QTimer { this };
lookupTimeoutTimer->setSingleShot(true);
connect(lookupTimeoutTimer, &QTimer::timeout, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
// delete the lookup timeout timer once it has fired
connect(lookupTimeoutTimer, &QTimer::timeout, lookupTimeoutTimer, &QTimer::deleteLater);
lookupTimeoutTimer->start(STUN_DNS_LOOKUP_TIMEOUT_MSECS);
} else {
_initialSTUNTimer->start();
// send an initial STUN request right away
sendSTUNRequest();
}
}
}
void LimitedNodeList::possiblyTimeoutSTUNAddressLookup() {
if (_stunSockAddr.getAddress().isNull()) {
// our stun address is still NULL, but we've been waiting for long enough - time to force a fail
stopInitialSTUNUpdate(false);
}
}
void LimitedNodeList::addSTUNHandlerToUnfiltered() {
// make ourselves the handler of STUN packets when they come in
_nodeSocket.addUnfilteredHandler(_stunSockAddr, [this](std::unique_ptr<udt::BasePacket> packet) { processSTUNResponse(std::move(packet)); });
}
void LimitedNodeList::stopInitialSTUNUpdate(bool success) {
_hasCompletedInitialSTUN = true;
if (!success) {
// if we're here this was the last failed STUN request
// use our DS as our stun server
qCDebug(networking, "Failed to lookup public address via STUN server at %s:%hu.",
STUN_SERVER_HOSTNAME, STUN_SERVER_PORT);
qCDebug(networking) << "LimitedNodeList public socket will be set with local port and null QHostAddress.";
// reset the public address and port to a null address
_publicSockAddr = HifiSockAddr(QHostAddress(), _nodeSocket.localPort());
// we have changed the publicSockAddr, so emit our signal
emit publicSockAddrChanged(_publicSockAddr);
flagTimeForConnectionStep(ConnectionStep::SetPublicSocketFromSTUN);
}
// stop our initial fast timer
if (_initialSTUNTimer) {
_initialSTUNTimer->stop();
_initialSTUNTimer->deleteLater();
}
// We now setup a timer here to fire every so often to check that our IP address has not changed.
// Or, if we failed - if will check if we can eventually get a public socket
const int STUN_IP_ADDRESS_CHECK_INTERVAL_MSECS = 30 * 1000;
QTimer* stunOccasionalTimer = new QTimer { this };
connect(stunOccasionalTimer, &QTimer::timeout, this, &LimitedNodeList::sendSTUNRequest);
stunOccasionalTimer->start(STUN_IP_ADDRESS_CHECK_INTERVAL_MSECS);
}
void LimitedNodeList::updateLocalSocket() {
// when update is called, if the local socket is empty then start with the guessed local socket
if (_localSockAddr.isNull()) {
setLocalSocket(HifiSockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
}
// attempt to use Google's DNS to confirm that local IP
static const QHostAddress RELIABLE_LOCAL_IP_CHECK_HOST = QHostAddress { "8.8.8.8" };
static const int RELIABLE_LOCAL_IP_CHECK_PORT = 53;
QTcpSocket* localIPTestSocket = new QTcpSocket;
connect(localIPTestSocket, &QTcpSocket::connected, this, &LimitedNodeList::connectedForLocalSocketTest);
connect(localIPTestSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorTestingLocalSocket()));
// attempt to connect to our reliable host
localIPTestSocket->connectToHost(RELIABLE_LOCAL_IP_CHECK_HOST, RELIABLE_LOCAL_IP_CHECK_PORT);
}
void LimitedNodeList::connectedForLocalSocketTest() {
auto localIPTestSocket = qobject_cast<QTcpSocket*>(sender());
if (localIPTestSocket) {
auto localHostAddress = localIPTestSocket->localAddress();
if (localHostAddress.protocol() == QAbstractSocket::IPv4Protocol) {
_hasTCPCheckedLocalSocket = true;
setLocalSocket(HifiSockAddr { localHostAddress, _nodeSocket.localPort() });
}
localIPTestSocket->deleteLater();
}
}
void LimitedNodeList::errorTestingLocalSocket() {
auto localIPTestSocket = qobject_cast<QTcpSocket*>(sender());
if (localIPTestSocket) {
// error connecting to the test socket - if we've never set our local socket using this test socket
// then use our possibly updated guessed local address as fallback
if (!_hasTCPCheckedLocalSocket) {
setLocalSocket(HifiSockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
}
localIPTestSocket->deleteLater();;
}
}
void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
if (sockAddr != _localSockAddr) {
if (_localSockAddr.isNull()) {
qCInfo(networking) << "Local socket is" << sockAddr;
} else {
qCInfo(networking) << "Local socket has changed from" << _localSockAddr << "to" << sockAddr;
}
_localSockAddr = sockAddr;
emit localSockAddrChanged(_localSockAddr);
}
}
void LimitedNodeList::sendPeerQueryToIceServer(const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
const QUuid& peerID) {
sendPacketToIceServer(PacketType::ICEServerQuery, iceServerSockAddr, clientID, peerID);
}
SharedNodePointer LimitedNodeList::findNodeWithAddr(const HifiSockAddr& addr) {
QReadLocker locker(&_nodeMutex);
auto it = std::find_if(std::begin(_nodeHash), std::end(_nodeHash), [&](const UUIDNodePair& pair) {
return pair.second->getActiveSocket() ? (*pair.second->getActiveSocket() == addr) : false;
});
return (it != std::end(_nodeHash)) ? it->second : SharedNodePointer();
}
void LimitedNodeList::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
const QUuid& clientID, const QUuid& peerID) {
auto icePacket = NLPacket::create(packetType);
QDataStream iceDataStream(icePacket.get());
iceDataStream << clientID << _publicSockAddr << _localSockAddr;
if (packetType == PacketType::ICEServerQuery) {
assert(!peerID.isNull());
iceDataStream << peerID;
qCDebug(networking) << "Sending packet to ICE server to request connection info for peer with ID"
<< uuidStringWithoutCurlyBraces(peerID);
}
sendPacket(std::move(icePacket), iceServerSockAddr);
}
void LimitedNodeList::putLocalPortIntoSharedMemory(const QString key, QObject* parent, quint16 localPort) {
// save our local port to shared memory so that assignment client children know how to talk to this parent
QSharedMemory* sharedPortMem = new QSharedMemory(key, parent);
// attempt to create the shared memory segment
if (sharedPortMem->create(sizeof(localPort)) || sharedPortMem->attach()) {
sharedPortMem->lock();
memcpy(sharedPortMem->data(), &localPort, sizeof(localPort));
sharedPortMem->unlock();
qCDebug(networking) << "Wrote local listening port" << localPort << "to shared memory at key" << key;
} else {
qWarning() << "Failed to create and attach to shared memory to share local port with assignment-client children.";
}
}
bool LimitedNodeList::getLocalServerPortFromSharedMemory(const QString key, quint16& localPort) {
QSharedMemory sharedMem(key);
if (!sharedMem.attach(QSharedMemory::ReadOnly)) {
qCWarning(networking) << "Could not attach to shared memory at key" << key;
return false;
} else {
sharedMem.lock();
memcpy(&localPort, sharedMem.data(), sizeof(localPort));
sharedMem.unlock();
return true;
}
}
void LimitedNodeList::flagTimeForConnectionStep(ConnectionStep connectionStep) {
QMetaObject::invokeMethod(this, "flagTimeForConnectionStep",
Q_ARG(ConnectionStep, connectionStep),
Q_ARG(quint64, usecTimestampNow()));
}
void LimitedNodeList::flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp) {
if (connectionStep == ConnectionStep::LookupAddress) {
QWriteLocker writeLock(&_connectionTimeLock);
// we clear the current times if the user just fired off a lookup
_lastConnectionTimes.clear();
_areConnectionTimesComplete = false;
_lastConnectionTimes[timestamp] = connectionStep;
} else if (!_areConnectionTimesComplete) {
QWriteLocker writeLock(&_connectionTimeLock);
// anything > than sending the first DS check should not come before the DS check in, so we drop those
// this handles the case where you lookup an address and get packets in the existing domain before changing domains
if (connectionStep > LimitedNodeList::ConnectionStep::SendDSCheckIn
&& (_lastConnectionTimes.key(ConnectionStep::SendDSCheckIn) == 0
|| timestamp <= _lastConnectionTimes.key(ConnectionStep::SendDSCheckIn))) {
return;
}
// if there is no time for existing step add a timestamp on the first call for each ConnectionStep
_lastConnectionTimes[timestamp] = connectionStep;
// if this is a received audio packet we consider our connection times complete
if (connectionStep == ConnectionStep::ReceiveFirstAudioPacket) {
_areConnectionTimesComplete = true;
}
}
}
void LimitedNodeList::clientConnectionToSockAddrReset(const HifiSockAddr& sockAddr) {
// for certain reliable channels higher level classes may need to know if the udt::Connection has been reset
auto matchingNode = findNodeWithAddr(sockAddr);
if (matchingNode) {
emit clientConnectionToNodeReset(matchingNode);
}
}
#if (PR_BUILD || DEV_BUILD)
void LimitedNodeList::sendFakedHandshakeRequestToNode(SharedNodePointer node) {
if (node && node->getActiveSocket()) {
_nodeSocket.sendFakedHandshakeRequest(*node->getActiveSocket());
}
}
#endif
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: bnfApplication.asm
AUTHOR: Adam de Boor, Oct 4, 1991
ROUTINES:
Name Description
---- -----------
METHOD_TA_BUILD_TASK_LIST
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 10/4/91 Initial revision
DESCRIPTION:
B&F-specific implementation of various TaskApplication messages
$Id: bnfApplication.asm,v 1.1 97/04/18 11:58:10 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Movable segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TAFetchTasks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fetch the array of current tasks from the switcher
CALLED BY: EXTERNAL
MSG_TA_REDO_TASKS, MSG_TA_BUILD_TASK_LIST
PASS: ds = object block
RETURN: *ds:ax = chunk array of TATask structures. TAT_flags is
ignored
DESTROYED: es, di, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 5/25/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
TAFetchTasks proc near
us local word
taskTable local BNF_MAX_TASKS dup(BNFTask)
uses bx, si, cx, dx
.enter
;
; Find our own task index so we can skip that entry in the table.
;
mov bx, BNFAPI_GET_ACTIVE_TASK_NUM
call BNFCall
mov ss:[us], ax
;
; Fetch the table of tasks
;
mov bx, BNFAPI_FIND_TASKS
segmov es, ss
lea di, ss:[taskTable]
call BNFCall
push ax ; save # of tasks
;
; Create the array itself.
;
mov bx, size TATask
clr cx
clr si
mov al, mask OCF_IGNORE_DIRTY
call ChunkArrayCreate
;
; During this loop:
; bx = current task index
; cx = # tasks left to process
; *ds:dx = chunk array
; ds:si = task table
; es = object block
pop cx ; cx <- # valid tasks in table
mov dx, si ; *ds:dx <- chunk array
clr bx ; first task is #0
segmov es, ds ; es <- object block
segmov ds, ss ; ds:si <- task table
lea si, ss:[taskTable]
createLoop:
cmp bx, ss:[us]
je nextTask
;
; Append another TATask record to the end of the array.
;
push cx, si
mov si, dx
push ds
segmov ds, es
call ChunkArrayAppend
;
; Set the entry's index to the current task index.
;
mov ds:[di].TAT_index, bx
pop ds
;
; Copy the name in from B&F to TAT_name
;
pop si
push si
add si, offset BNFT_description
mov cx, BNF_TASK_NAME_LENGTH
CheckHack <TAT_name eq 0>
rep movsb
;
; Make sure the thing is null-terminated
;
CheckHack <BNF_TASK_NAME_LENGTH lt TASK_NAME_LENGTH>
clr al
stosb
pop cx, si
nextTask:
;
; Advance to the next entry in the table.
;
inc bx
add si, size BNFTask
loop createLoop
;
; Return *ds:ax = array
;
mov_tr ax, dx
segmov ds, es
.leave
ret
TAFetchTasks endp
Movable ends
|
.386p
page 58,132
;******************************************************************************
title ELIMFUNC - CEMM functions module
;******************************************************************************
;
; (C) Copyright MICROSOFT Corp. 1986-1991
; (C) Copyright COMPAQ Computer Corp. 1986-1991
;
; Title: EMM386.EXE - MICROSOFT Expanded Memory Manager 386 Driver
;
; Module: ELIMFUNC - entry point for VDM functions
;
; Version: 2.00
;
; Date: May 24,1986
;
; Author: Steve Preston
;
;******************************************************************************
;
; Change Log:
;
; DATE REVISION Description
; -------- -------- --------------------------------------------
; 04/24/86 Original From EMML LIM driver.
; 06/28/86 0.02 Name change from CEMM386 to CEMM (SBP).
; 07/05/86 0.04 Added segment R_CODE (SBP).
; 07/10/86 0.05 jmp $+2 before "POPF" (SBP).
; 05/12/87 2.00 moved code to R_CODE (SBP).
; 05/21/87 2.00 added debug functions (SBP).
; 05/31/88 ?.?? set active flag AFTER GoVirtual (SBP).
;
;******************************************************************************
; Functional Description:
; This module contains the ON/OFF functionality code for activating/
; deactivating CEMM from DOS.
;
;******************************************************************************
.lfcond
page
;******************************************************************************
; P U B L I C D E C L A R A T I O N S
;******************************************************************************
;
public b2asc10
public b2asc10_far
public b2ascHEX
public b2ascHEX_far
public ELIM_Entry
public EFunTab
public EFUN_CNT
ifdef QHKN
public Debug_PhysIO
public E_Debug
endif
public E_GetStatus
public E_ONOFF
public E_Weitek
public I_Message_Display
public E_XStatus_Display
;
page
;******************************************************************************
; L O C A L C O N S T A N T S
;******************************************************************************
;
include vdmseg.inc
include vdmsel.inc
include emm386.inc
include page.inc
include emmfunct.inc
include emmdata.inc
include winemm.inc
;******************************************************************************
; E X T E R N A L R E F E R E N C E S
;******************************************************************************
;
R_CODE SEGMENT
EXTRN ttl_hndls: WORD
extrn GoVirtual:near
;; extrn check_XMM:far
; extrn XMMAllocateHMA:far
; extrn XMMDeallocateHMA:far
extrn XMMAllocHMAFar:dword
extrn XMMDeallHMAFar:dword
extrn checkXMMFar:dword
extrn Devname:byte
R_CODE ENDS
LAST SEGMENT
extrn StatusMess:byte
extrn LIMVerMess:byte
extrn TotalPagesMess:byte
extrn AvailPagesMess:byte
extrn TotalHanMess:byte
extrn AvailHanMess:byte
extrn PFBAMess:byte
extrn MemSizeMess:byte
extrn ISizeMess:byte
extrn InitMessage:byte
extrn NoEMSmess:byte
extrn UMBstatusMess:byte
extrn UMBavail:byte
extrn UMBlargest:byte
extrn UMBstart:byte
extrn AvailUMB:near
extrn LargestUMB:near
LAST ENDS
page
;******************************************************************************
; S E G M E N T D E F I N I T I O N
;******************************************************************************
;
;******************************************************************************
;
; Code Segment R_CODE
;
;******************************************************************************
;
R_CODE segment
assume CS:R_CODE, DS:R_CODE, ES:R_CODE
;
; ELIM functions table - far calls
;
EFunTab label dword
dw offset E_GetStatus
dw seg R_CODE
dw offset E_ONOFF
dw seg R_CODE
dw offset E_Weitek
dw seg R_CODE
ifdef QHKN
dw offset E_Debug
dw seg R_CODE
endif
EFUN_CNT equ ($-EFunTab)/4
page
;******************************************************************************
; ELIM_Entry - entry point for general ELIM functions
;
; THIS IS A FAR CALL ROUTINE
;
; ENTRY: REAL or VIRTUAL mode only
; AH = 0 => get current status of VDM/EMM386
; AH = 1 => ON/OFF/AUTO
; AH = 2 => Weitek functions
; AH = 3 => DEBUG entry
; AH = 4 => Message Display
; AH = 5 => Status Display
;
; EXIT: EMM386 is activated/deactivated if possible
; NC => no errors.
; CY => ERROR occured.
; AH = error number
; AH= 01 =>invalid function.
;
; USED: none
;
;******************************************************************************
ELIM_Entry proc far
;
push ebx
push ds
;
mov bx,seg R_CODE
mov ds,bx
assume ds:R_CODE
;
cmp ah,EFUN_CNT ;Q: valid function #
jae SHORT EE_inv_func ; N: return error
xor bx,bx ; Y: exec function
mov bl,ah ; bx = function #
shl bx,2 ; dword index
call CS:EFunTab[bx] ; call the function
;
EE_exit:
pop ds
pop ebx
ret
;
EE_inv_func:
mov ah,01
stc
jmp short EE_exit
;
ELIM_Entry endp
;******************************************************************************
; E_GetStatus - get ELIM/VDM status
;
; ENTRY: AH = 0
; DS = R_CODE
;
; EXIT: AH = 0 => ELIM ON
; = 1 => ELIM OFF
; = 2 => ELIM in AUTO mode (ON)
; = 3 => ELIM in AUTO mode (OFF)
;
; USED: none
;
;******************************************************************************
E_GetStatus proc far
;
xor ah,ah ; assume ON
test [Current_State],fState_Active
;Q: CEMM currently ON?
jnz SHORT EGS_chkAUTO ; Y: chk for AUTO mode
mov ah,1 ; N: set to OFF
EGS_chkAUTO:
cmp [Current_Mode],MODE_AUTO ;Q: Auto Mode?
jne SHORT EGS_exit ; N: leave
add ah,2 ; Y: map to 2,3
EGS_exit:
ret
;
E_GetStatus endp
;******************************************************************************
; E_ONOFF - general ON/OFF code for ELIM
;
; ENTRY: AH = 1
; AL = 0 => ON
; AL = 1 => OFF
; AL = 2 => AUTO
; DS = R_CODE
;
; EXIT: Virtual mode and ELIM ON
; OR Real mode and ELIM OFF
;
; USED: none
;
;******************************************************************************
E_ONOFF proc far
;
cmp al,0 ;Q: -> CEMM ON ?
jne SHORT EOO_chkOFF ; N: check for OFF/AUTO
mov [Current_Mode],MODE_ON ; set mode to ON
mov [Devname],'E' ; set to allow presense detect
jmp SHORT EOO_ON ; go to ON state
EOO_chkOFF:
cmp al,1 ;Q: -> CEMM OFF ?
jne SHORT EOO_chkAUTO ; N: check for AUTO
CMP [handle_count], 1 ; Q: entries in handle dir <= 1?
JA EOO_inv ; N: refuse the request
cmp [UsedVCPIPages],0 ;Q: Any VCPI pages allocated
jnz EOO_inv ; Y: continue
ifdef QEMS
MOV AX, [free_pages] ; Get original free 4K pages ;@PIW
CMP AX, [free_4k_pages] ; Q: Is any page (de)allocated? ;@PIW
jne EOO_inv ; Y:
endif
cmp cs:[UMBHMA],TRUE ;Q: Are UMBs defined?
je EOO_inv ; Y: don't turn off
mov [Current_Mode],MODE_OFF ; N: set mode to OFF
mov [Devname],'$' ;set to prevent presense detect
jmp SHORT EOO_OFF
EOO_chkAUTO:
cmp al,2 ;Q: -> CEMM AUTO ?
jne SHORT EOO_inv ; N: invalid function call
mov [Current_Mode],MODE_AUTO ; Y: set mode to AUTO
or [Auto_State],fAuto_Users ; assume users: active
cmp [handle_count],1 ;Q: EMS users active?
jne short EOOcont ; Y: continue
cmp cs:[UMBHMA],TRUE ;Q: Is virtual HMA/UMB provided?
je short EOOcont ; Y: continue
cmp [UsedVCPIPages],0 ;Q: Any VCPI pages allocated
jnz EOOcont ; Y: continue
ifdef QEMS
mov ax,[free_pages] ; Get original free 4K pages
cmp ax,[free_4k_pages] ;Q: Is any page allocated?
jne short EOOcont ; Y: continue
endif
and [Auto_State],not fAuto_Users ; N: CEMM may be turned inactive
EOOcont:
mov [Devname],'E' ;set to allow presense detect
cmp [Auto_State],0 ;Q: turn on for AUTO mode ?
je SHORT EOO_OFF ; N: go to OFF state
; Y: go to ON state
;
; go to Virtual Mode operation and activate CEMM
;
EOO_ON:
test [Current_State],fState_Active ;Q: currently active ?
jnz SHORT EOO_OK ; Y: just leave
call GoVirtual ; N: go to virtual mode & (sbp)
jc short EOOerror
or [Current_State],fState_Active ; set active flag (sbp)
jmp short EOO_OK
;
; go to Real Mode operation and deactivate CEMM
;
EOOerror:
and [Current_State],not fState_Active; make inactive
mov [Current_Mode],MODE_OFF ; set mode to OFF
mov [Devname],'$' ; set to prevent presense detect
EOO_OFF:
test [Current_State],fState_Active ;Q: currently inactive ?
jz SHORT EOO_OK ; Y: just leave
and [Current_State],NOT fState_Active ;N: reset active flag &
push ax ; and return to real mode
pushf
cli ;;; protect this sequence
mov al,0Fh ;;;
out 84h,al ;;; port 84/85 return to real
mov al,00h ;;; sequence ...
out 85h,al ;;;
jmp $+2 ;;; clear prefetch/avoid race cond
popf
pop ax
cmp [Current_Mode],MODE_OFF
jne short EOO_OK
;
; leave with no errors
;
EOO_OK:
clc
EOO_exit:
ret
;
; invalid ON/OFF/AUTO function call
;
EOO_inv:
stc
ret
;
E_ONOFF endp
;******************************************************************************
; E_Weitek - Weitek support functions
;
; ENTRY: AH = 2
; AL = 0 => sense current Weitek state
; AL = 1 => turn Weitek ON
; AL = 2 => turn Weitek OFF
; DS = R_CODE
;
; EXIT: STC and AH = 1 for invalid subfunction (AL)
; for AL = 0 (sense Weitek state)
; AL -> bit 0 = Weitek installed flag
; bit 1 = Weitek mapped flag
; for AL = 1 or 2
; STC and AH = 2 => Weitek not installed
; CEMM ON or OFF depending on current
; CEMM mode (ON/OFF/AUTO).
;
; USED: none
;
;******************************************************************************
E_Weitek proc far
;
push bx
cmp al,0 ;Q: sense status ?
jne SHORT EW_chkON ; N: check next function code
mov al,[Weitek_State] ; Y: return current state
jmp EW_OK
;
; Weitek ON function
; When Weitek state is set to ON, CEMM goes active whenever it is in
; AUTO mode and the page table mapping is set to point to the Weitek.
;
EW_chkON:
cmp al,1 ;Q: Weitek ON function ?
jne SHORT EW_chkOFF ; N: check for OFF function
test [Weitek_State],fWeitek_Inst ;Y: Q: Weitek installed ?
jz SHORT EWerror ; N: report error
call dword ptr [checkXMMFar] ;Q: Is there an XMM in the system
jc short EWok ; N: OK to take HMA for WEITEK
test [GenFlags],fHMA ;Q: Does CEMM own the HMA?
jnz short EWok ; Y: map WEITEK
call dword ptr [XMMAllocHMAFar]
;Q: Is the HMA available
jc short EWerror ; N: report error
EWok:
or [Weitek_State],fWeitek_Map ; Y: set Weitek ON
or [Auto_State],fAuto_Weitek ; and auto mode flag
;
; update CEMM's state
; if CEMM is inactive, check for AUTO mode.
; if AUTO mode, CEMM goes active.
;
test [Current_State],fState_Active ;Q: CEMM active ?
jnz SHORT EW_ONPg ; Y: nothing to do here ...
cmp [Current_Mode],MODE_AUTO ;Q: CEMM in AUTO mode ?
jne SHORT EW_ONPg ; N: CEMM stays inactive
call GoVirtual ;(sbp) Y: go to virtual mode &
jc short EWerror
or [Current_State],fState_Active ;(sbp) set active flag
;
; now change 1meg wraparound to point to Weitek addresses
;
EW_ONPg:
mov bx,0 ; Weitek mapping ON
jmp SHORT EW_UpdPageMap
;
; HMA not available for WEITEK
EWerror:
mov ah,2
stc
jmp SHORT EW_error
;
; Weitek OFF function
; When Weitek state is set to OFF, CEMM active/inactive state is unaffected
; by Weitek in AUTO mode. The 1Meg wraparound is placed back into the
; page tables.
;
EW_chkOFF:
cmp al,2 ;Q: Weitek OFF function ?
jne SHORT EW_InvFunc ; N: invalid Weitek subfunction
test [Weitek_State],fWeitek_Inst ;Y: Q: Weitek installed ?
jz short EWerror ; N: report error
call dword ptr [checkXMMFar] ;Q: Is there an XMM in the system
jc short EWOok ; N: OK to release HMA for WEITEK
test [GenFlags],fHMA ;Q: Does CEMM own the HMA?
jz short EWOok ; N: OK to release HMA for WEITEK
call dword ptr [XMMDeallHMAFar]
;Q: Is the HMA released?
jc short EWerror ; N: report error
EWOok:
and [Weitek_State],NOT fWeitek_Map ; Y: set Weitek OFF
and [Auto_State],NOT fAuto_Weitek ; and reset auto mode flag
;
; update CEMM's state
; if CEMM is in AUTO mode, it is active and CEMM may be able
; to go inactive now.
;
cmp [Current_Mode],MODE_AUTO ;Q: CEMM in AUTO mode ?
jne SHORT EW_OFFPg ; N: then no CEMM state change
cmp [Auto_State],0 ; Y: Q: CEMM stays active ?
jne SHORT EW_OFFPg ; Y: then leave
and [Current_State],NOT fState_Active ; N: reset active flag &
pushf ; and return to real mode
cli ;;; protect this sequence
mov al,0Fh ;;;
out 84h,al ;;; port 84/85 return to real
mov al,00h ;;; sequence ...
out 85h,al ;;;
jmp $+2 ;;; clear prefetch/avoid race cond
popf
;
; now enable 1meg wraparound
;
EW_OFFPg:
mov bx,1 ; Weitek mapping OFF
;
; Update page table mapping of 1meg linear wraparound area
; Entry: BX = 0 => Weitek mapping ON
; = 1 => 1 meg wraparound (Weitek OFF)
;
EW_UpdPageMap:
test [Current_State],fState_Active ;Q: CEMM active?
jz SHORT EW_InactMap ; N: change mapping
pushf ; Y: prot mode call to chg it
cli ;;; protect this sequence
Call_CEMM_PMF CEMM_84_Weitek
popf
jmp SHORT EW_OK
EW_InactMap: ; CEMM inactive, update Weitek mapping
EW_OK:
clc
EW_exit:
pop bx
ret
EW_InvFunc:
mov ah,1
stc
jmp SHORT EW_error
EW_error: ; error exit
stc
jmp EW_exit
;
E_Weitek endp
;LEO ;******************************************************************************
;LEO ; WeitekPageMap - change tables to include/exclude Weitek in page tables
;LEO ;
;LEO ; NOTE: THIS IS A FAR ROUTINE
;LEO ;
;LEO ; ENTRY: PROTECTED or REAL mode ONLY
;LEO ; ES -> page tables
;LEO ; BX = 0 => Weitek mapping ON
;LEO ; = 1 => Weitek mapping OFF (1meg wraparound)
;LEO ; EXIT: same as entry
;LEO ; USED: none
;LEO ;******************************************************************************
;LEO WeitekPageMap proc far
;LEO pushad
;LEO cld
;LEO cmp bx,0 ;Q: weitek map on function ?
;LEO jne SHORT WPM_chkoff ; N: check for off function
;LEO ; ; Y: change page tables
;LEO ; For Weitek 1167 mapping addresses,
;LEO ; change page table entries for (00100000h,0010EFFFh) ->
;LEO ; (C0000000h,C000EFFFh)
;LEO ;
;LEO mov eax,0C0000000h ; start with physical addr = C0000000h
;LEO jmp SHORT WPM_set_PT ; set page tables
;LEO
;LEO WPM_chkoff:
;LEO cmp bx,1 ;Q: weitek map off function ?
;LEO jne SHORT WPM_exit ; N: leave
;LEO xor eax,eax ; Y: 1meg wraparound
;LEO
;LEO ;
;LEO ; set 60k worth of entries in page tables for 1meg linear
;LEO ; entry: EAX = begin physical addr
;LEO ;
;LEO WPM_set_PT:
;LEO mov di,100h*4 ; ES:DI -> PTE for 1Meg linear
;LEO or al,P_AVAIL ; make pages available to all
;LEO mov cx,0Fh ; set 60k worth of entries
;LEO WPM_set_entry:
;LEO stosd ; store EAX to ES:[DI]
;LEO ; ES:[DI] pts to next page table entry
;LEO add eax,1000h ; EAX = next physical page (with attrs)
;LEO loop WPM_set_entry ;Q: done with page table entries ?
;LEO ; N: loop again
;LEO ; Y: all done
;LEO WPM_exit:
;LEO mov eax,cr3 ; clear the TLB !!!
;LEO mov cr3,eax
;LEO popad
;LEO ret
;LEO WeitekPageMap endp
ifdef QHKN
page
;******************************************************************************
; Debug Functions table
;******************************************************************************
;
DebugTab label word
dw offset DebugR_GetPTE
dw offset DebugR_PhysIO
DEBTAB_CNT equ ($-DebugTab)/2
;******************************************************************************
; E_Debug - Debug functions entry point
;
; ENTRY: REAL or VIRTUAL mode
; AH = 3
; AL = 0 => Get physical address
; AL = 1 => Get physical DMA contents
; DS = R_CODE
;
; EXIT: Same processor mode as entry
; CLC => no errors
; STC => error
;
; USED: BX
;
;******************************************************************************
E_Debug proc far
;
cmp al,DEBTAB_CNT ;Q: valid function #
jae SHORT ED_inv_func ; N: return error
xor bx,bx ; Y: exec function
mov bl,al ; bx = function #
shl bx,1 ; word index
call CS:DebugTab[bx] ; call the function
;
ED_exit:
ret
ED_inv_func:
stc
ret
;
E_Debug endp
;
page
;******************************************************************************
; DebugR_GetPTE - Returns the Page Table Entry for a Linear Address
;
; ENTRY: REAL or VIRTUAL mode
; AH = 3
; AL = 0 => Get page table entry
; ECX = linear address
; DX = 0 => don't map linear address first (for >1meg addrs)
; DX = 1 => map linear address first
; DS = R_CODE
;
; EXIT: Same processor mode as entry
; STC => error
; CLC => no errors and
; ECX = page table entry
;
; USED: none
;
;******************************************************************************
DebugR_GetPTE proc near
test [Current_State], fState_Active ;Q: in Real mode now ?
jnz SHORT DRGP_VM ; N: go to Virtual Mode hndlng
; Y: ok ..
push eax
push di
push es
mov ebx,[PageD_Addr] ; EBX = 32 bit addr of page dir
shr ebx,4 ; BX = seg addr of page dir
mov es,bx ; ES -> page dir
mov eax,ecx ; EAX = linear addr
PDOff ax ; EAX = page dir offset
mov di,ax ; DI = page dir offset for this addr
mov ebx,ES:[di] ; EBX = PTE for page table
test bx,P_PRES ;Q: is this page table present ?
jz SHORT DRGP_RM_error ; N: report error
and bx,(P_SIZE-1) ; Y: remove status bits
shr ebx,4 ; BX = seg addr of page table
mov es,bx ; ES -> page table
mov eax,ecx ; EAX = linear addr
PTOff ax ; EAX = page table offset
mov di,ax ; DI = page table offset for this addr
mov ecx,ES:[di] ; ECX = PTE for page table
clc ; no errors
DRGP_RM_exit:
pop es
pop di
pop eax
ret
DRGP_RM_error:
stc
jmp DRGP_RM_exit
;
; In virtual mode now. We need to go to protected mode to be sure we can
; access the page tables.
DRGP_VM:
push bx
mov bl,al ; BL = Diag function # for GetPTE
Call_CEMM_PMF CEMM_84_Diag ; exec diag function
pop bx
ret
DebugR_GetPTE endp
page
;******************************************************************************
; DebugR_PhysIO - do physical I/O (at ring 0 PM privilege level)
;
; ENTRY: REAL or VIRTUAL mode
; AH = 3
; AL = 1 => Do Physical I/O
; DX = I/O address
; ECX/CX/CL = for OUTs, the value to output
; SI = 0 for input
; = 1 for output
; DI = 0 for byte I/O
; = 1 for word I/O
; = 2 for dword I/O
; DS = R_CODE
;
; EXIT: Same processor mode as entry
; STC => error
; CLC => no errors and
; ECX/CX/CL = value input
;
; USED: none
;
;******************************************************************************
DebugR_PhysIO proc near
test [Current_State], fState_Active ;Q: in Real mode now ?
jnz SHORT DRPIO_VM ; N: go to Virtual Mode hndlng
call FAR PTR Debug_PhysIO ; Y: do I/O in real mode
ret ; and return
;
; here if virtual mode => call CEMM Protected Mode Function
;
DRPIO_VM:
push bx
mov bl,al ; BL = Diag function # for PhysIO
Call_CEMM_PMF CEMM_84_Diag ; exec diag function
pop bx
ret
DebugR_PhysIO endp
page
;******************************************************************************
; Debug_PhysIO - do physical I/O
;
; ENTRY: REAL MODE or Ring 0 PROT MODE
; DX = I/O address
; ECX/CX/CL = for OUTs, the value to output
; SI = 0 for input
; <> 0 for output
; DI = 0 for byte I/O
; = 1 for word I/O
; = 2 for dword I/O
; DS = R_CODE
;
; EXIT: Same processor mode as entry
; ECX/CX/CL = value input
; CLC => no error
; STC => invalid input
;
; USED: none
;
;******************************************************************************
Debug_PhysIO proc far
push eax
or si,si ;Q: Input ?
jnz SHORT DPIO_Out ; N: do output
; Y: do input
cmp di,0 ;Q: byte input ?
jne SHORT DPIO_InW ; N: chk for word
in al,dx ; Y: do input
mov cl,al ; and set value into CL
jmp SHORT DPIO_OK ; and leave
DPIO_InW:
cmp di,1 ;Q: word input ?
jne SHORT DPIO_InDW ; N: chk for dword
in ax,dx ; Y: do input
mov cx,ax ; and set value into CL
jmp SHORT DPIO_OK ; and leave
DPIO_InDW:
cmp di,2 ;Q: dword input ?
jne SHORT DPIO_error ; N: bad xfer size
in eax,dx ; Y: do input
mov ecx,eax ; and set value into CL
jmp SHORT DPIO_OK ; and leave
DPIO_Out:
cmp di,0 ;Q: byte output ?
jne SHORT DPIO_OutW ; N: chk for word
mov al,cl ; Y: get byte for out
out dx,al ; do output
jmp SHORT DPIO_OK ; and leave
DPIO_OutW:
cmp di,0 ;Q: word output ?
jne DPIO_OutW ; N: chk for dword
mov ax,cx ; Y: get word for out
out dx,ax ; do output
jmp SHORT DPIO_OK ; and leave
DPIO_OutDW:
cmp di,2 ;Q: dword output ?
jne SHORT DPIO_error; N: bad xfer size
mov eax,ecx ; Y: get dword for out
out dx,eax ; do output
; and leave
DPIO_OK:
clc
DPIO_exit:
pop eax
ret
DPIO_error:
stc
jmp DPIO_exit
Debug_PhysIO endp
endif
R_CODE ENDS
LAST segment
assume CS:LAST, DS:LAST, ES:R_CODE
;******************************************************************************
; I_Message_Display - display banner
;
; ENTRY: NONE
;
; EXIT: none
;
; USED: none
;
;******************************************************************************
I_Message_Display PROC near
push ds
mov dx, cs
mov ds, dx
mov dx,offset LAST:InitMessage
mov ah,PRINT_STRING
int MS_DOS ; output init message
pop ds
RET
I_Message_Display ENDP
;******************************************************************************
; E_XStatus_Display - display ELIM/VDM status
;
; ENTRY: DS = R_CODE
;
; EXIT: none
;
; USED: none
;
;******************************************************************************
E_XStatus_Display proc near
;
push ds
push es
push di
push ds
pop es ; es = R_CODE
mov ax, cs ; si = LAST
mov ds, ax ; ds = LAST
mov dx,offset LAST:NoEMSmess ; assume EMS N/A
;; cmp cs:[NoEMSset],TRUE ;Q: Is EMS available?
;; je short EXSprint ; N: print EMS N/A message
cmp es:[VCPIset], -1 ; Q: has noems been specifed
jne EXSprint ; Y: print EMS N/A message
EXSDcont:
ifdef QEMS
mov ax,es:[free_4k_pages]
shl ax,2 ; amount in K
endif
mov ax,es:[TopOfHandleSpace] ; top of free EMS handle space
sub ax,FIRST_HANDLE_PTE ; subtract start of handle space
sub ax,es:[UsedVCPIPages] ; number of free EMS pages
shr ax,2 ; convert to 16K pages
sub ax,es:[UsedEMSPages] ; number of free EMS pages
shl ax,4 ; number in KBs
mov di,offset LAST:ISizeMess; store decimal size in ASCII here.
mov cx,5
call b2asc10 ; convert to ASCII...(R_CODE)
mov dx,offset LAST:MemSizeMess
mov ah,PRINT_STRING
int MS_DOS ; output message
mov al,EMM_VERSION
xor ah,ah
ror ax,4
shr ah,4
or ax,'00'
mov di,offset LAST:LIMVerMess
;; stosb
mov byte ptr ds:[di], al
inc di
inc di
xchg al,ah
;; stosb
mov byte ptr ds:[di], al
inc di
mov ax,es:[TopOfHandleSpace]; top of free EMS handle space
sub ax,FIRST_HANDLE_PTE ; subtract start of handle space
shr ax,2
;QEMS mov ax,es:[total_4k_pages]
;QEMS shr ax,1
;QEMS shr ax,1
mov cx,4
mov di,offset LAST:TotalPagesMess
call b2asc10
mov ax,es:[TopOfHandleSpace]; top of free EMS handle space
sub ax,FIRST_HANDLE_PTE ; subtract start of handle space
sub ax,es:[UsedVCPIPages] ; number of free EMS pages
shr ax,2 ; convert to 16K pages
sub ax,es:[UsedEMSPages] ; number of free EMS pages
;QEMS mov ax,es:[free_4k_pages]
;QEMS shr ax,1
;QEMS shr ax,1
mov cx,4
mov di,offset LAST:AvailPagesMess
call b2asc10
mov ax,es:[ttl_hndls]
mov cx,4
mov di,offset LAST:TotalHanMess
call b2asc10
mov ax,es:[handle_count]
mov cx,4
mov di,offset LAST:AvailHanMess
call b2asc10
CMP es:[PF_Base], FREE ; Q: Is there a page frame? ;@PIW
JE SHORT get_status_mess ; N: Skip this part ;@PIW
mov ax,es:[PF_Base] ; page frame base addr
mov di,offset LAST:PFBAMess ; here for page frame base addr
call b2ascHEX
; Append " H" to hex value
MOV BYTE PTR [DI], ' ' ; Ensure blank for localized ver (IPG)
MOV BYTE PTR [DI+1], 'H' ; Put H at end of the segment ;@PIW
get_status_mess:
mov dx,offset LAST:StatusMess
EXSprint:
mov ah,PRINT_STRING
int MS_DOS ; output message
ifndef MSFLAG
call dword ptr es:[checkXMMFar]
;Q: Is there an XMM in the system
jc short EXSexit ; N: exit
endif
cmp es:[UMBptr],0 ;Q: Any UMBs?
je short EXSexit ; N: exit
call AvailUMB
shr ax,6
mov di,offset LAST:UMBavail; store decimal size in ASCII here.
mov cx,4
call b2asc10 ; convert to ASCII...(R_CODE)
call LargestUMB
shr ax,6
mov di,offset LAST:UMBlargest; store decimal size in ASCII here.
mov cx,4
call b2asc10 ; convert to ASCII...(R_CODE)
mov ax,es:[UMBptr] ; first UMB address
mov di,offset LAST:UMBstart
call b2ascHEX
mov byte ptr [di+1],'H' ; Put H at end of the segment
mov dx,offset LAST:UMBStatusMess
mov ah,PRINT_STRING
int MS_DOS ; output message
EXSexit:
pop di
pop es
pop ds
ret
;
E_XStatus_Display endp
;******************************************************************************
;
; b2asc10 - Converts binary to ascii decimal and stores at ES:DI.
; Stores CX ascii chars (decimal # is right justified and
; filled on left with blanks).
;
; entry: ax = binary number
; cx = digits to display
; es:di = place to store ascii chars.
;
; exit: ASCII decimal representation of number stored at DS:DI
;
; used: none
;
; stack:
;
;******************************************************************************
;
power10 dw 1,10,100,1000,10000
;
b2asc10_far proc far
call b2asc10
ret
b2asc10_far endp
;
b2asc10 proc near
;
push ax
push bx
push cx
push dx
push si
;
mov si,cx ; index to base 10 table
dec si
shl si,1 ;word index
xor bl,bl ; leading zeroes flag
cld
;
; convert binary number to decimal ascii
;
b2_loop:
xor dx,dx ; clear word extension
mov cx,cs:power10[si]
div cx ; divide by power of 10
or bl,bl
jnz short b2_ascii
;
or ax,ax ; q: zero result?
jnz short b2_ascii ; n: go convert to ascii
;
mov al,' ' ; y: go blank fill
jmp short b2_make_strg ;
;
b2_ascii:
add al,'0' ; put into ascii format
mov bl,1 ; leading zeroes on
;
b2_make_strg:
;; stosb ; put ascii number into string
mov byte ptr ds:[di], al
inc di
mov ax,dx
sub si,2 ; decrement power of 10 pointer
jg short b2_loop ; Q: Last digit? N: Jump if not
mov al,dl
and al,0Fh
add al,'0'
;; stosb
mov byte ptr ds:[di], al
inc di
;
pop si
pop dx
pop cx
pop bx
pop ax
ret ; *** return ***
;
b2asc10 endp
;******************************************************************************
;
; b2ascHEX- converts binary to ascii HEX and store at ES:DI
; stores 4 ascii chars (HEX # is right justified and
; filled on left with blanks)
;
; entry: ax = binary number
; es:di = place to store ascii chars.
;
; exit: ASCII HEX representation of number stored at DS:DI
;
; used: none
;
; stack:
;
;******************************************************************************
;
hextab db "0123456789ABCDEF"
;
b2ascHEX_far proc far
call b2ascHEX
ret
b2ascHEX_far endp
;
b2ascHEX proc near
;
push ax
push bx
push cx
push dx
cld ;forward,increment
mov dx,ax
mov cx,12
b2hex_loop:
mov bx,dx
shr bx,cl ; get highest nibble
and bx,0Fh ; nibble only
mov al,CS:hextab[bx] ; get ASCII for it
;; stosb ; store ASCII
mov byte ptr ds:[di], al
inc di
sub cx,4
jge short b2hex_loop
pop dx
pop cx
pop bx
pop ax
ret
;
b2ascHEX endp
LAST ends
end
|
title "Trap Processing"
;++
;
; Copyright (c) 1989 Microsoft Corporation
;
; Module Name:
;
; int.asm
;
; Abstract:
;
; This module implements the code necessary to field and process i386
; interrupt.
;
; Author:
;
; Shie-Lin Tzong (shielint) 8-Jan-1990
;
; Environment:
;
; Kernel mode only.
;
; Revision History:
;
;--
.386p
.xlist
include ks386.inc
include i386\kimacro.inc
include callconv.inc
.list
;
; Interrupt flag bit maks for EFLAGS
;
EFLAGS_IF equ 200H
EFLAGS_SHIFT equ 9
_TEXT SEGMENT DWORD PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:FLAT, FS:NOTHING, GS:NOTHING
; NOTE This routine is never actually called on standard x86 hardware,
; because passive level doesn't actually exist. It's here to
; fill out the portable skeleton.
;
; The following code is called when a passive release occurs and there is
; no interrupt to process.
;
cPublicProc _KiPassiveRelease ,0
stdRET _KiPassiveRelease ; cReturn
stdENDP _KiPassiveRelease
page ,132
subttl "Disable Processor Interrupts"
;++
;
; BOOLEAN
; KiDisableInterrupts(
; VOID
; )
;
; Routine Description:
;
; This routine disables interrupts at the processor level. It does not
; edit the PICS or adjust IRQL, it is for use in the debugger only.
;
; Arguments:
;
; None
;
; Return Value:
;
; (eax) = !0 if interrupts were on, 0 if they were off
;
;--
cPublicProc _KiDisableInterrupts ,0
cPublicFpo 0, 0
pushfd
pop eax
and eax,EFLAGS_IF ; (eax) = the interrupt bit
shr eax,EFLAGS_SHIFT ; low bit of (eax) == interrupt bit
cli
stdRET _KiDisableInterrupts
stdENDP _KiDisableInterrupts
page ,132
subttl "Restore Processor Interrupts"
;++
;
; VOID
; KiRestoreInterrupts(
; BOOLEAN Restore
; )
;
; Routine Description:
;
; This routine restores interrupts at the processor level. It does not
; edit the PICS or adjust IRQL, it is for use in the debugger only.
;
; Arguments:
;
; Restore (esp+4) - a "boolean" returned by KiDisableInterrupts, if
; !0 interrupts will be turned on, else left off.
;
; NOTE: We don't actually test the boolean as such, we just or
; it directly into the flags!
;
; Return Value:
;
; none.
;
;--
cPublicProc _KiRestoreInterrupts ,1
cPublicFpo 1, 0
xor eax, eax
mov al, byte ptr [esp]+4
shl eax,EFLAGS_SHIFT ; (eax) == the interrupt bit
pushfd
or [esp],eax ; or EI into flags
popfd
stdRET _KiRestoreInterrupts
stdENDP _KiRestoreInterrupts
_TEXT ends
end
|
_kill: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char **argv)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 56 push %esi
e: 53 push %ebx
f: 51 push %ecx
10: 83 ec 0c sub $0xc,%esp
13: 8b 01 mov (%ecx),%eax
15: 8b 51 04 mov 0x4(%ecx),%edx
int i;
if(argc < 2){
18: 83 f8 01 cmp $0x1,%eax
1b: 7e 2c jle 49 <main+0x49>
1d: 8d 5a 04 lea 0x4(%edx),%ebx
20: 8d 34 82 lea (%edx,%eax,4),%esi
23: 90 nop
24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(2, "usage: kill pid...\n");
exit();
}
for(i=1; i<argc; i++)
kill(atoi(argv[i]));
28: 83 ec 0c sub $0xc,%esp
2b: ff 33 pushl (%ebx)
2d: 83 c3 04 add $0x4,%ebx
30: e8 0b 02 00 00 call 240 <atoi>
35: 89 04 24 mov %eax,(%esp)
38: e8 a5 02 00 00 call 2e2 <kill>
for(i=1; i<argc; i++)
3d: 83 c4 10 add $0x10,%esp
40: 39 f3 cmp %esi,%ebx
42: 75 e4 jne 28 <main+0x28>
exit();
44: e8 69 02 00 00 call 2b2 <exit>
printf(2, "usage: kill pid...\n");
49: 50 push %eax
4a: 50 push %eax
4b: 68 68 07 00 00 push $0x768
50: 6a 02 push $0x2
52: e8 b9 03 00 00 call 410 <printf>
exit();
57: e8 56 02 00 00 call 2b2 <exit>
5c: 66 90 xchg %ax,%ax
5e: 66 90 xchg %ax,%ax
00000060 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 53 push %ebx
64: 8b 45 08 mov 0x8(%ebp),%eax
67: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
6a: 89 c2 mov %eax,%edx
6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
70: 83 c1 01 add $0x1,%ecx
73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
77: 83 c2 01 add $0x1,%edx
7a: 84 db test %bl,%bl
7c: 88 5a ff mov %bl,-0x1(%edx)
7f: 75 ef jne 70 <strcpy+0x10>
;
return os;
}
81: 5b pop %ebx
82: 5d pop %ebp
83: c3 ret
84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000090 <strcmp>:
int
strcmp(const char *p, const char *q)
{
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 53 push %ebx
94: 8b 55 08 mov 0x8(%ebp),%edx
97: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
9a: 0f b6 02 movzbl (%edx),%eax
9d: 0f b6 19 movzbl (%ecx),%ebx
a0: 84 c0 test %al,%al
a2: 75 1c jne c0 <strcmp+0x30>
a4: eb 2a jmp d0 <strcmp+0x40>
a6: 8d 76 00 lea 0x0(%esi),%esi
a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
b0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
b3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
b6: 83 c1 01 add $0x1,%ecx
b9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
bc: 84 c0 test %al,%al
be: 74 10 je d0 <strcmp+0x40>
c0: 38 d8 cmp %bl,%al
c2: 74 ec je b0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
c4: 29 d8 sub %ebx,%eax
}
c6: 5b pop %ebx
c7: 5d pop %ebp
c8: c3 ret
c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
d0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
d2: 29 d8 sub %ebx,%eax
}
d4: 5b pop %ebx
d5: 5d pop %ebp
d6: c3 ret
d7: 89 f6 mov %esi,%esi
d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000e0 <strlen>:
uint
strlen(const char *s)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
e6: 80 39 00 cmpb $0x0,(%ecx)
e9: 74 15 je 100 <strlen+0x20>
eb: 31 d2 xor %edx,%edx
ed: 8d 76 00 lea 0x0(%esi),%esi
f0: 83 c2 01 add $0x1,%edx
f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
f7: 89 d0 mov %edx,%eax
f9: 75 f5 jne f0 <strlen+0x10>
;
return n;
}
fb: 5d pop %ebp
fc: c3 ret
fd: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
100: 31 c0 xor %eax,%eax
}
102: 5d pop %ebp
103: c3 ret
104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000110 <memset>:
void*
memset(void *dst, int c, uint n)
{
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
113: 57 push %edi
114: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
117: 8b 4d 10 mov 0x10(%ebp),%ecx
11a: 8b 45 0c mov 0xc(%ebp),%eax
11d: 89 d7 mov %edx,%edi
11f: fc cld
120: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
122: 89 d0 mov %edx,%eax
124: 5f pop %edi
125: 5d pop %ebp
126: c3 ret
127: 89 f6 mov %esi,%esi
129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000130 <strchr>:
char*
strchr(const char *s, char c)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 53 push %ebx
134: 8b 45 08 mov 0x8(%ebp),%eax
137: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
13a: 0f b6 10 movzbl (%eax),%edx
13d: 84 d2 test %dl,%dl
13f: 74 1d je 15e <strchr+0x2e>
if(*s == c)
141: 38 d3 cmp %dl,%bl
143: 89 d9 mov %ebx,%ecx
145: 75 0d jne 154 <strchr+0x24>
147: eb 17 jmp 160 <strchr+0x30>
149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
150: 38 ca cmp %cl,%dl
152: 74 0c je 160 <strchr+0x30>
for(; *s; s++)
154: 83 c0 01 add $0x1,%eax
157: 0f b6 10 movzbl (%eax),%edx
15a: 84 d2 test %dl,%dl
15c: 75 f2 jne 150 <strchr+0x20>
return (char*)s;
return 0;
15e: 31 c0 xor %eax,%eax
}
160: 5b pop %ebx
161: 5d pop %ebp
162: c3 ret
163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000170 <gets>:
char*
gets(char *buf, int max)
{
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 57 push %edi
174: 56 push %esi
175: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
176: 31 f6 xor %esi,%esi
178: 89 f3 mov %esi,%ebx
{
17a: 83 ec 1c sub $0x1c,%esp
17d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
180: eb 2f jmp 1b1 <gets+0x41>
182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
188: 8d 45 e7 lea -0x19(%ebp),%eax
18b: 83 ec 04 sub $0x4,%esp
18e: 6a 01 push $0x1
190: 50 push %eax
191: 6a 00 push $0x0
193: e8 32 01 00 00 call 2ca <read>
if(cc < 1)
198: 83 c4 10 add $0x10,%esp
19b: 85 c0 test %eax,%eax
19d: 7e 1c jle 1bb <gets+0x4b>
break;
buf[i++] = c;
19f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1a3: 83 c7 01 add $0x1,%edi
1a6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1a9: 3c 0a cmp $0xa,%al
1ab: 74 23 je 1d0 <gets+0x60>
1ad: 3c 0d cmp $0xd,%al
1af: 74 1f je 1d0 <gets+0x60>
for(i=0; i+1 < max; ){
1b1: 83 c3 01 add $0x1,%ebx
1b4: 3b 5d 0c cmp 0xc(%ebp),%ebx
1b7: 89 fe mov %edi,%esi
1b9: 7c cd jl 188 <gets+0x18>
1bb: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1bd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1c0: c6 03 00 movb $0x0,(%ebx)
}
1c3: 8d 65 f4 lea -0xc(%ebp),%esp
1c6: 5b pop %ebx
1c7: 5e pop %esi
1c8: 5f pop %edi
1c9: 5d pop %ebp
1ca: c3 ret
1cb: 90 nop
1cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1d0: 8b 75 08 mov 0x8(%ebp),%esi
1d3: 8b 45 08 mov 0x8(%ebp),%eax
1d6: 01 de add %ebx,%esi
1d8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1da: c6 03 00 movb $0x0,(%ebx)
}
1dd: 8d 65 f4 lea -0xc(%ebp),%esp
1e0: 5b pop %ebx
1e1: 5e pop %esi
1e2: 5f pop %edi
1e3: 5d pop %ebp
1e4: c3 ret
1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001f0 <stat>:
int
stat(const char *n, struct stat *st)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 56 push %esi
1f4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1f5: 83 ec 08 sub $0x8,%esp
1f8: 6a 00 push $0x0
1fa: ff 75 08 pushl 0x8(%ebp)
1fd: e8 f0 00 00 00 call 2f2 <open>
if(fd < 0)
202: 83 c4 10 add $0x10,%esp
205: 85 c0 test %eax,%eax
207: 78 27 js 230 <stat+0x40>
return -1;
r = fstat(fd, st);
209: 83 ec 08 sub $0x8,%esp
20c: ff 75 0c pushl 0xc(%ebp)
20f: 89 c3 mov %eax,%ebx
211: 50 push %eax
212: e8 f3 00 00 00 call 30a <fstat>
close(fd);
217: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
21a: 89 c6 mov %eax,%esi
close(fd);
21c: e8 b9 00 00 00 call 2da <close>
return r;
221: 83 c4 10 add $0x10,%esp
}
224: 8d 65 f8 lea -0x8(%ebp),%esp
227: 89 f0 mov %esi,%eax
229: 5b pop %ebx
22a: 5e pop %esi
22b: 5d pop %ebp
22c: c3 ret
22d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
230: be ff ff ff ff mov $0xffffffff,%esi
235: eb ed jmp 224 <stat+0x34>
237: 89 f6 mov %esi,%esi
239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000240 <atoi>:
int
atoi(const char *s)
{
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 53 push %ebx
244: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
247: 0f be 11 movsbl (%ecx),%edx
24a: 8d 42 d0 lea -0x30(%edx),%eax
24d: 3c 09 cmp $0x9,%al
n = 0;
24f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
254: 77 1f ja 275 <atoi+0x35>
256: 8d 76 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
260: 8d 04 80 lea (%eax,%eax,4),%eax
263: 83 c1 01 add $0x1,%ecx
266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
26a: 0f be 11 movsbl (%ecx),%edx
26d: 8d 5a d0 lea -0x30(%edx),%ebx
270: 80 fb 09 cmp $0x9,%bl
273: 76 eb jbe 260 <atoi+0x20>
return n;
}
275: 5b pop %ebx
276: 5d pop %ebp
277: c3 ret
278: 90 nop
279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000280 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 56 push %esi
284: 53 push %ebx
285: 8b 5d 10 mov 0x10(%ebp),%ebx
288: 8b 45 08 mov 0x8(%ebp),%eax
28b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
28e: 85 db test %ebx,%ebx
290: 7e 14 jle 2a6 <memmove+0x26>
292: 31 d2 xor %edx,%edx
294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
298: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
29c: 88 0c 10 mov %cl,(%eax,%edx,1)
29f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
2a2: 39 d3 cmp %edx,%ebx
2a4: 75 f2 jne 298 <memmove+0x18>
return vdst;
}
2a6: 5b pop %ebx
2a7: 5e pop %esi
2a8: 5d pop %ebp
2a9: c3 ret
000002aa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2aa: b8 01 00 00 00 mov $0x1,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <exit>:
SYSCALL(exit)
2b2: b8 02 00 00 00 mov $0x2,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <wait>:
SYSCALL(wait)
2ba: b8 03 00 00 00 mov $0x3,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <pipe>:
SYSCALL(pipe)
2c2: b8 04 00 00 00 mov $0x4,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <read>:
SYSCALL(read)
2ca: b8 05 00 00 00 mov $0x5,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <write>:
SYSCALL(write)
2d2: b8 10 00 00 00 mov $0x10,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <close>:
SYSCALL(close)
2da: b8 15 00 00 00 mov $0x15,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <kill>:
SYSCALL(kill)
2e2: b8 06 00 00 00 mov $0x6,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <exec>:
SYSCALL(exec)
2ea: b8 07 00 00 00 mov $0x7,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <open>:
SYSCALL(open)
2f2: b8 0f 00 00 00 mov $0xf,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <mknod>:
SYSCALL(mknod)
2fa: b8 11 00 00 00 mov $0x11,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <unlink>:
SYSCALL(unlink)
302: b8 12 00 00 00 mov $0x12,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <fstat>:
SYSCALL(fstat)
30a: b8 08 00 00 00 mov $0x8,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <link>:
SYSCALL(link)
312: b8 13 00 00 00 mov $0x13,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <mkdir>:
SYSCALL(mkdir)
31a: b8 14 00 00 00 mov $0x14,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <chdir>:
SYSCALL(chdir)
322: b8 09 00 00 00 mov $0x9,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <dup>:
SYSCALL(dup)
32a: b8 0a 00 00 00 mov $0xa,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <getpid>:
SYSCALL(getpid)
332: b8 0b 00 00 00 mov $0xb,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <sbrk>:
SYSCALL(sbrk)
33a: b8 0c 00 00 00 mov $0xc,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <sleep>:
SYSCALL(sleep)
342: b8 0d 00 00 00 mov $0xd,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <uptime>:
SYSCALL(uptime)
34a: b8 0e 00 00 00 mov $0xe,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <cps>:
SYSCALL(cps)
352: b8 16 00 00 00 mov $0x16,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <date>:
SYSCALL(date)
35a: b8 17 00 00 00 mov $0x17,%eax
35f: cd 40 int $0x40
361: c3 ret
362: 66 90 xchg %ax,%ax
364: 66 90 xchg %ax,%ax
366: 66 90 xchg %ax,%ax
368: 66 90 xchg %ax,%ax
36a: 66 90 xchg %ax,%ax
36c: 66 90 xchg %ax,%ax
36e: 66 90 xchg %ax,%ax
00000370 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
370: 55 push %ebp
371: 89 e5 mov %esp,%ebp
373: 57 push %edi
374: 56 push %esi
375: 53 push %ebx
376: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
379: 85 d2 test %edx,%edx
{
37b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
37e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
380: 79 76 jns 3f8 <printint+0x88>
382: f6 45 08 01 testb $0x1,0x8(%ebp)
386: 74 70 je 3f8 <printint+0x88>
x = -xx;
388: f7 d8 neg %eax
neg = 1;
38a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
391: 31 f6 xor %esi,%esi
393: 8d 5d d7 lea -0x29(%ebp),%ebx
396: eb 0a jmp 3a2 <printint+0x32>
398: 90 nop
399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
3a0: 89 fe mov %edi,%esi
3a2: 31 d2 xor %edx,%edx
3a4: 8d 7e 01 lea 0x1(%esi),%edi
3a7: f7 f1 div %ecx
3a9: 0f b6 92 84 07 00 00 movzbl 0x784(%edx),%edx
}while((x /= base) != 0);
3b0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3b2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
3b5: 75 e9 jne 3a0 <printint+0x30>
if(neg)
3b7: 8b 45 c4 mov -0x3c(%ebp),%eax
3ba: 85 c0 test %eax,%eax
3bc: 74 08 je 3c6 <printint+0x56>
buf[i++] = '-';
3be: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3c3: 8d 7e 02 lea 0x2(%esi),%edi
3c6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3ca: 8b 7d c0 mov -0x40(%ebp),%edi
3cd: 8d 76 00 lea 0x0(%esi),%esi
3d0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3d3: 83 ec 04 sub $0x4,%esp
3d6: 83 ee 01 sub $0x1,%esi
3d9: 6a 01 push $0x1
3db: 53 push %ebx
3dc: 57 push %edi
3dd: 88 45 d7 mov %al,-0x29(%ebp)
3e0: e8 ed fe ff ff call 2d2 <write>
while(--i >= 0)
3e5: 83 c4 10 add $0x10,%esp
3e8: 39 de cmp %ebx,%esi
3ea: 75 e4 jne 3d0 <printint+0x60>
putc(fd, buf[i]);
}
3ec: 8d 65 f4 lea -0xc(%ebp),%esp
3ef: 5b pop %ebx
3f0: 5e pop %esi
3f1: 5f pop %edi
3f2: 5d pop %ebp
3f3: c3 ret
3f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3f8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3ff: eb 90 jmp 391 <printint+0x21>
401: eb 0d jmp 410 <printf>
403: 90 nop
404: 90 nop
405: 90 nop
406: 90 nop
407: 90 nop
408: 90 nop
409: 90 nop
40a: 90 nop
40b: 90 nop
40c: 90 nop
40d: 90 nop
40e: 90 nop
40f: 90 nop
00000410 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 57 push %edi
414: 56 push %esi
415: 53 push %ebx
416: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
419: 8b 75 0c mov 0xc(%ebp),%esi
41c: 0f b6 1e movzbl (%esi),%ebx
41f: 84 db test %bl,%bl
421: 0f 84 b3 00 00 00 je 4da <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
427: 8d 45 10 lea 0x10(%ebp),%eax
42a: 83 c6 01 add $0x1,%esi
state = 0;
42d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
42f: 89 45 d4 mov %eax,-0x2c(%ebp)
432: eb 2f jmp 463 <printf+0x53>
434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
438: 83 f8 25 cmp $0x25,%eax
43b: 0f 84 a7 00 00 00 je 4e8 <printf+0xd8>
write(fd, &c, 1);
441: 8d 45 e2 lea -0x1e(%ebp),%eax
444: 83 ec 04 sub $0x4,%esp
447: 88 5d e2 mov %bl,-0x1e(%ebp)
44a: 6a 01 push $0x1
44c: 50 push %eax
44d: ff 75 08 pushl 0x8(%ebp)
450: e8 7d fe ff ff call 2d2 <write>
455: 83 c4 10 add $0x10,%esp
458: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
45b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
45f: 84 db test %bl,%bl
461: 74 77 je 4da <printf+0xca>
if(state == 0){
463: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
465: 0f be cb movsbl %bl,%ecx
468: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
46b: 74 cb je 438 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
46d: 83 ff 25 cmp $0x25,%edi
470: 75 e6 jne 458 <printf+0x48>
if(c == 'd'){
472: 83 f8 64 cmp $0x64,%eax
475: 0f 84 05 01 00 00 je 580 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
47b: 81 e1 f7 00 00 00 and $0xf7,%ecx
481: 83 f9 70 cmp $0x70,%ecx
484: 74 72 je 4f8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
486: 83 f8 73 cmp $0x73,%eax
489: 0f 84 99 00 00 00 je 528 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
48f: 83 f8 63 cmp $0x63,%eax
492: 0f 84 08 01 00 00 je 5a0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
498: 83 f8 25 cmp $0x25,%eax
49b: 0f 84 ef 00 00 00 je 590 <printf+0x180>
write(fd, &c, 1);
4a1: 8d 45 e7 lea -0x19(%ebp),%eax
4a4: 83 ec 04 sub $0x4,%esp
4a7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4ab: 6a 01 push $0x1
4ad: 50 push %eax
4ae: ff 75 08 pushl 0x8(%ebp)
4b1: e8 1c fe ff ff call 2d2 <write>
4b6: 83 c4 0c add $0xc,%esp
4b9: 8d 45 e6 lea -0x1a(%ebp),%eax
4bc: 88 5d e6 mov %bl,-0x1a(%ebp)
4bf: 6a 01 push $0x1
4c1: 50 push %eax
4c2: ff 75 08 pushl 0x8(%ebp)
4c5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4c8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4ca: e8 03 fe ff ff call 2d2 <write>
for(i = 0; fmt[i]; i++){
4cf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4d3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4d6: 84 db test %bl,%bl
4d8: 75 89 jne 463 <printf+0x53>
}
}
}
4da: 8d 65 f4 lea -0xc(%ebp),%esp
4dd: 5b pop %ebx
4de: 5e pop %esi
4df: 5f pop %edi
4e0: 5d pop %ebp
4e1: c3 ret
4e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
4e8: bf 25 00 00 00 mov $0x25,%edi
4ed: e9 66 ff ff ff jmp 458 <printf+0x48>
4f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
4f8: 83 ec 0c sub $0xc,%esp
4fb: b9 10 00 00 00 mov $0x10,%ecx
500: 6a 00 push $0x0
502: 8b 7d d4 mov -0x2c(%ebp),%edi
505: 8b 45 08 mov 0x8(%ebp),%eax
508: 8b 17 mov (%edi),%edx
50a: e8 61 fe ff ff call 370 <printint>
ap++;
50f: 89 f8 mov %edi,%eax
511: 83 c4 10 add $0x10,%esp
state = 0;
514: 31 ff xor %edi,%edi
ap++;
516: 83 c0 04 add $0x4,%eax
519: 89 45 d4 mov %eax,-0x2c(%ebp)
51c: e9 37 ff ff ff jmp 458 <printf+0x48>
521: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
528: 8b 45 d4 mov -0x2c(%ebp),%eax
52b: 8b 08 mov (%eax),%ecx
ap++;
52d: 83 c0 04 add $0x4,%eax
530: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
533: 85 c9 test %ecx,%ecx
535: 0f 84 8e 00 00 00 je 5c9 <printf+0x1b9>
while(*s != 0){
53b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
53e: 31 ff xor %edi,%edi
s = (char*)*ap;
540: 89 cb mov %ecx,%ebx
while(*s != 0){
542: 84 c0 test %al,%al
544: 0f 84 0e ff ff ff je 458 <printf+0x48>
54a: 89 75 d0 mov %esi,-0x30(%ebp)
54d: 89 de mov %ebx,%esi
54f: 8b 5d 08 mov 0x8(%ebp),%ebx
552: 8d 7d e3 lea -0x1d(%ebp),%edi
555: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
558: 83 ec 04 sub $0x4,%esp
s++;
55b: 83 c6 01 add $0x1,%esi
55e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
561: 6a 01 push $0x1
563: 57 push %edi
564: 53 push %ebx
565: e8 68 fd ff ff call 2d2 <write>
while(*s != 0){
56a: 0f b6 06 movzbl (%esi),%eax
56d: 83 c4 10 add $0x10,%esp
570: 84 c0 test %al,%al
572: 75 e4 jne 558 <printf+0x148>
574: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
577: 31 ff xor %edi,%edi
579: e9 da fe ff ff jmp 458 <printf+0x48>
57e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
580: 83 ec 0c sub $0xc,%esp
583: b9 0a 00 00 00 mov $0xa,%ecx
588: 6a 01 push $0x1
58a: e9 73 ff ff ff jmp 502 <printf+0xf2>
58f: 90 nop
write(fd, &c, 1);
590: 83 ec 04 sub $0x4,%esp
593: 88 5d e5 mov %bl,-0x1b(%ebp)
596: 8d 45 e5 lea -0x1b(%ebp),%eax
599: 6a 01 push $0x1
59b: e9 21 ff ff ff jmp 4c1 <printf+0xb1>
putc(fd, *ap);
5a0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
5a3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5a6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
5a8: 6a 01 push $0x1
ap++;
5aa: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
5ad: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5b0: 8d 45 e4 lea -0x1c(%ebp),%eax
5b3: 50 push %eax
5b4: ff 75 08 pushl 0x8(%ebp)
5b7: e8 16 fd ff ff call 2d2 <write>
ap++;
5bc: 89 7d d4 mov %edi,-0x2c(%ebp)
5bf: 83 c4 10 add $0x10,%esp
state = 0;
5c2: 31 ff xor %edi,%edi
5c4: e9 8f fe ff ff jmp 458 <printf+0x48>
s = "(null)";
5c9: bb 7c 07 00 00 mov $0x77c,%ebx
while(*s != 0){
5ce: b8 28 00 00 00 mov $0x28,%eax
5d3: e9 72 ff ff ff jmp 54a <printf+0x13a>
5d8: 66 90 xchg %ax,%ax
5da: 66 90 xchg %ax,%ax
5dc: 66 90 xchg %ax,%ax
5de: 66 90 xchg %ax,%ax
000005e0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5e0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5e1: a1 30 0a 00 00 mov 0xa30,%eax
{
5e6: 89 e5 mov %esp,%ebp
5e8: 57 push %edi
5e9: 56 push %esi
5ea: 53 push %ebx
5eb: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
5ee: 8d 4b f8 lea -0x8(%ebx),%ecx
5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5f8: 39 c8 cmp %ecx,%eax
5fa: 8b 10 mov (%eax),%edx
5fc: 73 32 jae 630 <free+0x50>
5fe: 39 d1 cmp %edx,%ecx
600: 72 04 jb 606 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
602: 39 d0 cmp %edx,%eax
604: 72 32 jb 638 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
606: 8b 73 fc mov -0x4(%ebx),%esi
609: 8d 3c f1 lea (%ecx,%esi,8),%edi
60c: 39 fa cmp %edi,%edx
60e: 74 30 je 640 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
610: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
613: 8b 50 04 mov 0x4(%eax),%edx
616: 8d 34 d0 lea (%eax,%edx,8),%esi
619: 39 f1 cmp %esi,%ecx
61b: 74 3a je 657 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
61d: 89 08 mov %ecx,(%eax)
freep = p;
61f: a3 30 0a 00 00 mov %eax,0xa30
}
624: 5b pop %ebx
625: 5e pop %esi
626: 5f pop %edi
627: 5d pop %ebp
628: c3 ret
629: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
630: 39 d0 cmp %edx,%eax
632: 72 04 jb 638 <free+0x58>
634: 39 d1 cmp %edx,%ecx
636: 72 ce jb 606 <free+0x26>
{
638: 89 d0 mov %edx,%eax
63a: eb bc jmp 5f8 <free+0x18>
63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
640: 03 72 04 add 0x4(%edx),%esi
643: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
646: 8b 10 mov (%eax),%edx
648: 8b 12 mov (%edx),%edx
64a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
64d: 8b 50 04 mov 0x4(%eax),%edx
650: 8d 34 d0 lea (%eax,%edx,8),%esi
653: 39 f1 cmp %esi,%ecx
655: 75 c6 jne 61d <free+0x3d>
p->s.size += bp->s.size;
657: 03 53 fc add -0x4(%ebx),%edx
freep = p;
65a: a3 30 0a 00 00 mov %eax,0xa30
p->s.size += bp->s.size;
65f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
662: 8b 53 f8 mov -0x8(%ebx),%edx
665: 89 10 mov %edx,(%eax)
}
667: 5b pop %ebx
668: 5e pop %esi
669: 5f pop %edi
66a: 5d pop %ebp
66b: c3 ret
66c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000670 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
670: 55 push %ebp
671: 89 e5 mov %esp,%ebp
673: 57 push %edi
674: 56 push %esi
675: 53 push %ebx
676: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
679: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
67c: 8b 15 30 0a 00 00 mov 0xa30,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
682: 8d 78 07 lea 0x7(%eax),%edi
685: c1 ef 03 shr $0x3,%edi
688: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
68b: 85 d2 test %edx,%edx
68d: 0f 84 9d 00 00 00 je 730 <malloc+0xc0>
693: 8b 02 mov (%edx),%eax
695: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
698: 39 cf cmp %ecx,%edi
69a: 76 6c jbe 708 <malloc+0x98>
69c: 81 ff 00 10 00 00 cmp $0x1000,%edi
6a2: bb 00 10 00 00 mov $0x1000,%ebx
6a7: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
6aa: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
6b1: eb 0e jmp 6c1 <malloc+0x51>
6b3: 90 nop
6b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6b8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6ba: 8b 48 04 mov 0x4(%eax),%ecx
6bd: 39 f9 cmp %edi,%ecx
6bf: 73 47 jae 708 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6c1: 39 05 30 0a 00 00 cmp %eax,0xa30
6c7: 89 c2 mov %eax,%edx
6c9: 75 ed jne 6b8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6cb: 83 ec 0c sub $0xc,%esp
6ce: 56 push %esi
6cf: e8 66 fc ff ff call 33a <sbrk>
if(p == (char*)-1)
6d4: 83 c4 10 add $0x10,%esp
6d7: 83 f8 ff cmp $0xffffffff,%eax
6da: 74 1c je 6f8 <malloc+0x88>
hp->s.size = nu;
6dc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6df: 83 ec 0c sub $0xc,%esp
6e2: 83 c0 08 add $0x8,%eax
6e5: 50 push %eax
6e6: e8 f5 fe ff ff call 5e0 <free>
return freep;
6eb: 8b 15 30 0a 00 00 mov 0xa30,%edx
if((p = morecore(nunits)) == 0)
6f1: 83 c4 10 add $0x10,%esp
6f4: 85 d2 test %edx,%edx
6f6: 75 c0 jne 6b8 <malloc+0x48>
return 0;
}
}
6f8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
6fb: 31 c0 xor %eax,%eax
}
6fd: 5b pop %ebx
6fe: 5e pop %esi
6ff: 5f pop %edi
700: 5d pop %ebp
701: c3 ret
702: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
708: 39 cf cmp %ecx,%edi
70a: 74 54 je 760 <malloc+0xf0>
p->s.size -= nunits;
70c: 29 f9 sub %edi,%ecx
70e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
711: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
714: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
717: 89 15 30 0a 00 00 mov %edx,0xa30
}
71d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
720: 83 c0 08 add $0x8,%eax
}
723: 5b pop %ebx
724: 5e pop %esi
725: 5f pop %edi
726: 5d pop %ebp
727: c3 ret
728: 90 nop
729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
730: c7 05 30 0a 00 00 34 movl $0xa34,0xa30
737: 0a 00 00
73a: c7 05 34 0a 00 00 34 movl $0xa34,0xa34
741: 0a 00 00
base.s.size = 0;
744: b8 34 0a 00 00 mov $0xa34,%eax
749: c7 05 38 0a 00 00 00 movl $0x0,0xa38
750: 00 00 00
753: e9 44 ff ff ff jmp 69c <malloc+0x2c>
758: 90 nop
759: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
760: 8b 08 mov (%eax),%ecx
762: 89 0a mov %ecx,(%edx)
764: eb b1 jmp 717 <malloc+0xa7>
|
/*
* @Author: Ning Xu
* @Email: nxu@umich.edu
* @Date: 2020-05-15 23:55:28
* @LastEditor: Ning Xu
* @Description: two loops comparison
*/
#include <iostream>
#include <vector>
int main() {
int i;
while (std::cin >> i) { /* ... */ }
for (int j; std::cin >> j;) { /* ... */ }
std::vector<int> iv(10, 1);
for (auto it = iv.begin(); it != iv.end(); ++it) { /* ... */ }
auto it2 = iv.begin();
while (it2 != iv.end()) {
++it2;
/* ... */
}
// I would choose `for`-loop, because it can do what a `while`-loop can, but
// not vise versa.
return 0;
}
|
SafariZoneRestHouse3_h:
db GATE ; tileset
db SAFARI_ZONE_REST_HOUSE_3_HEIGHT, SAFARI_ZONE_REST_HOUSE_3_WIDTH ; dimensions (y, x)
dw SafariZoneRestHouse3Blocks, SafariZoneRestHouse3TextPointers, SafariZoneRestHouse3Script ; blocks, texts, scripts
db $00 ; connections
dw SafariZoneRestHouse3Object ; objects
|
%ifdef CONFIG
{
"Mode": "32BIT"
}
%endif
mov edx, 0xe0000000
; Just to ensure execution
fldcw [edx]
hlt
|
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Mult.asm
// Multiplies R0 and R1 and stores the result in R2.
// (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)
@2
M=0 // R2=0
@i
M=0 // i=0
(LOOP)
@i
D=M // D=i
@0
D=D-M // D=i-R0
@END
D;JGE // If i-R0 >=0 goto END
@1
D=M // D=R1
@2
M=D+M // R2=R2+R1
@i
M=M+1 // i=i+1
@LOOP
0;JMP // Infinite loop
(END)
@END
0;JMP |
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <libcheckup/test.h>
#include <libcheckup/assert.h>
#include <sys/collect.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syscalls.h>
#define TEST_MESSAGE "I am going to write some text to my stdout and then exit\n"
static void writeTask() {
printf(TEST_MESSAGE);
exit(0);
}
static uint16_t clone(void (*func)(), exec_fileop_t* fops) {
auto ok = clone_syscall( (uintptr_t)func, fops );
if (ok & 1) return 0;
return ok >> 1;
}
class TheTest : public Test {
public:
TheTest() : Test(TEST_NAME) {}
protected:
void run() override {
int pipefd[2] = {0,0};
CHECK_EQ(0, pipe(pipefd));
exec_fileop_t fops[] = {
exec_fileop_t{
.op = exec_fileop_t::operation::CLOSE_CHILD_FD,
.param1 = STDOUT_FILENO,
.param2 = 0,
.param3 = nullptr
},
exec_fileop_t{
.op = exec_fileop_t::operation::DUP_PARENT_FD,
.param1 = (size_t)pipefd[1],
.param2 = 0,
.param3 = nullptr,
},
exec_fileop_t{
.op = exec_fileop_t::operation::END_OF_LIST,
.param1 = 0,
.param2 = 0,
.param3 = nullptr
},
};
FILE* fpipe = fdopen(pipefd[0], "r");
auto wrPid = clone(writeTask, fops);
fclose_syscall(pipefd[1]);
char buf[1024] = {0};
size_t count = fread(buf, 1, 1024, fpipe);
CHECK_NOT_EQ(0, count);
CHECK_EQ(0, strcmp(&buf[0], TEST_MESSAGE));
count = fread(buf, 1, 1024, fpipe);
CHECK_EQ(0, count);
CHECK_TRUE(feof(fpipe));
auto s = collect(wrPid);
CHECK_EQ(s.reason, process_exit_status_t::reason_t::cleanExit);
}
};
int main() {
Test* test = new TheTest();
test->test();
return 0;
}
|
; A098557: E.g.f. (1/2)*(1+x)*log((1+x)/(1-x)).
; 0,1,2,2,8,24,144,720,5760,40320,403200,3628800,43545600,479001600,6706022400,87178291200,1394852659200,20922789888000,376610217984000,6402373705728000
mov $2,$0
sub $2,2
lpb $2,1
div $0,2
mul $0,$2
mul $0,2
sub $2,1
lpe
mov $1,$0
|
; Partially based on code from https://plutiedev.com/vdp-setup
VdpCtrl: Equ $c00004 ; VDP control port
VdpData: Equ $c00000 ; VDP data port
HvCounter: Equ $c00008 ; H/V counter
VDPREG_MODE1: Equ $8000 ; Mode register #1
VDPREG_MODE2: Equ $8100 ; Mode register #2
VDPREG_MODE3: Equ $8b00 ; Mode register #3
VDPREG_MODE4: Equ $8c00 ; Mode register #4
VDPREG_PLANEA: Equ $8200 ; Plane A table address
VDPREG_PLANEB: Equ $8400 ; Plane B table address
VDPREG_SPRITE: Equ $8500 ; Sprite table address
VDPREG_WINDOW: Equ $8300 ; Window table address
VDPREG_HSCROLL: Equ $8d00 ; HScroll table address
VDPREG_SIZE: Equ $9000 ; Plane A and B size
VDPREG_WINX: Equ $9100 ; Window X split position
VDPREG_WINY: Equ $9200 ; Window Y split position
VDPREG_INCR: Equ $8f00 ; Autoincrement
VDPREG_BGCOL: Equ $8700 ; Background color
VDPREG_HRATE: Equ $8a00 ; HBlank interrupt rate
VDPREG_DMALEN_L: Equ $9300 ; DMA length (low)
VDPREG_DMALEN_H: Equ $9400 ; DMA length (high)
VDPREG_DMASRC_L: Equ $9500 ; DMA source (low)
VDPREG_DMASRC_M: Equ $9600 ; DMA source (mid)
VDPREG_DMASRC_H: Equ $9700 ; DMA source (high)
VRAM_ADDR_CMD: Equ $40000000
CRAM_ADDR_CMD: Equ $c0000000
VSRAM_ADDR_CMD: Equ $40000010
VRAM_SIZE: Equ 65536
CRAM_SIZE: Equ 128
VSRAM_SIZE: Equ 80
PlaneA_VRAMAddress: Equ $2000
PlaneB_VRAMAddress: Equ $0000
SpriteAttrTable_VRAMAddress: Equ $1000
HScroll_VRAMAddress: Equ $1400
PatternBase_VRAMAddress: Equ $3000
ASICPatternBase_VRAMAddress: Equ (PatternBase_VRAMAddress + (StaticTilesEnd - StaticTiles))
DMA_SETUP Macro source, size
move.w #VDPREG_DMALEN_L + (((\size) >> 1) & $ff), VdpCtrl
move.w #VDPREG_DMALEN_H + ((((\size) >> 1) & $ff00) >> 8), VdpCtrl
move.w #VDPREG_DMASRC_L + (((\source) >> 1) & $ff), VdpCtrl
move.w #VDPREG_DMASRC_M + ((((\source) >> 1) & $ff00) >> 8), VdpCtrl
move.w #VDPREG_DMASRC_H + ((((\source) >> 1) & $7f0000) >> 16), VdpCtrl
Endm
VRAM_WRITE_ADDR_SET Macro target, flags
If (narg=2)
move.l #VRAM_ADDR_CMD + (\flags) + (((\target) & $3fff) << 16) + (((\target) & $c000) >> 14), VdpCtrl
Else
move.l #VRAM_ADDR_CMD + (((\target) & $3fff) << 16) + (((\target) & $c000) >> 14), VdpCtrl
EndIf
Endm
DMA_VRAM Macro source, target, size
DMA_SETUP \source, \size
VRAM_WRITE_ADDR_SET \target, $80
Endm
DMA_CRAM Macro source, target, size
DMA_SETUP \source, \size
move.l #CRAM_ADDR_CMD + $80 + ((\target) << 16), VdpCtrl
Endm
ENABLE_DISPLAY Macro
move.w #VDPREG_MODE2|$74, VdpCtrl
Endm
DISABLE_DISPLAY Macro
move.w #VDPREG_MODE2|$34, VdpCtrl
Endm
SET_HINT Macro line
move.w #VDPREG_HRATE|(\line), VdpCtrl
Endm
SET_BACKGROUND_COLOR Macro color
move.w #VDPREG_BGCOL|(\color), VdpCtrl
Endm
VDPInit:
lea (VdpCtrl), a0
tst.w (a0)
; Setup registers
move.w #VDPREG_HRATE|$ff, (a0)
move.w #VDPREG_MODE1|$14, (a0) ; Mode register #1; Enable hint
move.w #VDPREG_MODE2|$34, (a0) ; Mode register #2: Enable DMA + vint
move.w #VDPREG_MODE3|$00, (a0) ; Mode register #3: Full plane scrolling
move.w #VDPREG_MODE4|$00, (a0) ; Mode register #4: 32 cell mode (256x224 pixels)
move.w #VDPREG_PLANEA|(PlaneA_VRAMAddress >> 10), (a0)
move.w #VDPREG_PLANEB|(PlaneB_VRAMAddress >> 10), (a0)
move.w #VDPREG_SPRITE|(SpriteAttrTable_VRAMAddress >> 9), (a0)
move.w #VDPREG_WINDOW|$00, (a0)
move.w #VDPREG_HSCROLL|(HScroll_VRAMAddress >> 10), (a0)
move.w #VDPREG_SIZE|$00, (a0) ; 32x32 tilemap size
move.w #VDPREG_WINX|$00, (a0)
move.w #VDPREG_WINY|$00, (a0)
move.w #VDPREG_INCR|$02, (a0) ; Autoincrement
move.w #VDPREG_BGCOL|$00, (a0)
; Clear VRAM
moveq #0, d0 ; To write zeroes
lea (VdpCtrl), a0 ; VDP control port
lea (VdpData), a1 ; VDP data port
; Clear VRAM
move.l #VRAM_ADDR_CMD, (a0)
move.w #(VRAM_SIZE/4)-1, d1
.clearVram:
move.l d0, (a1)
dbf d1, .clearVram
; Clear CRAM
move.l #CRAM_ADDR_CMD, (a0)
move.w #(CRAM_SIZE/4)-1, d1
.clearCram:
move.l d0, (a1)
dbf d1, .clearCram
; Clear VSRAM
move.l #VSRAM_ADDR_CMD, (a0)
move.w #(VSRAM_SIZE/4)-1, d1
.clearVsram:
move.l d0, (a1)
dbf d1, .clearVsram
rts
VDPVSyncWait:
lea VdpCtrl + 1, a0
.waitVBLankEndLoop:
btst #3, (a0)
bne .waitVBLankEndLoop
.waitVBlankStartLoop:
btst #3, (a0)
beq .waitVBlankStartLoop
rts
|
; Disassembly of file: kernel.o
; Mon Oct 30 00:51:00 2017
; Mode: 32 bits
; Syntax: YASM/NASM
; Instruction set: 80386
global kernel_main: function
extern term_writestring ; near
extern term_init ; near
SECTION .text align=16 execute ; section number 1, code
kernel_main:; Function begin
sub esp, 12 ; 0000 _ 83. EC, 0C
call term_init ; 0003 _ E8, FFFFFFFC(rel)
sub esp, 12 ; 0008 _ 83. EC, 0C
push ?_001 ; 000B _ 68, 00000000(d)
call term_writestring ; 0010 _ E8, FFFFFFFC(rel)
add esp, 28 ; 0015 _ 83. C4, 1C
ret ; 0018 _ C3
; kernel_main End of function
SECTION .data align=1 noexecute ; section number 2, data
SECTION .bss align=1 noexecute ; section number 3, bss
SECTION .rodata.str1.4 align=4 noexecute ; section number 4, const
?_001: ; byte
db 53H, 69H, 6DH, 70H, 6CH, 65H, 20H, 4FH ; 0000 _ Simple O
db 53H, 20H, 56H, 65H, 72H, 73H, 69H, 6FH ; 0008 _ S Versio
db 6EH, 20H, 30H, 2EH, 30H, 2EH, 31H, 0AH ; 0010 _ n 0.0.1.
db 53H, 69H, 6EH, 20H, 48H, 69H, 6EH, 67H ; 0018 _ Sin Hing
db 20H, 61H, 6CH, 6CH, 20H, 72H, 69H, 67H ; 0020 _ all rig
db 68H, 74H, 73H, 20H, 72H, 65H, 73H, 65H ; 0028 _ hts rese
db 72H, 76H, 65H, 64H, 2EH, 0AH, 00H ; 0030 _ rved...
SECTION .eh_frame align=4 noexecute ; section number 5, const
db 14H, 00H, 00H, 00H, 00H, 00H, 00H, 00H ; 0000 _ ........
db 01H, 7AH, 52H, 00H, 01H, 7CH, 08H, 01H ; 0008 _ .zR..|..
db 1BH, 0CH, 04H, 04H, 88H, 01H, 00H, 00H ; 0010 _ ........
db 1CH, 00H, 00H, 00H, 1CH, 00H, 00H, 00H ; 0018 _ ........
dd kernel_main-$-20H ; 0020 _ 00000000 (rel)
dd 00000019H, 100E4300H ; 0024 _ 25 269370112
dd 451C0E48H, 0E48200EH ; 002C _ 1159466568 239607822
dd 00000004H ; 0034 _ 4
|
; A095822: Numerators of certain upper bounds for Euler's number e.
; Submitted by Simon Strandgaard
; 3,11,49,87,1631,11743,31967,876809,8877691,4697191,1193556233,2232105163,2222710781,3317652307271,53319412081141,303328210950491,2348085347268533,313262209859119579,42739099682215483
add $0,1
mov $1,1
lpb $0
mov $2,$0
sub $0,1
add $3,$1
mul $1,$2
add $1,$3
lpe
add $1,$3
gcd $3,$1
div $1,$3
mov $0,$1
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.text
.p2align 5, 0x90
SHA256_YMM_K:
.long 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5
.long 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5
.long 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3
.long 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174
.long 0xe49b69c1, 0xefbe4786, 0xfc19dc6, 0x240ca1cc, 0xe49b69c1, 0xefbe4786, 0xfc19dc6, 0x240ca1cc
.long 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da
.long 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7
.long 0xc6e00bf3, 0xd5a79147, 0x6ca6351, 0x14292967, 0xc6e00bf3, 0xd5a79147, 0x6ca6351, 0x14292967
.long 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13
.long 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85
.long 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3
.long 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070
.long 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5
.long 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3
.long 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208
.long 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
SHA256_YMM_BF:
.long 0x10203, 0x4050607, 0x8090a0b, 0xc0d0e0f, 0x10203, 0x4050607, 0x8090a0b, 0xc0d0e0f
SHA256_DCzz:
.byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0,1,2,3, 8,9,10,11
.byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0,1,2,3, 8,9,10,11
SHA256_zzBA:
.byte 0,1,2,3, 8,9,10,11, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
.byte 0,1,2,3, 8,9,10,11, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
.p2align 5, 0x90
.globl _UpdateSHA256
_UpdateSHA256:
push %rbx
push %rbp
push %rbx
push %r12
push %r13
push %r14
push %r15
sub $(544), %rsp
mov %rsp, %r15
and $(-32), %rsp
movslq %edx, %r14
movq %rdi, (8)(%rsp)
movq %r14, (16)(%rsp)
movq %r15, (24)(%rsp)
lea (32)(%rsp), %rsp
movl (%rdi), %eax
movl (4)(%rdi), %ebx
movl (8)(%rdi), %ecx
movl (12)(%rdi), %edx
movl (16)(%rdi), %r8d
movl (20)(%rdi), %r9d
movl (24)(%rdi), %r10d
movl (28)(%rdi), %r11d
vmovdqa SHA256_YMM_BF(%rip), %ymm10
vmovdqa SHA256_zzBA(%rip), %ymm8
vmovdqa SHA256_DCzz(%rip), %ymm9
.p2align 5, 0x90
.Lsha256_block2_loopgas_1:
lea (64)(%rsi), %r12
cmp $(64), %r14
cmovbe %rsi, %r12
lea SHA256_YMM_K(%rip), %rbp
vmovdqu (%rsi), %xmm0
vmovdqu (16)(%rsi), %xmm1
vmovdqu (32)(%rsi), %xmm2
vmovdqu (48)(%rsi), %xmm3
vinserti128 $(1), (%r12), %ymm0, %ymm0
vinserti128 $(1), (16)(%r12), %ymm1, %ymm1
vinserti128 $(1), (32)(%r12), %ymm2, %ymm2
vinserti128 $(1), (48)(%r12), %ymm3, %ymm3
vpshufb %ymm10, %ymm0, %ymm0
vpshufb %ymm10, %ymm1, %ymm1
vpshufb %ymm10, %ymm2, %ymm2
vpshufb %ymm10, %ymm3, %ymm3
vpaddd (%rbp), %ymm0, %ymm4
vpaddd (32)(%rbp), %ymm1, %ymm5
vpaddd (64)(%rbp), %ymm2, %ymm6
vpaddd (96)(%rbp), %ymm3, %ymm7
add $(128), %rbp
vmovdqa %ymm4, (%rsp)
vmovdqa %ymm5, (32)(%rsp)
vmovdqa %ymm6, (64)(%rsp)
vmovdqa %ymm7, (96)(%rsp)
mov %ebx, %edi
xor %r14d, %r14d
mov %r9d, %r12d
xor %ecx, %edi
.p2align 5, 0x90
.Lblock1_shed_procgas_1:
vpalignr $(4), %ymm0, %ymm1, %ymm6
addl (%rsp), %r11d
and %r8d, %r12d
rorx $(25), %r8d, %r13d
vpalignr $(4), %ymm2, %ymm3, %ymm5
rorx $(11), %r8d, %r15d
add %r14d, %eax
add %r12d, %r11d
vpsrld $(7), %ymm6, %ymm4
andn %r10d, %r8d, %r12d
xor %r15d, %r13d
rorx $(6), %r8d, %r14d
vpaddd %ymm5, %ymm0, %ymm0
add %r12d, %r11d
xor %r14d, %r13d
mov %eax, %r15d
vpsrld $(3), %ymm6, %ymm5
rorx $(22), %eax, %r12d
add %r13d, %r11d
xor %ebx, %r15d
vpslld $(14), %ymm6, %ymm7
rorx $(13), %eax, %r14d
rorx $(2), %eax, %r13d
add %r11d, %edx
vpxor %ymm4, %ymm5, %ymm6
and %r15d, %edi
xor %r12d, %r14d
xor %ebx, %edi
vpshufd $(250), %ymm3, %ymm5
xor %r13d, %r14d
add %edi, %r11d
mov %r8d, %r12d
vpsrld $(11), %ymm4, %ymm4
addl (4)(%rsp), %r10d
and %edx, %r12d
rorx $(25), %edx, %r13d
vpxor %ymm7, %ymm6, %ymm6
rorx $(11), %edx, %edi
add %r14d, %r11d
add %r12d, %r10d
vpslld $(11), %ymm7, %ymm7
andn %r9d, %edx, %r12d
xor %edi, %r13d
rorx $(6), %edx, %r14d
vpxor %ymm4, %ymm6, %ymm6
add %r12d, %r10d
xor %r14d, %r13d
mov %r11d, %edi
vpsrld $(10), %ymm5, %ymm4
rorx $(22), %r11d, %r12d
add %r13d, %r10d
xor %eax, %edi
vpxor %ymm7, %ymm6, %ymm6
rorx $(13), %r11d, %r14d
rorx $(2), %r11d, %r13d
add %r10d, %ecx
vpsrlq $(17), %ymm5, %ymm5
and %edi, %r15d
xor %r12d, %r14d
xor %eax, %r15d
vpaddd %ymm6, %ymm0, %ymm0
xor %r13d, %r14d
add %r15d, %r10d
mov %edx, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (8)(%rsp), %r9d
and %ecx, %r12d
rorx $(25), %ecx, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %ecx, %r15d
add %r14d, %r10d
add %r12d, %r9d
vpxor %ymm5, %ymm4, %ymm4
andn %r8d, %ecx, %r12d
xor %r15d, %r13d
rorx $(6), %ecx, %r14d
vpshufb %ymm8, %ymm4, %ymm4
add %r12d, %r9d
xor %r14d, %r13d
mov %r10d, %r15d
vpaddd %ymm4, %ymm0, %ymm0
rorx $(22), %r10d, %r12d
add %r13d, %r9d
xor %r11d, %r15d
vpshufd $(80), %ymm0, %ymm5
rorx $(13), %r10d, %r14d
rorx $(2), %r10d, %r13d
add %r9d, %ebx
vpsrld $(10), %ymm5, %ymm4
and %r15d, %edi
xor %r12d, %r14d
xor %r11d, %edi
vpsrlq $(17), %ymm5, %ymm5
xor %r13d, %r14d
add %edi, %r9d
mov %ecx, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (12)(%rsp), %r8d
and %ebx, %r12d
rorx $(25), %ebx, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %ebx, %edi
add %r14d, %r9d
add %r12d, %r8d
vpxor %ymm5, %ymm4, %ymm4
andn %edx, %ebx, %r12d
xor %edi, %r13d
rorx $(6), %ebx, %r14d
vpshufb %ymm9, %ymm4, %ymm4
add %r12d, %r8d
xor %r14d, %r13d
mov %r9d, %edi
vpaddd %ymm4, %ymm0, %ymm0
rorx $(22), %r9d, %r12d
add %r13d, %r8d
xor %r10d, %edi
vpaddd (%rbp), %ymm0, %ymm4
rorx $(13), %r9d, %r14d
rorx $(2), %r9d, %r13d
add %r8d, %eax
and %edi, %r15d
xor %r12d, %r14d
xor %r10d, %r15d
vmovdqa %ymm4, (128)(%rsp)
xor %r13d, %r14d
add %r15d, %r8d
mov %ebx, %r12d
vpalignr $(4), %ymm1, %ymm2, %ymm6
addl (32)(%rsp), %edx
and %eax, %r12d
rorx $(25), %eax, %r13d
vpalignr $(4), %ymm3, %ymm0, %ymm5
rorx $(11), %eax, %r15d
add %r14d, %r8d
add %r12d, %edx
vpsrld $(7), %ymm6, %ymm4
andn %ecx, %eax, %r12d
xor %r15d, %r13d
rorx $(6), %eax, %r14d
vpaddd %ymm5, %ymm1, %ymm1
add %r12d, %edx
xor %r14d, %r13d
mov %r8d, %r15d
vpsrld $(3), %ymm6, %ymm5
rorx $(22), %r8d, %r12d
add %r13d, %edx
xor %r9d, %r15d
vpslld $(14), %ymm6, %ymm7
rorx $(13), %r8d, %r14d
rorx $(2), %r8d, %r13d
add %edx, %r11d
vpxor %ymm4, %ymm5, %ymm6
and %r15d, %edi
xor %r12d, %r14d
xor %r9d, %edi
vpshufd $(250), %ymm0, %ymm5
xor %r13d, %r14d
add %edi, %edx
mov %eax, %r12d
vpsrld $(11), %ymm4, %ymm4
addl (36)(%rsp), %ecx
and %r11d, %r12d
rorx $(25), %r11d, %r13d
vpxor %ymm7, %ymm6, %ymm6
rorx $(11), %r11d, %edi
add %r14d, %edx
add %r12d, %ecx
vpslld $(11), %ymm7, %ymm7
andn %ebx, %r11d, %r12d
xor %edi, %r13d
rorx $(6), %r11d, %r14d
vpxor %ymm4, %ymm6, %ymm6
add %r12d, %ecx
xor %r14d, %r13d
mov %edx, %edi
vpsrld $(10), %ymm5, %ymm4
rorx $(22), %edx, %r12d
add %r13d, %ecx
xor %r8d, %edi
vpxor %ymm7, %ymm6, %ymm6
rorx $(13), %edx, %r14d
rorx $(2), %edx, %r13d
add %ecx, %r10d
vpsrlq $(17), %ymm5, %ymm5
and %edi, %r15d
xor %r12d, %r14d
xor %r8d, %r15d
vpaddd %ymm6, %ymm1, %ymm1
xor %r13d, %r14d
add %r15d, %ecx
mov %r11d, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (40)(%rsp), %ebx
and %r10d, %r12d
rorx $(25), %r10d, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %r10d, %r15d
add %r14d, %ecx
add %r12d, %ebx
vpxor %ymm5, %ymm4, %ymm4
andn %eax, %r10d, %r12d
xor %r15d, %r13d
rorx $(6), %r10d, %r14d
vpshufb %ymm8, %ymm4, %ymm4
add %r12d, %ebx
xor %r14d, %r13d
mov %ecx, %r15d
vpaddd %ymm4, %ymm1, %ymm1
rorx $(22), %ecx, %r12d
add %r13d, %ebx
xor %edx, %r15d
vpshufd $(80), %ymm1, %ymm5
rorx $(13), %ecx, %r14d
rorx $(2), %ecx, %r13d
add %ebx, %r9d
vpsrld $(10), %ymm5, %ymm4
and %r15d, %edi
xor %r12d, %r14d
xor %edx, %edi
vpsrlq $(17), %ymm5, %ymm5
xor %r13d, %r14d
add %edi, %ebx
mov %r10d, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (44)(%rsp), %eax
and %r9d, %r12d
rorx $(25), %r9d, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %r9d, %edi
add %r14d, %ebx
add %r12d, %eax
vpxor %ymm5, %ymm4, %ymm4
andn %r11d, %r9d, %r12d
xor %edi, %r13d
rorx $(6), %r9d, %r14d
vpshufb %ymm9, %ymm4, %ymm4
add %r12d, %eax
xor %r14d, %r13d
mov %ebx, %edi
vpaddd %ymm4, %ymm1, %ymm1
rorx $(22), %ebx, %r12d
add %r13d, %eax
xor %ecx, %edi
vpaddd (32)(%rbp), %ymm1, %ymm4
rorx $(13), %ebx, %r14d
rorx $(2), %ebx, %r13d
add %eax, %r8d
and %edi, %r15d
xor %r12d, %r14d
xor %ecx, %r15d
vmovdqa %ymm4, (160)(%rsp)
xor %r13d, %r14d
add %r15d, %eax
mov %r9d, %r12d
vpalignr $(4), %ymm2, %ymm3, %ymm6
addl (64)(%rsp), %r11d
and %r8d, %r12d
rorx $(25), %r8d, %r13d
vpalignr $(4), %ymm0, %ymm1, %ymm5
rorx $(11), %r8d, %r15d
add %r14d, %eax
add %r12d, %r11d
vpsrld $(7), %ymm6, %ymm4
andn %r10d, %r8d, %r12d
xor %r15d, %r13d
rorx $(6), %r8d, %r14d
vpaddd %ymm5, %ymm2, %ymm2
add %r12d, %r11d
xor %r14d, %r13d
mov %eax, %r15d
vpsrld $(3), %ymm6, %ymm5
rorx $(22), %eax, %r12d
add %r13d, %r11d
xor %ebx, %r15d
vpslld $(14), %ymm6, %ymm7
rorx $(13), %eax, %r14d
rorx $(2), %eax, %r13d
add %r11d, %edx
vpxor %ymm4, %ymm5, %ymm6
and %r15d, %edi
xor %r12d, %r14d
xor %ebx, %edi
vpshufd $(250), %ymm1, %ymm5
xor %r13d, %r14d
add %edi, %r11d
mov %r8d, %r12d
vpsrld $(11), %ymm4, %ymm4
addl (68)(%rsp), %r10d
and %edx, %r12d
rorx $(25), %edx, %r13d
vpxor %ymm7, %ymm6, %ymm6
rorx $(11), %edx, %edi
add %r14d, %r11d
add %r12d, %r10d
vpslld $(11), %ymm7, %ymm7
andn %r9d, %edx, %r12d
xor %edi, %r13d
rorx $(6), %edx, %r14d
vpxor %ymm4, %ymm6, %ymm6
add %r12d, %r10d
xor %r14d, %r13d
mov %r11d, %edi
vpsrld $(10), %ymm5, %ymm4
rorx $(22), %r11d, %r12d
add %r13d, %r10d
xor %eax, %edi
vpxor %ymm7, %ymm6, %ymm6
rorx $(13), %r11d, %r14d
rorx $(2), %r11d, %r13d
add %r10d, %ecx
vpsrlq $(17), %ymm5, %ymm5
and %edi, %r15d
xor %r12d, %r14d
xor %eax, %r15d
vpaddd %ymm6, %ymm2, %ymm2
xor %r13d, %r14d
add %r15d, %r10d
mov %edx, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (72)(%rsp), %r9d
and %ecx, %r12d
rorx $(25), %ecx, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %ecx, %r15d
add %r14d, %r10d
add %r12d, %r9d
vpxor %ymm5, %ymm4, %ymm4
andn %r8d, %ecx, %r12d
xor %r15d, %r13d
rorx $(6), %ecx, %r14d
vpshufb %ymm8, %ymm4, %ymm4
add %r12d, %r9d
xor %r14d, %r13d
mov %r10d, %r15d
vpaddd %ymm4, %ymm2, %ymm2
rorx $(22), %r10d, %r12d
add %r13d, %r9d
xor %r11d, %r15d
vpshufd $(80), %ymm2, %ymm5
rorx $(13), %r10d, %r14d
rorx $(2), %r10d, %r13d
add %r9d, %ebx
vpsrld $(10), %ymm5, %ymm4
and %r15d, %edi
xor %r12d, %r14d
xor %r11d, %edi
vpsrlq $(17), %ymm5, %ymm5
xor %r13d, %r14d
add %edi, %r9d
mov %ecx, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (76)(%rsp), %r8d
and %ebx, %r12d
rorx $(25), %ebx, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %ebx, %edi
add %r14d, %r9d
add %r12d, %r8d
vpxor %ymm5, %ymm4, %ymm4
andn %edx, %ebx, %r12d
xor %edi, %r13d
rorx $(6), %ebx, %r14d
vpshufb %ymm9, %ymm4, %ymm4
add %r12d, %r8d
xor %r14d, %r13d
mov %r9d, %edi
vpaddd %ymm4, %ymm2, %ymm2
rorx $(22), %r9d, %r12d
add %r13d, %r8d
xor %r10d, %edi
vpaddd (64)(%rbp), %ymm2, %ymm4
rorx $(13), %r9d, %r14d
rorx $(2), %r9d, %r13d
add %r8d, %eax
and %edi, %r15d
xor %r12d, %r14d
xor %r10d, %r15d
vmovdqa %ymm4, (192)(%rsp)
xor %r13d, %r14d
add %r15d, %r8d
mov %ebx, %r12d
vpalignr $(4), %ymm3, %ymm0, %ymm6
addl (96)(%rsp), %edx
and %eax, %r12d
rorx $(25), %eax, %r13d
vpalignr $(4), %ymm1, %ymm2, %ymm5
rorx $(11), %eax, %r15d
add %r14d, %r8d
add %r12d, %edx
vpsrld $(7), %ymm6, %ymm4
andn %ecx, %eax, %r12d
xor %r15d, %r13d
rorx $(6), %eax, %r14d
vpaddd %ymm5, %ymm3, %ymm3
add %r12d, %edx
xor %r14d, %r13d
mov %r8d, %r15d
vpsrld $(3), %ymm6, %ymm5
rorx $(22), %r8d, %r12d
add %r13d, %edx
xor %r9d, %r15d
vpslld $(14), %ymm6, %ymm7
rorx $(13), %r8d, %r14d
rorx $(2), %r8d, %r13d
add %edx, %r11d
vpxor %ymm4, %ymm5, %ymm6
and %r15d, %edi
xor %r12d, %r14d
xor %r9d, %edi
vpshufd $(250), %ymm2, %ymm5
xor %r13d, %r14d
add %edi, %edx
mov %eax, %r12d
vpsrld $(11), %ymm4, %ymm4
addl (100)(%rsp), %ecx
and %r11d, %r12d
rorx $(25), %r11d, %r13d
vpxor %ymm7, %ymm6, %ymm6
rorx $(11), %r11d, %edi
add %r14d, %edx
add %r12d, %ecx
vpslld $(11), %ymm7, %ymm7
andn %ebx, %r11d, %r12d
xor %edi, %r13d
rorx $(6), %r11d, %r14d
vpxor %ymm4, %ymm6, %ymm6
add %r12d, %ecx
xor %r14d, %r13d
mov %edx, %edi
vpsrld $(10), %ymm5, %ymm4
rorx $(22), %edx, %r12d
add %r13d, %ecx
xor %r8d, %edi
vpxor %ymm7, %ymm6, %ymm6
rorx $(13), %edx, %r14d
rorx $(2), %edx, %r13d
add %ecx, %r10d
vpsrlq $(17), %ymm5, %ymm5
and %edi, %r15d
xor %r12d, %r14d
xor %r8d, %r15d
vpaddd %ymm6, %ymm3, %ymm3
xor %r13d, %r14d
add %r15d, %ecx
mov %r11d, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (104)(%rsp), %ebx
and %r10d, %r12d
rorx $(25), %r10d, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %r10d, %r15d
add %r14d, %ecx
add %r12d, %ebx
vpxor %ymm5, %ymm4, %ymm4
andn %eax, %r10d, %r12d
xor %r15d, %r13d
rorx $(6), %r10d, %r14d
vpshufb %ymm8, %ymm4, %ymm4
add %r12d, %ebx
xor %r14d, %r13d
mov %ecx, %r15d
vpaddd %ymm4, %ymm3, %ymm3
rorx $(22), %ecx, %r12d
add %r13d, %ebx
xor %edx, %r15d
vpshufd $(80), %ymm3, %ymm5
rorx $(13), %ecx, %r14d
rorx $(2), %ecx, %r13d
add %ebx, %r9d
vpsrld $(10), %ymm5, %ymm4
and %r15d, %edi
xor %r12d, %r14d
xor %edx, %edi
vpsrlq $(17), %ymm5, %ymm5
xor %r13d, %r14d
add %edi, %ebx
mov %r10d, %r12d
vpxor %ymm5, %ymm4, %ymm4
addl (108)(%rsp), %eax
and %r9d, %r12d
rorx $(25), %r9d, %r13d
vpsrlq $(2), %ymm5, %ymm5
rorx $(11), %r9d, %edi
add %r14d, %ebx
add %r12d, %eax
vpxor %ymm5, %ymm4, %ymm4
andn %r11d, %r9d, %r12d
xor %edi, %r13d
rorx $(6), %r9d, %r14d
vpshufb %ymm9, %ymm4, %ymm4
add %r12d, %eax
xor %r14d, %r13d
mov %ebx, %edi
vpaddd %ymm4, %ymm3, %ymm3
rorx $(22), %ebx, %r12d
add %r13d, %eax
xor %ecx, %edi
vpaddd (96)(%rbp), %ymm3, %ymm4
rorx $(13), %ebx, %r14d
rorx $(2), %ebx, %r13d
add %eax, %r8d
and %edi, %r15d
xor %r12d, %r14d
xor %ecx, %r15d
vmovdqa %ymm4, (224)(%rsp)
xor %r13d, %r14d
add %r15d, %eax
mov %r9d, %r12d
add $(128), %rsp
add $(128), %rbp
cmpl $(3329325298), (-4)(%rbp)
jne .Lblock1_shed_procgas_1
addl (%rsp), %r11d
and %r8d, %r12d
rorx $(25), %r8d, %r13d
rorx $(11), %r8d, %r15d
add %r14d, %eax
add %r12d, %r11d
andn %r10d, %r8d, %r12d
xor %r15d, %r13d
rorx $(6), %r8d, %r14d
add %r12d, %r11d
xor %r14d, %r13d
mov %eax, %r15d
rorx $(22), %eax, %r12d
add %r13d, %r11d
xor %ebx, %r15d
rorx $(13), %eax, %r14d
rorx $(2), %eax, %r13d
add %r11d, %edx
and %r15d, %edi
xor %r12d, %r14d
xor %ebx, %edi
xor %r13d, %r14d
add %edi, %r11d
mov %r8d, %r12d
addl (4)(%rsp), %r10d
and %edx, %r12d
rorx $(25), %edx, %r13d
rorx $(11), %edx, %edi
add %r14d, %r11d
add %r12d, %r10d
andn %r9d, %edx, %r12d
xor %edi, %r13d
rorx $(6), %edx, %r14d
add %r12d, %r10d
xor %r14d, %r13d
mov %r11d, %edi
rorx $(22), %r11d, %r12d
add %r13d, %r10d
xor %eax, %edi
rorx $(13), %r11d, %r14d
rorx $(2), %r11d, %r13d
add %r10d, %ecx
and %edi, %r15d
xor %r12d, %r14d
xor %eax, %r15d
xor %r13d, %r14d
add %r15d, %r10d
mov %edx, %r12d
addl (8)(%rsp), %r9d
and %ecx, %r12d
rorx $(25), %ecx, %r13d
rorx $(11), %ecx, %r15d
add %r14d, %r10d
add %r12d, %r9d
andn %r8d, %ecx, %r12d
xor %r15d, %r13d
rorx $(6), %ecx, %r14d
add %r12d, %r9d
xor %r14d, %r13d
mov %r10d, %r15d
rorx $(22), %r10d, %r12d
add %r13d, %r9d
xor %r11d, %r15d
rorx $(13), %r10d, %r14d
rorx $(2), %r10d, %r13d
add %r9d, %ebx
and %r15d, %edi
xor %r12d, %r14d
xor %r11d, %edi
xor %r13d, %r14d
add %edi, %r9d
mov %ecx, %r12d
addl (12)(%rsp), %r8d
and %ebx, %r12d
rorx $(25), %ebx, %r13d
rorx $(11), %ebx, %edi
add %r14d, %r9d
add %r12d, %r8d
andn %edx, %ebx, %r12d
xor %edi, %r13d
rorx $(6), %ebx, %r14d
add %r12d, %r8d
xor %r14d, %r13d
mov %r9d, %edi
rorx $(22), %r9d, %r12d
add %r13d, %r8d
xor %r10d, %edi
rorx $(13), %r9d, %r14d
rorx $(2), %r9d, %r13d
add %r8d, %eax
and %edi, %r15d
xor %r12d, %r14d
xor %r10d, %r15d
xor %r13d, %r14d
add %r15d, %r8d
mov %ebx, %r12d
addl (32)(%rsp), %edx
and %eax, %r12d
rorx $(25), %eax, %r13d
rorx $(11), %eax, %r15d
add %r14d, %r8d
add %r12d, %edx
andn %ecx, %eax, %r12d
xor %r15d, %r13d
rorx $(6), %eax, %r14d
add %r12d, %edx
xor %r14d, %r13d
mov %r8d, %r15d
rorx $(22), %r8d, %r12d
add %r13d, %edx
xor %r9d, %r15d
rorx $(13), %r8d, %r14d
rorx $(2), %r8d, %r13d
add %edx, %r11d
and %r15d, %edi
xor %r12d, %r14d
xor %r9d, %edi
xor %r13d, %r14d
add %edi, %edx
mov %eax, %r12d
addl (36)(%rsp), %ecx
and %r11d, %r12d
rorx $(25), %r11d, %r13d
rorx $(11), %r11d, %edi
add %r14d, %edx
add %r12d, %ecx
andn %ebx, %r11d, %r12d
xor %edi, %r13d
rorx $(6), %r11d, %r14d
add %r12d, %ecx
xor %r14d, %r13d
mov %edx, %edi
rorx $(22), %edx, %r12d
add %r13d, %ecx
xor %r8d, %edi
rorx $(13), %edx, %r14d
rorx $(2), %edx, %r13d
add %ecx, %r10d
and %edi, %r15d
xor %r12d, %r14d
xor %r8d, %r15d
xor %r13d, %r14d
add %r15d, %ecx
mov %r11d, %r12d
addl (40)(%rsp), %ebx
and %r10d, %r12d
rorx $(25), %r10d, %r13d
rorx $(11), %r10d, %r15d
add %r14d, %ecx
add %r12d, %ebx
andn %eax, %r10d, %r12d
xor %r15d, %r13d
rorx $(6), %r10d, %r14d
add %r12d, %ebx
xor %r14d, %r13d
mov %ecx, %r15d
rorx $(22), %ecx, %r12d
add %r13d, %ebx
xor %edx, %r15d
rorx $(13), %ecx, %r14d
rorx $(2), %ecx, %r13d
add %ebx, %r9d
and %r15d, %edi
xor %r12d, %r14d
xor %edx, %edi
xor %r13d, %r14d
add %edi, %ebx
mov %r10d, %r12d
addl (44)(%rsp), %eax
and %r9d, %r12d
rorx $(25), %r9d, %r13d
rorx $(11), %r9d, %edi
add %r14d, %ebx
add %r12d, %eax
andn %r11d, %r9d, %r12d
xor %edi, %r13d
rorx $(6), %r9d, %r14d
add %r12d, %eax
xor %r14d, %r13d
mov %ebx, %edi
rorx $(22), %ebx, %r12d
add %r13d, %eax
xor %ecx, %edi
rorx $(13), %ebx, %r14d
rorx $(2), %ebx, %r13d
add %eax, %r8d
and %edi, %r15d
xor %r12d, %r14d
xor %ecx, %r15d
xor %r13d, %r14d
add %r15d, %eax
mov %r9d, %r12d
addl (64)(%rsp), %r11d
and %r8d, %r12d
rorx $(25), %r8d, %r13d
rorx $(11), %r8d, %r15d
add %r14d, %eax
add %r12d, %r11d
andn %r10d, %r8d, %r12d
xor %r15d, %r13d
rorx $(6), %r8d, %r14d
add %r12d, %r11d
xor %r14d, %r13d
mov %eax, %r15d
rorx $(22), %eax, %r12d
add %r13d, %r11d
xor %ebx, %r15d
rorx $(13), %eax, %r14d
rorx $(2), %eax, %r13d
add %r11d, %edx
and %r15d, %edi
xor %r12d, %r14d
xor %ebx, %edi
xor %r13d, %r14d
add %edi, %r11d
mov %r8d, %r12d
addl (68)(%rsp), %r10d
and %edx, %r12d
rorx $(25), %edx, %r13d
rorx $(11), %edx, %edi
add %r14d, %r11d
add %r12d, %r10d
andn %r9d, %edx, %r12d
xor %edi, %r13d
rorx $(6), %edx, %r14d
add %r12d, %r10d
xor %r14d, %r13d
mov %r11d, %edi
rorx $(22), %r11d, %r12d
add %r13d, %r10d
xor %eax, %edi
rorx $(13), %r11d, %r14d
rorx $(2), %r11d, %r13d
add %r10d, %ecx
and %edi, %r15d
xor %r12d, %r14d
xor %eax, %r15d
xor %r13d, %r14d
add %r15d, %r10d
mov %edx, %r12d
addl (72)(%rsp), %r9d
and %ecx, %r12d
rorx $(25), %ecx, %r13d
rorx $(11), %ecx, %r15d
add %r14d, %r10d
add %r12d, %r9d
andn %r8d, %ecx, %r12d
xor %r15d, %r13d
rorx $(6), %ecx, %r14d
add %r12d, %r9d
xor %r14d, %r13d
mov %r10d, %r15d
rorx $(22), %r10d, %r12d
add %r13d, %r9d
xor %r11d, %r15d
rorx $(13), %r10d, %r14d
rorx $(2), %r10d, %r13d
add %r9d, %ebx
and %r15d, %edi
xor %r12d, %r14d
xor %r11d, %edi
xor %r13d, %r14d
add %edi, %r9d
mov %ecx, %r12d
addl (76)(%rsp), %r8d
and %ebx, %r12d
rorx $(25), %ebx, %r13d
rorx $(11), %ebx, %edi
add %r14d, %r9d
add %r12d, %r8d
andn %edx, %ebx, %r12d
xor %edi, %r13d
rorx $(6), %ebx, %r14d
add %r12d, %r8d
xor %r14d, %r13d
mov %r9d, %edi
rorx $(22), %r9d, %r12d
add %r13d, %r8d
xor %r10d, %edi
rorx $(13), %r9d, %r14d
rorx $(2), %r9d, %r13d
add %r8d, %eax
and %edi, %r15d
xor %r12d, %r14d
xor %r10d, %r15d
xor %r13d, %r14d
add %r15d, %r8d
mov %ebx, %r12d
addl (96)(%rsp), %edx
and %eax, %r12d
rorx $(25), %eax, %r13d
rorx $(11), %eax, %r15d
add %r14d, %r8d
add %r12d, %edx
andn %ecx, %eax, %r12d
xor %r15d, %r13d
rorx $(6), %eax, %r14d
add %r12d, %edx
xor %r14d, %r13d
mov %r8d, %r15d
rorx $(22), %r8d, %r12d
add %r13d, %edx
xor %r9d, %r15d
rorx $(13), %r8d, %r14d
rorx $(2), %r8d, %r13d
add %edx, %r11d
and %r15d, %edi
xor %r12d, %r14d
xor %r9d, %edi
xor %r13d, %r14d
add %edi, %edx
mov %eax, %r12d
addl (100)(%rsp), %ecx
and %r11d, %r12d
rorx $(25), %r11d, %r13d
rorx $(11), %r11d, %edi
add %r14d, %edx
add %r12d, %ecx
andn %ebx, %r11d, %r12d
xor %edi, %r13d
rorx $(6), %r11d, %r14d
add %r12d, %ecx
xor %r14d, %r13d
mov %edx, %edi
rorx $(22), %edx, %r12d
add %r13d, %ecx
xor %r8d, %edi
rorx $(13), %edx, %r14d
rorx $(2), %edx, %r13d
add %ecx, %r10d
and %edi, %r15d
xor %r12d, %r14d
xor %r8d, %r15d
xor %r13d, %r14d
add %r15d, %ecx
mov %r11d, %r12d
addl (104)(%rsp), %ebx
and %r10d, %r12d
rorx $(25), %r10d, %r13d
rorx $(11), %r10d, %r15d
add %r14d, %ecx
add %r12d, %ebx
andn %eax, %r10d, %r12d
xor %r15d, %r13d
rorx $(6), %r10d, %r14d
add %r12d, %ebx
xor %r14d, %r13d
mov %ecx, %r15d
rorx $(22), %ecx, %r12d
add %r13d, %ebx
xor %edx, %r15d
rorx $(13), %ecx, %r14d
rorx $(2), %ecx, %r13d
add %ebx, %r9d
and %r15d, %edi
xor %r12d, %r14d
xor %edx, %edi
xor %r13d, %r14d
add %edi, %ebx
mov %r10d, %r12d
addl (108)(%rsp), %eax
and %r9d, %r12d
rorx $(25), %r9d, %r13d
rorx $(11), %r9d, %edi
add %r14d, %ebx
add %r12d, %eax
andn %r11d, %r9d, %r12d
xor %edi, %r13d
rorx $(6), %r9d, %r14d
add %r12d, %eax
xor %r14d, %r13d
mov %ebx, %edi
rorx $(22), %ebx, %r12d
add %r13d, %eax
xor %ecx, %edi
rorx $(13), %ebx, %r14d
rorx $(2), %ebx, %r13d
add %eax, %r8d
and %edi, %r15d
xor %r12d, %r14d
xor %ecx, %r15d
xor %r13d, %r14d
add %r15d, %eax
mov %r9d, %r12d
add %r14d, %eax
sub $(384), %rsp
movq (-24)(%rsp), %rdi
movq (-16)(%rsp), %r14
addl (%rdi), %eax
movl %eax, (%rdi)
addl (4)(%rdi), %ebx
movl %ebx, (4)(%rdi)
addl (8)(%rdi), %ecx
movl %ecx, (8)(%rdi)
addl (12)(%rdi), %edx
movl %edx, (12)(%rdi)
addl (16)(%rdi), %r8d
movl %r8d, (16)(%rdi)
addl (20)(%rdi), %r9d
movl %r9d, (20)(%rdi)
addl (24)(%rdi), %r10d
movl %r10d, (24)(%rdi)
addl (28)(%rdi), %r11d
movl %r11d, (28)(%rdi)
cmp $(128), %r14
jl .Ldonegas_1
add $(16), %rsp
lea (512)(%rsp), %rbp
mov %ebx, %edi
xor %r14d, %r14d
mov %r9d, %r12d
xor %ecx, %edi
.p2align 5, 0x90
.Lblock2_procgas_1:
addl (%rsp), %r11d
and %r8d, %r12d
rorx $(25), %r8d, %r13d
rorx $(11), %r8d, %r15d
add %r14d, %eax
add %r12d, %r11d
andn %r10d, %r8d, %r12d
xor %r15d, %r13d
rorx $(6), %r8d, %r14d
add %r12d, %r11d
xor %r14d, %r13d
mov %eax, %r15d
rorx $(22), %eax, %r12d
add %r13d, %r11d
xor %ebx, %r15d
rorx $(13), %eax, %r14d
rorx $(2), %eax, %r13d
add %r11d, %edx
and %r15d, %edi
xor %r12d, %r14d
xor %ebx, %edi
xor %r13d, %r14d
add %edi, %r11d
mov %r8d, %r12d
addl (4)(%rsp), %r10d
and %edx, %r12d
rorx $(25), %edx, %r13d
rorx $(11), %edx, %edi
add %r14d, %r11d
add %r12d, %r10d
andn %r9d, %edx, %r12d
xor %edi, %r13d
rorx $(6), %edx, %r14d
add %r12d, %r10d
xor %r14d, %r13d
mov %r11d, %edi
rorx $(22), %r11d, %r12d
add %r13d, %r10d
xor %eax, %edi
rorx $(13), %r11d, %r14d
rorx $(2), %r11d, %r13d
add %r10d, %ecx
and %edi, %r15d
xor %r12d, %r14d
xor %eax, %r15d
xor %r13d, %r14d
add %r15d, %r10d
mov %edx, %r12d
addl (8)(%rsp), %r9d
and %ecx, %r12d
rorx $(25), %ecx, %r13d
rorx $(11), %ecx, %r15d
add %r14d, %r10d
add %r12d, %r9d
andn %r8d, %ecx, %r12d
xor %r15d, %r13d
rorx $(6), %ecx, %r14d
add %r12d, %r9d
xor %r14d, %r13d
mov %r10d, %r15d
rorx $(22), %r10d, %r12d
add %r13d, %r9d
xor %r11d, %r15d
rorx $(13), %r10d, %r14d
rorx $(2), %r10d, %r13d
add %r9d, %ebx
and %r15d, %edi
xor %r12d, %r14d
xor %r11d, %edi
xor %r13d, %r14d
add %edi, %r9d
mov %ecx, %r12d
addl (12)(%rsp), %r8d
and %ebx, %r12d
rorx $(25), %ebx, %r13d
rorx $(11), %ebx, %edi
add %r14d, %r9d
add %r12d, %r8d
andn %edx, %ebx, %r12d
xor %edi, %r13d
rorx $(6), %ebx, %r14d
add %r12d, %r8d
xor %r14d, %r13d
mov %r9d, %edi
rorx $(22), %r9d, %r12d
add %r13d, %r8d
xor %r10d, %edi
rorx $(13), %r9d, %r14d
rorx $(2), %r9d, %r13d
add %r8d, %eax
and %edi, %r15d
xor %r12d, %r14d
xor %r10d, %r15d
xor %r13d, %r14d
add %r15d, %r8d
mov %ebx, %r12d
addl (32)(%rsp), %edx
and %eax, %r12d
rorx $(25), %eax, %r13d
rorx $(11), %eax, %r15d
add %r14d, %r8d
add %r12d, %edx
andn %ecx, %eax, %r12d
xor %r15d, %r13d
rorx $(6), %eax, %r14d
add %r12d, %edx
xor %r14d, %r13d
mov %r8d, %r15d
rorx $(22), %r8d, %r12d
add %r13d, %edx
xor %r9d, %r15d
rorx $(13), %r8d, %r14d
rorx $(2), %r8d, %r13d
add %edx, %r11d
and %r15d, %edi
xor %r12d, %r14d
xor %r9d, %edi
xor %r13d, %r14d
add %edi, %edx
mov %eax, %r12d
addl (36)(%rsp), %ecx
and %r11d, %r12d
rorx $(25), %r11d, %r13d
rorx $(11), %r11d, %edi
add %r14d, %edx
add %r12d, %ecx
andn %ebx, %r11d, %r12d
xor %edi, %r13d
rorx $(6), %r11d, %r14d
add %r12d, %ecx
xor %r14d, %r13d
mov %edx, %edi
rorx $(22), %edx, %r12d
add %r13d, %ecx
xor %r8d, %edi
rorx $(13), %edx, %r14d
rorx $(2), %edx, %r13d
add %ecx, %r10d
and %edi, %r15d
xor %r12d, %r14d
xor %r8d, %r15d
xor %r13d, %r14d
add %r15d, %ecx
mov %r11d, %r12d
addl (40)(%rsp), %ebx
and %r10d, %r12d
rorx $(25), %r10d, %r13d
rorx $(11), %r10d, %r15d
add %r14d, %ecx
add %r12d, %ebx
andn %eax, %r10d, %r12d
xor %r15d, %r13d
rorx $(6), %r10d, %r14d
add %r12d, %ebx
xor %r14d, %r13d
mov %ecx, %r15d
rorx $(22), %ecx, %r12d
add %r13d, %ebx
xor %edx, %r15d
rorx $(13), %ecx, %r14d
rorx $(2), %ecx, %r13d
add %ebx, %r9d
and %r15d, %edi
xor %r12d, %r14d
xor %edx, %edi
xor %r13d, %r14d
add %edi, %ebx
mov %r10d, %r12d
addl (44)(%rsp), %eax
and %r9d, %r12d
rorx $(25), %r9d, %r13d
rorx $(11), %r9d, %edi
add %r14d, %ebx
add %r12d, %eax
andn %r11d, %r9d, %r12d
xor %edi, %r13d
rorx $(6), %r9d, %r14d
add %r12d, %eax
xor %r14d, %r13d
mov %ebx, %edi
rorx $(22), %ebx, %r12d
add %r13d, %eax
xor %ecx, %edi
rorx $(13), %ebx, %r14d
rorx $(2), %ebx, %r13d
add %eax, %r8d
and %edi, %r15d
xor %r12d, %r14d
xor %ecx, %r15d
xor %r13d, %r14d
add %r15d, %eax
mov %r9d, %r12d
add $(64), %rsp
cmp %rbp, %rsp
jb .Lblock2_procgas_1
add %r14d, %eax
sub $(528), %rsp
movq (-24)(%rsp), %rdi
movq (-16)(%rsp), %r14
addl (%rdi), %eax
movl %eax, (%rdi)
addl (4)(%rdi), %ebx
movl %ebx, (4)(%rdi)
addl (8)(%rdi), %ecx
movl %ecx, (8)(%rdi)
addl (12)(%rdi), %edx
movl %edx, (12)(%rdi)
addl (16)(%rdi), %r8d
movl %r8d, (16)(%rdi)
addl (20)(%rdi), %r9d
movl %r9d, (20)(%rdi)
addl (24)(%rdi), %r10d
movl %r10d, (24)(%rdi)
addl (28)(%rdi), %r11d
movl %r11d, (28)(%rdi)
add $(128), %rsi
sub $(128), %r14
movq %r14, (-16)(%rsp)
jg .Lsha256_block2_loopgas_1
.Ldonegas_1:
movq (-8)(%rsp), %rsp
add $(544), %rsp
vzeroupper
pop %r15
pop %r14
pop %r13
pop %r12
pop %rbx
pop %rbp
pop %rbx
ret
|
Name: kart-enemy-p.asm
Type: file
Size: 25482
Last-Modified: '1992-08-06T06:37:38Z'
SHA-1: 518F79F6F50238F5FD30317AA82344E3213BA1DF
Description: null
|
#include "cleFlagExistingLabelsKernel.hpp"
#include "cleSetKernel.hpp"
namespace cle
{
FlagExistingLabelsKernel::FlagExistingLabelsKernel (std::shared_ptr<GPU> gpu) :
Kernel( gpu,
"flag_existing_labels",
{"dst" , "src"}
)
{
m_Sources.insert({this->m_KernelName + "", source});
}
void FlagExistingLabelsKernel::SetInput(Buffer& x)
{
this->AddObject(x, "src");
}
void FlagExistingLabelsKernel::SetOutput(Buffer& x)
{
this->AddObject(x, "dst");
}
void FlagExistingLabelsKernel::Execute()
{
std::shared_ptr<Buffer> dst = std::dynamic_pointer_cast<Buffer>(m_ParameterList.at("dst"));
SetKernel set(this->m_gpu);
set.SetInput(*dst);
set.SetValue(0);
set.Execute();
this->BuildProgramKernel();
this->SetArguments();
this->EnqueueKernel();
}
} // namespace cle
|
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "openvino/op/op.hpp"
namespace ov {
namespace op {
namespace util {
///
/// \brief Base class for ScatterXXX operators.
///
class OPENVINO_API ScatterBase : public Op {
public:
OPENVINO_RTTI_DECLARATION;
void validate_and_infer_types() override;
bool visit_attributes(AttributeVisitor& visitor) override;
protected:
ScatterBase() = default;
///
/// \brief Constructs ScatterBase object.
///
/// \param inputs The input tensor to be updated.
/// \param indices The tensor with indexes which will be updated.
/// \param updates The tensor with update values.
/// \param[in] axis The axis at which elements will be updated.
///
ScatterBase(const Output<Node>& inputs,
const Output<Node>& indices,
const Output<Node>& updates,
const Output<Node>& axis);
private:
// Respective input ordinal number.
static constexpr int DATA = 0;
static constexpr int INDICES = 1;
static constexpr int UPDATES = 2;
static constexpr int AXIS = 3;
};
} // namespace util
} // namespace op
} // namespace ov
|
ORG 0x8000 : OUTPUT "all_fake.bin"
OPT reset --zxnext=cspect --syntax=f ; fakes warning ON
break ; CSpect emulator breakpoint (was used to verify all fakes below in debugger)
rl_bc rl bc
rl_de rl de
rl_hl rl hl
rr_bc rr bc
rr_de rr de
rr_hl rr hl
sla_bc sla bc
sla_de sla de
sla_hl sla hl
sll_bc sll bc
sll_de sll de
sll_hl sll hl
sli_bc sli bc
sli_de sli de
sli_hl sli hl
sra_bc sra bc
sra_de sra de
sra_hl sra hl
srl_bc srl bc
srl_de srl de
srl_hl srl hl
ld_bc_bc ld bc,bc
ld_bc_de ld bc,de
ld_bc_hl ld bc,hl
ld_bc_ix ld bc,ix
ld_bc_iy ld bc,iy
ld_bc_#hl# ld bc,(hl)
ld_bc_#ix_nn# ld bc,(ix+$77)
ld_bc_#iy_nn# ld bc,(iy+$77)
ld_de_bc ld de,bc
ld_de_de ld de,de
ld_de_hl ld de,hl
ld_de_ix ld de,ix
ld_de_iy ld de,iy
ld_de_#hl# ld de,(hl)
ld_de_#ix_nn# ld de,(ix+$77)
ld_de_#iy_nn# ld de,(iy+$77)
ld_hl_bc ld hl,bc
ld_hl_de ld hl,de
ld_hl_hl ld hl,hl
ld_hl_ix ld hl,ix
ld_hl_iy ld hl,iy
ld_hl_#ix_nn# ld hl,(ix+$77)
ld_hl_#iy_nn# ld hl,(iy+$77)
ld_ix_bc ld ix,bc
ld_ix_de ld ix,de
ld_ix_hl ld ix,hl
ld_ix_ix ld ix,ix
ld_ix_iy ld ix,iy
ld_iy_bc ld iy,bc
ld_iy_de ld iy,de
ld_iy_hl ld iy,hl
ld_iy_ix ld iy,ix
ld_iy_iy ld iy,iy
ld_#hl#_bc ld (hl),bc
ld_#hl#_de ld (hl),de
ld_#ix_nn#_bc ld (ix+$77),bc
ld_#ix_nn#_de ld (ix+$77),de
ld_#ix_nn#_hl ld (ix+$77),hl
ld_#iy_nn#_bc ld (iy+$77),bc
ld_#iy_nn#_de ld (iy+$77),de
ld_#iy_nn#_hl ld (iy+$77),hl
ldi_bc_#hl# ldi bc,(hl)
ldi_bc_#ix_nn# ldi bc,(ix+$77)
ldi_bc_#iy_nn# ldi bc,(iy+$77)
ldi_de_#hl# ldi de,(hl)
ldi_de_#ix_nn# ldi de,(ix+$77)
ldi_de_#iy_nn# ldi de,(iy+$77)
ldi_hl_#ix_nn# ldi hl,(ix+$77)
ldi_hl_#iy_nn# ldi hl,(iy+$77)
ldi_#hl#_bc ldi (hl),bc
ldi_#hl#_de ldi (hl),de
ldi_#ix_nn#_bc ldi (ix+$77),bc
ldi_#ix_nn#_de ldi (ix+$77),de
ldi_#ix_nn#_hl ldi (ix+$77),hl
ldi_#iy_nn#_bc ldi (iy+$77),bc
ldi_#iy_nn#_de ldi (iy+$77),de
ldi_#iy_nn#_hl ldi (iy+$77),hl
ldi_a_#bc# ldi a,(bc)
ldi_a_#de# ldi a,(de)
ldi_a_#hl# ldi a,(hl)
ldi_b_#hl# ldi b,(hl)
ldi_c_#hl# ldi c,(hl)
ldi_d_#hl# ldi d,(hl)
ldi_e_#hl# ldi e,(hl)
ldi_h_#hl# ldi h,(hl)
ldi_l_#hl# ldi l,(hl)
ldi_a_#ix_nn# ldi a,(ix+$77)
ldi_b_#ix_nn# ldi b,(ix+$77)
ldi_c_#ix_nn# ldi c,(ix+$77)
ldi_d_#ix_nn# ldi d,(ix+$77)
ldi_e_#ix_nn# ldi e,(ix+$77)
ldi_h_#ix_nn# ldi h,(ix+$77)
ldi_l_#ix_nn# ldi l,(ix+$77)
ldi_a_#iy_nn# ldi a,(iy+$77)
ldi_b_#iy_nn# ldi b,(iy+$77)
ldi_c_#iy_nn# ldi c,(iy+$77)
ldi_d_#iy_nn# ldi d,(iy+$77)
ldi_e_#iy_nn# ldi e,(iy+$77)
ldi_h_#iy_nn# ldi h,(iy+$77)
ldi_l_#iy_nn# ldi l,(iy+$77)
ldd_a_#bc# ldd a,(bc)
ldd_a_#de# ldd a,(de)
ldd_a_#hl# ldd a,(hl)
ldd_b_#hl# ldd b,(hl)
ldd_c_#hl# ldd c,(hl)
ldd_d_#hl# ldd d,(hl)
ldd_e_#hl# ldd e,(hl)
ldd_h_#hl# ldd h,(hl)
ldd_l_#hl# ldd l,(hl)
ldd_a_#ix_nn# ldd a,(ix+$77)
ldd_b_#ix_nn# ldd b,(ix+$77)
ldd_c_#ix_nn# ldd c,(ix+$77)
ldd_d_#ix_nn# ldd d,(ix+$77)
ldd_e_#ix_nn# ldd e,(ix+$77)
ldd_h_#ix_nn# ldd h,(ix+$77)
ldd_l_#ix_nn# ldd l,(ix+$77)
ldd_a_#iy_nn# ldd a,(iy+$77)
ldd_b_#iy_nn# ldd b,(iy+$77)
ldd_c_#iy_nn# ldd c,(iy+$77)
ldd_d_#iy_nn# ldd d,(iy+$77)
ldd_e_#iy_nn# ldd e,(iy+$77)
ldd_h_#iy_nn# ldd h,(iy+$77)
ldd_l_#iy_nn# ldd l,(iy+$77)
ldi_#bc#_a ldi (bc),a
ldi_#de#_a ldi (de),a
ldi_#hl#_a ldi (hl),a
ldi_#hl#_b ldi (hl),b
ldi_#hl#_c ldi (hl),c
ldi_#hl#_d ldi (hl),d
ldi_#hl#_e ldi (hl),e
ldi_#hl#_h ldi (hl),h
ldi_#hl#_l ldi (hl),l
ldi_#ix_nn#_a ldi (ix+$77),a
ldi_#ix_nn#_b ldi (ix+$77),b
ldi_#ix_nn#_c ldi (ix+$77),c
ldi_#ix_nn#_d ldi (ix+$77),d
ldi_#ix_nn#_e ldi (ix+$77),e
ldi_#ix_nn#_h ldi (ix+$77),h
ldi_#ix_nn#_l ldi (ix+$77),l
ldi_#iy_nn#_a ldi (iy+$77),a
ldi_#iy_nn#_b ldi (iy+$77),b
ldi_#iy_nn#_c ldi (iy+$77),c
ldi_#iy_nn#_d ldi (iy+$77),d
ldi_#iy_nn#_e ldi (iy+$77),e
ldi_#iy_nn#_h ldi (iy+$77),h
ldi_#iy_nn#_l ldi (iy+$77),l
ldd_#bc#_a ldd (bc),a
ldd_#de#_a ldd (de),a
ldd_#hl#_a ldd (hl),a
ldd_#hl#_b ldd (hl),b
ldd_#hl#_c ldd (hl),c
ldd_#hl#_d ldd (hl),d
ldd_#hl#_e ldd (hl),e
ldd_#hl#_h ldd (hl),h
ldd_#hl#_l ldd (hl),l
ldd_#ix_nn#_a ldd (ix+$77),a
ldd_#ix_nn#_b ldd (ix+$77),b
ldd_#ix_nn#_c ldd (ix+$77),c
ldd_#ix_nn#_d ldd (ix+$77),d
ldd_#ix_nn#_e ldd (ix+$77),e
ldd_#ix_nn#_h ldd (ix+$77),h
ldd_#ix_nn#_l ldd (ix+$77),l
ldd_#iy_nn#_a ldd (iy+$77),a
ldd_#iy_nn#_b ldd (iy+$77),b
ldd_#iy_nn#_c ldd (iy+$77),c
ldd_#iy_nn#_d ldd (iy+$77),d
ldd_#iy_nn#_e ldd (iy+$77),e
ldd_#iy_nn#_h ldd (iy+$77),h
ldd_#iy_nn#_l ldd (iy+$77),l
ldi_#hl#_nn ldi (hl),$44
ldi_#ix_nn#_nn ldi (ix+$77),$44
ldi_#iy_nn#_nn ldi (iy+$77),$44
ldd_#hl#_nn ldd (hl),$44
ldd_#ix_nn#_nn ldd (ix+$77),$44
ldd_#iy_nn#_nn ldd (iy+$77),$44
adc_de_bc adc de,bc
adc_de_de adc de,de
adc_de_hl adc de,hl
adc_de_sp adc de,sp
add_de_bc add de,bc
add_de_de add de,de
add_de_hl add de,hl
add_de_sp add de,sp
sbc_de_bc sbc de,bc
sbc_de_de sbc de,de
sbc_de_hl sbc de,hl
sbc_de_sp sbc de,sp
sub_de_bc sub de,bc
sub_de_de sub de,de
sub_de_hl sub de,hl
sub_de_sp sub de,sp
sub_hl_bc sub hl,bc
sub_hl_de sub hl,de
sub_hl_hl sub hl,hl
sub_hl_sp sub hl,sp
; ZXNext section - there are no true regular fakes yet, but some specials
zxn_mul mul ; no warning "correct" syntax: "mul d,e" and "mul de"
; no message when in --zxnext=cspect mode
zxn_csp_break break ; CSpect emulator only: breakpoint instruction
zxn_csp_exit exit ; CSpect emulator only: exit instruction
OPT --zxnext ; do 2x error stating the requirement (using nops to advance labels)
zxn_csp_break2 break : nop
zxn_csp_exit2 exit : nop
; debug snapshot for Cspect
; DEVICE ZXSPECTRUM48 : CSPECTMAP : SAVESNA "all_fake.sna", 0x8000
|
;name: wordbcd2bin.asm
;
;description: wordbcd2bin: packed bcd word to binary conversion.
;
;use:
;packed bcd: mov rdi,packedbcd
; call wordbcd2bin
;
;build: nasm -felf64 wordbcd2bin.asm -o wordbcd2bin.o
bits 64
global wordbcd2bin
section .text
wordbcd2bin:
;convert packed bcd in AX to binary in EAX.
push rcx ;save used registers
push rdx
mov rax,rdi ;value in rax
and ax,0xFFFF ;only low word counts
ror eax,1 ;save bit 0
mov rcx,10 ;loop counter
.repeat:
mov dx,ax ;ax in temp register dx
add dx,0x3333 ;add 3 to each nibble
and dx,0x8888 ;keep bit 3 of each nibble
shr dx,2 ;divide result by 4
sub ax,dx ;subtract either 2 or 0 from each nibble in ax
shr dx,1 ;divide result by 2
sub ax,dx ;subtract either 1 or 0 from each nibble in ax
ror eax,1 ;save lowest nibble
loop .repeat ;repeat until number is converted
rol eax,11 ;result in 5 lowest nibbles
pop rdx ;restore used registers
pop rcx
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r9
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0xb969, %rsi
lea addresses_normal_ht+0x3e7, %rdi
nop
nop
nop
nop
cmp $47772, %r12
mov $123, %rcx
rep movsl
nop
nop
nop
nop
nop
add %rdx, %rdx
lea addresses_D_ht+0x15827, %r12
nop
nop
nop
sub %r15, %r15
movups (%r12), %xmm3
vpextrq $1, %xmm3, %rsi
nop
nop
sub %rsi, %rsi
lea addresses_UC_ht+0x11087, %rsi
lea addresses_UC_ht+0x1a90f, %rdi
nop
nop
nop
inc %r9
mov $47, %rcx
rep movsb
nop
nop
nop
nop
nop
xor %r12, %r12
lea addresses_WT_ht+0xeee7, %rdx
nop
nop
nop
nop
and $37160, %rcx
mov (%rdx), %esi
nop
nop
cmp %rdx, %rdx
lea addresses_normal_ht+0xf8e7, %rcx
nop
nop
nop
nop
nop
cmp %rsi, %rsi
movw $0x6162, (%rcx)
nop
nop
nop
nop
and %rcx, %rcx
lea addresses_A_ht+0xd3e7, %rsi
lea addresses_A_ht+0x181e7, %rdi
cmp %rbx, %rbx
mov $85, %rcx
rep movsq
nop
nop
nop
xor %r9, %r9
lea addresses_D_ht+0xb7e3, %rcx
nop
nop
nop
add %rbx, %rbx
mov $0x6162636465666768, %rdx
movq %rdx, (%rcx)
nop
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %rbx
push %rcx
push %rdi
push %rdx
// Load
lea addresses_US+0xa367, %rcx
nop
nop
nop
nop
xor $13874, %rdi
mov (%rcx), %edx
nop
cmp %rcx, %rcx
// Store
lea addresses_UC+0x1a7e7, %rbx
xor %r14, %r14
movl $0x51525354, (%rbx)
cmp %r10, %r10
// Load
lea addresses_A+0x9959, %rdi
nop
and %r12, %r12
movb (%rdi), %r14b
nop
nop
nop
add $4209, %rdx
// Store
lea addresses_WT+0xbce7, %rbx
nop
nop
nop
nop
add $64900, %r10
movl $0x51525354, (%rbx)
nop
xor %r10, %r10
// Load
lea addresses_UC+0x9f1f, %r12
clflush (%r12)
nop
nop
nop
nop
sub %rcx, %rcx
movb (%r12), %bl
nop
cmp %r14, %r14
// Store
lea addresses_UC+0x1441, %rdi
add $42579, %r10
movb $0x51, (%rdi)
and $28641, %r10
// Store
lea addresses_UC+0xeb67, %r14
dec %rdx
movw $0x5152, (%r14)
xor $35965, %r14
// Store
mov $0xaa1, %r10
clflush (%r10)
nop
add $27101, %rdi
mov $0x5152535455565758, %r12
movq %r12, %xmm2
movups %xmm2, (%r10)
nop
xor %r12, %r12
// Faulty Load
lea addresses_D+0x157e7, %rdx
nop
and $25748, %rbx
mov (%rdx), %rdi
lea oracles, %rbx
and $0xff, %rdi
shlq $12, %rdi
mov (%rbx,%rdi,1), %rdi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_D', 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_US', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC', 'congruent': 11}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A', 'congruent': 1}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT', 'congruent': 0}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC', 'congruent': 3}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC', 'congruent': 1}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 6}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_P', 'congruent': 0}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 5}}
{'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 0}, 'OP': 'STOR'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
#ifndef MALANG_VM_RUNTIME_STRING_HPP
#define MALANG_VM_RUNTIME_STRING_HPP
#include "primitive_types.hpp"
struct Type_Map;
struct Bound_Function_Map;
struct Malang_Buffer;
struct Malang_Object_Body;
namespace Malang_Runtime
{
void runtime_string_init(Bound_Function_Map&, Type_Map&);
void string_construct_intern(Malang_Object *place, const String_Constant &string_constant);
void string_construct_intern(Malang_Object *place, Fixnum size, char *buffer);
void string_construct_move_buf(Malang_Object *place, Malang_Buffer *move);
void string_alloc_push(Malang_VM &vm, const String_Constant &string);
char *string_alloc_c_str(Malang_Object_Body *str);
Fixnum string_length(Malang_Object_Body *str);
Char *string_data(Malang_Object_Body *str);
}
#endif /* MALANG_VM_RUNTIME_STRING_HPP */
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xbe25, %rsi
lea addresses_D_ht+0xce42, %rdi
nop
nop
nop
nop
nop
and $44255, %r8
mov $1, %rcx
rep movsb
inc %r13
lea addresses_D_ht+0x3342, %r10
nop
cmp $195, %r12
movl $0x61626364, (%r10)
nop
nop
add %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %r8
push %rax
push %rbx
// Faulty Load
mov $0xb42, %r12
nop
nop
nop
nop
cmp %r10, %r10
movups (%r12), %xmm0
vpextrq $1, %xmm0, %r15
lea oracles, %rbx
and $0xff, %r15
shlq $12, %r15
mov (%rbx,%r15,1), %r15
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 10, 'same': False}}
{'00': 82}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "intel_gpu/plugin/program.hpp"
#include "transformations/utils/utils.hpp"
#include "ngraph/op/tanh.hpp"
#include "ngraph/op/elu.hpp"
#include "ngraph/op/sigmoid.hpp"
#include "ngraph/op/relu.hpp"
#include "ngraph/op/prelu.hpp"
#include "ngraph/op/clamp.hpp"
#include "ngraph/op/exp.hpp"
#include "ngraph/op/not.hpp"
#include "ngraph/op/asin.hpp"
#include "ngraph/op/asinh.hpp"
#include "ngraph/op/acos.hpp"
#include "ngraph/op/acosh.hpp"
#include "ngraph/op/atan.hpp"
#include "ngraph/op/atanh.hpp"
#include "ngraph/op/abs.hpp"
#include "ngraph/op/floor.hpp"
#include "ngraph/op/ceiling.hpp"
#include "ngraph/op/erf.hpp"
#include "ngraph/op/hard_sigmoid.hpp"
#include "ngraph/op/log.hpp"
#include "ngraph/op/negative.hpp"
#include "ngraph/op/selu.hpp"
#include "ngraph/op/softplus.hpp"
#include "ngraph/op/tan.hpp"
#include "ngraph/op/sin.hpp"
#include "ngraph/op/sinh.hpp"
#include "ngraph/op/cos.hpp"
#include "ngraph/op/cosh.hpp"
#include "ngraph/op/swish.hpp"
#include "ngraph/op/hswish.hpp"
#include "ngraph/op/mish.hpp"
#include "ngraph/op/gelu.hpp"
#include "ngraph/op/sign.hpp"
#include "ngraph/op/hsigmoid.hpp"
#include "ngraph/op/round.hpp"
#include "intel_gpu/primitives/activation.hpp"
namespace ov {
namespace runtime {
namespace intel_gpu {
void CreateUnaryEltwiseOp(Program& p, const std::shared_ptr<ngraph::Node>& op,
cldnn::activation_func func, cldnn::activation_additional_params params) {
auto inputs = p.GetInputPrimitiveIDs(op);
std::string layerName = layer_type_name_ID(op);
auto activationPrimitive = cldnn::activation(layerName, inputs[0], func, params, op->get_friendly_name());
p.AddPrimitive(activationPrimitive);
p.AddPrimitiveToProfiler(op);
}
static void CreateTanhOp(Program& p, const std::shared_ptr<ngraph::op::v0::Tanh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::hyperbolic_tan, {});
}
static void CreateEluOp(Program& p, const std::shared_ptr<ngraph::op::v0::Elu>& op) {
auto alpha = static_cast<float>(op->get_alpha());
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::elu, {alpha});
}
static void CreateSigmoidOp(Program& p, const std::shared_ptr<ngraph::op::v0::Sigmoid>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::logistic, {});
}
static void CreateReluOp(Program& p, const std::shared_ptr<ngraph::op::v0::Relu>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::relu, {});
}
static void CreatePReluOp(Program& p, const std::shared_ptr<ngraph::op::v0::PRelu>& op) {
p.ValidateInputs(op, {2});
auto slope_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(1));
auto slope_shape = op->get_input_shape(1);
auto out_shape = op->get_output_shape(0);
if (slope_node && ngraph::shape_size(slope_shape) == 1) {
float slope;
if (!ngraph::op::util::get_single_value(slope_node, slope))
IE_THROW() << "Unsupported parameter size in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::relu_negative_slope, {slope});
} else if (out_shape.size() >= 2 && ngraph::shape_size(slope_shape) == out_shape[1]) {
auto inputs = p.GetInputPrimitiveIDs(op);
std::string layerName = layer_type_name_ID(op);
auto activationPrimitive = cldnn::activation(layerName,
inputs[0],
inputs[1],
cldnn::activation_func::relu_negative_slope,
op->get_friendly_name());
p.AddPrimitive(activationPrimitive);
p.AddPrimitiveToProfiler(op);
}
}
static void CreateClampOp(Program& p, const std::shared_ptr<ngraph::op::v0::Clamp>& op) {
float min = static_cast<float>(op->get_min());
float max = static_cast<float>(op->get_max());
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::clamp, {min, max});
}
static void CreateExpOp(Program& p, const std::shared_ptr<ngraph::op::v0::Exp>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::exp, {});
}
static void CreateLogicalNotOp(Program& p, const std::shared_ptr<ngraph::op::v1::LogicalNot>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::negation, {});
}
static void CreateAsinOp(Program& p, const std::shared_ptr<ngraph::op::v0::Asin>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::asin, {});
}
static void CreateAsinhOp(Program& p, const std::shared_ptr<ngraph::op::v3::Asinh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::asinh, {});
}
static void CreateAcosOp(Program& p, const std::shared_ptr<ngraph::op::v0::Acos>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::acos, {});
}
static void CreateAcoshOp(Program& p, const std::shared_ptr<ngraph::op::v3::Acosh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::acosh, {});
}
static void CreateAtanOp(Program& p, const std::shared_ptr<ngraph::op::v0::Atan>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::atan, {});
}
static void CreateAtanhOp(Program& p, const std::shared_ptr<ngraph::op::v3::Atanh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::atanh, {});
}
static void CreateAbsOp(Program& p, const std::shared_ptr<ngraph::op::v0::Abs>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::abs, {});
}
static void CreateFloorOp(Program& p, const std::shared_ptr<ngraph::op::v0::Floor>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::floor, {});
}
static void CreateCeilingOp(Program& p, const std::shared_ptr<ngraph::op::v0::Ceiling>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::ceil, {});
}
static void CreateSqrtOp(Program& p, const std::shared_ptr<ngraph::op::v0::Sqrt>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::sqrt, {});
}
static void CreateErfOp(Program& p, const std::shared_ptr<ngraph::op::v0::Erf>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::erf, {});
}
static void CreateHardSigmoidOp(Program& p, const std::shared_ptr<ngraph::op::v0::HardSigmoid>& op) {
p.ValidateInputs(op, {3});
auto alpha_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(1));
auto beta_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(2));
if (!alpha_node || !beta_node) {
IE_THROW() << "Unsupported parameter nodes type in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
if (ngraph::shape_size(alpha_node->get_output_shape(0)) == 1 &&
ngraph::shape_size(beta_node->get_output_shape(0)) == 1) {
float alpha, beta;
if (!ngraph::op::util::get_single_value(alpha_node, alpha) || !ngraph::op::util::get_single_value(beta_node, beta)) {
IE_THROW() << "Unsupported parameter size in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::hard_sigmoid, {alpha, beta});
}
}
static void CreateLogOp(Program& p, const std::shared_ptr<ngraph::op::v0::Log>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::log, {});
}
static void CreateNegativeOp(Program& p, const std::shared_ptr<ngraph::op::v0::Negative>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::negative, {});
}
static void CreateSeluOp(Program& p, const std::shared_ptr<ngraph::op::v0::Selu>& op) {
p.ValidateInputs(op, {3});
auto alpha_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(1));
auto lambda_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(2));
if (!alpha_node || !lambda_node) {
IE_THROW() << "Unsupported parameter nodes type in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
if (ngraph::shape_size(alpha_node->get_output_shape(0)) == 1 &&
ngraph::shape_size(lambda_node->get_output_shape(0)) == 1) {
float alpha, lambda;
if (!ngraph::op::util::get_single_value(alpha_node, alpha) || !ngraph::op::util::get_single_value(lambda_node, lambda)) {
IE_THROW() << "Unsupported parameter size in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::selu, {alpha, lambda});
} else {
IE_THROW() << "Unsupported shapes of parameter nodes in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
}
static void CreateSoftPlusOp(Program& p, const std::shared_ptr<ngraph::op::v4::SoftPlus>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::softplus, {});
}
static void CreateTanOp(Program& p, const std::shared_ptr<ngraph::op::v0::Tan>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::tan, {});
}
static void CreateSinOp(Program& p, const std::shared_ptr<ngraph::op::v0::Sin>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::sin, {});
}
static void CreateSinhOp(Program& p, const std::shared_ptr<ngraph::op::v0::Sinh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::sinh, {});
}
static void CreateCosOp(Program& p, const std::shared_ptr<ngraph::op::v0::Cos>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::cos, {});
}
static void CreateCoshOp(Program& p, const std::shared_ptr<ngraph::op::v0::Cosh>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::cosh, {});
}
static void CreateSwishOp(Program& p, const std::shared_ptr<ngraph::op::v4::Swish>& op) {
p.ValidateInputs(op, {1, 2});
if (op->get_input_size() == 2) {
auto beta_node = std::dynamic_pointer_cast<ngraph::op::v0::Constant>(op->get_input_node_shared_ptr(1));
if (beta_node) {
if (ngraph::shape_size(beta_node->get_output_shape(0)) == 1) {
float beta;
if (!ngraph::op::util::get_single_value(beta_node, beta)) {
IE_THROW() << "Unsupported parameter size in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::swish, {beta});
} else {
IE_THROW() << "Unsupported parameter size in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
} else {
IE_THROW() << "Unsupported parameter type in " << op->get_friendly_name() << " (" << op->get_type_name() << ")";
}
} else {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::swish, {1.0f});
}
}
static void CreateHSwishOp(Program& p, const std::shared_ptr<ngraph::op::v4::HSwish>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::hswish, {});
}
static void CreateMishOp(Program& p, const std::shared_ptr<ngraph::op::v4::Mish>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::mish, {});
}
static void CreateGeluOp(Program& p, const std::shared_ptr<ngraph::op::v0::Gelu>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::gelu, {});
}
static void CreateSignOp(Program& p, const std::shared_ptr<ngraph::op::v0::Sign>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::sign, {});
}
static void CreateHSigmoidOp(Program& p, const std::shared_ptr<ngraph::op::v5::HSigmoid>& op) {
CreateUnaryEltwiseOp(p, op, cldnn::activation_func::hsigmoid, {});
}
static void CreateRoundOp(Program& p, const std::shared_ptr<ngraph::op::v5::Round>& op) {
auto func = cldnn::activation_func::none;
switch (op->get_mode()) {
case ngraph::op::v5::Round::RoundMode::HALF_TO_EVEN : func = cldnn::activation_func::round_half_to_even; break;
case ngraph::op::v5::Round::RoundMode::HALF_AWAY_FROM_ZERO : func = cldnn::activation_func::round_half_away_from_zero; break;
default: IE_THROW() << "Unsupported round mode in " << op->get_friendly_name() << ": " << static_cast<int>(op->get_mode());
}
CreateUnaryEltwiseOp(p, op, func, {});
}
REGISTER_FACTORY_IMPL(v0, Tanh);
REGISTER_FACTORY_IMPL(v0, Elu);
REGISTER_FACTORY_IMPL(v0, Sigmoid);
REGISTER_FACTORY_IMPL(v0, Relu);
REGISTER_FACTORY_IMPL(v0, PRelu);
REGISTER_FACTORY_IMPL(v0, Clamp);
REGISTER_FACTORY_IMPL(v0, Exp);
REGISTER_FACTORY_IMPL(v1, LogicalNot);
REGISTER_FACTORY_IMPL(v0, Asin);
REGISTER_FACTORY_IMPL(v3, Asinh);
REGISTER_FACTORY_IMPL(v0, Acos);
REGISTER_FACTORY_IMPL(v3, Acosh);
REGISTER_FACTORY_IMPL(v0, Atan);
REGISTER_FACTORY_IMPL(v3, Atanh);
REGISTER_FACTORY_IMPL(v0, Abs);
REGISTER_FACTORY_IMPL(v0, Floor);
REGISTER_FACTORY_IMPL(v0, Ceiling);
REGISTER_FACTORY_IMPL(v0, Sqrt);
REGISTER_FACTORY_IMPL(v0, Erf);
REGISTER_FACTORY_IMPL(v0, HardSigmoid);
REGISTER_FACTORY_IMPL(v0, Log);
REGISTER_FACTORY_IMPL(v0, Negative);
REGISTER_FACTORY_IMPL(v0, Selu);
REGISTER_FACTORY_IMPL(v4, SoftPlus);
REGISTER_FACTORY_IMPL(v0, Tan);
REGISTER_FACTORY_IMPL(v0, Sin);
REGISTER_FACTORY_IMPL(v0, Sinh);
REGISTER_FACTORY_IMPL(v0, Cos);
REGISTER_FACTORY_IMPL(v0, Cosh);
REGISTER_FACTORY_IMPL(v4, Swish);
REGISTER_FACTORY_IMPL(v4, HSwish);
REGISTER_FACTORY_IMPL(v4, Mish);
REGISTER_FACTORY_IMPL(v0, Gelu);
REGISTER_FACTORY_IMPL(v0, Sign);
REGISTER_FACTORY_IMPL(v5, HSigmoid);
REGISTER_FACTORY_IMPL(v5, Round);
} // namespace intel_gpu
} // namespace runtime
} // namespace ov
|
; A196289: n^9 - n.
; 0,0,510,19680,262140,1953120,10077690,40353600,134217720,387420480,999999990,2357947680,5159780340,10604499360,20661046770,38443359360,68719476720,118587876480,198359290350,322687697760,511999999980,794280046560,1207269217770,1801152661440,2641807540200,3814697265600,5429503678950,7625597484960,10578455953380,14507145975840,19682999999970,26439622160640,35184372088800,46411484401920,60716992766430,78815638671840,101559956668380,129961739795040,165216101262810,208728361158720,262143999999960,327381934393920,406671383849430,502592611936800,618121839509460,756680642578080,922190162669010,1119130473102720,1352605460594640,1628413597910400,1953124999999950,2334165173090400,2779905883635660,3299763591802080,3904305912313290,4605366583984320,5416169448144840,6351461955384000,7427658739644870,8662995818654880,10077695999999940,11694146092834080,13537086546263490,15633814156853760,18014398509481920,20711912837890560,23762680013799870,27206534396294880,31087100296429500,35452087835576160,40353606999999930,45848500718448960,51998697814228920,58871586708267840,66540410775079350,75084686279296800,84590643846578100,95151694449171360,106868920913284530,119851595982618240,134217727999999920,150094635296999040,167619550409707950,186940255267540320,208215748530929580,231616946283203040,257327417311663530,285544154243029440,316478381828865960,350356403707485120,387420488999999910,427929800129788320,472161363286556580,520411082988487200,572994802228616610,630249409724609280,692533995824480160,760231058654565120,833747762130149790,913517247483640800
mov $1,$0
pow $0,9
sub $0,$1
|
; uint in_KeyPressed(uint scancode)
SECTION code_clib
PUBLIC in_KeyPressed
PUBLIC _in_KeyPressed
; Determines if a key is pressed using the scan code
; returned by in_LookupKey.
; enter : l = scan row
; h = key mask
; exit : carry = key is pressed & HL = 1
; no carry = key not pressed & HL = 0
; used : AF,BC,HL
.in_KeyPressed
._in_KeyPressed
ld a, 8 + 1 ;Read modifier row
out (0xf4),a
ld c,@00000101
in a,(0xf4)
bit 7,l
jr z,nocaps
bit 2,a
jr z,fail
res 2,c
.nocaps
bit 6,l
jr z,nofunc
bit 0,a
jr z,fail
res 0,c
.nofunc
and c
jr nz,fail
ld a,l
and 15
inc a
out (0xf4),a
in a,(0xf4)
and h ;Check with mask
jr z,fail
ld hl,1
scf
ret
fail:
ld hl,0
and a
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r15
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x12b17, %rsi
lea addresses_WC_ht+0x6797, %rdi
nop
nop
nop
nop
sub %r15, %r15
mov $74, %rcx
rep movsw
nop
nop
nop
nop
nop
sub $53833, %r11
lea addresses_normal_ht+0x17ca3, %rsi
lea addresses_normal_ht+0x9f17, %rdi
nop
nop
nop
nop
add %r15, %r15
mov $11, %rcx
rep movsw
nop
nop
nop
nop
nop
xor %rdi, %rdi
lea addresses_WT_ht+0xdf53, %r11
clflush (%r11)
nop
nop
nop
nop
dec %r13
mov $0x6162636465666768, %rsi
movq %rsi, (%r11)
nop
sub $60818, %rdi
lea addresses_normal_ht+0x13467, %r15
sub %rdi, %rdi
movl $0x61626364, (%r15)
nop
nop
nop
nop
nop
cmp $37825, %rsi
lea addresses_D_ht+0x12557, %r11
nop
nop
nop
cmp %rcx, %rcx
movb $0x61, (%r11)
nop
nop
nop
nop
nop
and $11641, %rsi
lea addresses_D_ht+0xd797, %r11
nop
nop
cmp %rax, %rax
mov $0x6162636465666768, %rdi
movq %rdi, %xmm2
vmovups %ymm2, (%r11)
inc %rax
lea addresses_WT_ht+0x11e61, %rcx
nop
nop
nop
nop
inc %r11
movl $0x61626364, (%rcx)
nop
nop
nop
nop
nop
xor $31998, %r15
lea addresses_WT_ht+0x1af97, %rsi
lea addresses_normal_ht+0xd617, %rdi
add $11468, %r15
mov $22, %rcx
rep movsw
nop
xor $52226, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rbx
push %rdi
push %rsi
// Store
lea addresses_UC+0x3617, %r15
nop
nop
nop
nop
xor %r13, %r13
mov $0x5152535455565758, %rsi
movq %rsi, %xmm7
movups %xmm7, (%r15)
// Exception!!!
nop
nop
nop
nop
mov (0), %r13
nop
nop
nop
xor $22169, %rbx
// Faulty Load
lea addresses_WT+0xce17, %r8
clflush (%r8)
nop
nop
add $33985, %r15
mov (%r8), %di
lea oracles, %r8
and $0xff, %rdi
shlq $12, %rdi
mov (%r8,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rbx
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}}
{'39': 480}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
SECTION code_fcntl
PUBLIC zx_01_output_char_32_tty_z88dk_31_down
EXTERN console_01_output_char_proc_move_down
zx_01_output_char_32_tty_z88dk_31_down:
; move cursor down
ld d,(ix+15) ; d = y coord
ld b,(ix+19) ; b = window.height
call console_01_output_char_proc_move_down
ld (ix+15),d ; store y coord
ret
|
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Wuwei Lin
*/
#include <gtest/gtest.h>
#include <shogun/base/some.h>
#include <shogun/distance/MahalanobisDistance.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/lib/common.h>
using namespace shogun;
TEST(MahalanobisDistance, compute_distance)
{
// create four points (0,0) (2,10) (2,8) (5,5)
SGMatrix<float64_t> rect(2, 4);
rect(0, 0) = 0;
rect(1, 0) = 0;
rect(0, 1) = 2;
rect(1, 1) = 10;
rect(0, 2) = 2;
rect(1, 2) = 8;
rect(0, 3) = 5;
rect(1, 3) = 5;
auto feature = some<CDenseFeatures<float64_t>>(rect);
auto distance = some<CMahalanobisDistance>(feature, feature);
EXPECT_NEAR(distance->distance(1, 1), 0.0, 1e-10);
EXPECT_NEAR(distance->distance(1, 3), 2.63447126986, 1e-10);
EXPECT_NEAR(distance->distance(2, 3), 2.22834405812, 1e-10);
}
|
ROUTE39FARMHOUSE_MILK_PRICE EQU 500
object_const_def ; object_event constants
const ROUTE39FARMHOUSE_POKEFAN_M
const ROUTE39FARMHOUSE_POKEFAN_F
Route39Farmhouse_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
PokefanM_DairyFarmer:
faceplayer
opentext
checkevent EVENT_HEALED_MOOMOO
iftrue FarmerMScript_SellMilk
writetext FarmerMText_SickCow
waitbutton
closetext
setevent EVENT_TALKED_TO_FARMER_ABOUT_MOOMOO
end
FarmerMScript_SellMilk:
checkitem MOOMOO_MILK
iftrue FarmerMScript_Milking
writetext FarmerMText_BuyMilk
special PlaceMoneyTopRight
yesorno
iffalse FarmerMScript_NoSale
checkmoney YOUR_MONEY, ROUTE39FARMHOUSE_MILK_PRICE
ifequal HAVE_LESS, FarmerMScript_NoMoney
giveitem MOOMOO_MILK
iffalse FarmerMScript_NoRoom
takemoney YOUR_MONEY, ROUTE39FARMHOUSE_MILK_PRICE
special PlaceMoneyTopRight
waitsfx
playsound SFX_TRANSACTION
writetext FarmerMText_GotMilk
buttonsound
itemnotify
closetext
end
FarmerMScript_NoMoney:
writetext FarmerMText_NoMoney
waitbutton
closetext
end
FarmerMScript_NoRoom:
writetext FarmerMText_NoRoom
waitbutton
closetext
end
FarmerMScript_NoSale:
writetext FarmerMText_NoSale
waitbutton
closetext
end
FarmerMScript_Milking:
writetext FarmerMText_Milking
waitbutton
closetext
end
PokefanF_SnoreFarmer:
faceplayer
opentext
checkevent EVENT_GOT_TM13_SNORE_FROM_MOOMOO_FARM
iftrue FarmerFScript_GotSnore
checkevent EVENT_HEALED_MOOMOO
iftrue FarmerFScript_GiveSnore
writetext FarmerFText_InTrouble
waitbutton
closetext
end
FarmerFScript_GiveSnore:
writetext FarmerFText_HealedMiltank
buttonsound
verbosegiveitem TM_SNORE
iffalse FarmerFScript_NoRoomForSnore
setevent EVENT_GOT_TM13_SNORE_FROM_MOOMOO_FARM
FarmerFScript_GotSnore:
writetext FarmerFText_SnoreSpeech
waitbutton
FarmerFScript_NoRoomForSnore:
closetext
end
FarmhouseBookshelf:
jumpstd picturebookshelf
FarmerMText_SickCow:
text "My MILTANK ain't"
line "givin' me milk"
cont "n'more."
para "This here FARM's"
line "got famous milk."
para "Most everyone"
line "wants a drink."
para "It'll give me lots"
line "o' milk if'n I"
para "feed it lots o'"
line "BERRIES, I reckon."
done
FarmerMText_BuyMilk:
text "How'd you like my"
line "MOOMOO MILK?"
para "It's my pride and"
line "joy, there."
para "Give it to #MON"
line "to restore HP!"
para "I'll give it to ya"
line "fer just ¥500."
done
FarmerMText_GotMilk:
text "Here ya go!"
line "Drink up'n enjoy!"
done
FarmerMText_NoMoney:
text "Sorry, there."
line "No cash, no sale!"
done
FarmerMText_NoRoom:
text "I reckon yer"
line "PACK's full."
done
FarmerMText_NoSale:
text "You don't want it?"
line "Come again, hear?"
done
FarmerMText_Milking:
text "I best go do my"
line "milkin'."
done
FarmerFText_InTrouble:
text "Our milk even goes"
line "out to KANTO."
para "So if our own"
line "MILTANK won't give"
para "us any milk, we're"
line "in trouble."
done
FarmerFText_HealedMiltank:
text "You fixed our"
line "MILTANK, hon. Now"
para "it gives MOOMOO"
line "MILK again."
para "Here's somethin'"
line "fer your trouble."
done
Text_ReceivedTM13:
text "<PLAYER> received"
line "TM13 SNORE."
done
FarmerFText_SnoreSpeech:
text "That there's"
line "SNORE."
para "It's a rare move"
line "that only works"
para "while the #MON"
line "is asleep."
para "You best think how"
line "you ought to use"
cont "it, hon."
done
Route39Farmhouse_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 2, 7, ROUTE_39, 2
warp_event 3, 7, ROUTE_39, 2
db 0 ; coord events
db 2 ; bg events
bg_event 0, 1, BGEVENT_READ, FarmhouseBookshelf
bg_event 1, 1, BGEVENT_READ, FarmhouseBookshelf
db 2 ; object events
object_event 3, 2, SPRITE_POKEFAN_M, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, PokefanM_DairyFarmer, -1
object_event 5, 4, SPRITE_POKEFAN_F, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_BROWN, OBJECTTYPE_SCRIPT, 0, PokefanF_SnoreFarmer, -1
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (C) 2022 Intel Corporation
;
; SPDX-License-Identifier: MIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include "reg_sizes.asm"
%include "lz0a_const.asm"
%include "data_struct2.asm"
%include "igzip_compare_types.asm"
%define NEQ 4
default rel
%ifidn __OUTPUT_FORMAT__, win64
%define arg1 rcx
%define arg2 rdx
%define arg3 r8
%define arg4 r9
%define len rdi
%define tmp2 rdi
%define dist rsi
%else
%define arg1 rdi
%define arg2 rsi
%define arg3 rdx
%define arg4 rcx
%define len r8
%define tmp2 r8
%define dist r9
%endif
%define next_in arg1
%define end_processed arg2
%define end_in arg3
%define match_lookup arg4
%define match_in rax
%define match_offset r10
%define tmp1 r11
%define end_processed_orig r12
%define dist_code r13
%define tmp3 r13
%define ymatch_lookup ymm0
%define ymatch_lookup2 ymm1
%define ylens ymm2
%define ycmp2 ymm3
%define ylens1 ymm4
%define ylens2 ymm5
%define ycmp ymm6
%define ytmp1 ymm7
%define ytmp2 ymm8
%define yvect_size ymm9
%define ymax_len ymm10
%define ytwofiftysix ymm11
%define ynlen_mask ymm12
%define ydists_mask ymm13
%define ylong_lens ymm14
%define ylens_mask ymm15
%ifidn __OUTPUT_FORMAT__, win64
%define stack_size 10*16 + 4 * 8 + 8
%define func(x) proc_frame x
%macro FUNC_SAVE 0
alloc_stack stack_size
vmovdqa [rsp + 0*16], xmm6
vmovdqa [rsp + 1*16], xmm7
vmovdqa [rsp + 2*16], xmm8
vmovdqa [rsp + 3*16], xmm9
vmovdqa [rsp + 4*16], xmm10
vmovdqa [rsp + 5*16], xmm11
vmovdqa [rsp + 6*16], xmm12
vmovdqa [rsp + 7*16], xmm13
vmovdqa [rsp + 8*16], xmm14
vmovdqa [rsp + 9*16], xmm15
save_reg rsi, 10*16 + 0*8
save_reg rdi, 10*16 + 1*8
save_reg r12, 10*16 + 2*8
save_reg r13, 10*16 + 3*8
end_prolog
%endm
%macro FUNC_RESTORE 0
vmovdqa xmm6, [rsp + 0*16]
vmovdqa xmm7, [rsp + 1*16]
vmovdqa xmm8, [rsp + 2*16]
vmovdqa xmm9, [rsp + 3*16]
vmovdqa xmm10, [rsp + 4*16]
vmovdqa xmm11, [rsp + 5*16]
vmovdqa xmm12, [rsp + 6*16]
vmovdqa xmm13, [rsp + 7*16]
vmovdqa xmm14, [rsp + 8*16]
vmovdqa xmm15, [rsp + 9*16]
mov rsi, [rsp + 10*16 + 0*8]
mov rdi, [rsp + 10*16 + 1*8]
mov r12, [rsp + 10*16 + 2*8]
mov r13, [rsp + 10*16 + 3*8]
add rsp, stack_size
%endm
%else
%define func(x) x: endbranch
%macro FUNC_SAVE 0
push r12
push r13
%endm
%macro FUNC_RESTORE 0
pop r13
pop r12
%endm
%endif
%define VECT_SIZE 8
[bits 64]
default rel
section .text
global set_long_icf_fg_04
func(set_long_icf_fg_04)
endbranch
FUNC_SAVE
lea end_in, [next_in + arg3]
add end_processed, next_in
mov end_processed_orig, end_processed
lea tmp1, [end_processed + LA_STATELESS]
cmp end_in, tmp1
cmovg end_in, tmp1
sub end_processed, VECT_SIZE - 1
vmovdqu ylong_lens, [long_len]
vmovdqu ylens_mask, [len_mask]
vmovdqu ydists_mask, [dists_mask]
vmovdqu ynlen_mask, [nlen_mask]
vmovdqu yvect_size, [vect_size]
vmovdqu ymax_len, [max_len]
vmovdqu ytwofiftysix, [twofiftysix]
vmovdqu ymatch_lookup, [match_lookup]
.fill_loop: ; Tahiti is a magical place
vmovdqu ymatch_lookup2, ymatch_lookup
vmovdqu ymatch_lookup, [match_lookup + ICF_CODE_BYTES * VECT_SIZE]
cmp next_in, end_processed
jae .end_fill
.finish_entry:
vpand ylens, ymatch_lookup2, ylens_mask
vpcmpgtd ycmp, ylens, ylong_lens
vpmovmskb tmp1, ycmp
;; Speculatively increment
add next_in, VECT_SIZE
add match_lookup, ICF_CODE_BYTES * VECT_SIZE
test tmp1, tmp1
jz .fill_loop
tzcnt match_offset, tmp1
shr match_offset, 2
lea next_in, [next_in + match_offset - VECT_SIZE]
lea match_lookup, [match_lookup + ICF_CODE_BYTES * (match_offset - VECT_SIZE)]
mov dist %+ d, [match_lookup]
vmovd ymatch_lookup2 %+ x, dist %+ d
mov tmp1, dist
shr dist, DIST_OFFSET
and dist, LIT_DIST_MASK
shr tmp1, EXTRA_BITS_OFFSET
lea tmp2, [dist_start]
mov dist %+ w, [tmp2 + 2 * dist]
add dist, tmp1
mov match_in, next_in
sub match_in, dist
mov len, 8
mov tmp3, end_in
sub tmp3, next_in
compare_y next_in, match_in, len, tmp3, tmp1, ytmp1, ytmp2
vmovd ylens1 %+ x, len %+ d
vpbroadcastd ylens1, ylens1 %+ x
vpsubd ylens1, ylens1, [increment]
vpaddd ylens1, ylens1, [twofiftyfour]
mov tmp3, end_processed
sub tmp3, next_in
cmp len, tmp3
cmovg len, tmp3
add next_in, len
lea match_lookup, [match_lookup + ICF_CODE_BYTES * len]
vmovdqu ymatch_lookup, [match_lookup]
vpbroadcastd ymatch_lookup2, ymatch_lookup2 %+ x
vpand ymatch_lookup2, ymatch_lookup2, ynlen_mask
neg len
.update_match_lookup:
vpand ylens2, ylens_mask, [match_lookup + ICF_CODE_BYTES * len]
vpcmpgtd ycmp, ylens1, ylens2
vpcmpgtd ytmp1, ylens1, ytwofiftysix
vpand ycmp, ycmp, ytmp1
vpmovmskb tmp1, ycmp
vpcmpgtd ycmp2, ylens1, ymax_len
vpandn ylens, ycmp2, ylens1
vpand ycmp2, ymax_len, ycmp2
vpor ylens, ycmp2
vpaddd ylens2, ylens, ymatch_lookup2
vpand ylens2, ylens2, ycmp
vpmaskmovd [match_lookup + ICF_CODE_BYTES * len], ycmp, ylens2
test tmp1 %+ d, tmp1 %+ d
jz .fill_loop
add len, VECT_SIZE
vpsubd ylens1, ylens1, yvect_size
jmp .update_match_lookup
.end_fill:
mov end_processed, end_processed_orig
cmp next_in, end_processed
jge .finish
mov tmp1, end_processed
sub tmp1, next_in
vmovd ytmp1 %+ x, tmp1 %+ d
vpbroadcastd ytmp1, ytmp1 %+ x
vpcmpgtd ytmp1, ytmp1, [increment]
vpand ymatch_lookup2, ymatch_lookup2, ytmp1
jmp .finish_entry
.finish:
FUNC_RESTORE
ret
endproc_frame
section .data
align 64
dist_start:
dw 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0007, 0x0009, 0x000d
dw 0x0011, 0x0019, 0x0021, 0x0031, 0x0041, 0x0061, 0x0081, 0x00c1
dw 0x0101, 0x0181, 0x0201, 0x0301, 0x0401, 0x0601, 0x0801, 0x0c01
dw 0x1001, 0x1801, 0x2001, 0x3001, 0x4001, 0x6001, 0x0000, 0x0000
len_mask:
dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK
dd LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK, LIT_LEN_MASK
dists_mask:
dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK
dd LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK, LIT_DIST_MASK
long_len:
dd 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105, 0x105
increment:
dd 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
vect_size:
dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE
dd VECT_SIZE, VECT_SIZE, VECT_SIZE, VECT_SIZE
twofiftyfour:
dd 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe
twofiftysix:
dd 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100
nlen_mask:
dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00
dd 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00
max_len:
dd 0xfe + 0x102, 0xfe + 0x102, 0xfe + 0x102, 0xfe + 0x102
dd 0xfe + 0x102, 0xfe + 0x102, 0xfe + 0x102, 0xfe + 0x102
|
obj/__user_badsegment.out: 文件格式 elf32-i386
Disassembly of section .text:
00800020 <__panic>:
#include <stdio.h>
#include <ulib.h>
#include <error.h>
void
__panic(const char *file, int line, const char *fmt, ...) {
800020: 55 push %ebp
800021: 89 e5 mov %esp,%ebp
800023: 83 ec 18 sub $0x18,%esp
// print the 'message'
va_list ap;
va_start(ap, fmt);
800026: 8d 45 14 lea 0x14(%ebp),%eax
800029: 89 45 f4 mov %eax,-0xc(%ebp)
cprintf("user panic at %s:%d:\n ", file, line);
80002c: 83 ec 04 sub $0x4,%esp
80002f: ff 75 0c pushl 0xc(%ebp)
800032: ff 75 08 pushl 0x8(%ebp)
800035: 68 60 0f 80 00 push $0x800f60
80003a: e8 9a 02 00 00 call 8002d9 <cprintf>
80003f: 83 c4 10 add $0x10,%esp
vcprintf(fmt, ap);
800042: 8b 45 f4 mov -0xc(%ebp),%eax
800045: 83 ec 08 sub $0x8,%esp
800048: 50 push %eax
800049: ff 75 10 pushl 0x10(%ebp)
80004c: e8 5f 02 00 00 call 8002b0 <vcprintf>
800051: 83 c4 10 add $0x10,%esp
cprintf("\n");
800054: 83 ec 0c sub $0xc,%esp
800057: 68 7a 0f 80 00 push $0x800f7a
80005c: e8 78 02 00 00 call 8002d9 <cprintf>
800061: 83 c4 10 add $0x10,%esp
va_end(ap);
exit(-E_PANIC);
800064: 83 ec 0c sub $0xc,%esp
800067: 6a f6 push $0xfffffff6
800069: e8 49 01 00 00 call 8001b7 <exit>
0080006e <__warn>:
}
void
__warn(const char *file, int line, const char *fmt, ...) {
80006e: 55 push %ebp
80006f: 89 e5 mov %esp,%ebp
800071: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
800074: 8d 45 14 lea 0x14(%ebp),%eax
800077: 89 45 f4 mov %eax,-0xc(%ebp)
cprintf("user warning at %s:%d:\n ", file, line);
80007a: 83 ec 04 sub $0x4,%esp
80007d: ff 75 0c pushl 0xc(%ebp)
800080: ff 75 08 pushl 0x8(%ebp)
800083: 68 7c 0f 80 00 push $0x800f7c
800088: e8 4c 02 00 00 call 8002d9 <cprintf>
80008d: 83 c4 10 add $0x10,%esp
vcprintf(fmt, ap);
800090: 8b 45 f4 mov -0xc(%ebp),%eax
800093: 83 ec 08 sub $0x8,%esp
800096: 50 push %eax
800097: ff 75 10 pushl 0x10(%ebp)
80009a: e8 11 02 00 00 call 8002b0 <vcprintf>
80009f: 83 c4 10 add $0x10,%esp
cprintf("\n");
8000a2: 83 ec 0c sub $0xc,%esp
8000a5: 68 7a 0f 80 00 push $0x800f7a
8000aa: e8 2a 02 00 00 call 8002d9 <cprintf>
8000af: 83 c4 10 add $0x10,%esp
va_end(ap);
}
8000b2: 90 nop
8000b3: c9 leave
8000b4: c3 ret
008000b5 <syscall>:
#include <syscall.h>
#define MAX_ARGS 5
static inline int
syscall(int num, ...) {
8000b5: 55 push %ebp
8000b6: 89 e5 mov %esp,%ebp
8000b8: 57 push %edi
8000b9: 56 push %esi
8000ba: 53 push %ebx
8000bb: 83 ec 20 sub $0x20,%esp
va_list ap;
va_start(ap, num);
8000be: 8d 45 0c lea 0xc(%ebp),%eax
8000c1: 89 45 e8 mov %eax,-0x18(%ebp)
uint32_t a[MAX_ARGS];
int i, ret;
for (i = 0; i < MAX_ARGS; i ++) {
8000c4: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
8000cb: eb 16 jmp 8000e3 <syscall+0x2e>
a[i] = va_arg(ap, uint32_t);
8000cd: 8b 45 e8 mov -0x18(%ebp),%eax
8000d0: 8d 50 04 lea 0x4(%eax),%edx
8000d3: 89 55 e8 mov %edx,-0x18(%ebp)
8000d6: 8b 10 mov (%eax),%edx
8000d8: 8b 45 f0 mov -0x10(%ebp),%eax
8000db: 89 54 85 d4 mov %edx,-0x2c(%ebp,%eax,4)
syscall(int num, ...) {
va_list ap;
va_start(ap, num);
uint32_t a[MAX_ARGS];
int i, ret;
for (i = 0; i < MAX_ARGS; i ++) {
8000df: 83 45 f0 01 addl $0x1,-0x10(%ebp)
8000e3: 83 7d f0 04 cmpl $0x4,-0x10(%ebp)
8000e7: 7e e4 jle 8000cd <syscall+0x18>
asm volatile (
"int %1;"
: "=a" (ret)
: "i" (T_SYSCALL),
"a" (num),
"d" (a[0]),
8000e9: 8b 55 d4 mov -0x2c(%ebp),%edx
"c" (a[1]),
8000ec: 8b 4d d8 mov -0x28(%ebp),%ecx
"b" (a[2]),
8000ef: 8b 5d dc mov -0x24(%ebp),%ebx
"D" (a[3]),
8000f2: 8b 7d e0 mov -0x20(%ebp),%edi
"S" (a[4])
8000f5: 8b 75 e4 mov -0x1c(%ebp),%esi
for (i = 0; i < MAX_ARGS; i ++) {
a[i] = va_arg(ap, uint32_t);
}
va_end(ap);
asm volatile (
8000f8: 8b 45 08 mov 0x8(%ebp),%eax
8000fb: cd 80 int $0x80
8000fd: 89 45 ec mov %eax,-0x14(%ebp)
"c" (a[1]),
"b" (a[2]),
"D" (a[3]),
"S" (a[4])
: "cc", "memory");
return ret;
800100: 8b 45 ec mov -0x14(%ebp),%eax
}
800103: 83 c4 20 add $0x20,%esp
800106: 5b pop %ebx
800107: 5e pop %esi
800108: 5f pop %edi
800109: 5d pop %ebp
80010a: c3 ret
0080010b <sys_exit>:
int
sys_exit(int error_code) {
80010b: 55 push %ebp
80010c: 89 e5 mov %esp,%ebp
return syscall(SYS_exit, error_code);
80010e: ff 75 08 pushl 0x8(%ebp)
800111: 6a 01 push $0x1
800113: e8 9d ff ff ff call 8000b5 <syscall>
800118: 83 c4 08 add $0x8,%esp
}
80011b: c9 leave
80011c: c3 ret
0080011d <sys_fork>:
int
sys_fork(void) {
80011d: 55 push %ebp
80011e: 89 e5 mov %esp,%ebp
return syscall(SYS_fork);
800120: 6a 02 push $0x2
800122: e8 8e ff ff ff call 8000b5 <syscall>
800127: 83 c4 04 add $0x4,%esp
}
80012a: c9 leave
80012b: c3 ret
0080012c <sys_wait>:
int
sys_wait(int pid, int *store) {
80012c: 55 push %ebp
80012d: 89 e5 mov %esp,%ebp
return syscall(SYS_wait, pid, store);
80012f: ff 75 0c pushl 0xc(%ebp)
800132: ff 75 08 pushl 0x8(%ebp)
800135: 6a 03 push $0x3
800137: e8 79 ff ff ff call 8000b5 <syscall>
80013c: 83 c4 0c add $0xc,%esp
}
80013f: c9 leave
800140: c3 ret
00800141 <sys_yield>:
int
sys_yield(void) {
800141: 55 push %ebp
800142: 89 e5 mov %esp,%ebp
return syscall(SYS_yield);
800144: 6a 0a push $0xa
800146: e8 6a ff ff ff call 8000b5 <syscall>
80014b: 83 c4 04 add $0x4,%esp
}
80014e: c9 leave
80014f: c3 ret
00800150 <sys_kill>:
int
sys_kill(int pid) {
800150: 55 push %ebp
800151: 89 e5 mov %esp,%ebp
return syscall(SYS_kill, pid);
800153: ff 75 08 pushl 0x8(%ebp)
800156: 6a 0c push $0xc
800158: e8 58 ff ff ff call 8000b5 <syscall>
80015d: 83 c4 08 add $0x8,%esp
}
800160: c9 leave
800161: c3 ret
00800162 <sys_getpid>:
int
sys_getpid(void) {
800162: 55 push %ebp
800163: 89 e5 mov %esp,%ebp
return syscall(SYS_getpid);
800165: 6a 12 push $0x12
800167: e8 49 ff ff ff call 8000b5 <syscall>
80016c: 83 c4 04 add $0x4,%esp
}
80016f: c9 leave
800170: c3 ret
00800171 <sys_putc>:
int
sys_putc(int c) {
800171: 55 push %ebp
800172: 89 e5 mov %esp,%ebp
return syscall(SYS_putc, c);
800174: ff 75 08 pushl 0x8(%ebp)
800177: 6a 1e push $0x1e
800179: e8 37 ff ff ff call 8000b5 <syscall>
80017e: 83 c4 08 add $0x8,%esp
}
800181: c9 leave
800182: c3 ret
00800183 <sys_pgdir>:
int
sys_pgdir(void) {
800183: 55 push %ebp
800184: 89 e5 mov %esp,%ebp
return syscall(SYS_pgdir);
800186: 6a 1f push $0x1f
800188: e8 28 ff ff ff call 8000b5 <syscall>
80018d: 83 c4 04 add $0x4,%esp
}
800190: c9 leave
800191: c3 ret
00800192 <sys_gettime>:
size_t
sys_gettime(void) {
800192: 55 push %ebp
800193: 89 e5 mov %esp,%ebp
return syscall(SYS_gettime);
800195: 6a 11 push $0x11
800197: e8 19 ff ff ff call 8000b5 <syscall>
80019c: 83 c4 04 add $0x4,%esp
}
80019f: c9 leave
8001a0: c3 ret
008001a1 <sys_lab6_set_priority>:
void
sys_lab6_set_priority(uint32_t priority)
{
8001a1: 55 push %ebp
8001a2: 89 e5 mov %esp,%ebp
syscall(SYS_lab6_set_priority, priority);
8001a4: ff 75 08 pushl 0x8(%ebp)
8001a7: 68 ff 00 00 00 push $0xff
8001ac: e8 04 ff ff ff call 8000b5 <syscall>
8001b1: 83 c4 08 add $0x8,%esp
}
8001b4: 90 nop
8001b5: c9 leave
8001b6: c3 ret
008001b7 <exit>:
#include <syscall.h>
#include <stdio.h>
#include <ulib.h>
void
exit(int error_code) {
8001b7: 55 push %ebp
8001b8: 89 e5 mov %esp,%ebp
8001ba: 83 ec 08 sub $0x8,%esp
sys_exit(error_code);
8001bd: 83 ec 0c sub $0xc,%esp
8001c0: ff 75 08 pushl 0x8(%ebp)
8001c3: e8 43 ff ff ff call 80010b <sys_exit>
8001c8: 83 c4 10 add $0x10,%esp
cprintf("BUG: exit failed.\n");
8001cb: 83 ec 0c sub $0xc,%esp
8001ce: 68 98 0f 80 00 push $0x800f98
8001d3: e8 01 01 00 00 call 8002d9 <cprintf>
8001d8: 83 c4 10 add $0x10,%esp
while (1);
8001db: eb fe jmp 8001db <exit+0x24>
008001dd <fork>:
}
int
fork(void) {
8001dd: 55 push %ebp
8001de: 89 e5 mov %esp,%ebp
8001e0: 83 ec 08 sub $0x8,%esp
return sys_fork();
8001e3: e8 35 ff ff ff call 80011d <sys_fork>
}
8001e8: c9 leave
8001e9: c3 ret
008001ea <wait>:
int
wait(void) {
8001ea: 55 push %ebp
8001eb: 89 e5 mov %esp,%ebp
8001ed: 83 ec 08 sub $0x8,%esp
return sys_wait(0, NULL);
8001f0: 83 ec 08 sub $0x8,%esp
8001f3: 6a 00 push $0x0
8001f5: 6a 00 push $0x0
8001f7: e8 30 ff ff ff call 80012c <sys_wait>
8001fc: 83 c4 10 add $0x10,%esp
}
8001ff: c9 leave
800200: c3 ret
00800201 <waitpid>:
int
waitpid(int pid, int *store) {
800201: 55 push %ebp
800202: 89 e5 mov %esp,%ebp
800204: 83 ec 08 sub $0x8,%esp
return sys_wait(pid, store);
800207: 83 ec 08 sub $0x8,%esp
80020a: ff 75 0c pushl 0xc(%ebp)
80020d: ff 75 08 pushl 0x8(%ebp)
800210: e8 17 ff ff ff call 80012c <sys_wait>
800215: 83 c4 10 add $0x10,%esp
}
800218: c9 leave
800219: c3 ret
0080021a <yield>:
void
yield(void) {
80021a: 55 push %ebp
80021b: 89 e5 mov %esp,%ebp
80021d: 83 ec 08 sub $0x8,%esp
sys_yield();
800220: e8 1c ff ff ff call 800141 <sys_yield>
}
800225: 90 nop
800226: c9 leave
800227: c3 ret
00800228 <kill>:
int
kill(int pid) {
800228: 55 push %ebp
800229: 89 e5 mov %esp,%ebp
80022b: 83 ec 08 sub $0x8,%esp
return sys_kill(pid);
80022e: 83 ec 0c sub $0xc,%esp
800231: ff 75 08 pushl 0x8(%ebp)
800234: e8 17 ff ff ff call 800150 <sys_kill>
800239: 83 c4 10 add $0x10,%esp
}
80023c: c9 leave
80023d: c3 ret
0080023e <getpid>:
int
getpid(void) {
80023e: 55 push %ebp
80023f: 89 e5 mov %esp,%ebp
800241: 83 ec 08 sub $0x8,%esp
return sys_getpid();
800244: e8 19 ff ff ff call 800162 <sys_getpid>
}
800249: c9 leave
80024a: c3 ret
0080024b <print_pgdir>:
//print_pgdir - print the PDT&PT
void
print_pgdir(void) {
80024b: 55 push %ebp
80024c: 89 e5 mov %esp,%ebp
80024e: 83 ec 08 sub $0x8,%esp
sys_pgdir();
800251: e8 2d ff ff ff call 800183 <sys_pgdir>
}
800256: 90 nop
800257: c9 leave
800258: c3 ret
00800259 <gettime_msec>:
unsigned int
gettime_msec(void) {
800259: 55 push %ebp
80025a: 89 e5 mov %esp,%ebp
80025c: 83 ec 08 sub $0x8,%esp
return (unsigned int)sys_gettime();
80025f: e8 2e ff ff ff call 800192 <sys_gettime>
}
800264: c9 leave
800265: c3 ret
00800266 <lab6_set_priority>:
void
lab6_set_priority(uint32_t priority)
{
800266: 55 push %ebp
800267: 89 e5 mov %esp,%ebp
800269: 83 ec 08 sub $0x8,%esp
sys_lab6_set_priority(priority);
80026c: 83 ec 0c sub $0xc,%esp
80026f: ff 75 08 pushl 0x8(%ebp)
800272: e8 2a ff ff ff call 8001a1 <sys_lab6_set_priority>
800277: 83 c4 10 add $0x10,%esp
}
80027a: 90 nop
80027b: c9 leave
80027c: c3 ret
0080027d <_start>:
.text
.globl _start
_start:
# set ebp for backtrace
movl $0x0, %ebp
80027d: bd 00 00 00 00 mov $0x0,%ebp
# move down the esp register
# since it may cause page fault in backtrace
subl $0x20, %esp
800282: 83 ec 20 sub $0x20,%esp
# call user-program function
call umain
800285: e8 c3 00 00 00 call 80034d <umain>
1: jmp 1b
80028a: eb fe jmp 80028a <_start+0xd>
0080028c <cputch>:
/* *
* cputch - writes a single character @c to stdout, and it will
* increace the value of counter pointed by @cnt.
* */
static void
cputch(int c, int *cnt) {
80028c: 55 push %ebp
80028d: 89 e5 mov %esp,%ebp
80028f: 83 ec 08 sub $0x8,%esp
sys_putc(c);
800292: 83 ec 0c sub $0xc,%esp
800295: ff 75 08 pushl 0x8(%ebp)
800298: e8 d4 fe ff ff call 800171 <sys_putc>
80029d: 83 c4 10 add $0x10,%esp
(*cnt) ++;
8002a0: 8b 45 0c mov 0xc(%ebp),%eax
8002a3: 8b 00 mov (%eax),%eax
8002a5: 8d 50 01 lea 0x1(%eax),%edx
8002a8: 8b 45 0c mov 0xc(%ebp),%eax
8002ab: 89 10 mov %edx,(%eax)
}
8002ad: 90 nop
8002ae: c9 leave
8002af: c3 ret
008002b0 <vcprintf>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want cprintf() instead.
* */
int
vcprintf(const char *fmt, va_list ap) {
8002b0: 55 push %ebp
8002b1: 89 e5 mov %esp,%ebp
8002b3: 83 ec 18 sub $0x18,%esp
int cnt = 0;
8002b6: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
vprintfmt((void*)cputch, &cnt, fmt, ap);
8002bd: ff 75 0c pushl 0xc(%ebp)
8002c0: ff 75 08 pushl 0x8(%ebp)
8002c3: 8d 45 f4 lea -0xc(%ebp),%eax
8002c6: 50 push %eax
8002c7: 68 8c 02 80 00 push $0x80028c
8002cc: e8 fc 06 00 00 call 8009cd <vprintfmt>
8002d1: 83 c4 10 add $0x10,%esp
return cnt;
8002d4: 8b 45 f4 mov -0xc(%ebp),%eax
}
8002d7: c9 leave
8002d8: c3 ret
008002d9 <cprintf>:
*
* The return value is the number of characters which would be
* written to stdout.
* */
int
cprintf(const char *fmt, ...) {
8002d9: 55 push %ebp
8002da: 89 e5 mov %esp,%ebp
8002dc: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
8002df: 8d 45 0c lea 0xc(%ebp),%eax
8002e2: 89 45 f0 mov %eax,-0x10(%ebp)
int cnt = vcprintf(fmt, ap);
8002e5: 8b 45 f0 mov -0x10(%ebp),%eax
8002e8: 83 ec 08 sub $0x8,%esp
8002eb: 50 push %eax
8002ec: ff 75 08 pushl 0x8(%ebp)
8002ef: e8 bc ff ff ff call 8002b0 <vcprintf>
8002f4: 83 c4 10 add $0x10,%esp
8002f7: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return cnt;
8002fa: 8b 45 f4 mov -0xc(%ebp),%eax
}
8002fd: c9 leave
8002fe: c3 ret
008002ff <cputs>:
/* *
* cputs- writes the string pointed by @str to stdout and
* appends a newline character.
* */
int
cputs(const char *str) {
8002ff: 55 push %ebp
800300: 89 e5 mov %esp,%ebp
800302: 83 ec 18 sub $0x18,%esp
int cnt = 0;
800305: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
char c;
while ((c = *str ++) != '\0') {
80030c: eb 14 jmp 800322 <cputs+0x23>
cputch(c, &cnt);
80030e: 0f be 45 f7 movsbl -0x9(%ebp),%eax
800312: 83 ec 08 sub $0x8,%esp
800315: 8d 55 f0 lea -0x10(%ebp),%edx
800318: 52 push %edx
800319: 50 push %eax
80031a: e8 6d ff ff ff call 80028c <cputch>
80031f: 83 c4 10 add $0x10,%esp
* */
int
cputs(const char *str) {
int cnt = 0;
char c;
while ((c = *str ++) != '\0') {
800322: 8b 45 08 mov 0x8(%ebp),%eax
800325: 8d 50 01 lea 0x1(%eax),%edx
800328: 89 55 08 mov %edx,0x8(%ebp)
80032b: 0f b6 00 movzbl (%eax),%eax
80032e: 88 45 f7 mov %al,-0x9(%ebp)
800331: 80 7d f7 00 cmpb $0x0,-0x9(%ebp)
800335: 75 d7 jne 80030e <cputs+0xf>
cputch(c, &cnt);
}
cputch('\n', &cnt);
800337: 83 ec 08 sub $0x8,%esp
80033a: 8d 45 f0 lea -0x10(%ebp),%eax
80033d: 50 push %eax
80033e: 6a 0a push $0xa
800340: e8 47 ff ff ff call 80028c <cputch>
800345: 83 c4 10 add $0x10,%esp
return cnt;
800348: 8b 45 f0 mov -0x10(%ebp),%eax
}
80034b: c9 leave
80034c: c3 ret
0080034d <umain>:
#include <ulib.h>
int main(void);
void
umain(void) {
80034d: 55 push %ebp
80034e: 89 e5 mov %esp,%ebp
800350: 83 ec 18 sub $0x18,%esp
int ret = main();
800353: e8 d3 0b 00 00 call 800f2b <main>
800358: 89 45 f4 mov %eax,-0xc(%ebp)
exit(ret);
80035b: 83 ec 0c sub $0xc,%esp
80035e: ff 75 f4 pushl -0xc(%ebp)
800361: e8 51 fe ff ff call 8001b7 <exit>
00800366 <strlen>:
* @s: the input string
*
* The strlen() function returns the length of string @s.
* */
size_t
strlen(const char *s) {
800366: 55 push %ebp
800367: 89 e5 mov %esp,%ebp
800369: 83 ec 10 sub $0x10,%esp
size_t cnt = 0;
80036c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s ++ != '\0') {
800373: eb 04 jmp 800379 <strlen+0x13>
cnt ++;
800375: 83 45 fc 01 addl $0x1,-0x4(%ebp)
* The strlen() function returns the length of string @s.
* */
size_t
strlen(const char *s) {
size_t cnt = 0;
while (*s ++ != '\0') {
800379: 8b 45 08 mov 0x8(%ebp),%eax
80037c: 8d 50 01 lea 0x1(%eax),%edx
80037f: 89 55 08 mov %edx,0x8(%ebp)
800382: 0f b6 00 movzbl (%eax),%eax
800385: 84 c0 test %al,%al
800387: 75 ec jne 800375 <strlen+0xf>
cnt ++;
}
return cnt;
800389: 8b 45 fc mov -0x4(%ebp),%eax
}
80038c: c9 leave
80038d: c3 ret
0080038e <strnlen>:
* The return value is strlen(s), if that is less than @len, or
* @len if there is no '\0' character among the first @len characters
* pointed by @s.
* */
size_t
strnlen(const char *s, size_t len) {
80038e: 55 push %ebp
80038f: 89 e5 mov %esp,%ebp
800391: 83 ec 10 sub $0x10,%esp
size_t cnt = 0;
800394: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (cnt < len && *s ++ != '\0') {
80039b: eb 04 jmp 8003a1 <strnlen+0x13>
cnt ++;
80039d: 83 45 fc 01 addl $0x1,-0x4(%ebp)
* pointed by @s.
* */
size_t
strnlen(const char *s, size_t len) {
size_t cnt = 0;
while (cnt < len && *s ++ != '\0') {
8003a1: 8b 45 fc mov -0x4(%ebp),%eax
8003a4: 3b 45 0c cmp 0xc(%ebp),%eax
8003a7: 73 10 jae 8003b9 <strnlen+0x2b>
8003a9: 8b 45 08 mov 0x8(%ebp),%eax
8003ac: 8d 50 01 lea 0x1(%eax),%edx
8003af: 89 55 08 mov %edx,0x8(%ebp)
8003b2: 0f b6 00 movzbl (%eax),%eax
8003b5: 84 c0 test %al,%al
8003b7: 75 e4 jne 80039d <strnlen+0xf>
cnt ++;
}
return cnt;
8003b9: 8b 45 fc mov -0x4(%ebp),%eax
}
8003bc: c9 leave
8003bd: c3 ret
008003be <strcpy>:
* To avoid overflows, the size of array pointed by @dst should be long enough to
* contain the same string as @src (including the terminating null character), and
* should not overlap in memory with @src.
* */
char *
strcpy(char *dst, const char *src) {
8003be: 55 push %ebp
8003bf: 89 e5 mov %esp,%ebp
8003c1: 57 push %edi
8003c2: 56 push %esi
8003c3: 83 ec 20 sub $0x20,%esp
8003c6: 8b 45 08 mov 0x8(%ebp),%eax
8003c9: 89 45 f4 mov %eax,-0xc(%ebp)
8003cc: 8b 45 0c mov 0xc(%ebp),%eax
8003cf: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_STRCPY
#define __HAVE_ARCH_STRCPY
static inline char *
__strcpy(char *dst, const char *src) {
int d0, d1, d2;
asm volatile (
8003d2: 8b 55 f0 mov -0x10(%ebp),%edx
8003d5: 8b 45 f4 mov -0xc(%ebp),%eax
8003d8: 89 d1 mov %edx,%ecx
8003da: 89 c2 mov %eax,%edx
8003dc: 89 ce mov %ecx,%esi
8003de: 89 d7 mov %edx,%edi
8003e0: ac lods %ds:(%esi),%al
8003e1: aa stos %al,%es:(%edi)
8003e2: 84 c0 test %al,%al
8003e4: 75 fa jne 8003e0 <strcpy+0x22>
8003e6: 89 fa mov %edi,%edx
8003e8: 89 f1 mov %esi,%ecx
8003ea: 89 4d ec mov %ecx,-0x14(%ebp)
8003ed: 89 55 e8 mov %edx,-0x18(%ebp)
8003f0: 89 45 e4 mov %eax,-0x1c(%ebp)
"stosb;"
"testb %%al, %%al;"
"jne 1b;"
: "=&S" (d0), "=&D" (d1), "=&a" (d2)
: "0" (src), "1" (dst) : "memory");
return dst;
8003f3: 8b 45 f4 mov -0xc(%ebp),%eax
#ifdef __HAVE_ARCH_STRCPY
return __strcpy(dst, src);
8003f6: 90 nop
char *p = dst;
while ((*p ++ = *src ++) != '\0')
/* nothing */;
return dst;
#endif /* __HAVE_ARCH_STRCPY */
}
8003f7: 83 c4 20 add $0x20,%esp
8003fa: 5e pop %esi
8003fb: 5f pop %edi
8003fc: 5d pop %ebp
8003fd: c3 ret
008003fe <strncpy>:
* @len: maximum number of characters to be copied from @src
*
* The return value is @dst
* */
char *
strncpy(char *dst, const char *src, size_t len) {
8003fe: 55 push %ebp
8003ff: 89 e5 mov %esp,%ebp
800401: 83 ec 10 sub $0x10,%esp
char *p = dst;
800404: 8b 45 08 mov 0x8(%ebp),%eax
800407: 89 45 fc mov %eax,-0x4(%ebp)
while (len > 0) {
80040a: eb 21 jmp 80042d <strncpy+0x2f>
if ((*p = *src) != '\0') {
80040c: 8b 45 0c mov 0xc(%ebp),%eax
80040f: 0f b6 10 movzbl (%eax),%edx
800412: 8b 45 fc mov -0x4(%ebp),%eax
800415: 88 10 mov %dl,(%eax)
800417: 8b 45 fc mov -0x4(%ebp),%eax
80041a: 0f b6 00 movzbl (%eax),%eax
80041d: 84 c0 test %al,%al
80041f: 74 04 je 800425 <strncpy+0x27>
src ++;
800421: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
p ++, len --;
800425: 83 45 fc 01 addl $0x1,-0x4(%ebp)
800429: 83 6d 10 01 subl $0x1,0x10(%ebp)
* The return value is @dst
* */
char *
strncpy(char *dst, const char *src, size_t len) {
char *p = dst;
while (len > 0) {
80042d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
800431: 75 d9 jne 80040c <strncpy+0xe>
if ((*p = *src) != '\0') {
src ++;
}
p ++, len --;
}
return dst;
800433: 8b 45 08 mov 0x8(%ebp),%eax
}
800436: c9 leave
800437: c3 ret
00800438 <strcmp>:
* - A value greater than zero indicates that the first character that does
* not match has a greater value in @s1 than in @s2;
* - And a value less than zero indicates the opposite.
* */
int
strcmp(const char *s1, const char *s2) {
800438: 55 push %ebp
800439: 89 e5 mov %esp,%ebp
80043b: 57 push %edi
80043c: 56 push %esi
80043d: 83 ec 20 sub $0x20,%esp
800440: 8b 45 08 mov 0x8(%ebp),%eax
800443: 89 45 f4 mov %eax,-0xc(%ebp)
800446: 8b 45 0c mov 0xc(%ebp),%eax
800449: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_STRCMP
#define __HAVE_ARCH_STRCMP
static inline int
__strcmp(const char *s1, const char *s2) {
int d0, d1, ret;
asm volatile (
80044c: 8b 55 f4 mov -0xc(%ebp),%edx
80044f: 8b 45 f0 mov -0x10(%ebp),%eax
800452: 89 d1 mov %edx,%ecx
800454: 89 c2 mov %eax,%edx
800456: 89 ce mov %ecx,%esi
800458: 89 d7 mov %edx,%edi
80045a: ac lods %ds:(%esi),%al
80045b: ae scas %es:(%edi),%al
80045c: 75 08 jne 800466 <strcmp+0x2e>
80045e: 84 c0 test %al,%al
800460: 75 f8 jne 80045a <strcmp+0x22>
800462: 31 c0 xor %eax,%eax
800464: eb 04 jmp 80046a <strcmp+0x32>
800466: 19 c0 sbb %eax,%eax
800468: 0c 01 or $0x1,%al
80046a: 89 fa mov %edi,%edx
80046c: 89 f1 mov %esi,%ecx
80046e: 89 45 ec mov %eax,-0x14(%ebp)
800471: 89 4d e8 mov %ecx,-0x18(%ebp)
800474: 89 55 e4 mov %edx,-0x1c(%ebp)
"orb $1, %%al;"
"3:"
: "=a" (ret), "=&S" (d0), "=&D" (d1)
: "1" (s1), "2" (s2)
: "memory");
return ret;
800477: 8b 45 ec mov -0x14(%ebp),%eax
#ifdef __HAVE_ARCH_STRCMP
return __strcmp(s1, s2);
80047a: 90 nop
while (*s1 != '\0' && *s1 == *s2) {
s1 ++, s2 ++;
}
return (int)((unsigned char)*s1 - (unsigned char)*s2);
#endif /* __HAVE_ARCH_STRCMP */
}
80047b: 83 c4 20 add $0x20,%esp
80047e: 5e pop %esi
80047f: 5f pop %edi
800480: 5d pop %ebp
800481: c3 ret
00800482 <strncmp>:
* they are equal to each other, it continues with the following pairs until
* the characters differ, until a terminating null-character is reached, or
* until @n characters match in both strings, whichever happens first.
* */
int
strncmp(const char *s1, const char *s2, size_t n) {
800482: 55 push %ebp
800483: 89 e5 mov %esp,%ebp
while (n > 0 && *s1 != '\0' && *s1 == *s2) {
800485: eb 0c jmp 800493 <strncmp+0x11>
n --, s1 ++, s2 ++;
800487: 83 6d 10 01 subl $0x1,0x10(%ebp)
80048b: 83 45 08 01 addl $0x1,0x8(%ebp)
80048f: 83 45 0c 01 addl $0x1,0xc(%ebp)
* the characters differ, until a terminating null-character is reached, or
* until @n characters match in both strings, whichever happens first.
* */
int
strncmp(const char *s1, const char *s2, size_t n) {
while (n > 0 && *s1 != '\0' && *s1 == *s2) {
800493: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
800497: 74 1a je 8004b3 <strncmp+0x31>
800499: 8b 45 08 mov 0x8(%ebp),%eax
80049c: 0f b6 00 movzbl (%eax),%eax
80049f: 84 c0 test %al,%al
8004a1: 74 10 je 8004b3 <strncmp+0x31>
8004a3: 8b 45 08 mov 0x8(%ebp),%eax
8004a6: 0f b6 10 movzbl (%eax),%edx
8004a9: 8b 45 0c mov 0xc(%ebp),%eax
8004ac: 0f b6 00 movzbl (%eax),%eax
8004af: 38 c2 cmp %al,%dl
8004b1: 74 d4 je 800487 <strncmp+0x5>
n --, s1 ++, s2 ++;
}
return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
8004b3: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
8004b7: 74 18 je 8004d1 <strncmp+0x4f>
8004b9: 8b 45 08 mov 0x8(%ebp),%eax
8004bc: 0f b6 00 movzbl (%eax),%eax
8004bf: 0f b6 d0 movzbl %al,%edx
8004c2: 8b 45 0c mov 0xc(%ebp),%eax
8004c5: 0f b6 00 movzbl (%eax),%eax
8004c8: 0f b6 c0 movzbl %al,%eax
8004cb: 29 c2 sub %eax,%edx
8004cd: 89 d0 mov %edx,%eax
8004cf: eb 05 jmp 8004d6 <strncmp+0x54>
8004d1: b8 00 00 00 00 mov $0x0,%eax
}
8004d6: 5d pop %ebp
8004d7: c3 ret
008004d8 <strchr>:
*
* The strchr() function returns a pointer to the first occurrence of
* character in @s. If the value is not found, the function returns 'NULL'.
* */
char *
strchr(const char *s, char c) {
8004d8: 55 push %ebp
8004d9: 89 e5 mov %esp,%ebp
8004db: 83 ec 04 sub $0x4,%esp
8004de: 8b 45 0c mov 0xc(%ebp),%eax
8004e1: 88 45 fc mov %al,-0x4(%ebp)
while (*s != '\0') {
8004e4: eb 14 jmp 8004fa <strchr+0x22>
if (*s == c) {
8004e6: 8b 45 08 mov 0x8(%ebp),%eax
8004e9: 0f b6 00 movzbl (%eax),%eax
8004ec: 3a 45 fc cmp -0x4(%ebp),%al
8004ef: 75 05 jne 8004f6 <strchr+0x1e>
return (char *)s;
8004f1: 8b 45 08 mov 0x8(%ebp),%eax
8004f4: eb 13 jmp 800509 <strchr+0x31>
}
s ++;
8004f6: 83 45 08 01 addl $0x1,0x8(%ebp)
* The strchr() function returns a pointer to the first occurrence of
* character in @s. If the value is not found, the function returns 'NULL'.
* */
char *
strchr(const char *s, char c) {
while (*s != '\0') {
8004fa: 8b 45 08 mov 0x8(%ebp),%eax
8004fd: 0f b6 00 movzbl (%eax),%eax
800500: 84 c0 test %al,%al
800502: 75 e2 jne 8004e6 <strchr+0xe>
if (*s == c) {
return (char *)s;
}
s ++;
}
return NULL;
800504: b8 00 00 00 00 mov $0x0,%eax
}
800509: c9 leave
80050a: c3 ret
0080050b <strfind>:
* The strfind() function is like strchr() except that if @c is
* not found in @s, then it returns a pointer to the null byte at the
* end of @s, rather than 'NULL'.
* */
char *
strfind(const char *s, char c) {
80050b: 55 push %ebp
80050c: 89 e5 mov %esp,%ebp
80050e: 83 ec 04 sub $0x4,%esp
800511: 8b 45 0c mov 0xc(%ebp),%eax
800514: 88 45 fc mov %al,-0x4(%ebp)
while (*s != '\0') {
800517: eb 0f jmp 800528 <strfind+0x1d>
if (*s == c) {
800519: 8b 45 08 mov 0x8(%ebp),%eax
80051c: 0f b6 00 movzbl (%eax),%eax
80051f: 3a 45 fc cmp -0x4(%ebp),%al
800522: 74 10 je 800534 <strfind+0x29>
break;
}
s ++;
800524: 83 45 08 01 addl $0x1,0x8(%ebp)
* not found in @s, then it returns a pointer to the null byte at the
* end of @s, rather than 'NULL'.
* */
char *
strfind(const char *s, char c) {
while (*s != '\0') {
800528: 8b 45 08 mov 0x8(%ebp),%eax
80052b: 0f b6 00 movzbl (%eax),%eax
80052e: 84 c0 test %al,%al
800530: 75 e7 jne 800519 <strfind+0xe>
800532: eb 01 jmp 800535 <strfind+0x2a>
if (*s == c) {
break;
800534: 90 nop
}
s ++;
}
return (char *)s;
800535: 8b 45 08 mov 0x8(%ebp),%eax
}
800538: c9 leave
800539: c3 ret
0080053a <strtol>:
* an optional "0x" or "0X" prefix.
*
* The strtol() function returns the converted integral number as a long int value.
* */
long
strtol(const char *s, char **endptr, int base) {
80053a: 55 push %ebp
80053b: 89 e5 mov %esp,%ebp
80053d: 83 ec 10 sub $0x10,%esp
int neg = 0;
800540: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
long val = 0;
800547: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp)
// gobble initial whitespace
while (*s == ' ' || *s == '\t') {
80054e: eb 04 jmp 800554 <strtol+0x1a>
s ++;
800550: 83 45 08 01 addl $0x1,0x8(%ebp)
strtol(const char *s, char **endptr, int base) {
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t') {
800554: 8b 45 08 mov 0x8(%ebp),%eax
800557: 0f b6 00 movzbl (%eax),%eax
80055a: 3c 20 cmp $0x20,%al
80055c: 74 f2 je 800550 <strtol+0x16>
80055e: 8b 45 08 mov 0x8(%ebp),%eax
800561: 0f b6 00 movzbl (%eax),%eax
800564: 3c 09 cmp $0x9,%al
800566: 74 e8 je 800550 <strtol+0x16>
s ++;
}
// plus/minus sign
if (*s == '+') {
800568: 8b 45 08 mov 0x8(%ebp),%eax
80056b: 0f b6 00 movzbl (%eax),%eax
80056e: 3c 2b cmp $0x2b,%al
800570: 75 06 jne 800578 <strtol+0x3e>
s ++;
800572: 83 45 08 01 addl $0x1,0x8(%ebp)
800576: eb 15 jmp 80058d <strtol+0x53>
}
else if (*s == '-') {
800578: 8b 45 08 mov 0x8(%ebp),%eax
80057b: 0f b6 00 movzbl (%eax),%eax
80057e: 3c 2d cmp $0x2d,%al
800580: 75 0b jne 80058d <strtol+0x53>
s ++, neg = 1;
800582: 83 45 08 01 addl $0x1,0x8(%ebp)
800586: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp)
}
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) {
80058d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
800591: 74 06 je 800599 <strtol+0x5f>
800593: 83 7d 10 10 cmpl $0x10,0x10(%ebp)
800597: 75 24 jne 8005bd <strtol+0x83>
800599: 8b 45 08 mov 0x8(%ebp),%eax
80059c: 0f b6 00 movzbl (%eax),%eax
80059f: 3c 30 cmp $0x30,%al
8005a1: 75 1a jne 8005bd <strtol+0x83>
8005a3: 8b 45 08 mov 0x8(%ebp),%eax
8005a6: 83 c0 01 add $0x1,%eax
8005a9: 0f b6 00 movzbl (%eax),%eax
8005ac: 3c 78 cmp $0x78,%al
8005ae: 75 0d jne 8005bd <strtol+0x83>
s += 2, base = 16;
8005b0: 83 45 08 02 addl $0x2,0x8(%ebp)
8005b4: c7 45 10 10 00 00 00 movl $0x10,0x10(%ebp)
8005bb: eb 2a jmp 8005e7 <strtol+0xad>
}
else if (base == 0 && s[0] == '0') {
8005bd: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
8005c1: 75 17 jne 8005da <strtol+0xa0>
8005c3: 8b 45 08 mov 0x8(%ebp),%eax
8005c6: 0f b6 00 movzbl (%eax),%eax
8005c9: 3c 30 cmp $0x30,%al
8005cb: 75 0d jne 8005da <strtol+0xa0>
s ++, base = 8;
8005cd: 83 45 08 01 addl $0x1,0x8(%ebp)
8005d1: c7 45 10 08 00 00 00 movl $0x8,0x10(%ebp)
8005d8: eb 0d jmp 8005e7 <strtol+0xad>
}
else if (base == 0) {
8005da: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
8005de: 75 07 jne 8005e7 <strtol+0xad>
base = 10;
8005e0: c7 45 10 0a 00 00 00 movl $0xa,0x10(%ebp)
// digits
while (1) {
int dig;
if (*s >= '0' && *s <= '9') {
8005e7: 8b 45 08 mov 0x8(%ebp),%eax
8005ea: 0f b6 00 movzbl (%eax),%eax
8005ed: 3c 2f cmp $0x2f,%al
8005ef: 7e 1b jle 80060c <strtol+0xd2>
8005f1: 8b 45 08 mov 0x8(%ebp),%eax
8005f4: 0f b6 00 movzbl (%eax),%eax
8005f7: 3c 39 cmp $0x39,%al
8005f9: 7f 11 jg 80060c <strtol+0xd2>
dig = *s - '0';
8005fb: 8b 45 08 mov 0x8(%ebp),%eax
8005fe: 0f b6 00 movzbl (%eax),%eax
800601: 0f be c0 movsbl %al,%eax
800604: 83 e8 30 sub $0x30,%eax
800607: 89 45 f4 mov %eax,-0xc(%ebp)
80060a: eb 48 jmp 800654 <strtol+0x11a>
}
else if (*s >= 'a' && *s <= 'z') {
80060c: 8b 45 08 mov 0x8(%ebp),%eax
80060f: 0f b6 00 movzbl (%eax),%eax
800612: 3c 60 cmp $0x60,%al
800614: 7e 1b jle 800631 <strtol+0xf7>
800616: 8b 45 08 mov 0x8(%ebp),%eax
800619: 0f b6 00 movzbl (%eax),%eax
80061c: 3c 7a cmp $0x7a,%al
80061e: 7f 11 jg 800631 <strtol+0xf7>
dig = *s - 'a' + 10;
800620: 8b 45 08 mov 0x8(%ebp),%eax
800623: 0f b6 00 movzbl (%eax),%eax
800626: 0f be c0 movsbl %al,%eax
800629: 83 e8 57 sub $0x57,%eax
80062c: 89 45 f4 mov %eax,-0xc(%ebp)
80062f: eb 23 jmp 800654 <strtol+0x11a>
}
else if (*s >= 'A' && *s <= 'Z') {
800631: 8b 45 08 mov 0x8(%ebp),%eax
800634: 0f b6 00 movzbl (%eax),%eax
800637: 3c 40 cmp $0x40,%al
800639: 7e 3c jle 800677 <strtol+0x13d>
80063b: 8b 45 08 mov 0x8(%ebp),%eax
80063e: 0f b6 00 movzbl (%eax),%eax
800641: 3c 5a cmp $0x5a,%al
800643: 7f 32 jg 800677 <strtol+0x13d>
dig = *s - 'A' + 10;
800645: 8b 45 08 mov 0x8(%ebp),%eax
800648: 0f b6 00 movzbl (%eax),%eax
80064b: 0f be c0 movsbl %al,%eax
80064e: 83 e8 37 sub $0x37,%eax
800651: 89 45 f4 mov %eax,-0xc(%ebp)
}
else {
break;
}
if (dig >= base) {
800654: 8b 45 f4 mov -0xc(%ebp),%eax
800657: 3b 45 10 cmp 0x10(%ebp),%eax
80065a: 7d 1a jge 800676 <strtol+0x13c>
break;
}
s ++, val = (val * base) + dig;
80065c: 83 45 08 01 addl $0x1,0x8(%ebp)
800660: 8b 45 f8 mov -0x8(%ebp),%eax
800663: 0f af 45 10 imul 0x10(%ebp),%eax
800667: 89 c2 mov %eax,%edx
800669: 8b 45 f4 mov -0xc(%ebp),%eax
80066c: 01 d0 add %edx,%eax
80066e: 89 45 f8 mov %eax,-0x8(%ebp)
// we don't properly detect overflow!
}
800671: e9 71 ff ff ff jmp 8005e7 <strtol+0xad>
}
else {
break;
}
if (dig >= base) {
break;
800676: 90 nop
}
s ++, val = (val * base) + dig;
// we don't properly detect overflow!
}
if (endptr) {
800677: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
80067b: 74 08 je 800685 <strtol+0x14b>
*endptr = (char *) s;
80067d: 8b 45 0c mov 0xc(%ebp),%eax
800680: 8b 55 08 mov 0x8(%ebp),%edx
800683: 89 10 mov %edx,(%eax)
}
return (neg ? -val : val);
800685: 83 7d fc 00 cmpl $0x0,-0x4(%ebp)
800689: 74 07 je 800692 <strtol+0x158>
80068b: 8b 45 f8 mov -0x8(%ebp),%eax
80068e: f7 d8 neg %eax
800690: eb 03 jmp 800695 <strtol+0x15b>
800692: 8b 45 f8 mov -0x8(%ebp),%eax
}
800695: c9 leave
800696: c3 ret
00800697 <memset>:
* @n: number of bytes to be set to the value
*
* The memset() function returns @s.
* */
void *
memset(void *s, char c, size_t n) {
800697: 55 push %ebp
800698: 89 e5 mov %esp,%ebp
80069a: 57 push %edi
80069b: 83 ec 24 sub $0x24,%esp
80069e: 8b 45 0c mov 0xc(%ebp),%eax
8006a1: 88 45 d8 mov %al,-0x28(%ebp)
#ifdef __HAVE_ARCH_MEMSET
return __memset(s, c, n);
8006a4: 0f be 45 d8 movsbl -0x28(%ebp),%eax
8006a8: 8b 55 08 mov 0x8(%ebp),%edx
8006ab: 89 55 f8 mov %edx,-0x8(%ebp)
8006ae: 88 45 f7 mov %al,-0x9(%ebp)
8006b1: 8b 45 10 mov 0x10(%ebp),%eax
8006b4: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_MEMSET
#define __HAVE_ARCH_MEMSET
static inline void *
__memset(void *s, char c, size_t n) {
int d0, d1;
asm volatile (
8006b7: 8b 4d f0 mov -0x10(%ebp),%ecx
8006ba: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
8006be: 8b 55 f8 mov -0x8(%ebp),%edx
8006c1: 89 d7 mov %edx,%edi
8006c3: f3 aa rep stos %al,%es:(%edi)
8006c5: 89 fa mov %edi,%edx
8006c7: 89 4d ec mov %ecx,-0x14(%ebp)
8006ca: 89 55 e8 mov %edx,-0x18(%ebp)
"rep; stosb;"
: "=&c" (d0), "=&D" (d1)
: "0" (n), "a" (c), "1" (s)
: "memory");
return s;
8006cd: 8b 45 f8 mov -0x8(%ebp),%eax
8006d0: 90 nop
while (n -- > 0) {
*p ++ = c;
}
return s;
#endif /* __HAVE_ARCH_MEMSET */
}
8006d1: 83 c4 24 add $0x24,%esp
8006d4: 5f pop %edi
8006d5: 5d pop %ebp
8006d6: c3 ret
008006d7 <memmove>:
* @n: number of bytes to copy
*
* The memmove() function returns @dst.
* */
void *
memmove(void *dst, const void *src, size_t n) {
8006d7: 55 push %ebp
8006d8: 89 e5 mov %esp,%ebp
8006da: 57 push %edi
8006db: 56 push %esi
8006dc: 53 push %ebx
8006dd: 83 ec 30 sub $0x30,%esp
8006e0: 8b 45 08 mov 0x8(%ebp),%eax
8006e3: 89 45 f0 mov %eax,-0x10(%ebp)
8006e6: 8b 45 0c mov 0xc(%ebp),%eax
8006e9: 89 45 ec mov %eax,-0x14(%ebp)
8006ec: 8b 45 10 mov 0x10(%ebp),%eax
8006ef: 89 45 e8 mov %eax,-0x18(%ebp)
#ifndef __HAVE_ARCH_MEMMOVE
#define __HAVE_ARCH_MEMMOVE
static inline void *
__memmove(void *dst, const void *src, size_t n) {
if (dst < src) {
8006f2: 8b 45 f0 mov -0x10(%ebp),%eax
8006f5: 3b 45 ec cmp -0x14(%ebp),%eax
8006f8: 73 42 jae 80073c <memmove+0x65>
8006fa: 8b 45 f0 mov -0x10(%ebp),%eax
8006fd: 89 45 e4 mov %eax,-0x1c(%ebp)
800700: 8b 45 ec mov -0x14(%ebp),%eax
800703: 89 45 e0 mov %eax,-0x20(%ebp)
800706: 8b 45 e8 mov -0x18(%ebp),%eax
800709: 89 45 dc mov %eax,-0x24(%ebp)
"andl $3, %%ecx;"
"jz 1f;"
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
80070c: 8b 45 dc mov -0x24(%ebp),%eax
80070f: c1 e8 02 shr $0x2,%eax
800712: 89 c1 mov %eax,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
int d0, d1, d2;
asm volatile (
800714: 8b 55 e4 mov -0x1c(%ebp),%edx
800717: 8b 45 e0 mov -0x20(%ebp),%eax
80071a: 89 d7 mov %edx,%edi
80071c: 89 c6 mov %eax,%esi
80071e: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
800720: 8b 4d dc mov -0x24(%ebp),%ecx
800723: 83 e1 03 and $0x3,%ecx
800726: 74 02 je 80072a <memmove+0x53>
800728: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
80072a: 89 f0 mov %esi,%eax
80072c: 89 fa mov %edi,%edx
80072e: 89 4d d8 mov %ecx,-0x28(%ebp)
800731: 89 55 d4 mov %edx,-0x2c(%ebp)
800734: 89 45 d0 mov %eax,-0x30(%ebp)
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
: "memory");
return dst;
800737: 8b 45 e4 mov -0x1c(%ebp),%eax
#ifdef __HAVE_ARCH_MEMMOVE
return __memmove(dst, src, n);
80073a: eb 36 jmp 800772 <memmove+0x9b>
asm volatile (
"std;"
"rep; movsb;"
"cld;"
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
80073c: 8b 45 e8 mov -0x18(%ebp),%eax
80073f: 8d 50 ff lea -0x1(%eax),%edx
800742: 8b 45 ec mov -0x14(%ebp),%eax
800745: 01 c2 add %eax,%edx
800747: 8b 45 e8 mov -0x18(%ebp),%eax
80074a: 8d 48 ff lea -0x1(%eax),%ecx
80074d: 8b 45 f0 mov -0x10(%ebp),%eax
800750: 8d 1c 01 lea (%ecx,%eax,1),%ebx
__memmove(void *dst, const void *src, size_t n) {
if (dst < src) {
return __memcpy(dst, src, n);
}
int d0, d1, d2;
asm volatile (
800753: 8b 45 e8 mov -0x18(%ebp),%eax
800756: 89 c1 mov %eax,%ecx
800758: 89 d8 mov %ebx,%eax
80075a: 89 d6 mov %edx,%esi
80075c: 89 c7 mov %eax,%edi
80075e: fd std
80075f: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
800761: fc cld
800762: 89 f8 mov %edi,%eax
800764: 89 f2 mov %esi,%edx
800766: 89 4d cc mov %ecx,-0x34(%ebp)
800769: 89 55 c8 mov %edx,-0x38(%ebp)
80076c: 89 45 c4 mov %eax,-0x3c(%ebp)
"rep; movsb;"
"cld;"
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
: "memory");
return dst;
80076f: 8b 45 f0 mov -0x10(%ebp),%eax
*d ++ = *s ++;
}
}
return dst;
#endif /* __HAVE_ARCH_MEMMOVE */
}
800772: 83 c4 30 add $0x30,%esp
800775: 5b pop %ebx
800776: 5e pop %esi
800777: 5f pop %edi
800778: 5d pop %ebp
800779: c3 ret
0080077a <memcpy>:
* it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed
* by both @src and @dst, should be at least @n bytes, and should not overlap
* (for overlapping memory area, memmove is a safer approach).
* */
void *
memcpy(void *dst, const void *src, size_t n) {
80077a: 55 push %ebp
80077b: 89 e5 mov %esp,%ebp
80077d: 57 push %edi
80077e: 56 push %esi
80077f: 83 ec 20 sub $0x20,%esp
800782: 8b 45 08 mov 0x8(%ebp),%eax
800785: 89 45 f4 mov %eax,-0xc(%ebp)
800788: 8b 45 0c mov 0xc(%ebp),%eax
80078b: 89 45 f0 mov %eax,-0x10(%ebp)
80078e: 8b 45 10 mov 0x10(%ebp),%eax
800791: 89 45 ec mov %eax,-0x14(%ebp)
"andl $3, %%ecx;"
"jz 1f;"
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
800794: 8b 45 ec mov -0x14(%ebp),%eax
800797: c1 e8 02 shr $0x2,%eax
80079a: 89 c1 mov %eax,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
int d0, d1, d2;
asm volatile (
80079c: 8b 55 f4 mov -0xc(%ebp),%edx
80079f: 8b 45 f0 mov -0x10(%ebp),%eax
8007a2: 89 d7 mov %edx,%edi
8007a4: 89 c6 mov %eax,%esi
8007a6: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
8007a8: 8b 4d ec mov -0x14(%ebp),%ecx
8007ab: 83 e1 03 and $0x3,%ecx
8007ae: 74 02 je 8007b2 <memcpy+0x38>
8007b0: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
8007b2: 89 f0 mov %esi,%eax
8007b4: 89 fa mov %edi,%edx
8007b6: 89 4d e8 mov %ecx,-0x18(%ebp)
8007b9: 89 55 e4 mov %edx,-0x1c(%ebp)
8007bc: 89 45 e0 mov %eax,-0x20(%ebp)
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
: "memory");
return dst;
8007bf: 8b 45 f4 mov -0xc(%ebp),%eax
#ifdef __HAVE_ARCH_MEMCPY
return __memcpy(dst, src, n);
8007c2: 90 nop
while (n -- > 0) {
*d ++ = *s ++;
}
return dst;
#endif /* __HAVE_ARCH_MEMCPY */
}
8007c3: 83 c4 20 add $0x20,%esp
8007c6: 5e pop %esi
8007c7: 5f pop %edi
8007c8: 5d pop %ebp
8007c9: c3 ret
008007ca <memcmp>:
* match in both memory blocks has a greater value in @v1 than in @v2
* as if evaluated as unsigned char values;
* - And a value less than zero indicates the opposite.
* */
int
memcmp(const void *v1, const void *v2, size_t n) {
8007ca: 55 push %ebp
8007cb: 89 e5 mov %esp,%ebp
8007cd: 83 ec 10 sub $0x10,%esp
const char *s1 = (const char *)v1;
8007d0: 8b 45 08 mov 0x8(%ebp),%eax
8007d3: 89 45 fc mov %eax,-0x4(%ebp)
const char *s2 = (const char *)v2;
8007d6: 8b 45 0c mov 0xc(%ebp),%eax
8007d9: 89 45 f8 mov %eax,-0x8(%ebp)
while (n -- > 0) {
8007dc: eb 30 jmp 80080e <memcmp+0x44>
if (*s1 != *s2) {
8007de: 8b 45 fc mov -0x4(%ebp),%eax
8007e1: 0f b6 10 movzbl (%eax),%edx
8007e4: 8b 45 f8 mov -0x8(%ebp),%eax
8007e7: 0f b6 00 movzbl (%eax),%eax
8007ea: 38 c2 cmp %al,%dl
8007ec: 74 18 je 800806 <memcmp+0x3c>
return (int)((unsigned char)*s1 - (unsigned char)*s2);
8007ee: 8b 45 fc mov -0x4(%ebp),%eax
8007f1: 0f b6 00 movzbl (%eax),%eax
8007f4: 0f b6 d0 movzbl %al,%edx
8007f7: 8b 45 f8 mov -0x8(%ebp),%eax
8007fa: 0f b6 00 movzbl (%eax),%eax
8007fd: 0f b6 c0 movzbl %al,%eax
800800: 29 c2 sub %eax,%edx
800802: 89 d0 mov %edx,%eax
800804: eb 1a jmp 800820 <memcmp+0x56>
}
s1 ++, s2 ++;
800806: 83 45 fc 01 addl $0x1,-0x4(%ebp)
80080a: 83 45 f8 01 addl $0x1,-0x8(%ebp)
* */
int
memcmp(const void *v1, const void *v2, size_t n) {
const char *s1 = (const char *)v1;
const char *s2 = (const char *)v2;
while (n -- > 0) {
80080e: 8b 45 10 mov 0x10(%ebp),%eax
800811: 8d 50 ff lea -0x1(%eax),%edx
800814: 89 55 10 mov %edx,0x10(%ebp)
800817: 85 c0 test %eax,%eax
800819: 75 c3 jne 8007de <memcmp+0x14>
if (*s1 != *s2) {
return (int)((unsigned char)*s1 - (unsigned char)*s2);
}
s1 ++, s2 ++;
}
return 0;
80081b: b8 00 00 00 00 mov $0x0,%eax
}
800820: c9 leave
800821: c3 ret
00800822 <printnum>:
* @width: maximum number of digits, if the actual width is less than @width, use @padc instead
* @padc: character that padded on the left if the actual width is less than @width
* */
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc) {
800822: 55 push %ebp
800823: 89 e5 mov %esp,%ebp
800825: 83 ec 38 sub $0x38,%esp
800828: 8b 45 10 mov 0x10(%ebp),%eax
80082b: 89 45 d0 mov %eax,-0x30(%ebp)
80082e: 8b 45 14 mov 0x14(%ebp),%eax
800831: 89 45 d4 mov %eax,-0x2c(%ebp)
unsigned long long result = num;
800834: 8b 45 d0 mov -0x30(%ebp),%eax
800837: 8b 55 d4 mov -0x2c(%ebp),%edx
80083a: 89 45 e8 mov %eax,-0x18(%ebp)
80083d: 89 55 ec mov %edx,-0x14(%ebp)
unsigned mod = do_div(result, base);
800840: 8b 45 18 mov 0x18(%ebp),%eax
800843: 89 45 e4 mov %eax,-0x1c(%ebp)
800846: 8b 45 e8 mov -0x18(%ebp),%eax
800849: 8b 55 ec mov -0x14(%ebp),%edx
80084c: 89 45 e0 mov %eax,-0x20(%ebp)
80084f: 89 55 f0 mov %edx,-0x10(%ebp)
800852: 8b 45 f0 mov -0x10(%ebp),%eax
800855: 89 45 f4 mov %eax,-0xc(%ebp)
800858: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
80085c: 74 1c je 80087a <printnum+0x58>
80085e: 8b 45 f0 mov -0x10(%ebp),%eax
800861: ba 00 00 00 00 mov $0x0,%edx
800866: f7 75 e4 divl -0x1c(%ebp)
800869: 89 55 f4 mov %edx,-0xc(%ebp)
80086c: 8b 45 f0 mov -0x10(%ebp),%eax
80086f: ba 00 00 00 00 mov $0x0,%edx
800874: f7 75 e4 divl -0x1c(%ebp)
800877: 89 45 f0 mov %eax,-0x10(%ebp)
80087a: 8b 45 e0 mov -0x20(%ebp),%eax
80087d: 8b 55 f4 mov -0xc(%ebp),%edx
800880: f7 75 e4 divl -0x1c(%ebp)
800883: 89 45 e0 mov %eax,-0x20(%ebp)
800886: 89 55 dc mov %edx,-0x24(%ebp)
800889: 8b 45 e0 mov -0x20(%ebp),%eax
80088c: 8b 55 f0 mov -0x10(%ebp),%edx
80088f: 89 45 e8 mov %eax,-0x18(%ebp)
800892: 89 55 ec mov %edx,-0x14(%ebp)
800895: 8b 45 dc mov -0x24(%ebp),%eax
800898: 89 45 d8 mov %eax,-0x28(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
80089b: 8b 45 18 mov 0x18(%ebp),%eax
80089e: ba 00 00 00 00 mov $0x0,%edx
8008a3: 3b 55 d4 cmp -0x2c(%ebp),%edx
8008a6: 77 41 ja 8008e9 <printnum+0xc7>
8008a8: 3b 55 d4 cmp -0x2c(%ebp),%edx
8008ab: 72 05 jb 8008b2 <printnum+0x90>
8008ad: 3b 45 d0 cmp -0x30(%ebp),%eax
8008b0: 77 37 ja 8008e9 <printnum+0xc7>
printnum(putch, putdat, result, base, width - 1, padc);
8008b2: 8b 45 1c mov 0x1c(%ebp),%eax
8008b5: 83 e8 01 sub $0x1,%eax
8008b8: 83 ec 04 sub $0x4,%esp
8008bb: ff 75 20 pushl 0x20(%ebp)
8008be: 50 push %eax
8008bf: ff 75 18 pushl 0x18(%ebp)
8008c2: ff 75 ec pushl -0x14(%ebp)
8008c5: ff 75 e8 pushl -0x18(%ebp)
8008c8: ff 75 0c pushl 0xc(%ebp)
8008cb: ff 75 08 pushl 0x8(%ebp)
8008ce: e8 4f ff ff ff call 800822 <printnum>
8008d3: 83 c4 20 add $0x20,%esp
8008d6: eb 1b jmp 8008f3 <printnum+0xd1>
} else {
// print any needed pad characters before first digit
while (-- width > 0)
putch(padc, putdat);
8008d8: 83 ec 08 sub $0x8,%esp
8008db: ff 75 0c pushl 0xc(%ebp)
8008de: ff 75 20 pushl 0x20(%ebp)
8008e1: 8b 45 08 mov 0x8(%ebp),%eax
8008e4: ff d0 call *%eax
8008e6: 83 c4 10 add $0x10,%esp
// first recursively print all preceding (more significant) digits
if (num >= base) {
printnum(putch, putdat, result, base, width - 1, padc);
} else {
// print any needed pad characters before first digit
while (-- width > 0)
8008e9: 83 6d 1c 01 subl $0x1,0x1c(%ebp)
8008ed: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp)
8008f1: 7f e5 jg 8008d8 <printnum+0xb6>
putch(padc, putdat);
}
// then print this (the least significant) digit
putch("0123456789abcdef"[mod], putdat);
8008f3: 8b 45 d8 mov -0x28(%ebp),%eax
8008f6: 05 c4 10 80 00 add $0x8010c4,%eax
8008fb: 0f b6 00 movzbl (%eax),%eax
8008fe: 0f be c0 movsbl %al,%eax
800901: 83 ec 08 sub $0x8,%esp
800904: ff 75 0c pushl 0xc(%ebp)
800907: 50 push %eax
800908: 8b 45 08 mov 0x8(%ebp),%eax
80090b: ff d0 call *%eax
80090d: 83 c4 10 add $0x10,%esp
}
800910: 90 nop
800911: c9 leave
800912: c3 ret
00800913 <getuint>:
* getuint - get an unsigned int of various possible sizes from a varargs list
* @ap: a varargs list pointer
* @lflag: determines the size of the vararg that @ap points to
* */
static unsigned long long
getuint(va_list *ap, int lflag) {
800913: 55 push %ebp
800914: 89 e5 mov %esp,%ebp
if (lflag >= 2) {
800916: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
80091a: 7e 14 jle 800930 <getuint+0x1d>
return va_arg(*ap, unsigned long long);
80091c: 8b 45 08 mov 0x8(%ebp),%eax
80091f: 8b 00 mov (%eax),%eax
800921: 8d 48 08 lea 0x8(%eax),%ecx
800924: 8b 55 08 mov 0x8(%ebp),%edx
800927: 89 0a mov %ecx,(%edx)
800929: 8b 50 04 mov 0x4(%eax),%edx
80092c: 8b 00 mov (%eax),%eax
80092e: eb 30 jmp 800960 <getuint+0x4d>
}
else if (lflag) {
800930: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800934: 74 16 je 80094c <getuint+0x39>
return va_arg(*ap, unsigned long);
800936: 8b 45 08 mov 0x8(%ebp),%eax
800939: 8b 00 mov (%eax),%eax
80093b: 8d 48 04 lea 0x4(%eax),%ecx
80093e: 8b 55 08 mov 0x8(%ebp),%edx
800941: 89 0a mov %ecx,(%edx)
800943: 8b 00 mov (%eax),%eax
800945: ba 00 00 00 00 mov $0x0,%edx
80094a: eb 14 jmp 800960 <getuint+0x4d>
}
else {
return va_arg(*ap, unsigned int);
80094c: 8b 45 08 mov 0x8(%ebp),%eax
80094f: 8b 00 mov (%eax),%eax
800951: 8d 48 04 lea 0x4(%eax),%ecx
800954: 8b 55 08 mov 0x8(%ebp),%edx
800957: 89 0a mov %ecx,(%edx)
800959: 8b 00 mov (%eax),%eax
80095b: ba 00 00 00 00 mov $0x0,%edx
}
}
800960: 5d pop %ebp
800961: c3 ret
00800962 <getint>:
* getint - same as getuint but signed, we can't use getuint because of sign extension
* @ap: a varargs list pointer
* @lflag: determines the size of the vararg that @ap points to
* */
static long long
getint(va_list *ap, int lflag) {
800962: 55 push %ebp
800963: 89 e5 mov %esp,%ebp
if (lflag >= 2) {
800965: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
800969: 7e 14 jle 80097f <getint+0x1d>
return va_arg(*ap, long long);
80096b: 8b 45 08 mov 0x8(%ebp),%eax
80096e: 8b 00 mov (%eax),%eax
800970: 8d 48 08 lea 0x8(%eax),%ecx
800973: 8b 55 08 mov 0x8(%ebp),%edx
800976: 89 0a mov %ecx,(%edx)
800978: 8b 50 04 mov 0x4(%eax),%edx
80097b: 8b 00 mov (%eax),%eax
80097d: eb 28 jmp 8009a7 <getint+0x45>
}
else if (lflag) {
80097f: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800983: 74 12 je 800997 <getint+0x35>
return va_arg(*ap, long);
800985: 8b 45 08 mov 0x8(%ebp),%eax
800988: 8b 00 mov (%eax),%eax
80098a: 8d 48 04 lea 0x4(%eax),%ecx
80098d: 8b 55 08 mov 0x8(%ebp),%edx
800990: 89 0a mov %ecx,(%edx)
800992: 8b 00 mov (%eax),%eax
800994: 99 cltd
800995: eb 10 jmp 8009a7 <getint+0x45>
}
else {
return va_arg(*ap, int);
800997: 8b 45 08 mov 0x8(%ebp),%eax
80099a: 8b 00 mov (%eax),%eax
80099c: 8d 48 04 lea 0x4(%eax),%ecx
80099f: 8b 55 08 mov 0x8(%ebp),%edx
8009a2: 89 0a mov %ecx,(%edx)
8009a4: 8b 00 mov (%eax),%eax
8009a6: 99 cltd
}
}
8009a7: 5d pop %ebp
8009a8: c3 ret
008009a9 <printfmt>:
* @putch: specified putch function, print a single character
* @putdat: used by @putch function
* @fmt: the format string to use
* */
void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
8009a9: 55 push %ebp
8009aa: 89 e5 mov %esp,%ebp
8009ac: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
8009af: 8d 45 14 lea 0x14(%ebp),%eax
8009b2: 89 45 f4 mov %eax,-0xc(%ebp)
vprintfmt(putch, putdat, fmt, ap);
8009b5: 8b 45 f4 mov -0xc(%ebp),%eax
8009b8: 50 push %eax
8009b9: ff 75 10 pushl 0x10(%ebp)
8009bc: ff 75 0c pushl 0xc(%ebp)
8009bf: ff 75 08 pushl 0x8(%ebp)
8009c2: e8 06 00 00 00 call 8009cd <vprintfmt>
8009c7: 83 c4 10 add $0x10,%esp
va_end(ap);
}
8009ca: 90 nop
8009cb: c9 leave
8009cc: c3 ret
008009cd <vprintfmt>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want printfmt() instead.
* */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
8009cd: 55 push %ebp
8009ce: 89 e5 mov %esp,%ebp
8009d0: 56 push %esi
8009d1: 53 push %ebx
8009d2: 83 ec 20 sub $0x20,%esp
register int ch, err;
unsigned long long num;
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
8009d5: eb 17 jmp 8009ee <vprintfmt+0x21>
if (ch == '\0') {
8009d7: 85 db test %ebx,%ebx
8009d9: 0f 84 8e 03 00 00 je 800d6d <vprintfmt+0x3a0>
return;
}
putch(ch, putdat);
8009df: 83 ec 08 sub $0x8,%esp
8009e2: ff 75 0c pushl 0xc(%ebp)
8009e5: 53 push %ebx
8009e6: 8b 45 08 mov 0x8(%ebp),%eax
8009e9: ff d0 call *%eax
8009eb: 83 c4 10 add $0x10,%esp
register int ch, err;
unsigned long long num;
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
8009ee: 8b 45 10 mov 0x10(%ebp),%eax
8009f1: 8d 50 01 lea 0x1(%eax),%edx
8009f4: 89 55 10 mov %edx,0x10(%ebp)
8009f7: 0f b6 00 movzbl (%eax),%eax
8009fa: 0f b6 d8 movzbl %al,%ebx
8009fd: 83 fb 25 cmp $0x25,%ebx
800a00: 75 d5 jne 8009d7 <vprintfmt+0xa>
}
putch(ch, putdat);
}
// Process a %-escape sequence
char padc = ' ';
800a02: c6 45 db 20 movb $0x20,-0x25(%ebp)
width = precision = -1;
800a06: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
800a0d: 8b 45 e4 mov -0x1c(%ebp),%eax
800a10: 89 45 e8 mov %eax,-0x18(%ebp)
lflag = altflag = 0;
800a13: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
800a1a: 8b 45 dc mov -0x24(%ebp),%eax
800a1d: 89 45 e0 mov %eax,-0x20(%ebp)
reswitch:
switch (ch = *(unsigned char *)fmt ++) {
800a20: 8b 45 10 mov 0x10(%ebp),%eax
800a23: 8d 50 01 lea 0x1(%eax),%edx
800a26: 89 55 10 mov %edx,0x10(%ebp)
800a29: 0f b6 00 movzbl (%eax),%eax
800a2c: 0f b6 d8 movzbl %al,%ebx
800a2f: 8d 43 dd lea -0x23(%ebx),%eax
800a32: 83 f8 55 cmp $0x55,%eax
800a35: 0f 87 05 03 00 00 ja 800d40 <vprintfmt+0x373>
800a3b: 8b 04 85 e8 10 80 00 mov 0x8010e8(,%eax,4),%eax
800a42: ff e0 jmp *%eax
// flag to pad on the right
case '-':
padc = '-';
800a44: c6 45 db 2d movb $0x2d,-0x25(%ebp)
goto reswitch;
800a48: eb d6 jmp 800a20 <vprintfmt+0x53>
// flag to pad with 0's instead of spaces
case '0':
padc = '0';
800a4a: c6 45 db 30 movb $0x30,-0x25(%ebp)
goto reswitch;
800a4e: eb d0 jmp 800a20 <vprintfmt+0x53>
// width field
case '1' ... '9':
for (precision = 0; ; ++ fmt) {
800a50: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
800a57: 8b 55 e4 mov -0x1c(%ebp),%edx
800a5a: 89 d0 mov %edx,%eax
800a5c: c1 e0 02 shl $0x2,%eax
800a5f: 01 d0 add %edx,%eax
800a61: 01 c0 add %eax,%eax
800a63: 01 d8 add %ebx,%eax
800a65: 83 e8 30 sub $0x30,%eax
800a68: 89 45 e4 mov %eax,-0x1c(%ebp)
ch = *fmt;
800a6b: 8b 45 10 mov 0x10(%ebp),%eax
800a6e: 0f b6 00 movzbl (%eax),%eax
800a71: 0f be d8 movsbl %al,%ebx
if (ch < '0' || ch > '9') {
800a74: 83 fb 2f cmp $0x2f,%ebx
800a77: 7e 39 jle 800ab2 <vprintfmt+0xe5>
800a79: 83 fb 39 cmp $0x39,%ebx
800a7c: 7f 34 jg 800ab2 <vprintfmt+0xe5>
padc = '0';
goto reswitch;
// width field
case '1' ... '9':
for (precision = 0; ; ++ fmt) {
800a7e: 83 45 10 01 addl $0x1,0x10(%ebp)
precision = precision * 10 + ch - '0';
ch = *fmt;
if (ch < '0' || ch > '9') {
break;
}
}
800a82: eb d3 jmp 800a57 <vprintfmt+0x8a>
goto process_precision;
case '*':
precision = va_arg(ap, int);
800a84: 8b 45 14 mov 0x14(%ebp),%eax
800a87: 8d 50 04 lea 0x4(%eax),%edx
800a8a: 89 55 14 mov %edx,0x14(%ebp)
800a8d: 8b 00 mov (%eax),%eax
800a8f: 89 45 e4 mov %eax,-0x1c(%ebp)
goto process_precision;
800a92: eb 1f jmp 800ab3 <vprintfmt+0xe6>
case '.':
if (width < 0)
800a94: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800a98: 79 86 jns 800a20 <vprintfmt+0x53>
width = 0;
800a9a: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
goto reswitch;
800aa1: e9 7a ff ff ff jmp 800a20 <vprintfmt+0x53>
case '#':
altflag = 1;
800aa6: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp)
goto reswitch;
800aad: e9 6e ff ff ff jmp 800a20 <vprintfmt+0x53>
ch = *fmt;
if (ch < '0' || ch > '9') {
break;
}
}
goto process_precision;
800ab2: 90 nop
case '#':
altflag = 1;
goto reswitch;
process_precision:
if (width < 0)
800ab3: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800ab7: 0f 89 63 ff ff ff jns 800a20 <vprintfmt+0x53>
width = precision, precision = -1;
800abd: 8b 45 e4 mov -0x1c(%ebp),%eax
800ac0: 89 45 e8 mov %eax,-0x18(%ebp)
800ac3: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
goto reswitch;
800aca: e9 51 ff ff ff jmp 800a20 <vprintfmt+0x53>
// long flag (doubled for long long)
case 'l':
lflag ++;
800acf: 83 45 e0 01 addl $0x1,-0x20(%ebp)
goto reswitch;
800ad3: e9 48 ff ff ff jmp 800a20 <vprintfmt+0x53>
// character
case 'c':
putch(va_arg(ap, int), putdat);
800ad8: 8b 45 14 mov 0x14(%ebp),%eax
800adb: 8d 50 04 lea 0x4(%eax),%edx
800ade: 89 55 14 mov %edx,0x14(%ebp)
800ae1: 8b 00 mov (%eax),%eax
800ae3: 83 ec 08 sub $0x8,%esp
800ae6: ff 75 0c pushl 0xc(%ebp)
800ae9: 50 push %eax
800aea: 8b 45 08 mov 0x8(%ebp),%eax
800aed: ff d0 call *%eax
800aef: 83 c4 10 add $0x10,%esp
break;
800af2: e9 71 02 00 00 jmp 800d68 <vprintfmt+0x39b>
// error message
case 'e':
err = va_arg(ap, int);
800af7: 8b 45 14 mov 0x14(%ebp),%eax
800afa: 8d 50 04 lea 0x4(%eax),%edx
800afd: 89 55 14 mov %edx,0x14(%ebp)
800b00: 8b 18 mov (%eax),%ebx
if (err < 0) {
800b02: 85 db test %ebx,%ebx
800b04: 79 02 jns 800b08 <vprintfmt+0x13b>
err = -err;
800b06: f7 db neg %ebx
}
if (err > MAXERROR || (p = error_string[err]) == NULL) {
800b08: 83 fb 18 cmp $0x18,%ebx
800b0b: 7f 0b jg 800b18 <vprintfmt+0x14b>
800b0d: 8b 34 9d 60 10 80 00 mov 0x801060(,%ebx,4),%esi
800b14: 85 f6 test %esi,%esi
800b16: 75 19 jne 800b31 <vprintfmt+0x164>
printfmt(putch, putdat, "error %d", err);
800b18: 53 push %ebx
800b19: 68 d5 10 80 00 push $0x8010d5
800b1e: ff 75 0c pushl 0xc(%ebp)
800b21: ff 75 08 pushl 0x8(%ebp)
800b24: e8 80 fe ff ff call 8009a9 <printfmt>
800b29: 83 c4 10 add $0x10,%esp
}
else {
printfmt(putch, putdat, "%s", p);
}
break;
800b2c: e9 37 02 00 00 jmp 800d68 <vprintfmt+0x39b>
}
if (err > MAXERROR || (p = error_string[err]) == NULL) {
printfmt(putch, putdat, "error %d", err);
}
else {
printfmt(putch, putdat, "%s", p);
800b31: 56 push %esi
800b32: 68 de 10 80 00 push $0x8010de
800b37: ff 75 0c pushl 0xc(%ebp)
800b3a: ff 75 08 pushl 0x8(%ebp)
800b3d: e8 67 fe ff ff call 8009a9 <printfmt>
800b42: 83 c4 10 add $0x10,%esp
}
break;
800b45: e9 1e 02 00 00 jmp 800d68 <vprintfmt+0x39b>
// string
case 's':
if ((p = va_arg(ap, char *)) == NULL) {
800b4a: 8b 45 14 mov 0x14(%ebp),%eax
800b4d: 8d 50 04 lea 0x4(%eax),%edx
800b50: 89 55 14 mov %edx,0x14(%ebp)
800b53: 8b 30 mov (%eax),%esi
800b55: 85 f6 test %esi,%esi
800b57: 75 05 jne 800b5e <vprintfmt+0x191>
p = "(null)";
800b59: be e1 10 80 00 mov $0x8010e1,%esi
}
if (width > 0 && padc != '-') {
800b5e: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800b62: 7e 76 jle 800bda <vprintfmt+0x20d>
800b64: 80 7d db 2d cmpb $0x2d,-0x25(%ebp)
800b68: 74 70 je 800bda <vprintfmt+0x20d>
for (width -= strnlen(p, precision); width > 0; width --) {
800b6a: 8b 45 e4 mov -0x1c(%ebp),%eax
800b6d: 83 ec 08 sub $0x8,%esp
800b70: 50 push %eax
800b71: 56 push %esi
800b72: e8 17 f8 ff ff call 80038e <strnlen>
800b77: 83 c4 10 add $0x10,%esp
800b7a: 89 c2 mov %eax,%edx
800b7c: 8b 45 e8 mov -0x18(%ebp),%eax
800b7f: 29 d0 sub %edx,%eax
800b81: 89 45 e8 mov %eax,-0x18(%ebp)
800b84: eb 17 jmp 800b9d <vprintfmt+0x1d0>
putch(padc, putdat);
800b86: 0f be 45 db movsbl -0x25(%ebp),%eax
800b8a: 83 ec 08 sub $0x8,%esp
800b8d: ff 75 0c pushl 0xc(%ebp)
800b90: 50 push %eax
800b91: 8b 45 08 mov 0x8(%ebp),%eax
800b94: ff d0 call *%eax
800b96: 83 c4 10 add $0x10,%esp
case 's':
if ((p = va_arg(ap, char *)) == NULL) {
p = "(null)";
}
if (width > 0 && padc != '-') {
for (width -= strnlen(p, precision); width > 0; width --) {
800b99: 83 6d e8 01 subl $0x1,-0x18(%ebp)
800b9d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800ba1: 7f e3 jg 800b86 <vprintfmt+0x1b9>
putch(padc, putdat);
}
}
for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
800ba3: eb 35 jmp 800bda <vprintfmt+0x20d>
if (altflag && (ch < ' ' || ch > '~')) {
800ba5: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
800ba9: 74 1c je 800bc7 <vprintfmt+0x1fa>
800bab: 83 fb 1f cmp $0x1f,%ebx
800bae: 7e 05 jle 800bb5 <vprintfmt+0x1e8>
800bb0: 83 fb 7e cmp $0x7e,%ebx
800bb3: 7e 12 jle 800bc7 <vprintfmt+0x1fa>
putch('?', putdat);
800bb5: 83 ec 08 sub $0x8,%esp
800bb8: ff 75 0c pushl 0xc(%ebp)
800bbb: 6a 3f push $0x3f
800bbd: 8b 45 08 mov 0x8(%ebp),%eax
800bc0: ff d0 call *%eax
800bc2: 83 c4 10 add $0x10,%esp
800bc5: eb 0f jmp 800bd6 <vprintfmt+0x209>
}
else {
putch(ch, putdat);
800bc7: 83 ec 08 sub $0x8,%esp
800bca: ff 75 0c pushl 0xc(%ebp)
800bcd: 53 push %ebx
800bce: 8b 45 08 mov 0x8(%ebp),%eax
800bd1: ff d0 call *%eax
800bd3: 83 c4 10 add $0x10,%esp
if (width > 0 && padc != '-') {
for (width -= strnlen(p, precision); width > 0; width --) {
putch(padc, putdat);
}
}
for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
800bd6: 83 6d e8 01 subl $0x1,-0x18(%ebp)
800bda: 89 f0 mov %esi,%eax
800bdc: 8d 70 01 lea 0x1(%eax),%esi
800bdf: 0f b6 00 movzbl (%eax),%eax
800be2: 0f be d8 movsbl %al,%ebx
800be5: 85 db test %ebx,%ebx
800be7: 74 26 je 800c0f <vprintfmt+0x242>
800be9: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
800bed: 78 b6 js 800ba5 <vprintfmt+0x1d8>
800bef: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
800bf3: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
800bf7: 79 ac jns 800ba5 <vprintfmt+0x1d8>
}
else {
putch(ch, putdat);
}
}
for (; width > 0; width --) {
800bf9: eb 14 jmp 800c0f <vprintfmt+0x242>
putch(' ', putdat);
800bfb: 83 ec 08 sub $0x8,%esp
800bfe: ff 75 0c pushl 0xc(%ebp)
800c01: 6a 20 push $0x20
800c03: 8b 45 08 mov 0x8(%ebp),%eax
800c06: ff d0 call *%eax
800c08: 83 c4 10 add $0x10,%esp
}
else {
putch(ch, putdat);
}
}
for (; width > 0; width --) {
800c0b: 83 6d e8 01 subl $0x1,-0x18(%ebp)
800c0f: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800c13: 7f e6 jg 800bfb <vprintfmt+0x22e>
putch(' ', putdat);
}
break;
800c15: e9 4e 01 00 00 jmp 800d68 <vprintfmt+0x39b>
// (signed) decimal
case 'd':
num = getint(&ap, lflag);
800c1a: 83 ec 08 sub $0x8,%esp
800c1d: ff 75 e0 pushl -0x20(%ebp)
800c20: 8d 45 14 lea 0x14(%ebp),%eax
800c23: 50 push %eax
800c24: e8 39 fd ff ff call 800962 <getint>
800c29: 83 c4 10 add $0x10,%esp
800c2c: 89 45 f0 mov %eax,-0x10(%ebp)
800c2f: 89 55 f4 mov %edx,-0xc(%ebp)
if ((long long)num < 0) {
800c32: 8b 45 f0 mov -0x10(%ebp),%eax
800c35: 8b 55 f4 mov -0xc(%ebp),%edx
800c38: 85 d2 test %edx,%edx
800c3a: 79 23 jns 800c5f <vprintfmt+0x292>
putch('-', putdat);
800c3c: 83 ec 08 sub $0x8,%esp
800c3f: ff 75 0c pushl 0xc(%ebp)
800c42: 6a 2d push $0x2d
800c44: 8b 45 08 mov 0x8(%ebp),%eax
800c47: ff d0 call *%eax
800c49: 83 c4 10 add $0x10,%esp
num = -(long long)num;
800c4c: 8b 45 f0 mov -0x10(%ebp),%eax
800c4f: 8b 55 f4 mov -0xc(%ebp),%edx
800c52: f7 d8 neg %eax
800c54: 83 d2 00 adc $0x0,%edx
800c57: f7 da neg %edx
800c59: 89 45 f0 mov %eax,-0x10(%ebp)
800c5c: 89 55 f4 mov %edx,-0xc(%ebp)
}
base = 10;
800c5f: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
800c66: e9 9f 00 00 00 jmp 800d0a <vprintfmt+0x33d>
// unsigned decimal
case 'u':
num = getuint(&ap, lflag);
800c6b: 83 ec 08 sub $0x8,%esp
800c6e: ff 75 e0 pushl -0x20(%ebp)
800c71: 8d 45 14 lea 0x14(%ebp),%eax
800c74: 50 push %eax
800c75: e8 99 fc ff ff call 800913 <getuint>
800c7a: 83 c4 10 add $0x10,%esp
800c7d: 89 45 f0 mov %eax,-0x10(%ebp)
800c80: 89 55 f4 mov %edx,-0xc(%ebp)
base = 10;
800c83: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
800c8a: eb 7e jmp 800d0a <vprintfmt+0x33d>
// (unsigned) octal
case 'o':
num = getuint(&ap, lflag);
800c8c: 83 ec 08 sub $0x8,%esp
800c8f: ff 75 e0 pushl -0x20(%ebp)
800c92: 8d 45 14 lea 0x14(%ebp),%eax
800c95: 50 push %eax
800c96: e8 78 fc ff ff call 800913 <getuint>
800c9b: 83 c4 10 add $0x10,%esp
800c9e: 89 45 f0 mov %eax,-0x10(%ebp)
800ca1: 89 55 f4 mov %edx,-0xc(%ebp)
base = 8;
800ca4: c7 45 ec 08 00 00 00 movl $0x8,-0x14(%ebp)
goto number;
800cab: eb 5d jmp 800d0a <vprintfmt+0x33d>
// pointer
case 'p':
putch('0', putdat);
800cad: 83 ec 08 sub $0x8,%esp
800cb0: ff 75 0c pushl 0xc(%ebp)
800cb3: 6a 30 push $0x30
800cb5: 8b 45 08 mov 0x8(%ebp),%eax
800cb8: ff d0 call *%eax
800cba: 83 c4 10 add $0x10,%esp
putch('x', putdat);
800cbd: 83 ec 08 sub $0x8,%esp
800cc0: ff 75 0c pushl 0xc(%ebp)
800cc3: 6a 78 push $0x78
800cc5: 8b 45 08 mov 0x8(%ebp),%eax
800cc8: ff d0 call *%eax
800cca: 83 c4 10 add $0x10,%esp
num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
800ccd: 8b 45 14 mov 0x14(%ebp),%eax
800cd0: 8d 50 04 lea 0x4(%eax),%edx
800cd3: 89 55 14 mov %edx,0x14(%ebp)
800cd6: 8b 00 mov (%eax),%eax
800cd8: 89 45 f0 mov %eax,-0x10(%ebp)
800cdb: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
base = 16;
800ce2: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
goto number;
800ce9: eb 1f jmp 800d0a <vprintfmt+0x33d>
// (unsigned) hexadecimal
case 'x':
num = getuint(&ap, lflag);
800ceb: 83 ec 08 sub $0x8,%esp
800cee: ff 75 e0 pushl -0x20(%ebp)
800cf1: 8d 45 14 lea 0x14(%ebp),%eax
800cf4: 50 push %eax
800cf5: e8 19 fc ff ff call 800913 <getuint>
800cfa: 83 c4 10 add $0x10,%esp
800cfd: 89 45 f0 mov %eax,-0x10(%ebp)
800d00: 89 55 f4 mov %edx,-0xc(%ebp)
base = 16;
800d03: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
number:
printnum(putch, putdat, num, base, width, padc);
800d0a: 0f be 55 db movsbl -0x25(%ebp),%edx
800d0e: 8b 45 ec mov -0x14(%ebp),%eax
800d11: 83 ec 04 sub $0x4,%esp
800d14: 52 push %edx
800d15: ff 75 e8 pushl -0x18(%ebp)
800d18: 50 push %eax
800d19: ff 75 f4 pushl -0xc(%ebp)
800d1c: ff 75 f0 pushl -0x10(%ebp)
800d1f: ff 75 0c pushl 0xc(%ebp)
800d22: ff 75 08 pushl 0x8(%ebp)
800d25: e8 f8 fa ff ff call 800822 <printnum>
800d2a: 83 c4 20 add $0x20,%esp
break;
800d2d: eb 39 jmp 800d68 <vprintfmt+0x39b>
// escaped '%' character
case '%':
putch(ch, putdat);
800d2f: 83 ec 08 sub $0x8,%esp
800d32: ff 75 0c pushl 0xc(%ebp)
800d35: 53 push %ebx
800d36: 8b 45 08 mov 0x8(%ebp),%eax
800d39: ff d0 call *%eax
800d3b: 83 c4 10 add $0x10,%esp
break;
800d3e: eb 28 jmp 800d68 <vprintfmt+0x39b>
// unrecognized escape sequence - just print it literally
default:
putch('%', putdat);
800d40: 83 ec 08 sub $0x8,%esp
800d43: ff 75 0c pushl 0xc(%ebp)
800d46: 6a 25 push $0x25
800d48: 8b 45 08 mov 0x8(%ebp),%eax
800d4b: ff d0 call *%eax
800d4d: 83 c4 10 add $0x10,%esp
for (fmt --; fmt[-1] != '%'; fmt --)
800d50: 83 6d 10 01 subl $0x1,0x10(%ebp)
800d54: eb 04 jmp 800d5a <vprintfmt+0x38d>
800d56: 83 6d 10 01 subl $0x1,0x10(%ebp)
800d5a: 8b 45 10 mov 0x10(%ebp),%eax
800d5d: 83 e8 01 sub $0x1,%eax
800d60: 0f b6 00 movzbl (%eax),%eax
800d63: 3c 25 cmp $0x25,%al
800d65: 75 ef jne 800d56 <vprintfmt+0x389>
/* do nothing */;
break;
800d67: 90 nop
}
}
800d68: e9 68 fc ff ff jmp 8009d5 <vprintfmt+0x8>
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
if (ch == '\0') {
return;
800d6d: 90 nop
for (fmt --; fmt[-1] != '%'; fmt --)
/* do nothing */;
break;
}
}
}
800d6e: 8d 65 f8 lea -0x8(%ebp),%esp
800d71: 5b pop %ebx
800d72: 5e pop %esi
800d73: 5d pop %ebp
800d74: c3 ret
00800d75 <sprintputch>:
* sprintputch - 'print' a single character in a buffer
* @ch: the character will be printed
* @b: the buffer to place the character @ch
* */
static void
sprintputch(int ch, struct sprintbuf *b) {
800d75: 55 push %ebp
800d76: 89 e5 mov %esp,%ebp
b->cnt ++;
800d78: 8b 45 0c mov 0xc(%ebp),%eax
800d7b: 8b 40 08 mov 0x8(%eax),%eax
800d7e: 8d 50 01 lea 0x1(%eax),%edx
800d81: 8b 45 0c mov 0xc(%ebp),%eax
800d84: 89 50 08 mov %edx,0x8(%eax)
if (b->buf < b->ebuf) {
800d87: 8b 45 0c mov 0xc(%ebp),%eax
800d8a: 8b 10 mov (%eax),%edx
800d8c: 8b 45 0c mov 0xc(%ebp),%eax
800d8f: 8b 40 04 mov 0x4(%eax),%eax
800d92: 39 c2 cmp %eax,%edx
800d94: 73 12 jae 800da8 <sprintputch+0x33>
*b->buf ++ = ch;
800d96: 8b 45 0c mov 0xc(%ebp),%eax
800d99: 8b 00 mov (%eax),%eax
800d9b: 8d 48 01 lea 0x1(%eax),%ecx
800d9e: 8b 55 0c mov 0xc(%ebp),%edx
800da1: 89 0a mov %ecx,(%edx)
800da3: 8b 55 08 mov 0x8(%ebp),%edx
800da6: 88 10 mov %dl,(%eax)
}
}
800da8: 90 nop
800da9: 5d pop %ebp
800daa: c3 ret
00800dab <snprintf>:
* @str: the buffer to place the result into
* @size: the size of buffer, including the trailing null space
* @fmt: the format string to use
* */
int
snprintf(char *str, size_t size, const char *fmt, ...) {
800dab: 55 push %ebp
800dac: 89 e5 mov %esp,%ebp
800dae: 83 ec 18 sub $0x18,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
800db1: 8d 45 14 lea 0x14(%ebp),%eax
800db4: 89 45 f0 mov %eax,-0x10(%ebp)
cnt = vsnprintf(str, size, fmt, ap);
800db7: 8b 45 f0 mov -0x10(%ebp),%eax
800dba: 50 push %eax
800dbb: ff 75 10 pushl 0x10(%ebp)
800dbe: ff 75 0c pushl 0xc(%ebp)
800dc1: ff 75 08 pushl 0x8(%ebp)
800dc4: e8 0b 00 00 00 call 800dd4 <vsnprintf>
800dc9: 83 c4 10 add $0x10,%esp
800dcc: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return cnt;
800dcf: 8b 45 f4 mov -0xc(%ebp),%eax
}
800dd2: c9 leave
800dd3: c3 ret
00800dd4 <vsnprintf>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want snprintf() instead.
* */
int
vsnprintf(char *str, size_t size, const char *fmt, va_list ap) {
800dd4: 55 push %ebp
800dd5: 89 e5 mov %esp,%ebp
800dd7: 83 ec 18 sub $0x18,%esp
struct sprintbuf b = {str, str + size - 1, 0};
800dda: 8b 45 08 mov 0x8(%ebp),%eax
800ddd: 89 45 ec mov %eax,-0x14(%ebp)
800de0: 8b 45 0c mov 0xc(%ebp),%eax
800de3: 8d 50 ff lea -0x1(%eax),%edx
800de6: 8b 45 08 mov 0x8(%ebp),%eax
800de9: 01 d0 add %edx,%eax
800deb: 89 45 f0 mov %eax,-0x10(%ebp)
800dee: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (str == NULL || b.buf > b.ebuf) {
800df5: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
800df9: 74 0a je 800e05 <vsnprintf+0x31>
800dfb: 8b 55 ec mov -0x14(%ebp),%edx
800dfe: 8b 45 f0 mov -0x10(%ebp),%eax
800e01: 39 c2 cmp %eax,%edx
800e03: 76 07 jbe 800e0c <vsnprintf+0x38>
return -E_INVAL;
800e05: b8 fd ff ff ff mov $0xfffffffd,%eax
800e0a: eb 20 jmp 800e2c <vsnprintf+0x58>
}
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
800e0c: ff 75 14 pushl 0x14(%ebp)
800e0f: ff 75 10 pushl 0x10(%ebp)
800e12: 8d 45 ec lea -0x14(%ebp),%eax
800e15: 50 push %eax
800e16: 68 75 0d 80 00 push $0x800d75
800e1b: e8 ad fb ff ff call 8009cd <vprintfmt>
800e20: 83 c4 10 add $0x10,%esp
// null terminate the buffer
*b.buf = '\0';
800e23: 8b 45 ec mov -0x14(%ebp),%eax
800e26: c6 00 00 movb $0x0,(%eax)
return b.cnt;
800e29: 8b 45 f4 mov -0xc(%ebp),%eax
}
800e2c: c9 leave
800e2d: c3 ret
00800e2e <hash32>:
* @bits: the number of bits in a return value
*
* High bits are more random, so we use them.
* */
uint32_t
hash32(uint32_t val, unsigned int bits) {
800e2e: 55 push %ebp
800e2f: 89 e5 mov %esp,%ebp
800e31: 83 ec 10 sub $0x10,%esp
uint32_t hash = val * GOLDEN_RATIO_PRIME_32;
800e34: 8b 45 08 mov 0x8(%ebp),%eax
800e37: 69 c0 01 00 37 9e imul $0x9e370001,%eax,%eax
800e3d: 89 45 fc mov %eax,-0x4(%ebp)
return (hash >> (32 - bits));
800e40: b8 20 00 00 00 mov $0x20,%eax
800e45: 2b 45 0c sub 0xc(%ebp),%eax
800e48: 8b 55 fc mov -0x4(%ebp),%edx
800e4b: 89 c1 mov %eax,%ecx
800e4d: d3 ea shr %cl,%edx
800e4f: 89 d0 mov %edx,%eax
}
800e51: c9 leave
800e52: c3 ret
00800e53 <rand>:
* rand - returns a pseudo-random integer
*
* The rand() function return a value in the range [0, RAND_MAX].
* */
int
rand(void) {
800e53: 55 push %ebp
800e54: 89 e5 mov %esp,%ebp
800e56: 57 push %edi
800e57: 56 push %esi
800e58: 53 push %ebx
800e59: 83 ec 24 sub $0x24,%esp
next = (next * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1);
800e5c: a1 00 20 80 00 mov 0x802000,%eax
800e61: 8b 15 04 20 80 00 mov 0x802004,%edx
800e67: 69 fa 6d e6 ec de imul $0xdeece66d,%edx,%edi
800e6d: 6b f0 05 imul $0x5,%eax,%esi
800e70: 01 fe add %edi,%esi
800e72: bf 6d e6 ec de mov $0xdeece66d,%edi
800e77: f7 e7 mul %edi
800e79: 01 d6 add %edx,%esi
800e7b: 89 f2 mov %esi,%edx
800e7d: 83 c0 0b add $0xb,%eax
800e80: 83 d2 00 adc $0x0,%edx
800e83: 89 c7 mov %eax,%edi
800e85: 83 e7 ff and $0xffffffff,%edi
800e88: 89 f9 mov %edi,%ecx
800e8a: 0f b7 da movzwl %dx,%ebx
800e8d: 89 0d 00 20 80 00 mov %ecx,0x802000
800e93: 89 1d 04 20 80 00 mov %ebx,0x802004
unsigned long long result = (next >> 12);
800e99: a1 00 20 80 00 mov 0x802000,%eax
800e9e: 8b 15 04 20 80 00 mov 0x802004,%edx
800ea4: 0f ac d0 0c shrd $0xc,%edx,%eax
800ea8: c1 ea 0c shr $0xc,%edx
800eab: 89 45 e0 mov %eax,-0x20(%ebp)
800eae: 89 55 e4 mov %edx,-0x1c(%ebp)
return (int)do_div(result, RAND_MAX + 1);
800eb1: c7 45 dc 00 00 00 80 movl $0x80000000,-0x24(%ebp)
800eb8: 8b 45 e0 mov -0x20(%ebp),%eax
800ebb: 8b 55 e4 mov -0x1c(%ebp),%edx
800ebe: 89 45 d8 mov %eax,-0x28(%ebp)
800ec1: 89 55 e8 mov %edx,-0x18(%ebp)
800ec4: 8b 45 e8 mov -0x18(%ebp),%eax
800ec7: 89 45 ec mov %eax,-0x14(%ebp)
800eca: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
800ece: 74 1c je 800eec <rand+0x99>
800ed0: 8b 45 e8 mov -0x18(%ebp),%eax
800ed3: ba 00 00 00 00 mov $0x0,%edx
800ed8: f7 75 dc divl -0x24(%ebp)
800edb: 89 55 ec mov %edx,-0x14(%ebp)
800ede: 8b 45 e8 mov -0x18(%ebp),%eax
800ee1: ba 00 00 00 00 mov $0x0,%edx
800ee6: f7 75 dc divl -0x24(%ebp)
800ee9: 89 45 e8 mov %eax,-0x18(%ebp)
800eec: 8b 45 d8 mov -0x28(%ebp),%eax
800eef: 8b 55 ec mov -0x14(%ebp),%edx
800ef2: f7 75 dc divl -0x24(%ebp)
800ef5: 89 45 d8 mov %eax,-0x28(%ebp)
800ef8: 89 55 d4 mov %edx,-0x2c(%ebp)
800efb: 8b 45 d8 mov -0x28(%ebp),%eax
800efe: 8b 55 e8 mov -0x18(%ebp),%edx
800f01: 89 45 e0 mov %eax,-0x20(%ebp)
800f04: 89 55 e4 mov %edx,-0x1c(%ebp)
800f07: 8b 45 d4 mov -0x2c(%ebp),%eax
}
800f0a: 83 c4 24 add $0x24,%esp
800f0d: 5b pop %ebx
800f0e: 5e pop %esi
800f0f: 5f pop %edi
800f10: 5d pop %ebp
800f11: c3 ret
00800f12 <srand>:
/* *
* srand - seed the random number generator with the given number
* @seed: the required seed number
* */
void
srand(unsigned int seed) {
800f12: 55 push %ebp
800f13: 89 e5 mov %esp,%ebp
next = seed;
800f15: 8b 45 08 mov 0x8(%ebp),%eax
800f18: ba 00 00 00 00 mov $0x0,%edx
800f1d: a3 00 20 80 00 mov %eax,0x802000
800f22: 89 15 04 20 80 00 mov %edx,0x802004
}
800f28: 90 nop
800f29: 5d pop %ebp
800f2a: c3 ret
00800f2b <main>:
#include <ulib.h>
/* try to load the kernel's TSS selector into the DS register */
int
main(void) {
800f2b: 8d 4c 24 04 lea 0x4(%esp),%ecx
800f2f: 83 e4 f0 and $0xfffffff0,%esp
800f32: ff 71 fc pushl -0x4(%ecx)
800f35: 55 push %ebp
800f36: 89 e5 mov %esp,%ebp
800f38: 51 push %ecx
800f39: 83 ec 04 sub $0x4,%esp
asm volatile("movw $0x28,%ax; movw %ax,%ds");
800f3c: 66 b8 28 00 mov $0x28,%ax
800f40: 8e d8 mov %eax,%ds
panic("FAIL: T.T\n");
800f42: 83 ec 04 sub $0x4,%esp
800f45: 68 40 12 80 00 push $0x801240
800f4a: 6a 09 push $0x9
800f4c: 68 4b 12 80 00 push $0x80124b
800f51: e8 ca f0 ff ff call 800020 <__panic>
|
; A184116: n + floor(5*sqrt(n)).
; 8,10,13,15,17,19,21,23,24,26,28,30,31,33,35,36,38,39,41,42,44,45,47,49,50,51,53,54,56,57,59,60,62,63,65,66,67,69,70,72,73,74,76,77,78,80,81,83,84,85,87,88,89,91,92,93,95,96,97,99,100,101,103,104,105,106,108,109,110,112,113,114,116,117,118,119,121,122,123,125,126,127,128,130,131,132,133,135,136,137,138,140,141,142,143,145,146,147,149,150
add $0,1
seq $0,184104 ; n+floor(5*sqrt(n)); complement of A184105.
sub $0,1
|
; A024065: a(n) = 6^n - n^3.
; 1,5,28,189,1232,7651,46440,279593,1679104,10076967,60465176,362795725,2176780608,13060691819,78364161352,470184981201,2821109903360,16926659439823,101559956662584,609359740003637,3656158440054976,21936950640368595,131621703842256488,789730223053590649,4738381338321603072,28430288029929685751,170581728179578190680,1023490369077469229853,6140942214464815475264,36845653286788892958907,221073919720733357872776,1326443518324400147368865,7958661109946400884359168,47751966659678405306315679
mov $2,$0
mov $0,6
pow $0,$2
pow $2,3
sub $0,$2
|
#ifndef __MOJIE_SKILL_IMPL_HPP__
#define __MOJIE_SKILL_IMPL_HPP__
#include "skill/skillbase.hpp"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MojieSkill70 : public SkillBase
{
public:
MojieSkill70() : SkillBase(SKILL_TYPE_ACTIVE, true, true) {}
virtual ~MojieSkill70() {}
virtual bool LoadConfig(const char *dir, std::string *err){return true;};
virtual void Perform(Character *chara, int level, Character *target, const Posi &pos, int special_param = 0) const;
virtual const char * GetSkillName() { return "s70"; }
};
class MojieSkill71 : public SkillBase
{
public:
MojieSkill71() : SkillBase(SKILL_TYPE_PASSIVE, true, true) {}
virtual ~MojieSkill71() {}
virtual bool LoadConfig(const char *dir, std::string *err){return true;};
virtual void Perform(Character *chara, int level, Character *target, const Posi &pos, int special_param = 0) const;
virtual const char * GetSkillName() { return "s71"; }
};
class MojieSkill72 : public SkillBase
{
public:
MojieSkill72() : SkillBase(SKILL_TYPE_PASSIVE, true, false) {}
virtual ~MojieSkill72() {}
virtual bool LoadConfig(const char *dir, std::string *err){return true;};
virtual void Perform(Character *chara, int level, Character *target, const Posi &pos, int special_param = 0) const;
virtual const char * GetSkillName() { return "s72"; }
};
class MojieSkill73 : public SkillBase
{
public:
MojieSkill73() : SkillBase(SKILL_TYPE_PASSIVE, true, false) {}
virtual ~MojieSkill73() {}
virtual bool LoadConfig(const char *dir, std::string *err){return true;};
virtual void Perform(Character *chara, int level, Character *target, const Posi &pos, int special_param = 0) const;
virtual const char * GetSkillName() { return "s73"; }
};
#endif // __MOJIE_SKILL_IMPL_HPP__
|
; A119272: Product of numerator and denominator in Stern-Brocot tree.
; Submitted by Christian Krause
; 0,0,1,2,2,3,6,6,3,4,10,15,12,12,15,10,4,5,14,24,21,28,40,35,20,20,35,40,28,21,24,14,5,6,18,33,30,44,65,60,36,45,84,104,77,70,88,63,30,30,63,88,70,77,104,84,45,36,60,65,44,30,33,18,6,7,22,42,39,60,90,85,52,70,133,168,126,119,152,112,55,66,144,209,170,198,273,228,126,117,204,234,165,130,154,99,42,42,99,154
mul $0,4
sub $0,5
mov $1,1
lpb $0
sub $0,1
div $0,2
sub $2,$3
mov $3,6
add $3,$0
div $3,2
mod $3,2
mov $4,$2
add $2,$1
mul $3,$4
mul $4,$1
add $1,$3
lpe
mov $0,$4
|
; A161983: Irregular triangle read by rows: the group of 2n + 1 integers starting at A014105(n).
; 0,3,4,5,10,11,12,13,14,21,22,23,24,25,26,27,36,37,38,39,40,41,42,43,44,55,56,57,58,59,60,61,62,63,64,65,78,79,80,81,82,83,84,85,86,87,88,89,90,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,136,137
mov $1,$0
lpb $1
sub $1,1
add $2,2
add $0,$2
trn $1,$2
lpe
|
/* scheme/make_sob_fract.asm
* Takes two numbers, a numinator and a denuminator as arguments, and places the corresponding Scheme object in R0
*
* Programmer: Mayer Goldberg, 2010
*/
MAKE_SOB_FRACT:
PUSH(FP);
MOV(FP, SP);
PUSH(IMM(3));
CALL(MALLOC);
DROP(1);
MOV(IND(R0), T_FRACT);
MOV(INDD(R0, 1), FPARG(0));
MOV(INDD(R0, 2), FPARG(1));
POP(FP);
RETURN;
|
section .text
align 4
global memset
; void *memset(void *addr, int c, size_t n);
; returns the input addr
memset:
; set up the stack frame
push ebp
mov ebp, esp
; save registers (we can only destroy EAX, ECX and EDX)
push ebx
push edi
; slosl: Fill (E)CX dwords at ES:[(E)DI] with EAX
; stosb: Fill (E)CX bytes at ES:[(E)DI] with AL
mov edi, [ebp + 8] ; param #1 (addr)
mov ebx, [ebp + 12] ; param #2 (character)
mov ecx, [ebp + 16] ; param #3 (length)
; push the first argument; it's our return value
push edi
; set up the value to write; since we should only use the lower 8 bits of it, we need to repeat it.
; i.e. the input may be 0x000000ab (meaning the user specified 0xab; the rest is padding for the int type used),
; meaning we want to write the dword 0xabababab.
; bl contains the bits to use and repeat.
and ebx, 0xff ; clear any other bits
xor eax, eax ; clear the target register
or eax, ebx ; add the lowest two bits, 0x000000YY
shl ebx, 8
or eax, ebx ; add 0x0000YY00 bits
shl ebx, 8
or eax, ebx ; add 0x00YY0000 bits
shl ebx, 8
or eax, ebx ; add 0xYY000000 bits
; eax should now contain the pattern we want (for stosd), e.g. 0xabababab for the input 0xab
; likewise, al should contain the pattern we want (for stosb)
push eax ; store the value (temporarily, while we calculate the number of dwords and bytes)
; Set ecx to the number of dwords to set
mov eax, ecx ; ecx = number of bytes to set
xor edx, edx ; clear edx before division
mov ebx, 4 ; div doesn't accept immediate operands
div ebx
mov ecx, eax ; len/4 dwords to copy (since each is 4 bytes!)
mov ebx, edx ; len%4 bytes left; store this in ebx for the moment
pop eax ; fetch the value to set into eax
rep stosd ; set the dwords
mov ecx, ebx ; ebx = number of bytes remaining (i.e. len % 4)
rep stosb ; set the bytes, if any
; pop the return value
pop eax
; restore the registers we pushed
pop edi
pop ebx
leave ; clean up the stack frame
ret |
db 0 ; species ID placeholder
db 65, 100, 60, 105, 45, 80
; hp atk def spd sat sdf
db BUG, POISON ; type
db 45 ; catch rate
db 159 ; base exp
db NO_ITEM, POISON_BARB ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 15 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/beedrill/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_BUG, EGG_BUG ; egg groups
; tm/hm learnset
tmhm CURSE, STRUGGLE_BUG, TOXIC, DARK_PULSE, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, GIGA_DRAIN, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, SWIFT, PURSUIT, LEECH_LIFE, REST, ATTRACT, THRASH, CUT
; end
|
; Exception handlers.
global exc_div0_handler
global exc_debug_handler
global exc_nmi_handler
global exc_breakpoint_handler
global exc_overflow_handler
global exc_bound_range_handler
global exc_inv_opcode_handler
global exc_no_dev_handler
global exc_double_fault_handler
global exc_inv_tss_handler
global exc_no_segment_handler
global exc_ss_fault_handler
global exc_gpf_handler
global exc_page_fault_handler
global exc_x87_fp_handler
global exc_alignment_check_handler
global exc_machine_check_handler
global exc_simd_fp_handler
global exc_virt_handler
global exc_security_handler
extern exception_handler
; IRQs
global irq0_handler
global irq1_handler
global pic0_generic
global pic1_generic
global apic_nmi
global apic_spurious
extern pit_handler
extern pic0_generic_handler
extern pic1_generic_handler
extern apic_nmi_handler
extern apic_spurious_handler
; IPIs
global ipi_abort
global ipi_resched
global ipi_abortexec
; Misc.
extern task_resched_bsp
extern task_resched
extern task_trigger_resched
global syscall_entry
extern kbd_handler
extern lapic_eoi_ptr
; Fast EOI function
global eoi
eoi:
push rax
mov rax, qword [lapic_eoi_ptr]
mov dword [rax], 0
pop rax
ret
%macro common_handler 1
pusham
call %1
popam
iretq
%endmacro
%macro isr_handler 1
section .text
global isr_handler_%1
isr_handler_%1:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
mov r12, 1
.loop:
mov rbx, [isr_%1_functions + r12 * 8]
test rbx, rbx
jz .out
mov rdi, %1
mov rsi, rsp
call rbx
inc r12
jmp .loop
.out:
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
iretq
section .bss
global isr_%1_functions
isr_%1_functions resq 256
section .text
%endmacro
%assign i 0
%rep 256
isr_handler i
%assign i i+1
%endrep
%macro isr_addresses_add 1
dq isr_handler_%1
%endmacro
global isr_handler_addresses
isr_handler_addresses:
%assign i 0
%rep 256
isr_addresses_add i
%assign i i+1
%endrep
%macro isr_fnaddr_add 1
dq isr_%1_functions
%endmacro
global isr_function_addresses
isr_function_addresses:
%assign i 0
%rep 256
isr_fnaddr_add i
%assign i i+1
%endrep
%macro raise_irq 1
lock inc dword [irq+%1*4]
push rax
mov rax, qword [lapic_eoi_ptr]
mov dword [rax], 0
pop rax
iretq
%endmacro
%macro except_handler_err_code 1
push qword [rsp+5*8]
push qword [rsp+5*8]
push qword [rsp+5*8]
push qword [rsp+5*8]
push qword [rsp+5*8]
pusham
mov rdi, %1
mov rsi, rsp
mov rdx, qword [rsp+20*8]
call exception_handler
popam
iretq
%endmacro
%macro except_handler 1
pusham
mov rdi, %1
mov rsi, rsp
xor rdx, rdx
call exception_handler
popam
iretq
%endmacro
; Save registers.
%macro pusham 0
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popam 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
; this doesn't pop rax which is the return register for syscalls
%macro popams 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
%endmacro
section .text
bits 64
; Exception handlers
exc_div0_handler:
except_handler 0x0
exc_debug_handler:
except_handler 0x1
exc_nmi_handler:
except_handler 0x2
exc_breakpoint_handler:
except_handler 0x3
exc_overflow_handler:
except_handler 0x4
exc_bound_range_handler:
except_handler 0x5
exc_inv_opcode_handler:
except_handler 0x6
exc_no_dev_handler:
except_handler 0x7
exc_double_fault_handler:
except_handler_err_code 0x8
exc_inv_tss_handler:
except_handler_err_code 0xa
exc_no_segment_handler:
except_handler_err_code 0xb
exc_ss_fault_handler:
except_handler_err_code 0xc
exc_gpf_handler:
except_handler_err_code 0xd
exc_page_fault_handler:
except_handler_err_code 0xe
exc_x87_fp_handler:
except_handler 0x10
exc_alignment_check_handler:
except_handler_err_code 0x11
exc_machine_check_handler:
except_handler 0x12
exc_simd_fp_handler:
except_handler 0x13
exc_virt_handler:
except_handler 0x14
exc_security_handler:
except_handler_err_code 0x1e
; IRQs
ipi_abortexec:
mov rdi, qword [rsp]
mov rsp, qword [gs:0008]
extern abort_thread_exec
call abort_thread_exec
.wait:
hlt
jmp .wait
ipi_resched:
pusham
mov rax, qword [lapic_eoi_ptr]
mov dword [rax], 0
mov rdi, rsp
extern task_resched_ap
call task_resched_ap
popam
iretq
invalid_syscall:
mov rax, -1
ret
section .data
syscall_count equ ((syscall_table.end - syscall_table) / 8)
align 16
syscall_table:
.end:
section .text
syscall_entry:
mov qword [gs:0024], rsp ; save the user stack
mov rsp, qword [gs:0016] ; switch to the kernel space stack for the thread
sti
push 0x1b ; ss
push qword [gs:0024] ; rsp
push r11 ; rflags
push 0x23 ; cs
push rcx ; rip
pusham
cmp rax, syscall_count ; is syscall_number too big?
jae .err
mov rdi, rsp
call [syscall_table + rax * 8]
.out:
popams
mov rdx, qword [gs:0032] ; return errno in rdx
cli
mov rsp, qword [gs:0024] ; restore the user stack
o64 sysret
.err:
mov rax, -1
jmp .out
pic0_generic:
common_handler pic0_generic_handler
pic1_generic:
common_handler pic1_generic_handler
section .bss
global irq
align 16
irq: resq 256
section .text
irq0_handler:
pusham
call pit_handler
mov rax, qword [lapic_eoi_ptr]
mov dword [rax], 0
mov rdi, rsp
call task_resched_bsp
popam
iretq
; == Keyboard IRQ handler
irq1_handler:
raise_irq 1
; IPIs
ipi_abort:
lock inc qword [gs:0040]
cli
.hlt:
hlt
jmp .hlt
; APIC NMI + Spurious interrupts
apic_nmi:
common_handler apic_nmi_handler
apic_spurious:
common_handler apic_spurious_handler
|
; void clearerr_fastcall(FILE *stream)
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _clearerr_fastcall
EXTERN asm_clearerr
_clearerr_fastcall:
pop af
pop ix
push hl
push af
jp asm_clearerr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _clearerr_fastcall
EXTERN _clearerr_unlocked_fastcall
defc _clearerr_fastcall = _clearerr_unlocked_fastcall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
BITS 16
section .text
foo:
mov [es:eax], dword 3
add edx, [ds:ebx]
xor ecx, [cs:4+eax]
push dword [dword es:4]
sub eax, [dword fs:foo]
and dword [dword gs:foo+edx], byte 3
|
; A343572: a(n) = ceiling((16^n)*Sum_{k=0..n+1} (4/(8k+1)-2/(8k+4)-1/(8k+5)-1/(8k+6))/16^k).
; Submitted by Christian Krause
; 4,51,805,12868,205888,3294199,52707179,843314857,13493037705,215888603273,3454217652358,55267482437723,884279719003556,14148475504056881,226375608064910089,3622009729038561422,57952155664616982740,927234490633871723826,14835751850141947581204
mul $0,4
seq $0,293342 ; Least integer k such that k/2^n > Pi.
|
global StrToNum
global NumToStr
section .text
;transform string to number
;eax - that number
;string is placed in mass with length <= 20
;spoils eax, ebx, ecx, esi
;edi = array, edx = 19
StrToNum:
push ebp
mov ebp, esp
mov eax, 0
mov ecx, 0
mov esi, 0 ;esi - counter
.stn_lp:
mov eax, [edi+esi*4] ;eax - current element
cmp eax, 0 ;end of massive
je .stn_quit
cmp eax, '0'
jl .stn_quit
cmp eax, '9'
jg .stn_quit
sub eax, '0'
mov ebx, eax
mov eax, ecx
mov ecx, ebx
mov ebx, 10
mul ebx
add ecx, eax
inc esi
jmp .stn_lp
.stn_quit:
mov eax, ecx
mov esp, ebp
pop ebp
ret
;eax = number
;move number that placed in eax in string (massive)
;spoils esi, ebx, edx
;edi = array, ecx = 19
NumToStr:
push ebp
mov ebp, esp
mov ebx, 10
mov esi, 0 ; esi- index counter
.nts_lp:
cmp esi, ecx
je .nts_quit
mov edx, 0
div ebx
add edx, '0'
mov [edi+esi*4], edx
cmp eax, 0
je .nts_quit
inc esi
jmp .nts_lp
.nts_quit:
inc esi
mov dword [edi+esi*4], 0
mov esi, 0
mov ebx, 0
.nts_rev:
cmp dword [edi+esi*4], 0
je .nts_rev_q
push dword [edi+esi*4]
inc esi
jmp .nts_rev
.nts_rev_q:
mov ebx, 0
.nts_rev_lp:
pop dword [edi+ebx*4]
inc ebx
cmp esi, ebx
je .quit
jmp .nts_rev_lp
.quit:
mov esp, ebp
pop ebp
ret
|
//===-test_convtranspose_1d_xnnpack.cc-----------------------------------------------------------===//
//
// Copyright (C) 2019-2020 Alibaba Group Holding Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
// clang-format off
// Testing CXX Code Gen using ODLA API on xnnpack
// RUN: %halo_compiler -target cxx -o %data_path/test_convtranspose_1d/test_data_set_0/input_0.cc -x onnx -emit-data-as-c %data_path/test_convtranspose_1d/test_data_set_0/input_0.pb
// RUN: %halo_compiler -target cxx -o %data_path/test_convtranspose_1d/test_data_set_0/output_0.cc -x onnx -emit-data-as-c %data_path/test_convtranspose_1d/test_data_set_0/output_0.pb
// RUN: %halo_compiler -target cxx -o %data_path/test_convtranspose_1d/test_data_set_0/input_1.cc -x onnx -emit-data-as-c %data_path/test_convtranspose_1d/test_data_set_0/input_1.pb
// RUN: %halo_compiler -target cxx -batch-size 1 %halo_compile_flags %data_path/test_convtranspose_1d/model.onnx -o %t.cc
// RUN: %cxx -c -fPIC -o %t.o %t.cc -I%odla_path/include
// RUN: %cxx -g %s %t.o %t.bin -I%T -I%odla_path/include -I%unittests_path -I%data_path/test_convtranspose_1d/test_data_set_0 %odla_link %device_link -lodla_xnnpack -o %t_xnnpack.exe -Wno-deprecated-declarations
// RUN: %t_xnnpack.exe 0.0001 0 xnnpack %data_path/test_convtranspose_1d | FileCheck %s
// CHECK: Result Pass
// clang-format on
// XFAIL: *
#include "test_convtranspose_1d_xnnpack.cc.tmp.main.cc.in"
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r8
push %rax
push %rbx
push %rcx
lea addresses_WC_ht+0xc6ed, %r14
nop
nop
nop
sub %rcx, %rcx
mov $0x6162636465666768, %rax
movq %rax, (%r14)
nop
nop
nop
nop
nop
add $51112, %rbx
lea addresses_normal_ht+0xe725, %r10
nop
nop
xor %rax, %rax
movb $0x61, (%r10)
nop
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_WC_ht+0x1eaed, %r10
nop
xor %r13, %r13
mov $0x6162636465666768, %r14
movq %r14, %xmm7
vmovups %ymm7, (%r10)
nop
and %r13, %r13
lea addresses_WT_ht+0x18eed, %r8
nop
nop
nop
nop
add %rax, %rax
movups (%r8), %xmm5
vpextrq $0, %xmm5, %r10
nop
nop
nop
nop
xor $22127, %rbx
lea addresses_A_ht+0x17d3, %rbx
nop
cmp $37902, %rcx
mov $0x6162636465666768, %r14
movq %r14, %xmm6
movups %xmm6, (%rbx)
and $58919, %rcx
lea addresses_WT_ht+0x111c7, %r14
sub $58836, %rcx
mov $0x6162636465666768, %r8
movq %r8, %xmm2
vmovups %ymm2, (%r14)
nop
inc %rbx
lea addresses_UC_ht+0xaeed, %r8
nop
nop
sub $24581, %r13
mov $0x6162636465666768, %r10
movq %r10, %xmm2
movups %xmm2, (%r8)
nop
nop
nop
xor %r8, %r8
lea addresses_UC_ht+0x5be9, %rcx
nop
sub %r10, %r10
mov $0x6162636465666768, %r8
movq %r8, %xmm7
vmovups %ymm7, (%rcx)
sub $59538, %r10
lea addresses_UC_ht+0x12eed, %r14
nop
inc %r13
movw $0x6162, (%r14)
nop
sub %r13, %r13
lea addresses_D_ht+0xd3ad, %r8
nop
nop
nop
nop
inc %r10
movb $0x61, (%r8)
nop
nop
nop
xor %rbx, %rbx
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r8
push %r9
push %rbx
push %rsi
// Store
mov $0x7deb000000046e, %r11
nop
nop
nop
nop
nop
inc %rsi
mov $0x5152535455565758, %rbx
movq %rbx, %xmm2
movups %xmm2, (%r11)
nop
nop
nop
nop
nop
add $43255, %r8
// Load
mov $0x25336b0000000eed, %r9
nop
cmp %r12, %r12
movb (%r9), %r8b
nop
nop
nop
nop
cmp $32657, %rsi
// Store
lea addresses_US+0x12bd5, %r8
nop
nop
nop
cmp %r11, %r11
mov $0x5152535455565758, %r9
movq %r9, %xmm6
movups %xmm6, (%r8)
nop
nop
nop
nop
nop
cmp $62864, %rbx
// Faulty Load
lea addresses_D+0x9eed, %rsi
nop
dec %rbx
mov (%rsi), %r12
lea oracles, %r9
and $0xff, %r12
shlq $12, %r12
mov (%r9,%r12,1), %r12
pop %rsi
pop %rbx
pop %r9
pop %r8
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 5, 'size': 1, 'same': True, 'NT': False}}
{'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
*/
|
song9_header:
.byte $04 ;4 streams
.byte MUSIC_SQ1 ;which stream
.byte $01 ;status byte (stream enabled)
.byte SQUARE_1 ;which channel
.byte $B0 ;initial duty (10)
.byte ve_short_staccato ;volume envelope
.word song9_square1 ;pointer to stream
.byte $60 ;tempo
.byte MUSIC_SQ2 ;which stream
.byte $01 ;status byte (stream enabled)
.byte SQUARE_2 ;which channel
.byte $B0 ;initial duty (10)
.byte ve_short_staccato ;volume envelope
.word song9_square2 ;pointer to stream
.byte $60 ;tempo
.byte MUSIC_TRI ;which stream
.byte $01 ;status byte (stream enabled)
.byte TRIANGLE ;which channel
.byte $81 ;initial volume (on)
.byte ve_short_staccato ;volume envelope
.word song9_tri ;pointer to stream
.byte $60 ;tempo
.byte MUSIC_NOI ;which stream
.byte $01 ;enabled
.byte Noise
.byte $30 ;initial duty_vol
.byte ve_drum_decay ;volume envelope
.word song9_noise ;pointer to stream
.byte $60 ;tempo
; now that we have envelopes we don't need the weird rests for consecutive notes
song9_square1:
.byte eighth, Fs4, Fs4, D4, B3, rest, B3, rest, E4
.byte rest, E4, rest, E4, Gs4, Gs4, A4, B4
.byte A4, A4, A4, E4, rest, D4, rest, Fs4
.byte rest, Fs4, rest, Fs4, E4, E4, Fs4, E4
.byte loop
.word song9_square1
song9_square2:
.byte set_note_offset, $18 ; up an octave and a half - this enriches the sound and gets it closer to the synth of the original
.byte eighth, Fs4, Fs4, D4, B3, rest, B3, rest, E4
.byte rest, E4, rest, E4, Gs4, Gs4, A4, B4
.byte A4, A4, A4, E4, rest, D4, rest, Fs4
.byte rest, Fs4, rest, Fs4, E4, E4, Fs4, E4
.byte loop
.word song9_square2
song9_tri:
.byte quarter, B2, B3, eighth, rest, B2, quarter, B3
.byte E3, E4, eighth, rest, E3, quarter, E4
.byte A2, A3, eighth, rest, A2, quarter, A3
.byte D3, D4, C3, Cs4
.byte loop
.word song9_tri
song9_noise:
.byte quarter
.byte set_loop1_counter, 7 ; 7 bum hit before the bumbum hit
@loop_point:
.byte $0F, $05
.byte loop1
.word @loop_point
.byte eighth, $0F, $0F, quarter, $05
.byte loop
.word song9_noise |
; A056976: Number of blocks of {0, 1, 0} in the binary expansion of n.
; 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,1,1,2,1,2,2,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,1,1,2,1,2,2,1,1,0,0,1,0,0,0,0,0,1,1,2,1,2,2,1,1,2,2,3,2,1,1,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,1,1,2,1,2,2,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,2,1,0,0,0,0,0,0,1,0,1,1,0,0,0,0,1
sub $0,1
mov $1,1
lpb $0,1
mov $4,$0
div $0,2
mov $3,2
cal $4,10887 ; Simple periodic sequence: repeat 1,2,3,4,5,6,7,8.
sub $0,1
mov $2,$4
cmp $2,0
add $4,$2
div $3,$4
div $3,2
add $1,$3
lpe
mul $1,2
sub $1,2
div $1,2
|
; 05.2005 aralbrec
; iterative qsort, partition element taken from middle
SECTION code_clib
PUBLIC Lqsort
EXTERN l_jpix
; The ansi-C qsort function sorts an array of n-byte items.
; This is a 'little' version that sorts arrays of 2-byte items.
; Those 2-byte items can be integers or pointers to objects. The
; reason for the 'little' version is that a full ansi implementation
; would require either one multiply or one div operation for each
; array slice -- these are things that would be very time consuming
; on a z80 and hence not worthwhile implementing. I have only ever
; used qsort on arrays of pointers to objects and this z80 version
; will do that just fine.
; enter: bc = base address of array
; hl = size of array
; ix = cmp function (DE=key, BC=datum ; result in A (see ".compare"),
; MUST PRESERVE BC,DE,HL,IX registers)
; uses : AF,BC,DE,HL,AF'
;
; If you prefer to enter with hl = last item in array, call Lqsort+3
.Lqsort
dec hl
add hl,hl
add hl,bc
; bc = left, hl = right
ld de,0
push de ; mark end of qsort -- empty stack
jp qsort2
.qsort1 ; check stack for pending qsorts
pop bc ; bc = left
ld a,b
or c
ret z ; if 0, done
pop hl ; hl = right
.qsort2 ; qsort(bc=left,hl=right)
ld a,b ; left < right? bc < hl?
cp h
jr c, swap3
jr nz, qsort1
ld a,c
cp l
jr nc, qsort1
; picking middle item as partition element
.swap3 ; swap(left,(left+right)/2)
ld e,l
ld d,h ; de = right
add hl,bc
rr h
rr l ; hl = unrounded (left+right)/2
ld a,l ; shenanigans to ensure HL aligns on item
xor c
rra
jr nc, doswap
dec hl
.doswap ; move partition element to start of array
ld a,(bc)
ex af,af
ld a,(hl)
ld (bc),a
ex af,af
ld (hl),a
inc hl
inc bc ; bc = left+1b, de=right
ld a,(bc)
ex af,af
ld a,(hl)
ld (bc),a
ex af,af
ld (hl),a
inc bc
push bc ; stack = left+1 = last+1
ld l,c
ld h,b
ex de,hl ; de = left+1, hl = right
dec bc
dec bc ; bc = left
jp ent
; de = i, bc = left, hl = right, stack = last+1
.partition
inc de ; i++
inc de
.ent
ld a,h ; i <= right? de <= hl ?
cp d
jr c, endlp
jr nz, compare
ld a,l
cp e
jr c, endlp
.compare ; is v[i] < v[left]? (de) < (bc) ?
call l_jpix ; returns A<0 for less, A==0 for equals, A>0 for greater
or a
jp p, partition
.swap1 ; swap(i,++last)
ex (sp),hl ; hl = ++last, stack = right
ld a,(de)
ex af,af
ld a,(hl)
ld (de),a
ex af,af
ld (hl),a
inc hl
inc de
ld a,(de)
ex af,af
ld a,(hl)
ld (de),a
ex af,af
ld (hl),a
inc hl
inc de
ex (sp),hl ; hl = right, stack = last+1, de=i++
jp ent
.endlp ; bc = left, hl = right, stack = last+1
ex (sp),hl ; hl = last+1
push hl ; qsort(l=last+1,r=right) <==> stack = right,last+1
.swap2 ; swap(left,last)
inc bc ; bc = left+1b
dec hl ; hl = last+1b
ld a,(bc)
ex af,af
ld a,(hl)
ld (bc),a
ex af,af
ld (hl),a
dec hl ; hl = last
dec bc ; bc = left
ld a,(bc)
ex af,af
ld a,(hl)
ld (bc),a
ex af,af
ld (hl),a
dec hl
dec hl ; hl = last-1
jp qsort2 ; qsort(l=bc=left,r=hl=last-1)
|
; A017039: a(n) = (7*n + 4)^11.
; 4194304,285311670611,64268410079232,2384185791015625,36028797018963968,317475837322472439,1951354384207722496,9269035929372191597,36279705600000000000,122130132904968017083,364375289404334925824,984770902183611232881,2450808588882738675712,5688000922764599609375,12433743083946522728448,25804264053054077850709,51172646912339021398016,97489136981438262577827,179216039403700000000000,319099584516184696444313,552061438912436417593344,930564370500844495614151,1531891323960362862344192
mul $0,7
add $0,4
pow $0,11
|
;;
;; MEG-OS Zero - Kernel
;;
;; Copyright (c) 2014-2017 MEG-OS project
;; 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.
;;
;; 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 "oszbio.inc"
%include "osz.inc"
%include "oszfs.inc"
; v1.2 -> 0x0201
%define VER_DOS 0x0B02
%define MCB_PID_SYSTEM 8
%define MCB_PID_RESERVED 9
%define PSP_OLDINT2X 0x000A
%define PSP_PARENT 0x0016
%define PSP_DEFAULT_JFT 0x0018
%define PSP_SAVE_SSSP 0x002E
%define PSP_JFT_SIZE 0x0032
%define PSP_JFT 0x0034
%define PSP_OSZ_BDOS 0x004A
%define PSP_DEFAULT_JFT_SIZE 20
%define MAX_INHERIT_JFT 5
%define STK_AX 0
%define STK_BX 2
%define STK_CX 4
%define STK_DX 6
%define STK_SI 8
%define STK_DI 10
%define STK_BP 12
%define STK_DS 14
%define STK_ES 16
%define STK_IP 18
%define STK_CS 20
%define STK_FLAGS 22
%define N_FILES 8
%define N_DRIVES 26
%define SIZE_DRIVE 4
%define MCB_TYPE 0x0000
%define MCB_OWNER 0x0001
%define MCB_SIZE 0x0003
%define MAX_ESC_BUFFER 16
%define OSZ_NATIVE_SVC_INT 0x80
%define OSZ_STD_COM_SIGN_1 0xED31
%define OSZ_STD_COM_SIGN_2 0xED33
%define OSZ_STD_COM_SIGN_x1 0xED29
%define OSZ_STD_COM_SIGN_x2 0xED2B
%define MIN_COM_SIZE 3
%define MAX_COM_SIZE 0xFC00
%define READ_EXE_SIZE 0x20
%define MIN_COM_STACK 256
[CPU 8086]
[BITS 16]
_HEAD:
db 0xCB, 0x1A
dw _init
_dev_hdr_NULL dw 0xFFFF, 0xFFFF, OSZ_DEV_MAJ_NULL, _NULL_intr
db "NUL "
LP_SFT dd 0
FIRST_MCB dw 0
CURRENT_PSP dw 0
MCB_STRATEGY db MCB_BEST_FIT
CURRENT_DRIVE db 0
alignb 2
; ---------------------------------------------------------------------
; OSZ API
int80_function_table:
dw _BDOS_00, _BDOS_sysinfo, _BDOS_gettick, _BDOS_sleep
dw _BDOS_puts, _BDOS_itoa, _BDOS_00, _BDOS_beep, _BDOS_00, _BDOS_00
dw _BDOS_mcb_alloc, _BDOS_mcb_free, _BDOS_mcb_realloc
dw _BDOS_mount, _BDOS_select_drive, _BDOS_get_drive, _BDOS_open
dw _BDOS_close, _BDOS_read, _BDOS_write, _BDOS_lseek, _BDOS_ioctl
dw _BDOS_unlink, _BDOS_dup1, _BDOS_dup2, _BDOS_readdir, _BDOS_exec
dw _BDOS_temp_rtc
end_int80_function:
_NULL_intr:
xor ax, ax
retf
_int80_over:
xor ax, ax
iret
_int20: ; TERMINATE PROGRAM
xor ax, ax
_int80:
cmp ah, (end_int80_function-int80_function_table)/2
jae short _int80_over
cli
cld
push es
push ds
push bp
push di
push si
push dx
push cx
push bx
push ax
mov bp, sp
mov bx, ds
mov ds, [cs:CURRENT_PSP]
mov [PSP_SAVE_SSSP], sp
mov [PSP_SAVE_SSSP+2], ss
mov ds, bx
mov bl, ah
xor bh, bh
add bx, bx
call [cs:int80_function_table + bx]
_return_from_int80:
add sp, byte 2
pop bx
pop cx
pop dx
pop si
pop di
pop bp
pop ds
pop es
iret
_crlf:
mov al, 10
int 0x29
ret
_hard_bs:
mov al, 8
int 0x29
mov al, ' '
int 0x29
mov al, 8
int 0x29
ret
_call_bios:
db 0x9A
_osz_systbl dd 0
ret
_dos_wait:
int 0x28
mov ah, 0x84
int 0x2A
ret
_BDOS_beep: ; BEEP
mov ah, BIOS_BEEP
jmp short _call_bios
_BDOS_sysinfo: ; SYSINFO
les bx,[cs:_osz_systbl]
or al, al
jnz .no00
;; OSZ_GET_VERSION
mov ax, [es:bx + OSZ_SYSTBL_REVISION]
mov [bp+STK_BX], ax
mov cx, [es:bx + OSZ_SYSTBL_CPUID]
mov [bp+STK_CX], cx
xor dx, dx
mov [bp+STK_DX], dx
mov ax, [es:bx + OSZ_SYSTBL_VERSION]
ret
.no00:
cmp al, 0x01
jnz .no01
;; OSZ_GET_MEMINFO
mov ax, [cs:FIRST_MCB]
mov [bp+STK_BX], ax
mov cx, [es:bx + OSZ_SYSTBL_MEMSZ]
mov [bp+STK_CX], cx
xor dx, dx
mov [bp+STK_DX], dx
jmp _mcb_find_max_size
.no01:
cmp al, 0x02
jnz .no02
;; OSZ_GET_ALLOC_STRA
mov al, [cs:MCB_STRATEGY]
ret
.no02:
cmp al, 0x03
jnz .no03
;; OSZ_SET_ALLOC_STRA
mov al, dl
xchg al, [cs:MCB_STRATEGY]
ret
.no03:
;; UNKNOWN
xor ax, ax
ret
_BDOS_gettick: ; GET TICK
mov ah, BIOS_GET_TICK
call _call_bios
mov [bp+STK_CX], cx
mov [bp+STK_DX], dx
ret
_BDOS_sleep: ; SLEEP
mov bx, cx
mov ah, BIOS_GET_TICK
call _call_bios
mov si, ax
mov di, dx
.loop:
call _dos_wait
mov ah, BIOS_GET_TICK
call _call_bios
sub ax, si
sbb dx, di
or dx, dx
jnz .end
mul cx
or dx, dx
jnz .end
cmp ax, bx
jb .loop
.end:
ret
; CONOUT STRING
_BDOS_puts:
mov si, dx
.loop:
lodsb
or al,al
jz short .end
int 0x29
jmp short .loop
.end:
ret
; Integer to Ascii
; in AL: Leading char CL: base BX: buffer DX: value
_BDOS_itoa:
push ds
pop es
mov di, [bp+STK_BX]
mov ah, al
stosw
stosw
xor ah, ah
mov [di], ax
xor ch, ch
mov ax, dx
.loop:
xor dx, dx
div cx
add dl, '0'
cmp dl, 0x3A
jb .no_0A
add dl, 0x41-0x3A
.no_0A:
mov [di], dl
dec di
or ax, ax
jnz .loop
ret
; ---------------------------------------------------------------------
; YMD convert test
%define DEFAULT_CENTURY 20
epoch_bias dd 719528 ; 1970-01-01
md_tbl dw 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
_BDOS_temp_rtc:
push ds
pop es
mov bp, dx
mov di, bp
mov cx, 8
xor ax, ax
rep stosw
mov ah, BIOS_GET_RTC
call _call_bios
mov si, bp
mov di, si
mov cl, 4
mov bx, 7
.loop:
lodsb
mov ah, al
shr ah, cl
and al, 0x0F
aad
stosb
dec bx
jnz .loop
mov si, bp
mov ax, [si]
or ax, [si+2]
jz .skip_zero
mov al, [si]
or al, al
jnz .century_ok
mov al, DEFAULT_CENTURY
.century_ok:
mov cl, 100
mul cl
add al, [si+1]
adc al, 0
mov [si], ax
; YMD to INT
mov bx, [si]
mov cx, 400
xor dx, dx
div cx
or dx, dx
jz .leap
mov ax, bx
mov cx, 100
xor dx, dx
div cx
or dx, dx
jz .not_leap
test bx, 3
jz .leap
.not_leap:
xor al, al
jmp short .end_check_leap
.leap:
mov al, 1
.end_check_leap:
mov [si+7], al
mov ax, [si]
shr ax, 1
shr ax, 1
mov di, ax
xor dx, dx
mov cx, 25
div cx
mov dx, ax
shr dx, 1
shr dx, 1
sub di, ax
add di, dx
mov ax, [si]
mov cx, 365
mul cx
mov bl, [si+2]
xor bh, bh
add bx, bx
add di, [cs:md_tbl-2+bx]
mov bl, [si+3]
xor bh, bh
add di, bx
add ax, di
adc dx, BYTE 0
mov bx, [cs:epoch_bias]
mov cx, [cs:epoch_bias+2]
cmp BYTE [si+2], 3
jae .skip_adjust_leap
add bl, [si+7]
adc bh, 0
adc cx, BYTE 0
.skip_adjust_leap:
sub ax, bx
sbb dx, cx
mov [si], ax
mov [si+2], dx
mov cx, 86400/2
mul cx
shl dx, 1
shl ax, 1
adc dx, BYTE 0
mov [si+8], ax
mov [si+10], dx
; HMS to INT
mov cx, 60
mov al, [si+4]
mul cl
add al, [si+5]
adc ah, 0
mul cx
add al, [si+6]
adc ah, 0
adc dx, BYTE 0
mov [si+4], ax
mov [si+6], dx
add [si+8], ax
adc [si+10], dx
.skip_zero:
ret
; ---------------------------------------------------------------------
; MCB FUNCTIONS
; ---------------------------------------------------------------------
; ALLOCATE NEW MCB AND PSP
; AL STORATEGY CX SIZE
_ZP_alloc:
mov dx, MCB_PID_RESERVED
call _mcb_alloc
or ax, ax
jz .fail
push ds
mov ds, ax
inc ax
mov [MCB_OWNER], ax
push ax
call _INIT_ZEROPAGE
pop ax
pop ds
ret
.fail:
ret
_BDOS_mcb_alloc:
mov al, [cs:MCB_STRATEGY]
mov dx, [cs:CURRENT_PSP]
call _mcb_alloc
or ax, ax
jz .nomem
inc ax
jmp _mcb_merge
.nomem:
ret
_BDOS_mcb_free:
; TODO: check MCB
cmp dx, [cs:FIRST_MCB]
jbe .badmcb
dec dx
mov ds, dx
cmp [ds:MCB_TYPE], BYTE 'M'
jnz .badmcb
xor ax, ax
mov [ds:MCB_OWNER], ax
.badmcb:
jmp _mcb_merge
_BDOS_mcb_realloc:
mov bx, cx
or bx, bx
jz _BDOS_mcb_free
dec dx
mov ds, dx
cmp [ds:MCB_SIZE], bx
jz .end
jb .grow
mov cx, bx
xchg cx, [ds:MCB_SIZE]
sub cx, bx
dec cx
add dx, bx
inc dx
mov es, dx
xor di, di
mov al, 'M'
stosb
xor ax, ax
stosw
mov ax, cx
stosw
xor ax, ax
stosb
stosw
stosw
stosw
stosw
stosw
mov ax, ds
.end:
jmp _mcb_merge
.grow:
mov ax, ds
mov cx, [ds:MCB_SIZE]
add ax, cx
inc ax
mov es, ax
cmp byte [es:MCB_TYPE], 'M'
jnz .no_mem
cmp word [es:MCB_OWNER], 0
jnz .no_mem
add cx, [es:MCB_SIZE]
inc cx
cmp cx, bx
jb .no_mem
mov [ds:MCB_SIZE], bx
sub cx, bx
dec cx
add dx, bx
inc dx
mov es, dx
xor di, di
mov al, 'M'
stosb
xor ax, ax
stosw
mov ax, cx
stosw
xor ax, ax
stosb
stosw
stosw
stosw
stosw
stosw
mov ax, ds
jmp _mcb_merge
.no_mem:
xor ax, ax
ret
; Purge all MCB for context
; DX context
_MCB_purge:
mov cx, [cs:FIRST_MCB]
.loop:
mov ds, cx
cmp BYTE [MCB_TYPE], 'M'
jnz .end
cmp [MCB_OWNER], dx
jnz .skip
xor [MCB_OWNER], dx
.skip:
add cx, [MCB_SIZE]
inc cx
jmp .loop
.end:
; jmp _mcb_merge
; Merge MCB
_mcb_merge:
mov si, ax
mov di, [cs:FIRST_MCB]
.loop:
mov ds, di
mov al, [ds:MCB_TYPE]
cmp al, 'Z'
jz .end
cmp al, 'M'
jnz .broken
cmp word [ds:MCB_OWNER], 0
jnz .skip
mov bx, [ds:MCB_SIZE]
inc bx
.loop2:
lea cx, [bx+di]
mov es, cx
mov al, [es:MCB_TYPE]
cmp al, 'Z'
jz .end
cmp al, 'M'
jnz .broken
cmp word [es:MCB_OWNER], 0
jnz .skip
add bx, [es:MCB_SIZE]
mov [ds:MCB_SIZE], bx
inc bx
jmp .loop2
.skip:
add di, [ds:MCB_SIZE]
inc di
jmp .loop
.broken:
xor si, si
.end:
mov ax, si
ret
; MCB ALLOC
; IN AL STRATEGY, CX SIZE, DX CONTEXT
; OUT AX MCB
_mcb_alloc:
push es
push ds
push bx
push si
push di
mov di, dx
mov bx, cx
cmp al, MCB_FIRST_FIT
jnz .no_ff
call _mcb_find_first_area
jmp .next
.no_ff:
cmp al, MCB_BEST_FIT
jnz .no_bf
call _mcb_find_min_area
.next:
or ax, ax
jz .end
mov ds, ax
mov [ds:MCB_OWNER], di
mov cx, bx
xchg cx, [ds:MCB_SIZE]
cmp cx, bx
jz .end
sub cx, bx
dec cx
mov dx, ax
add dx, bx
inc dx
mov es, dx
xor di, di
mov al, 'M'
stosb
xor ax, ax
stosw
mov ax, cx
stosw
xor ax, ax
stosb
stosw
stosw
stosw
stosw
stosw
mov ax, ds
.end:
pop di
pop si
pop bx
pop ds
pop es
ret
; LAST FIT
.no_bf:
call _mcb_get_n_mcb
mov si, ax
dec si
.loop:
mov cx, si
call _mcb_enum_mcb
or ax, ax
jz .end
mov ds, ax
cmp WORD [ds:MCB_OWNER], 0
jnz .skip
mov cx, [ds:MCB_SIZE]
cmp cx, bx
jae .found
.skip:
dec si
jnz .loop
xor ax, ax
jmp .end
.found:
jz .same
sub cx, bx
dec cx
mov [ds:MCB_SIZE], cx
inc cx
add ax, cx
mov ds, ax
.same:
mov BYTE [ds:MCB_TYPE], 'M'
mov [ds:MCB_OWNER], di
mov [ds:MCB_SIZE], bx
mov ax, ds
jmp .end
; COMPUTE NUMBER OF MCBs
; RETURN AX NUMBER OF VALID MCBs
_mcb_get_n_mcb:
push ds
xor ax, ax
mov dx, [cs:FIRST_MCB]
.loop:
mov ds, dx
cmp BYTE [ds:MCB_TYPE], 'M'
jnz .break
inc ax
add dx, [ds:MCB_SIZE]
inc dx
jmp .loop
.break:
pop ds
ret
; ENUM MCB BY INDEX
; IN CX INDEX
; OUT AX MCB OR NULL
_mcb_enum_mcb:
push ds
mov dx, [cs:FIRST_MCB]
.loop:
mov ds, dx
cmp BYTE [ds:MCB_TYPE], 'M'
jnz .break
dec cx
jz .found
add dx, [ds:MCB_SIZE]
inc dx
jmp .loop
.found:
mov ax, dx
.break:
pop ds
ret
; IN CX REQUEST SIZE
; OUT AX MCB OR NULL
_mcb_find_first_area:
push ds
push bx
xor bx, bx
mov dx, [cs:FIRST_MCB]
.loop:
mov ds, dx
cmp byte [ds:MCB_TYPE], 'M'
jnz .break
mov ax, [ds:MCB_SIZE]
cmp word [ds:MCB_OWNER], 0
jnz .skip
cmp ax, cx
jb .skip
mov bx, dx
.skip:
add dx, ax
inc dx
jmp .loop
.break:
mov ax, bx
pop bx
pop ds
ret
; IN CX REQUEST SIZE
; OUT AX MCB OR NULL
_mcb_find_min_area:
push ds
push bx
push si
mov bx, 0xFFFF
xor si, si
mov dx, [cs:FIRST_MCB]
.loop:
mov ds, dx
cmp byte [ds:MCB_TYPE], 'M'
jnz .break
mov ax, [ds:MCB_SIZE]
cmp word [ds:MCB_OWNER], 0
jnz .skip
cmp ax, cx
jb .skip
cmp ax, bx
ja .skip
mov bx, ax
mov si, dx
.skip:
add dx, ax
inc dx
jmp .loop
.break:
mov ax, si
pop si
pop bx
pop ds
ret
_mcb_find_max_size:
push ds
xor cx, cx
mov dx, [cs:FIRST_MCB]
.loop:
mov ds, dx
cmp byte [ds:MCB_TYPE], 'M'
jnz .break
mov ax, [ds:MCB_SIZE]
cmp word [ds:MCB_OWNER], 0
jnz .skip
cmp cx, ax
ja .skip
mov cx, ax
.skip:
add dx, ax
inc dx
jmp .loop
.break:
mov ax, cx
pop ds
ret
; ---------------------------------------------------------------------
; CON Device Driver
; ---------------------------------------------------------------------
alignb 16
_dev_hdr_CON dw 0xFFFF, 0xFFFF, OSZ_DEV_MAJ_CON, _CON_intr
db "CON "
ESC_PHASE db -1
ESC_BUFFER resb MAX_ESC_BUFFER
; FAST CONSOLE OUTPUT
_int29:
push ds
push ax
push cx
push bx
push cs
pop ds
cmp al, 0x1B
jnz .no_start_esc
mov BYTE [ESC_PHASE], 0
jmp .end
.no_start_esc:
cmp BYTE [ESC_PHASE], -1
jnz .in_esc
.no_esc:
mov ah, BIOS_CONOUT
call _call_bios
.end:
pop bx
pop cx
pop ax
pop ds
iret
.in_esc:
mov bl, [ESC_PHASE]
xor bh, bh
mov [ESC_BUFFER+bx], al
inc BYTE [ESC_PHASE]
.no_esc1:
cmp BYTE [ESC_BUFFER], '['
jnz .esc_final
cmp al, 'J'
jnz .no_cls
mov ah, BIOS_CLS
call _call_bios
jmp .esc_final
.no_cls:
cmp al, 'A'
jb .skip
cmp al, 'z'
ja .skip
cmp al, 'Z'
jbe .esc_final
cmp al, 'a'
jae .esc_final
.skip:
jmp .end
.esc_final:
mov BYTE [ESC_PHASE], -1
jmp .end
_CON_intr:
cmp ax, OSZ_IFS_INIT
jz .init
cmp ax, OSZ_IFS_READ
jz .read
cmp ax, OSZ_IFS_WRITE
jz .write
mov ax, EINVAL
retf
.init:
xor ax, ax
retf
.read:
call _gets
retf
.write:
push cx
jcxz .end
mov si, dx
cld
.loop:
lodsb
int 0x29
loop .loop
.end:
pop ax
retf
; CONIN BUFFERED
; IN cx = limit ds:dx = buffer
; OUT ax = length
_gets:
push bx
push si
push di
mov di, cx
mov si, dx
xor bx, bx
.main_loop:
mov ah, BIOS_CONST
call _call_bios
or al,al
jnz .has_key
call _dos_wait
jmp short .main_loop
.has_key:
mov ah, BIOS_CONIN
call _call_bios
cmp al, 0x03
jnz short .no_break
mov al, '^'
int 0x29
mov al, 'C'
int 0x29
mov al, 13
int 0x29
mov al, 10
int 0x29
xor bx, bx
jmp short .end
;jmp _BDOS_00
.no_break:
cmp al, 0x0D ; cr
jz short .crlf
cmp al, 0x0A ; lf
jnz short .no_crlf
.crlf:
cmp bx, di
jae .crlf_skip
mov al, 0x0A
mov [si+bx], al
inc bx
.crlf_skip:
call _crlf
jmp short .end
.no_crlf:
cmp al, 0x1B
jnz short .no_esc
.loop_esc:
or bx, bx
jz short .main_loop
dec bx
call _hard_bs
jmp short .loop_esc
.no_esc:
cmp al, 0x08 ; ascii backspace
jz short .backspace
cmp al, 0x7F ; some unicses standard backspace
jnz short .no_bs
.backspace:
or bx, bx
jz short .main_loop
dec bx
mov al, [si+bx]
cmp al, 0x20
jnc short .bs_printchar
call _hard_bs
.bs_printchar:
call _hard_bs
jmp short .main_loop
.no_bs:
cmp bx, di
jae short .main_loop
mov [si+bx], al
inc bx
cmp al, 0x20
jc short .print_ctrl
int 0x29
jmp .main_loop
.print_ctrl:
xchg ax, cx
mov al, '^'
int 0x29
xchg ax, cx
add al, 0x40
int 0x29
jmp .main_loop
.end:
cmp bx, di
jae short .no_last_nul
xor cl, cl
mov [si+bx],cl
.no_last_nul:
mov ax,bx
pop di
pop si
pop bx
ret
; ---------------------------------------------------------------------
; RAMFS Driver
; ---------------------------------------------------------------------
alignb 16
_dev_hdr_RAMFS dw 0xFFFF, 0xFFFF, OSZ_DEV_MAJ_RAMFS, _RAMFS_intr
db "RAMFS "
_RAMFS_intr:
cmp ax, OSZ_IFS_WRITE
jz _ramfs_write
cmp ax, OSZ_IFS_READ
jz _ramfs_read
cmp ax, OSZ_IFS_READDIR
jz _ramfs_readdir
cmp ax, OSZ_IFS_OPEN
jz _ramfs_open
mov ax, EINVAL
retf
_ramfs_write:
mov ax, EROFS
retf
_ramfs_read:
push ds
mov di, dx
lds si, [cs:_osz_systbl]
mov ds, [si+OSZ_SYSTBL_RAMD]
mov si, [es:bx+OSZ_SFT_FIRST_CLUSTER]
mov dx, [es:bx+OSZ_SFT_FP]
mov ax, [es:bx+OSZ_SFT_FILESIZE]
cmp dx, ax
ja .size_over
sub ax, dx
add si, dx
cmp cx, ax
jb .no_limit_over
mov cx, ax
.no_limit_over:
add [es:bx+OSZ_SFT_FP], cx
pop es
mov ax, cx
rep movsb
retf
.size_over:
add sp, 2
mov ax, EIO
retf
_ramfs_readdir:
push ds
pop es
mov di, dx
lds bx, [cs:_osz_systbl]
mov si, [bx+OSZ_SYSTBL_RAMDSZ]
mov ds, [bx+OSZ_SYSTBL_RAMD]
lea bx, [si-0x10]
cmp cx, [bx+2]
jae .terminate
push cx
mov dx, cx
mov cl, 4
shl dx, cl
mov si, [bx]
add si, dx
mov bx, si
mov cx, 11
rep movsb
xor ax, ax
mov cx, 9
rep stosb
mov ax, ds
stosw
xor ax, ax
stosw
stosw
lea si, [bx+12]
movsw
movsw
xor ax, ax
stosw
pop ax
inc ax
retf
.terminate:
xor ax, ax
retf
_ramfs_open:
lds di, [cs:_osz_systbl]
mov si, [di+OSZ_SYSTBL_RAMDSZ]
mov ds, [di+OSZ_SYSTBL_RAMD]
mov cx, [si-14]
mov si, [si-16]
.loop:
push cx
lea di, [bx+OSZ_SFT_FCBNAME]
push si
mov cx, 11
rep cmpsb
pop si
pop cx
jz .found
add si, 16
loop .loop
mov ax, ENOENT
retf
.found:
mov ax, [ds:si+12]
mov [es:bx+OSZ_SFT_FIRST_CLUSTER], ax
mov ax, [ds:si+14]
mov [es:bx+OSZ_SFT_FILESIZE], ax
xor ax, ax
retf
; ---------------------------------------------------------------------
; FILE API
; ---------------------------------------------------------------------
_to_upper:
cmp al, 'a'
jb .noa
cmp al, 'z'
ja .noa
sub al, 0x20
.noa:
ret
; convert ascii 8.3 to fcb
; DS:SI src ES:DI dest
; TODO: check invalid char
_ascii_to_fcb:
push si
push di
mov ax, [si]
cmp ah, ':'
jnz .nodrive
inc si
inc si
and al, 0x1F
jmp .enddrive
.nodrive:
xor al, al
.enddrive:
or al, al
jnz .nodefaultdrive
mov al, [cs:CURRENT_DRIVE]
inc ax
.nodefaultdrive:
stosb
mov cx, 8
.loop0:
lodsb
cmp al, '.'
jz .has_ext
cmp al, 0
jz .end_no_ext
cmp al, '*'
jz .wildcard0
call _to_upper
stosb
loop .loop0
.loop01:
lodsb
or al, al
jz .end_no_ext
cmp al, '.'
jz .ext
jmp .loop01
.wildcard0:
mov al, '?'
rep stosb
.loopw0:
lodsb
cmp al, 0
jz .end_no_ext
cmp al, '.'
jz .has_ext
jmp .loopw0
.has_ext:
mov al, ' '
rep stosb
.ext:
mov cx, 3
.loop1:
lodsb
or al, al
jz .end_ext
cmp al, '*'
jz .wildcard1
call _to_upper
stosb
loop .loop1
.end_ext:
mov al, ' '
.end:
rep stosb
pop di
pop si
ret
.wildcard1:
mov al, '?'
jmp .end
.end_no_ext:
add cx, byte 3
mov al, ' '
jmp .end
; RETURN: AX: handle or FFFF
_alloc_sft:
push es
push di
les di, [cs:LP_SFT]
xor ax, ax
xor dx, dx
mov cx, N_FILES
.loop:
cmp [es:di+OSZ_SFT_REFCNT], ax
jz .found
inc dx
add di, OSZ_SFT_MAX
loop .loop
mov ax, 0xFFFF
jmp .end
.found:
inc word [es:di+OSZ_SFT_REFCNT]
inc di
inc di
mov cx, (OSZ_SFT_MAX-2)/2
rep stosw
mov ax, dx
.end:
pop di
pop es
ret
; IN BX:SFT HANDLE OUT ES:BX:SFT
_SFT_handle_to_sft:
mov ax, OSZ_SFT_MAX
mul bl
les bx, [cs:LP_SFT]
add bx, ax
ret
;; Return AL JFT Handle or FF
_alloc_jft:
push ds
push bx
push si
mov ds, [cs:CURRENT_PSP]
mov dx, [PSP_JFT_SIZE]
lds si, [PSP_JFT]
xor bx, bx
mov ax, 0xFFFF
.loop:
cmp [bx+si], al
jz .found
inc bx
cmp bx, dx
jb .loop
jmp .end
.found:
mov ax, bx
.end:
pop si
pop bx
pop ds
ret
; BX: JFT handle -> SFT handle
; AX=BX
_JFT_to_SFT:
push ds
push si
mov ds, [cs:CURRENT_PSP]
cmp bx, [PSP_JFT_SIZE]
jb .handle_ok
mov ax, 0xFFFF
jmp .end
.handle_ok:
lds si, [PSP_JFT]
mov al, [bx+si]
xor ah, ah
.end:
mov bx, ax
pop si
pop ds
ret
; IN DS:DX FCB OUT ES:BX DEVICE
_find_device:
push si
push di
push cs
pop es
mov bx, _dev_hdr_NULL
inc dx
mov ax, 0xFFFF
.loop:
mov si, dx
lea di, [bx+8]
mov cx, 4
rep cmpsw
jz .found
cmp ax, [es:bx]
jnz .next
cmp ax, [es:bx+2]
jz .not_found
.next:
les bx, [es:bx]
jmp .loop
.not_found:
xor bx, bx
mov es, bx
.found:
pop di
pop si
ret
; AX command ES:BX SFT
_device_call:
push bp
mov bp, sp
push es
push bx
push ds
push si
push di
les bx, [es:bx+OSZ_SFT_DEVICE]
mov bx, [es:bx+6]
push es
push bx
les bx, [bp-4]
call FAR [bp-14]
add sp, BYTE 4
pop di
pop si
pop ds
pop bx
pop es
pop bp
ret
; BX sft handle
; DX:AX size
_SFT_get_size:
push es
push bx
call _SFT_handle_to_sft
mov ax, [es:bx+OSZ_SFT_FILESIZE]
mov dx, [es:bx+OSZ_SFT_FILESIZE+2]
pop bx
pop es
ret
_BDOS_mount:
xor ax, ax
ret
_BDOS_select_drive:
cmp dl, 0xFF
jz .nodrive
cmp dl, N_DRIVES
jae .noset
.nodrive:
mov [cs:CURRENT_DRIVE], dl
.noset:
_BDOS_get_drive:
mov al, [cs:CURRENT_DRIVE]
ret
;; IN AL:FLAG CX:mode DS:DX:filename
_BDOS_open:
call _alloc_jft
cmp al, 0xFF
jnz .alloc_jft_ok
mov ax, EMFILE
jmp .end
.alloc_jft_ok:
mov si, ax
mov dx, [bp+STK_DX]
mov ax, [bp+STK_AX]
xor ah, ah
push cx
push ax
push ds
push dx
call _SFT_open
add sp, 8
or ax, ax
js .end
; set SFT handle to JFT
mov ds, [cs:CURRENT_PSP]
les bx, [PSP_JFT]
add bx, si
mov [es:bx], al
mov ax, si
.end:
ret
;; BP +4 filename +8 flag +10 mode
;; -2 SFT handle -6 SFT ptr
_SFT_open:
push bp
mov bp, sp
sub sp, 6
push ds
push es
push bx
push si
push di
call _alloc_sft
cmp ax, 0xFFFF
jnz .alloc_ok
mov ax, ENFILE
jmp .end
.alloc_ok:
mov [bp-2], ax
mov bx, ax
call _SFT_handle_to_sft
mov [bp-6], bx
mov [bp-4], es
lea di, [bx+OSZ_SFT_DRIVE]
lds si, [bp+4]
push es
push di
call _ascii_to_fcb
pop dx
pop ds
call _find_device
mov ax, es
or ax, bx
jz .nodev
lds si, [bp-6]
mov WORD [si+OSZ_SFT_STATUS], OSZ_SFT_OPENED | OSZ_SFT_CDEV
mov [si+OSZ_SFT_DEVICE], bx
mov [si+OSZ_SFT_DEVICE+2], es
mov ax, [es:bx+4]
mov [si+OSZ_SFT_FILE_ID], ax
les bx, [bp-6]
mov ax, OSZ_IFS_OPEN
call _device_call
jmp .end_succeed
.nodev:
les bx, [bp-6]
mov al, [es:bx+OSZ_SFT_DRIVE]
dec ax
or al, al
jnz .end_enoent
mov ax, _dev_hdr_RAMFS
mov [es:bx+OSZ_SFT_DEVICE], ax
mov [es:bx+OSZ_SFT_DEVICE+2], cs
lds dx, [bp+4]
mov ax, OSZ_IFS_OPEN
call _device_call
or ax, ax
js .cancel
mov WORD [es:bx+OSZ_SFT_STATUS], OSZ_SFT_OPENED
.end_succeed:
mov ax, [bp-2]
jmp .end
.end_enoent:
mov ax, ENOENT
.cancel:
; cancel SFT
xor cx, cx
lds bx, [bp-6]
mov [bx], cx
.end:
pop di
pop si
pop bx
pop es
pop ds
mov sp, bp
pop bp
ret
_BDOS_close:
mov bx, [bp+STK_BX]
_close:
push es
push ds
push bx
push si
mov si, bx
call _JFT_to_SFT
cmp al, 0xFF
jnz .okhandle
mov ax, EBADF
jmp .end
.okhandle:
push bx
call _SFT_close
pop ax
mov ds, [cs:CURRENT_PSP]
les bx, [PSP_JFT]
mov BYTE [es:bx+si], 0xFF
xor ax, ax
.end:
pop si
pop bx
pop ds
pop es
ret
_SFT_close:
push bp
mov bp, sp
push es
push bx
mov bx, [bp+4]
call _SFT_handle_to_sft
mov ax, [es:bx+OSZ_SFT_REFCNT]
dec ax
jnz .nonzero
mov ax, OSZ_IFS_CLOSE
call _device_call
xor ax, ax
mov [es:bx+OSZ_SFT_STATUS], ax
.nonzero:
mov [es:bx+OSZ_SFT_REFCNT], ax
pop bx
pop es
mov sp, bp
pop bp
ret
_BDOS_unlink:
mov ax, EACCES
ret
; BP+4 command BP+6 SFT handle BP+8 buffer BP+12 count
_SFT_RW:
push bp
mov bp, sp
push es
push bx
mov bx, [bp+6]
call _SFT_handle_to_sft
lds dx, [bp+8]
mov cx, [bp+12]
mov ax, [bp+4]
call _device_call
pop bx
pop es
pop bp
ret
_BDOS_read:
mov si, OSZ_IFS_READ
jmp _BDOS_rw
_BDOS_write:
mov si, OSZ_IFS_WRITE
_BDOS_rw:
mov bx, [bp+STK_BX]
call _JFT_to_SFT
cmp al, 0xFF
jnz .okhandle
mov ax, EBADF
jmp .end
.okhandle:
push cx
push ds
push dx
push bx
push si
call _SFT_RW
add sp, BYTE 10
.end:
ret
_BDOS_ioctl:
mov si, OSZ_IFS_IOCTL
jmp _BDOS_rw
; TODO
_BDOS_readdir:
mov al, [cs:CURRENT_DRIVE]
cmp al, 0
jnz .error
push cs
call _ramfs_readdir
ret
.error:
mov ax, ENOENT
ret
_BDOS_lseek:
mov bx, [bp+STK_BX]
call _JFT_to_SFT
cmp al, 0xFF
jnz .okhandle
mov ax, EBADF
cwd
jmp .end
.okhandle:
push WORD [bp+STK_AX]
push WORD [bp+STK_CX]
push WORD [bp+STK_DX]
push bx
call _SFT_lseek
add sp, BYTE 8
.end:
mov [bp+STK_DX], dx
ret
; BP+4 fd +6 fp +10 whence
_SFT_lseek:
push bp
mov bp, sp
push es
push bx
mov bx, [bp+4]
call _SFT_handle_to_sft
mov al, [bp+10]
or al, al
jnz .no_seek_set
xor ax, ax
xor dx, dx
jmp .whenceok
.no_seek_set:
cmp al, 0x01
jnz .no_seek_cur
mov ax, [es:bx+OSZ_SFT_FP]
mov dx, [es:bx+OSZ_SFT_FP+2]
jmp .whenceok
.no_seek_cur:
cmp al, 0x02
jnz .einval
mov ax, [es:bx+OSZ_SFT_FILESIZE]
mov dx, [es:bx+OSZ_SFT_FILESIZE+2]
.whenceok:
add ax, [bp+6]
adc dx, [bp+8]
cmp dx, 0
js .einval
mov [es:bx+OSZ_SFT_FP], ax
mov [es:bx+OSZ_SFT_FP+2], dx
jmp .end
.einval:
mov ax, EINVAL
.error:
mov dx, 0xFFFF
.end:
pop bx
pop es
pop bp
ret
_BDOS_dup1:
call _alloc_jft
cmp al, 0xFF
jnz .alloc_jft_ok
mov ax, EMFILE
ret
.alloc_jft_ok:
mov si, [bp+STK_BX]
mov di, ax
jmp _dup
_BDOS_dup2:
mov si, [bp+STK_BX]
mov di, cx
_dup:
push es
push ds
push bx
mov ds, [cs:CURRENT_PSP]
cmp di, [PSP_JFT_SIZE]
jb .okhandle2
mov ax, EBADF
jmp .end
.okhandle2:
mov bx, si
call _JFT_to_SFT
cmp al, 0xFF
jnz .okhandle1
mov ax, EBADF
jmp .end
.okhandle1:
cmp si, di
jz .same
push bx
mov bx, di
call _close
pop bx
call _SFT_handle_to_sft
inc WORD [es:bx+OSZ_SFT_REFCNT]
les bx, [PSP_JFT]
mov dl, [es:bx+si]
mov [es:bx+di], dl
.same:
mov ax, di
.end:
pop bx
pop ds
pop es
ret
; ---------------------------------------------------------------------
; DOS APIs
; ---------------------------------------------------------------------
; NETWORK REDIRECT
_int2A:
cmp ah, 0x84
jz i2A84
iret
i2A84:
sti
hlt
iret
; DUMMY DOS API
_int21:
cmp ah, 0x09
jz .i2109
xor al, al
iret
.i2109:
push si
cld
mov si, dx
.loop:
lodsb
cmp al, '$'
jz .end
int 0x29
jmp .loop
.end:
pop si
iret
_int_nop:
iret
int21_25n: ; SET IVT (internal)
push es
push bx
xor bx, bx
mov es, bx
mov bl, al
add bx, bx
add bx, bx
cli
mov [es:bx], dx
mov [es:bx+2], ds
pop bx
pop es
ret
; TODO
_int00: ; INTEGER DIVIDE BY ZERO
mov dx, int00_msg
jmp short _abort_w_msg
_int01: ; DEBUG FAULT
mov dx, int01_msg
jmp short _abort_w_msg
_int03: ; BREAK POINT
mov dx, int03_msg
jmp short _abort_w_msg
_int04: ; INTO DETECTED OVERFLOW
mov dx, int04_msg
_abort_w_msg:
push cs
pop ds
call _BDOS_puts
jmp _crit_exit
_INIT_ZEROPAGE:
push es
push ds
push si
push di
mov es, ax
xor di, di
mov ax, 0x20CD ; INT 20
stosw
xor ax, ax
mov cx, 127
rep stosw
; save INT 22,23,24
mov di, PSP_OLDINT2X
xor ax, ax
mov ds, ax
mov si, 0x22*4
mov cx, 6
rep movsw
; init JFT
mov di, PSP_DEFAULT_JFT
mov cx, PSP_DEFAULT_JFT_SIZE
mov [es:PSP_JFT_SIZE], cx
mov [es:PSP_JFT], di
mov [es:PSP_JFT+2], es
mov al, 0xFF
rep stosb
mov di, PSP_OSZ_BDOS
mov ax, (OSZ_NATIVE_SVC_INT * 0x100) + 0xCD
stosw
mov al, 0xC3 ; RETN
stosb
pop di
pop si
pop ds
pop es
ret
_clone:
push es
push ds
push bx
push si
push di
mov ax, ds
or ax, ax
jz .dont_clone
mov [es:PSP_PARENT], ds
mov cx, [PSP_JFT_SIZE]
lds si, [PSP_JFT]
mov di, PSP_DEFAULT_JFT
cmp cx, MAX_INHERIT_JFT
jna .jft_size_ok
mov cx, MAX_INHERIT_JFT
.jft_size_ok:
push cx
push di
rep movsb
pop si
pop cx
push es
pop ds
.loop:
lodsb
mov bl, al
call _SFT_handle_to_sft
inc WORD [es:bx+OSZ_SFT_REFCNT]
loop .loop
.dont_clone:
pop di
pop si
pop bx
pop ds
pop es
ret
_ctrl_c_break:
mov al, '^'
int 0x29
mov al, 'C'
int 0x29
mov ax, 0x0101
jmp short _exit_main
_crit_exit:
mov ax, 0x02FF
jmp short _exit_main
_BDOS_00: ; EXIT
xor ah, ah
_exit_main:
cli
mov es, [cs:CURRENT_PSP]
mov cx, [es:PSP_JFT_SIZE]
xor bx, bx
.auto_closing_loop:
push cx
inc bx
call _close
pop cx
loop .auto_closing_loop
mov ds, [es:PSP_PARENT]
mov cx, ds
jcxz _int22_default
mov [cs:CURRENT_PSP], ds
mov ss, [PSP_SAVE_SSSP+2]
mov sp, [PSP_SAVE_SSSP]
mov dx, es
call _MCB_purge
xor ax, ax
jmp _return_from_int80
_int22_default:
push cs
pop ds
les bx, [_osz_systbl]
mov ax, [es:bx+OSZ_SYSTBL_ACPI]
or ax, ax
jz .no_acpi
mov ah, 5
call far [es:bx+OSZ_SYSTBL_ACPI]
.no_acpi:
mov ax, BIOS_POWER * 0x100
call _call_bios
_forever:
hlt
jmp _forever
_BDOS_exec:
mov bx, [bp+STK_BX]
push es
push bx
push ds
push dx
xor ah, ah
push ax
call _exec
add sp, 10
ret
; BP +4 ? 6 filename 10 arg?
_exec:
push bp
mov bp, sp
push es
push ds
push bx
push di
push si
lds si, [bp+6]
push cs
pop es
cmp BYTE [si+1], ':'
jnz .skip_drive
add si, 2
.skip_drive:
mov di, PROGNAME
mov cx, 8
.loop_progname:
lodsb
or al, al
jz .end_progname
cmp al, '.'
jz .end_progname
call _to_upper
stosb
loop .loop_progname
jmp .end_progname
.end_progname:
mov al, ' '
rep stosb
push cs
pop ds
xor cx, cx
push cx
mov ax, O_RDONLY
push ax
push WORD [bp+8]
push WORD [bp+6]
call _SFT_open
add sp, 8
or ax, ax
jns .open_ok
jmp .end
.open_ok:
mov bx, ax
mov cx, READ_EXE_SIZE
mov dx, EXE_HEADER
push cx
push ds
push dx
push bx
mov ax, OSZ_IFS_READ
push ax
call _SFT_RW
add sp, 10
or ax, ax
js .close
cmp ax, MIN_COM_SIZE
jb .noexec
.size_ok:
mov ax, [EXE_HEADER]
cmp ax, OSZ_STD_COM_SIGN_1
jz .std_com
cmp ax, OSZ_STD_COM_SIGN_2
jz .std_com
cmp ax, OSZ_STD_COM_SIGN_x1
jz .std_com2
cmp ax, OSZ_STD_COM_SIGN_x2
jz .std_com2
jmp .noexec
.std_com:
call _load_com
or ax, ax
js .close
jmp .end
.std_com2:
call _load_com2
or ax, ax
js .close
jmp .end
.noexec:
mov ax, ENOEXEC
.close:
push ax
push bx
call _SFT_close
pop ax
pop ax
.end:
pop di
pop si
pop bx
pop ds
pop es
mov sp, bp
pop bp
ret
_load_com_size_ng:
mov ax, ENOMEM
ret
_load_com:
call _SFT_get_size
or dx, dx
jnz short _load_com_size_ng
cmp ax, MAX_COM_SIZE
ja short _load_com_size_ng
mov si, ax
call _mcb_find_max_size
mov cl, 4
mov dx, MIN_COM_STACK + 0x010F
add dx, si
shr dx, cl
cmp ax, dx
jb short _load_com_size_ng
cmp ax, 0x1000
jae .mem_over64k
mov di, ax
shl di, cl
jmp .mem_ok
.mem_over64k:
xor di, di
.mem_ok:
mov cx, ax
mov al, MCB_FIRST_FIT
call _ZP_alloc
or ax, ax
jz short _load_com_size_ng
mov es, ax
jmp _load_com_next
_load_com2:
call _SFT_get_size
or dx, dx
jnz short _load_com_size_ng
cmp ax, MAX_COM_SIZE
ja short _load_com_size_ng
mov si, ax
call _mcb_find_max_size
mov cl, 4
mov dx, MIN_COM_STACK + 0x010F
add dx, si
shr dx, cl
cmp ax, dx
jb short _load_com_size_ng
mov di, dx
shl di, cl
mov cx, dx
mov al, MCB_LAST_FIT
call _ZP_alloc
or ax, ax
jz short _load_com_size_ng
mov es, ax
_load_com_next:
xor ax, ax
push ax
push ax
push ax
push bx
call _SFT_lseek
add sp, 8
push si
push es
mov dx, 0x0100
push dx
push bx
mov ax, OSZ_IFS_READ
push ax
call _SFT_RW
add sp, 10
cmp ax, si
jnz .ioerr
push bx
call _SFT_close
pop ax
push es
push di
mov ax, es
dec ax
mov es, ax
push cs
pop ds
mov si, PROGNAME
mov cx, 8
mov di, 8
rep movsb
pop di
pop es
mov ds, [cs:CURRENT_PSP]
call _clone
mov [cs:CURRENT_PSP], es
push di
lds si, [bp+10]
mov ax, ds
or ax, si
jz .noarg
lodsb
or al, al
jz .noarg
cmp al, 126
jc .nocliparg
mov al, 126
.nocliparg:
mov di, 0x0080
stosb
mov cl, al
xor ch, ch
rep movsb
mov al, 13
stosb
.endarg:
.noarg:
pop di
cli
mov dx, es
mov ds, dx
mov ss, dx
mov sp, di
xor ax, ax
mov si, 0x0102
push ax
push es
push si
xor cx, cx
xor dx, dx
xor bx, bx
xor si, si
xor di, di
mov bp, PSP_OSZ_BDOS
sti
retf
.ioerr:
; TODO: free
mov ax, EIO
.end:
ret
; ---------------------------------------------------------------------
int00_msg db 10, "#DIV/0", 10, 0
int01_msg db 10, "#DE", 10, 0
int03_msg db 10, "#BP", 10, 0
int04_msg db 10, "#OV", 10, 0
PROGNAME resb 8
EXE_HEADER resb READ_EXE_SIZE
alignb 16
_END_RESIDENT:
; ---------------------------------------------------------------------
db "M"
dw MCB_PID_SYSTEM, 0
resb 11
; TODO: dynamic
_SFT resb N_FILES * OSZ_SFT_MAX
DRIVES resb N_DRIVES * SIZE_DRIVE
SYSINIT db "INIT.BIN", 0
PANIC_NO_INIT_msg db "PANIC: Failed to invoke INIT.BIN",10,0
_init:
mov [_osz_systbl], bx
mov [_osz_systbl+2], es
;; INIT MCB
mov ax, cs
add ax, (_END_RESIDENT-_HEAD)/16
mov [FIRST_MCB], ax
mov dx, [es:bx+OSZ_SYSTBL_MEMSZ]
mov bp, [es:bx+OSZ_SYSTBL_RAMDSZ]
mov si, bp
add si, byte 0x000F
mov cl, 4
shr si, cl
sub dx, si
dec dx
mov ds, [es:bx+OSZ_SYSTBL_RAMD]
mov [es:bx+OSZ_SYSTBL_RAMD], dx
mov cx, bp
mov es, dx
mov si, cx
mov di, cx
dec si
dec di
std
rep movsb
cld
dec dx
mov es, dx
xor di, di
mov al, 'M'
stosb
mov ax, MCB_PID_SYSTEM
stosw
mov ax, bp
mov cl, 4
add ax, byte 0x000F
shr ax, cl
stosw
xor ax, ax
stosb
stosw
push cs
pop ds
stosw
stosw
stosw
stosw
mov bx, es
add bx, [es:3]
mov es, bx
mov al, 'Z'
stosb
mov ax, MCB_PID_SYSTEM
stosw
xor ax, ax
stosw
stosb
stosw
stosw
stosw
stosw
stosw
mov ax, [cs:FIRST_MCB]
sub dx, ax
dec dx
mov es, ax
mov [es:0x0003], dx
;; INIT DEVICE HEADER
push cs
pop ds
mov bx, _dev_hdr_NULL
mov ax, _dev_hdr_CON
mov [ds:bx], ax
mov [ds:bx+2], ds
mov word [LP_SFT], _SFT
mov [LP_SFT+2], ds
;; SET IVTS
push cs
pop ds
mov al, 0x21
mov dx, _int21
call int21_25n
mov al, OSZ_NATIVE_SVC_INT
mov dx, _int80
call int21_25n
mov ax, 0x2500
mov dx, _int00
call int21_25n
inc ax
mov dx, _int01
call int21_25n
inc ax
; skip int2
inc ax
mov dx, _int03
call int21_25n
inc ax
mov dx, _int04
call int21_25n
; ---
mov al, 0x20
mov dx, _int20
call int21_25n
inc ax
; skip 21
inc ax
mov dx, _int22_default
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int_nop
call int21_25n
inc ax
mov dx, _int29
call int21_25n
inc ax
mov dx, _int2A
call int21_25n
; 2B 2C 2D 2E 2F
mov cx, 5
.loop_int_nop:
inc ax
mov dx, _int_nop
call int21_25n
loop .loop_int_nop
;; PREPARE TO INVOKE SYSINIT
mov dx, [cs:FIRST_MCB]
inc dx
mov cx, (_END-_END_RESIDENT+15)/16
call _BDOS_mcb_realloc
;; INVOKE SYSINIT
push cs
pop ds
mov dx, SYSINIT
xor ax, ax
push ax
push ax
push ds
push dx
push ax
call _exec
add sp, 10
mov dx, PANIC_NO_INIT_msg
call _BDOS_puts
xor cx, cx
call _gets
jmp _int22_default
_END:
|
; A135916: (n^4 - 10*n^2 + 15*n - 6)/2.
; Submitted by Christian Krause
; 0,0,15,75,222,510,1005,1785,2940,4572,6795,9735,13530,18330,24297,31605,40440,51000,63495,78147,95190,114870,137445,163185,192372,225300,262275,303615,349650,400722,457185,519405,587760,662640,744447,833595,930510
mov $1,$0
add $0,5
mul $0,$1
bin $1,2
mul $0,$1
add $0,$1
|
; A010924: Pisot sequence E(8,55), a(n) = floor(a(n-1)^2/a(n-2) + 1/2).
; Submitted by Jon Maiga
; 8,55,378,2598,17856,122724,843480,5797224,39844224,273848688,1882157472,12936036960,88909166592,611071221312,4199882327424,28865721292416,198393621719040,1363556058068736,9371698078726656,64411524820772352,442699337396994048,3042665173306598400,20912187064221554688,143729113425168918528,987847802936342839296,6789461498169070546944,46663855806632480317440,320719903828809305186304,2204302557812650713022464,15150134769848760109252608,104126623965968464933650432,715660552414903350257418240
mov $1,1
add $1,$0
add $1,2
mov $0,$1
seq $0,57089 ; Scaled Chebyshev U-polynomials evaluated at i*sqrt(6)/2. Generalized Fibonacci sequence.
sub $0,288
div $0,36
add $0,8
|
; A107659: a(n) = Sum_{k=0..n} 2^max(k, n-k).
; 1,4,10,24,52,112,232,480,976,1984,4000,8064,16192,32512,65152,130560,261376,523264,1047040,2095104,4191232,8384512,16771072,33546240,67096576,134201344,268410880,536838144,1073692672,2147418112
add $0,1
mov $2,$0
mov $3,$0
lpb $0
sub $0,1
mov $1,$2
mul $2,2
trn $3,2
sub $2,$3
lpe
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ClapTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asfaihi <asfaihi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/01 09:17:01 by asfaihi #+# #+# */
/* Updated: 2021/11/12 14:17:14 by asfaihi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ClapTrap.hpp"
/// Constructors / Destructor
ClapTrap::ClapTrap( void ) : _HitPoints(10), _EnergyPoints(10), _AttackDamage(0) {
std::cout << "ClapTrap default constructor called" << std::endl;
}
ClapTrap::ClapTrap(std::string aName) : _Name(aName), _HitPoints(10), _EnergyPoints(10), _AttackDamage(0) {
std::cout << "ClapTrap parameterized constructor called" << std::endl;
}
ClapTrap::ClapTrap(ClapTrap const & src) {
std::cout << "ClapTrap Copy constructor called" << std::endl;
*this = src;
}
ClapTrap & ClapTrap::operator=(ClapTrap const & rhs) {
if (this == &rhs)
return *this;
this->_Name = rhs._Name;
this->_AttackDamage = rhs._AttackDamage;
this->_HitPoints = rhs._HitPoints;
this->_EnergyPoints = rhs._EnergyPoints;
return *this;
}
ClapTrap::~ClapTrap() {
std::cout << "ClapTrap destructor called" << std::endl;
}
/// Member functions
void ClapTrap::attack(std::string const & target) const {
std::cout << "ClapTrap " << this->_Name << " attacks " << target << ", causing " << this->_AttackDamage << " points of damage!" << std::endl;
}
void ClapTrap::takeDamage(unsigned int amount) const {
std::cout << "ClapTrap " << this->_Name << " took " << amount << " points of damage." << std::endl;
}
void ClapTrap::beRepaired(unsigned int amount) const {
std::cout << "ClapTrap " << this->_Name << " repaired life points by " << amount << "." << std::endl;
} |
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by D Morris - 15/10/98
;
;
; Page the graphics bank in/out - used by all gfx functions
; Simply does a swap...
;
; $Id: swapgfxbk.asm,v 1.8 2017/01/02 22:57:59 aralbrec Exp $
;
SECTION code_clib
PUBLIC swapgfxbk
PUBLIC _swapgfxbk
EXTERN gfx_bank
EXTERN z88_map_bank
PUBLIC swapgfxbk1
PUBLIC _swapgfxbk1
INCLUDE "graphics/grafix.inc"
.swapgfxbk
._swapgfxbk
.swapgfxbk1
._swapgfxbk1
push hl
push de
ld hl,z88_map_bank ;$4Dx
ld e,(hl)
ld a,(gfx_bank) ;in crt0
ld (hl),a
out (z88_map_bank-$400),a
ld a,e
ld (gfx_bank),a
pop de
pop hl
ret
|
0x0000 (0x000000) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0001 (0x000002) 0x2919- f:00024 d: 281 | OR[281] = A
0x0002 (0x000004) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0003 (0x000006) 0x291A- f:00024 d: 282 | OR[282] = A
0x0004 (0x000008) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0005 (0x00000A) 0x291B- f:00024 d: 283 | OR[283] = A
0x0006 (0x00000C) 0x101A- f:00010 d: 26 | A = 26 (0x001A)
0x0007 (0x00000E) 0x2929- f:00024 d: 297 | OR[297] = A
0x0008 (0x000010) 0x111B- f:00010 d: 283 | A = 283 (0x011B)
0x0009 (0x000012) 0x292A- f:00024 d: 298 | OR[298] = A
0x000A (0x000014) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x000B (0x000016) 0x5800- f:00054 d: 0 | B = A
0x000C (0x000018) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x000D (0x00001A) 0x7C09- f:00076 d: 9 | R = OR[9]
0x000E (0x00001C) 0x8602- f:00103 d: 2 | P = P + 2 (0x0010), A # 0
0x000F (0x00001E) 0x700B- f:00070 d: 11 | P = P + 11 (0x001A)
0x0010 (0x000020) 0x1007- f:00010 d: 7 | A = 7 (0x0007)
0x0011 (0x000022) 0x2929- f:00024 d: 297 | OR[297] = A
0x0012 (0x000024) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0013 (0x000026) 0x292A- f:00024 d: 298 | OR[298] = A
0x0014 (0x000028) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x0015 (0x00002A) 0x5800- f:00054 d: 0 | B = A
0x0016 (0x00002C) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x0018 (0x000030) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0019 (0x000032) 0x7213- f:00071 d: 19 | P = P - 19 (0x0006)
0x001A (0x000034) 0x2118- f:00020 d: 280 | A = OR[280]
0x001B (0x000036) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x001C (0x000038) 0x2908- f:00024 d: 264 | OR[264] = A
0x001D (0x00003A) 0x3108- f:00030 d: 264 | A = (OR[264])
0x001E (0x00003C) 0x291C- f:00024 d: 284 | OR[284] = A
0x001F (0x00003E) 0x211C- f:00020 d: 284 | A = OR[284]
0x0020 (0x000040) 0x290D- f:00024 d: 269 | OR[269] = A
0x0021 (0x000042) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0022 (0x000044) 0x290E- f:00024 d: 270 | OR[270] = A
0x0023 (0x000046) 0x2006- f:00020 d: 6 | A = OR[6]
0x0024 (0x000048) 0x2910- f:00024 d: 272 | OR[272] = A
0x0025 (0x00004A) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x0026 (0x00004C) 0x2929- f:00024 d: 297 | OR[297] = A
0x0027 (0x00004E) 0x1800-0x00A9 f:00014 d: 0 | A = 169 (0x00A9)
0x0029 (0x000052) 0x292A- f:00024 d: 298 | OR[298] = A
0x002A (0x000054) 0x1800-0x444B f:00014 d: 0 | A = 17483 (0x444B)
0x002C (0x000058) 0x292B- f:00024 d: 299 | OR[299] = A
0x002D (0x00005A) 0x210D- f:00020 d: 269 | A = OR[269]
0x002E (0x00005C) 0x292C- f:00024 d: 300 | OR[300] = A
0x002F (0x00005E) 0x1004- f:00010 d: 4 | A = 4 (0x0004)
0x0030 (0x000060) 0x292D- f:00024 d: 301 | OR[301] = A
0x0031 (0x000062) 0x210E- f:00020 d: 270 | A = OR[270]
0x0032 (0x000064) 0x292E- f:00024 d: 302 | OR[302] = A
0x0033 (0x000066) 0x210F- f:00020 d: 271 | A = OR[271]
0x0034 (0x000068) 0x292F- f:00024 d: 303 | OR[303] = A
0x0035 (0x00006A) 0x2110- f:00020 d: 272 | A = OR[272]
0x0036 (0x00006C) 0x2930- f:00024 d: 304 | OR[304] = A
0x0037 (0x00006E) 0x100E- f:00010 d: 14 | A = 14 (0x000E)
0x0038 (0x000070) 0x2931- f:00024 d: 305 | OR[305] = A
0x0039 (0x000072) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x003A (0x000074) 0x5800- f:00054 d: 0 | B = A
0x003B (0x000076) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x003D (0x00007A) 0x7C09- f:00076 d: 9 | R = OR[9]
0x003E (0x00007C) 0x2919- f:00024 d: 281 | OR[281] = A
0x003F (0x00007E) 0x2119- f:00020 d: 281 | A = OR[281]
0x0040 (0x000080) 0x8602- f:00103 d: 2 | P = P + 2 (0x0042), A # 0
0x0041 (0x000082) 0x7002- f:00070 d: 2 | P = P + 2 (0x0043)
0x0042 (0x000084) 0x7134- f:00070 d: 308 | P = P + 308 (0x0176)
0x0043 (0x000086) 0x1800-0x02D1 f:00014 d: 0 | A = 721 (0x02D1)
0x0045 (0x00008A) 0x291D- f:00024 d: 285 | OR[285] = A
0x0046 (0x00008C) 0x7E03-0x02CE f:00077 d: 3 | R = OR[3]+718 (0x02CE)
0x0048 (0x000090) 0x7E03-0x0295 f:00077 d: 3 | R = OR[3]+661 (0x0295)
0x004A (0x000094) 0x211A- f:00020 d: 282 | A = OR[282]
0x004B (0x000096) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002)
0x004C (0x000098) 0x2908- f:00024 d: 264 | OR[264] = A
0x004D (0x00009A) 0x3108- f:00030 d: 264 | A = (OR[264])
0x004E (0x00009C) 0x291E- f:00024 d: 286 | OR[286] = A
0x004F (0x00009E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0050 (0x0000A0) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x0051 (0x0000A2) 0x211E- f:00020 d: 286 | A = OR[286]
0x0052 (0x0000A4) 0xCA0F- f:00145 d: 15 | io 0017 (EXB), fn005 | Load device address
0x0053 (0x0000A6) 0x1002- f:00010 d: 2 | A = 2 (0x0002)
0x0054 (0x0000A8) 0xDE0F- f:00157 d: 15 | io 0017 (EXB), fn017 | Send control
0x0055 (0x0000AA) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x0057 (0x0000AE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0058 (0x0000B0) 0x291F- f:00024 d: 287 | OR[287] = A
0x0059 (0x0000B2) 0x2920- f:00024 d: 288 | OR[288] = A
0x005A (0x0000B4) 0x2921- f:00024 d: 289 | OR[289] = A
0x005B (0x0000B6) 0x211E- f:00020 d: 286 | A = OR[286]
0x005C (0x0000B8) 0x1630- f:00013 d: 48 | A = A - 48 (0x0030)
0x005D (0x0000BA) 0x8402- f:00102 d: 2 | P = P + 2 (0x005F), A = 0
0x005E (0x0000BC) 0x700B- f:00070 d: 11 | P = P + 11 (0x0069)
0x005F (0x0000BE) 0x1020- f:00010 d: 32 | A = 32 (0x0020)
0x0060 (0x0000C0) 0x2922- f:00024 d: 290 | OR[290] = A
0x0061 (0x0000C2) 0x1050- f:00010 d: 80 | A = 80 (0x0050)
0x0062 (0x0000C4) 0x2924- f:00024 d: 292 | OR[292] = A
0x0063 (0x0000C6) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0064 (0x0000C8) 0x2923- f:00024 d: 291 | OR[291] = A
0x0065 (0x0000CA) 0x211B- f:00020 d: 283 | A = OR[283]
0x0066 (0x0000CC) 0x2925- f:00024 d: 293 | OR[293] = A
0x0067 (0x0000CE) 0x753A- f:00072 d: 314 | R = P + 314 (0x01A1)
0x0068 (0x0000D0) 0x7011- f:00070 d: 17 | P = P + 17 (0x0079)
0x0069 (0x0000D2) 0x211E- f:00020 d: 286 | A = OR[286]
0x006A (0x0000D4) 0x1617- f:00013 d: 23 | A = A - 23 (0x0017)
0x006B (0x0000D6) 0x8402- f:00102 d: 2 | P = P + 2 (0x006D), A = 0
0x006C (0x0000D8) 0x700D- f:00070 d: 13 | P = P + 13 (0x0079)
0x006D (0x0000DA) 0x1023- f:00010 d: 35 | A = 35 (0x0023)
0x006E (0x0000DC) 0x2922- f:00024 d: 290 | OR[290] = A
0x006F (0x0000DE) 0x1080- f:00010 d: 128 | A = 128 (0x0080)
0x0070 (0x0000E0) 0xD80F- f:00154 d: 15 | io 0017 (EXB), fn014 | Data output to A register (DOA)
0x0071 (0x0000E2) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x0073 (0x0000E6) 0x1004- f:00010 d: 4 | A = 4 (0x0004)
0x0074 (0x0000E8) 0xDE0F- f:00157 d: 15 | io 0017 (EXB), fn017 | Send control
0x0075 (0x0000EA) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x0077 (0x0000EE) 0x7E03-0x023F f:00077 d: 3 | R = OR[3]+575 (0x023F)
0x0079 (0x0000F2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x007A (0x0000F4) 0x291F- f:00024 d: 287 | OR[287] = A
0x007B (0x0000F6) 0x211F- f:00020 d: 287 | A = OR[287]
0x007C (0x0000F8) 0x1E00-0x0337 f:00017 d: 0 | A = A - 823 (0x0337)
0x007E (0x0000FC) 0x84CF- f:00102 d: 207 | P = P + 207 (0x014D), A = 0
0x007F (0x0000FE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0080 (0x000100) 0x2920- f:00024 d: 288 | OR[288] = A
0x0081 (0x000102) 0x2120- f:00020 d: 288 | A = OR[288]
0x0082 (0x000104) 0x1605- f:00013 d: 5 | A = A - 5 (0x0005)
0x0083 (0x000106) 0x84C8- f:00102 d: 200 | P = P + 200 (0x014B), A = 0
0x0084 (0x000108) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0085 (0x00010A) 0x2921- f:00024 d: 289 | OR[289] = A
0x0086 (0x00010C) 0x211B- f:00020 d: 283 | A = OR[283]
0x0087 (0x00010E) 0x290E- f:00024 d: 270 | OR[270] = A
0x0088 (0x000110) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800)
0x008A (0x000114) 0x290D- f:00024 d: 269 | OR[269] = A
0x008B (0x000116) 0x210D- f:00020 d: 269 | A = OR[269]
0x008C (0x000118) 0x8406- f:00102 d: 6 | P = P + 6 (0x0092), A = 0
0x008D (0x00011A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x008E (0x00011C) 0x390E- f:00034 d: 270 | (OR[270]) = A
0x008F (0x00011E) 0x2F0D- f:00027 d: 269 | OR[269] = OR[269] - 1
0x0090 (0x000120) 0x2D0E- f:00026 d: 270 | OR[270] = OR[270] + 1
0x0091 (0x000122) 0x7206- f:00071 d: 6 | P = P - 6 (0x008B)
0x0092 (0x000124) 0x211B- f:00020 d: 283 | A = OR[283]
0x0093 (0x000126) 0x2925- f:00024 d: 293 | OR[293] = A
0x0094 (0x000128) 0x211E- f:00020 d: 286 | A = OR[286]
0x0095 (0x00012A) 0x1630- f:00013 d: 48 | A = A - 48 (0x0030)
0x0096 (0x00012C) 0x8402- f:00102 d: 2 | P = P + 2 (0x0098), A = 0
0x0097 (0x00012E) 0x7046- f:00070 d: 70 | P = P + 70 (0x00DD)
0x0098 (0x000130) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0099 (0x000132) 0x2913- f:00024 d: 275 | OR[275] = A
0x009A (0x000134) 0x2120- f:00020 d: 288 | A = OR[288]
0x009B (0x000136) 0x0A06- f:00005 d: 6 | A = A < 6 (0x0006)
0x009C (0x000138) 0x2921- f:00024 d: 289 | OR[289] = A
0x009D (0x00013A) 0x2113- f:00020 d: 275 | A = OR[275]
0x009E (0x00013C) 0x1620- f:00013 d: 32 | A = A - 32 (0x0020)
0x009F (0x00013E) 0x842C- f:00102 d: 44 | P = P + 44 (0x00CB), A = 0
0x00A0 (0x000140) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00A1 (0x000142) 0x2914- f:00024 d: 276 | OR[276] = A
0x00A2 (0x000144) 0x2113- f:00020 d: 275 | A = OR[275]
0x00A3 (0x000146) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x00A4 (0x000148) 0x2908- f:00024 d: 264 | OR[264] = A
0x00A5 (0x00014A) 0x1020- f:00010 d: 32 | A = 32 (0x0020)
0x00A6 (0x00014C) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x00A7 (0x00014E) 0x8402- f:00102 d: 2 | P = P + 2 (0x00A9), A = 0
0x00A8 (0x000150) 0x7019- f:00070 d: 25 | P = P + 25 (0x00C1)
0x00A9 (0x000152) 0x1800-0x1000 f:00014 d: 0 | A = 4096 (0x1000)
0x00AB (0x000156) 0x2914- f:00024 d: 276 | OR[276] = A
0x00AC (0x000158) 0x2120- f:00020 d: 288 | A = OR[288]
0x00AD (0x00015A) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x00AE (0x00015C) 0x2908- f:00024 d: 264 | OR[264] = A
0x00AF (0x00015E) 0x1005- f:00010 d: 5 | A = 5 (0x0005)
0x00B0 (0x000160) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x00B1 (0x000162) 0x8402- f:00102 d: 2 | P = P + 2 (0x00B3), A = 0
0x00B2 (0x000164) 0x700F- f:00070 d: 15 | P = P + 15 (0x00C1)
0x00B3 (0x000166) 0x1800-0x3000 f:00014 d: 0 | A = 12288 (0x3000)
0x00B5 (0x00016A) 0x2914- f:00024 d: 276 | OR[276] = A
0x00B6 (0x00016C) 0x211F- f:00020 d: 287 | A = OR[287]
0x00B7 (0x00016E) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x00B8 (0x000170) 0x2908- f:00024 d: 264 | OR[264] = A
0x00B9 (0x000172) 0x1800-0x0337 f:00014 d: 0 | A = 823 (0x0337)
0x00BB (0x000176) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x00BC (0x000178) 0x8402- f:00102 d: 2 | P = P + 2 (0x00BE), A = 0
0x00BD (0x00017A) 0x7004- f:00070 d: 4 | P = P + 4 (0x00C1)
0x00BE (0x00017C) 0x1800-0x7000 f:00014 d: 0 | A = 28672 (0x7000)
0x00C0 (0x000180) 0x2914- f:00024 d: 276 | OR[276] = A
0x00C1 (0x000182) 0x211F- f:00020 d: 287 | A = OR[287]
0x00C2 (0x000184) 0x2514- f:00022 d: 276 | A = A + OR[276]
0x00C3 (0x000186) 0x3925- f:00034 d: 293 | (OR[293]) = A
0x00C4 (0x000188) 0x2D25- f:00026 d: 293 | OR[293] = OR[293] + 1
0x00C5 (0x00018A) 0x2121- f:00020 d: 289 | A = OR[289]
0x00C6 (0x00018C) 0x3925- f:00034 d: 293 | (OR[293]) = A
0x00C7 (0x00018E) 0x2D25- f:00026 d: 293 | OR[293] = OR[293] + 1
0x00C8 (0x000190) 0x2D21- f:00026 d: 289 | OR[289] = OR[289] + 1
0x00C9 (0x000192) 0x2D13- f:00026 d: 275 | OR[275] = OR[275] + 1
0x00CA (0x000194) 0x722D- f:00071 d: 45 | P = P - 45 (0x009D)
0x00CB (0x000196) 0x1010- f:00010 d: 16 | A = 16 (0x0010)
0x00CC (0x000198) 0x2924- f:00024 d: 292 | OR[292] = A
0x00CD (0x00019A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00CE (0x00019C) 0x2923- f:00024 d: 291 | OR[291] = A
0x00CF (0x00019E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00D0 (0x0001A0) 0x2921- f:00024 d: 289 | OR[289] = A
0x00D1 (0x0001A2) 0x211B- f:00020 d: 283 | A = OR[283]
0x00D2 (0x0001A4) 0x2925- f:00024 d: 293 | OR[293] = A
0x00D3 (0x0001A6) 0x74CE- f:00072 d: 206 | R = P + 206 (0x01A1)
0x00D4 (0x0001A8) 0x1020- f:00010 d: 32 | A = 32 (0x0020)
0x00D5 (0x0001AA) 0x2924- f:00024 d: 292 | OR[292] = A
0x00D6 (0x0001AC) 0x1800-0x4000 f:00014 d: 0 | A = 16384 (0x4000)
0x00D8 (0x0001B0) 0x2923- f:00024 d: 291 | OR[291] = A
0x00D9 (0x0001B2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00DA (0x0001B4) 0x2925- f:00024 d: 293 | OR[293] = A
0x00DB (0x0001B6) 0x74C6- f:00072 d: 198 | R = P + 198 (0x01A1)
0x00DC (0x0001B8) 0x706D- f:00070 d: 109 | P = P + 109 (0x0149)
0x00DD (0x0001BA) 0x211E- f:00020 d: 286 | A = OR[286]
0x00DE (0x0001BC) 0x1617- f:00013 d: 23 | A = A - 23 (0x0017)
0x00DF (0x0001BE) 0x8402- f:00102 d: 2 | P = P + 2 (0x00E1), A = 0
0x00E0 (0x0001C0) 0x7069- f:00070 d: 105 | P = P + 105 (0x0149)
0x00E1 (0x0001C2) 0x2121- f:00020 d: 289 | A = OR[289]
0x00E2 (0x0001C4) 0x1623- f:00013 d: 35 | A = A - 35 (0x0023)
0x00E3 (0x0001C6) 0x845C- f:00102 d: 92 | P = P + 92 (0x013F), A = 0
0x00E4 (0x0001C8) 0x2125- f:00020 d: 293 | A = OR[293]
0x00E5 (0x0001CA) 0x140D- f:00012 d: 13 | A = A + 13 (0x000D)
0x00E6 (0x0001CC) 0x2908- f:00024 d: 264 | OR[264] = A
0x00E7 (0x0001CE) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00E8 (0x0001D0) 0x0E0C- f:00007 d: 12 | A = A << 12 (0x000C)
0x00E9 (0x0001D2) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x00EA (0x0001D4) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x00EB (0x0001D6) 0x0C0D- f:00006 d: 13 | A = A >> 13 (0x000D)
0x00EC (0x0001D8) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x00ED (0x0001DA) 0x2125- f:00020 d: 293 | A = OR[293]
0x00EE (0x0001DC) 0x1415- f:00012 d: 21 | A = A + 21 (0x0015)
0x00EF (0x0001DE) 0x2908- f:00024 d: 264 | OR[264] = A
0x00F0 (0x0001E0) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00F1 (0x0001E2) 0x1A00-0xFFFE f:00015 d: 0 | A = A & 65534 (0xFFFE)
0x00F3 (0x0001E6) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x00F4 (0x0001E8) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x00F5 (0x0001EA) 0x2120- f:00020 d: 288 | A = OR[288]
0x00F6 (0x0001EC) 0x121F- f:00011 d: 31 | A = A & 31 (0x001F)
0x00F7 (0x0001EE) 0x2920- f:00024 d: 288 | OR[288] = A
0x00F8 (0x0001F0) 0x2125- f:00020 d: 293 | A = OR[293]
0x00F9 (0x0001F2) 0x140E- f:00012 d: 14 | A = A + 14 (0x000E)
0x00FA (0x0001F4) 0x2908- f:00024 d: 264 | OR[264] = A
0x00FB (0x0001F6) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00FC (0x0001F8) 0x0E04- f:00007 d: 4 | A = A << 4 (0x0004)
0x00FD (0x0001FA) 0x0A05- f:00005 d: 5 | A = A < 5 (0x0005)
0x00FE (0x0001FC) 0x2520- f:00022 d: 288 | A = A + OR[288]
0x00FF (0x0001FE) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x0100 (0x000200) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0101 (0x000202) 0x2121- f:00020 d: 289 | A = OR[289]
0x0102 (0x000204) 0x0803- f:00004 d: 3 | A = A > 3 (0x0003)
0x0103 (0x000206) 0x1207- f:00011 d: 7 | A = A & 7 (0x0007)
0x0104 (0x000208) 0x2913- f:00024 d: 275 | OR[275] = A
0x0105 (0x00020A) 0x2113- f:00020 d: 275 | A = OR[275]
0x0106 (0x00020C) 0x1207- f:00011 d: 7 | A = A & 7 (0x0007)
0x0107 (0x00020E) 0x2913- f:00024 d: 275 | OR[275] = A
0x0108 (0x000210) 0x2125- f:00020 d: 293 | A = OR[293]
0x0109 (0x000212) 0x140D- f:00012 d: 13 | A = A + 13 (0x000D)
0x010A (0x000214) 0x2908- f:00024 d: 264 | OR[264] = A
0x010B (0x000216) 0x3108- f:00030 d: 264 | A = (OR[264])
0x010C (0x000218) 0x1A00-0xFFF8 f:00015 d: 0 | A = A & 65528 (0xFFF8)
0x010E (0x00021C) 0x2513- f:00022 d: 275 | A = A + OR[275]
0x010F (0x00021E) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0110 (0x000220) 0x2121- f:00020 d: 289 | A = OR[289]
0x0111 (0x000222) 0x1207- f:00011 d: 7 | A = A & 7 (0x0007)
0x0112 (0x000224) 0x2913- f:00024 d: 275 | OR[275] = A
0x0113 (0x000226) 0x2113- f:00020 d: 275 | A = OR[275]
0x0114 (0x000228) 0x1207- f:00011 d: 7 | A = A & 7 (0x0007)
0x0115 (0x00022A) 0x2913- f:00024 d: 275 | OR[275] = A
0x0116 (0x00022C) 0x2125- f:00020 d: 293 | A = OR[293]
0x0117 (0x00022E) 0x140E- f:00012 d: 14 | A = A + 14 (0x000E)
0x0118 (0x000230) 0x2908- f:00024 d: 264 | OR[264] = A
0x0119 (0x000232) 0x3108- f:00030 d: 264 | A = (OR[264])
0x011A (0x000234) 0x0A04- f:00005 d: 4 | A = A < 4 (0x0004)
0x011B (0x000236) 0x2513- f:00022 d: 275 | A = A + OR[275]
0x011C (0x000238) 0x0C04- f:00006 d: 4 | A = A >> 4 (0x0004)
0x011D (0x00023A) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x011E (0x00023C) 0x211F- f:00020 d: 287 | A = OR[287]
0x011F (0x00023E) 0x0802- f:00004 d: 2 | A = A > 2 (0x0002)
0x0120 (0x000240) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x0121 (0x000242) 0x2913- f:00024 d: 275 | OR[275] = A
0x0122 (0x000244) 0x2113- f:00020 d: 275 | A = OR[275]
0x0123 (0x000246) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x0124 (0x000248) 0x2913- f:00024 d: 275 | OR[275] = A
0x0125 (0x00024A) 0x2125- f:00020 d: 293 | A = OR[293]
0x0126 (0x00024C) 0x140E- f:00012 d: 14 | A = A + 14 (0x000E)
0x0127 (0x00024E) 0x2908- f:00024 d: 264 | OR[264] = A
0x0128 (0x000250) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0129 (0x000252) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x012B (0x000256) 0x2513- f:00022 d: 275 | A = A + OR[275]
0x012C (0x000258) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x012D (0x00025A) 0x211F- f:00020 d: 287 | A = OR[287]
0x012E (0x00025C) 0x1203- f:00011 d: 3 | A = A & 3 (0x0003)
0x012F (0x00025E) 0x2913- f:00024 d: 275 | OR[275] = A
0x0130 (0x000260) 0x2113- f:00020 d: 275 | A = OR[275]
0x0131 (0x000262) 0x1203- f:00011 d: 3 | A = A & 3 (0x0003)
0x0132 (0x000264) 0x2913- f:00024 d: 275 | OR[275] = A
0x0133 (0x000266) 0x2125- f:00020 d: 293 | A = OR[293]
0x0134 (0x000268) 0x140F- f:00012 d: 15 | A = A + 15 (0x000F)
0x0135 (0x00026A) 0x2908- f:00024 d: 264 | OR[264] = A
0x0136 (0x00026C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0137 (0x00026E) 0x0A03- f:00005 d: 3 | A = A < 3 (0x0003)
0x0138 (0x000270) 0x2513- f:00022 d: 275 | A = A + OR[275]
0x0139 (0x000272) 0x0C03- f:00006 d: 3 | A = A >> 3 (0x0003)
0x013A (0x000274) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x013B (0x000276) 0x2D21- f:00026 d: 289 | OR[289] = OR[289] + 1
0x013C (0x000278) 0x1020- f:00010 d: 32 | A = 32 (0x0020)
0x013D (0x00027A) 0x2B25- f:00025 d: 293 | OR[293] = A + OR[293]
0x013E (0x00027C) 0x725D- f:00071 d: 93 | P = P - 93 (0x00E1)
0x013F (0x00027E) 0x1800-0x0780 f:00014 d: 0 | A = 1920 (0x0780)
0x0141 (0x000282) 0x2924- f:00024 d: 292 | OR[292] = A
0x0142 (0x000284) 0x1100- f:00010 d: 256 | A = 256 (0x0100)
0x0143 (0x000286) 0x2923- f:00024 d: 291 | OR[291] = A
0x0144 (0x000288) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0145 (0x00028A) 0x2921- f:00024 d: 289 | OR[289] = A
0x0146 (0x00028C) 0x211B- f:00020 d: 283 | A = OR[283]
0x0147 (0x00028E) 0x2925- f:00024 d: 293 | OR[293] = A
0x0148 (0x000290) 0x7459- f:00072 d: 89 | R = P + 89 (0x01A1)
0x0149 (0x000292) 0x2D20- f:00026 d: 288 | OR[288] = OR[288] + 1
0x014A (0x000294) 0x72C9- f:00071 d: 201 | P = P - 201 (0x0081)
0x014B (0x000296) 0x2D1F- f:00026 d: 287 | OR[287] = OR[287] + 1
0x014C (0x000298) 0x72D1- f:00071 d: 209 | P = P - 209 (0x007B)
0x014D (0x00029A) 0x211B- f:00020 d: 283 | A = OR[283]
0x014E (0x00029C) 0x8602- f:00103 d: 2 | P = P + 2 (0x0150), A # 0
0x014F (0x00029E) 0x7009- f:00070 d: 9 | P = P + 9 (0x0158)
0x0150 (0x0002A0) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x0151 (0x0002A2) 0x2929- f:00024 d: 297 | OR[297] = A
0x0152 (0x0002A4) 0x211B- f:00020 d: 283 | A = OR[283]
0x0153 (0x0002A6) 0x292A- f:00024 d: 298 | OR[298] = A
0x0154 (0x0002A8) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x0155 (0x0002AA) 0x5800- f:00054 d: 0 | B = A
0x0156 (0x0002AC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0157 (0x0002AE) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0158 (0x0002B0) 0x211A- f:00020 d: 282 | A = OR[282]
0x0159 (0x0002B2) 0x8602- f:00103 d: 2 | P = P + 2 (0x015B), A # 0
0x015A (0x0002B4) 0x7011- f:00070 d: 17 | P = P + 17 (0x016B)
0x015B (0x0002B6) 0x1006- f:00010 d: 6 | A = 6 (0x0006)
0x015C (0x0002B8) 0x290D- f:00024 d: 269 | OR[269] = A
0x015D (0x0002BA) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x015E (0x0002BC) 0x2929- f:00024 d: 297 | OR[297] = A
0x015F (0x0002BE) 0x1800-0x00A5 f:00014 d: 0 | A = 165 (0x00A5)
0x0161 (0x0002C2) 0x292A- f:00024 d: 298 | OR[298] = A
0x0162 (0x0002C4) 0x211A- f:00020 d: 282 | A = OR[282]
0x0163 (0x0002C6) 0x292B- f:00024 d: 299 | OR[299] = A
0x0164 (0x0002C8) 0x210D- f:00020 d: 269 | A = OR[269]
0x0165 (0x0002CA) 0x292C- f:00024 d: 300 | OR[300] = A
0x0166 (0x0002CC) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x0167 (0x0002CE) 0x5800- f:00054 d: 0 | B = A
0x0168 (0x0002D0) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x016A (0x0002D4) 0x7C09- f:00076 d: 9 | R = OR[9]
0x016B (0x0002D6) 0x2005- f:00020 d: 5 | A = OR[5]
0x016C (0x0002D8) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006)
0x016D (0x0002DA) 0x2908- f:00024 d: 264 | OR[264] = A
0x016E (0x0002DC) 0x2119- f:00020 d: 281 | A = OR[281]
0x016F (0x0002DE) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0170 (0x0002E0) 0x102A- f:00010 d: 42 | A = 42 (0x002A)
0x0171 (0x0002E2) 0x2929- f:00024 d: 297 | OR[297] = A
0x0172 (0x0002E4) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x0173 (0x0002E6) 0x5800- f:00054 d: 0 | B = A
0x0174 (0x0002E8) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0175 (0x0002EA) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0176 (0x0002EC) 0x2119- f:00020 d: 281 | A = OR[281]
0x0177 (0x0002EE) 0x1605- f:00013 d: 5 | A = A - 5 (0x0005)
0x0178 (0x0002F0) 0x8402- f:00102 d: 2 | P = P + 2 (0x017A), A = 0
0x0179 (0x0002F2) 0x7005- f:00070 d: 5 | P = P + 5 (0x017E)
0x017A (0x0002F4) 0x1800-0x0646 f:00014 d: 0 | A = 1606 (0x0646)
0x017C (0x0002F8) 0x2919- f:00024 d: 281 | OR[281] = A
0x017D (0x0002FA) 0x7023- f:00070 d: 35 | P = P + 35 (0x01A0)
0x017E (0x0002FC) 0x2119- f:00020 d: 281 | A = OR[281]
0x017F (0x0002FE) 0x160A- f:00013 d: 10 | A = A - 10 (0x000A)
0x0180 (0x000300) 0x8402- f:00102 d: 2 | P = P + 2 (0x0182), A = 0
0x0181 (0x000302) 0x7005- f:00070 d: 5 | P = P + 5 (0x0186)
0x0182 (0x000304) 0x1800-0x064E f:00014 d: 0 | A = 1614 (0x064E)
0x0184 (0x000308) 0x2919- f:00024 d: 281 | OR[281] = A
0x0185 (0x00030A) 0x701B- f:00070 d: 27 | P = P + 27 (0x01A0)
0x0186 (0x00030C) 0x2119- f:00020 d: 281 | A = OR[281]
0x0187 (0x00030E) 0x1608- f:00013 d: 8 | A = A - 8 (0x0008)
0x0188 (0x000310) 0x8402- f:00102 d: 2 | P = P + 2 (0x018A), A = 0
0x0189 (0x000312) 0x7005- f:00070 d: 5 | P = P + 5 (0x018E)
0x018A (0x000314) 0x1800-0x0649 f:00014 d: 0 | A = 1609 (0x0649)
0x018C (0x000318) 0x2919- f:00024 d: 281 | OR[281] = A
0x018D (0x00031A) 0x7013- f:00070 d: 19 | P = P + 19 (0x01A0)
0x018E (0x00031C) 0x2119- f:00020 d: 281 | A = OR[281]
0x018F (0x00031E) 0x1609- f:00013 d: 9 | A = A - 9 (0x0009)
0x0190 (0x000320) 0x8402- f:00102 d: 2 | P = P + 2 (0x0192), A = 0
0x0191 (0x000322) 0x7005- f:00070 d: 5 | P = P + 5 (0x0196)
0x0192 (0x000324) 0x1800-0x064D f:00014 d: 0 | A = 1613 (0x064D)
0x0194 (0x000328) 0x2919- f:00024 d: 281 | OR[281] = A
0x0195 (0x00032A) 0x700B- f:00070 d: 11 | P = P + 11 (0x01A0)
0x0196 (0x00032C) 0x2119- f:00020 d: 281 | A = OR[281]
0x0197 (0x00032E) 0x1602- f:00013 d: 2 | A = A - 2 (0x0002)
0x0198 (0x000330) 0x8405- f:00102 d: 5 | P = P + 5 (0x019D), A = 0
0x0199 (0x000332) 0x2119- f:00020 d: 281 | A = OR[281]
0x019A (0x000334) 0x1603- f:00013 d: 3 | A = A - 3 (0x0003)
0x019B (0x000336) 0x8402- f:00102 d: 2 | P = P + 2 (0x019D), A = 0
0x019C (0x000338) 0x7004- f:00070 d: 4 | P = P + 4 (0x01A0)
0x019D (0x00033A) 0x1800-0x064C f:00014 d: 0 | A = 1612 (0x064C)
0x019F (0x00033E) 0x2919- f:00024 d: 281 | OR[281] = A
0x01A0 (0x000340) 0x7253- f:00071 d: 83 | P = P - 83 (0x014D)
0x01A1 (0x000342) 0x211A- f:00020 d: 282 | A = OR[282]
0x01A2 (0x000344) 0x1413- f:00012 d: 19 | A = A + 19 (0x0013)
0x01A3 (0x000346) 0x2908- f:00024 d: 264 | OR[264] = A
0x01A4 (0x000348) 0x2124- f:00020 d: 292 | A = OR[292]
0x01A5 (0x00034A) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01A6 (0x00034C) 0x211A- f:00020 d: 282 | A = OR[282]
0x01A7 (0x00034E) 0x1414- f:00012 d: 20 | A = A + 20 (0x0014)
0x01A8 (0x000350) 0x2908- f:00024 d: 264 | OR[264] = A
0x01A9 (0x000352) 0x211F- f:00020 d: 287 | A = OR[287]
0x01AA (0x000354) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01AB (0x000356) 0x211A- f:00020 d: 282 | A = OR[282]
0x01AC (0x000358) 0x1415- f:00012 d: 21 | A = A + 21 (0x0015)
0x01AD (0x00035A) 0x2908- f:00024 d: 264 | OR[264] = A
0x01AE (0x00035C) 0x2120- f:00020 d: 288 | A = OR[288]
0x01AF (0x00035E) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01B0 (0x000360) 0x211A- f:00020 d: 282 | A = OR[282]
0x01B1 (0x000362) 0x1416- f:00012 d: 22 | A = A + 22 (0x0016)
0x01B2 (0x000364) 0x2908- f:00024 d: 264 | OR[264] = A
0x01B3 (0x000366) 0x2121- f:00020 d: 289 | A = OR[289]
0x01B4 (0x000368) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01B5 (0x00036A) 0x211A- f:00020 d: 282 | A = OR[282]
0x01B6 (0x00036C) 0x1417- f:00012 d: 23 | A = A + 23 (0x0017)
0x01B7 (0x00036E) 0x2908- f:00024 d: 264 | OR[264] = A
0x01B8 (0x000370) 0x2125- f:00020 d: 293 | A = OR[293]
0x01B9 (0x000372) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01BA (0x000374) 0x211E- f:00020 d: 286 | A = OR[286]
0x01BB (0x000376) 0x1630- f:00013 d: 48 | A = A - 48 (0x0030)
0x01BC (0x000378) 0x8402- f:00102 d: 2 | P = P + 2 (0x01BE), A = 0
0x01BD (0x00037A) 0x702F- f:00070 d: 47 | P = P + 47 (0x01EC)
0x01BE (0x00037C) 0x2123- f:00020 d: 291 | A = OR[291]
0x01BF (0x00037E) 0xD80F- f:00154 d: 15 | io 0017 (EXB), fn014 | Data output to A register (DOA)
0x01C0 (0x000380) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01C2 (0x000384) 0x211F- f:00020 d: 287 | A = OR[287]
0x01C3 (0x000386) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x01C4 (0x000388) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01C6 (0x00038C) 0x1005- f:00010 d: 5 | A = 5 (0x0005)
0x01C7 (0x00038E) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01C8 (0x000390) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01CA (0x000394) 0x2120- f:00020 d: 288 | A = OR[288]
0x01CB (0x000396) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x01CC (0x000398) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01CE (0x00039C) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x01CF (0x00039E) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01D0 (0x0003A0) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01D2 (0x0003A4) 0x2121- f:00020 d: 289 | A = OR[289]
0x01D3 (0x0003A6) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x01D4 (0x0003A8) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01D6 (0x0003AC) 0x1002- f:00010 d: 2 | A = 2 (0x0002)
0x01D7 (0x0003AE) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01D8 (0x0003B0) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01DA (0x0003B4) 0x2122- f:00020 d: 290 | A = OR[290]
0x01DB (0x0003B6) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x01DC (0x0003B8) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01DE (0x0003BC) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x01DF (0x0003BE) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01E0 (0x0003C0) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01E2 (0x0003C4) 0x2125- f:00020 d: 293 | A = OR[293]
0x01E3 (0x0003C6) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x01E4 (0x0003C8) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01E6 (0x0003CC) 0x2124- f:00020 d: 292 | A = OR[292]
0x01E7 (0x0003CE) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01E8 (0x0003D0) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01EA (0x0003D4) 0x7A03-0x0224 f:00075 d: 3 | P = OR[3]+548 (0x0224)
0x01EC (0x0003D8) 0x211E- f:00020 d: 286 | A = OR[286]
0x01ED (0x0003DA) 0x1617- f:00013 d: 23 | A = A - 23 (0x0017)
0x01EE (0x0003DC) 0x8403- f:00102 d: 3 | P = P + 3 (0x01F1), A = 0
0x01EF (0x0003DE) 0x7A03-0x0224 f:00075 d: 3 | P = OR[3]+548 (0x0224)
0x01F1 (0x0003E2) 0x2123- f:00020 d: 291 | A = OR[291]
0x01F2 (0x0003E4) 0xD80F- f:00154 d: 15 | io 0017 (EXB), fn014 | Data output to A register (DOA)
0x01F3 (0x0003E6) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01F5 (0x0003EA) 0x211F- f:00020 d: 287 | A = OR[287]
0x01F6 (0x0003EC) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x01F7 (0x0003EE) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01F9 (0x0003F2) 0x1004- f:00010 d: 4 | A = 4 (0x0004)
0x01FA (0x0003F4) 0xDE0F- f:00157 d: 15 | io 0017 (EXB), fn017 | Send control
0x01FB (0x0003F6) 0x7E03-0x0233 f:00077 d: 3 | R = OR[3]+563 (0x0233)
0x01FD (0x0003FA) 0x7E03-0x023F f:00077 d: 3 | R = OR[3]+575 (0x023F)
0x01FF (0x0003FE) 0x2124- f:00020 d: 292 | A = OR[292]
0x0200 (0x000400) 0xD80F- f:00154 d: 15 | io 0017 (EXB), fn014 | Data output to A register (DOA)
0x0201 (0x000402) 0x742C- f:00072 d: 44 | R = P + 44 (0x022D)
0x0202 (0x000404) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0203 (0x000406) 0x2722- f:00023 d: 290 | A = A - OR[290]
0x0204 (0x000408) 0x1220- f:00011 d: 32 | A = A & 32 (0x0020)
0x0205 (0x00040A) 0x290D- f:00024 d: 269 | OR[269] = A
0x0206 (0x00040C) 0x2121- f:00020 d: 289 | A = OR[289]
0x0207 (0x00040E) 0x1220- f:00011 d: 32 | A = A & 32 (0x0020)
0x0208 (0x000410) 0x0A05- f:00005 d: 5 | A = A < 5 (0x0005)
0x0209 (0x000412) 0x250D- f:00022 d: 269 | A = A + OR[269]
0x020A (0x000414) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x020B (0x000416) 0x7422- f:00072 d: 34 | R = P + 34 (0x022D)
0x020C (0x000418) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x020D (0x00041A) 0x2722- f:00023 d: 290 | A = A - OR[290]
0x020E (0x00041C) 0x121F- f:00011 d: 31 | A = A & 31 (0x001F)
0x020F (0x00041E) 0x290D- f:00024 d: 269 | OR[269] = A
0x0210 (0x000420) 0x2121- f:00020 d: 289 | A = OR[289]
0x0211 (0x000422) 0x121F- f:00011 d: 31 | A = A & 31 (0x001F)
0x0212 (0x000424) 0x0A05- f:00005 d: 5 | A = A < 5 (0x0005)
0x0213 (0x000426) 0x250D- f:00022 d: 269 | A = A + OR[269]
0x0214 (0x000428) 0x290D- f:00024 d: 269 | OR[269] = A
0x0215 (0x00042A) 0x2120- f:00020 d: 288 | A = OR[288]
0x0216 (0x00042C) 0x121F- f:00011 d: 31 | A = A & 31 (0x001F)
0x0217 (0x00042E) 0x0A0A- f:00005 d: 10 | A = A < 10 (0x000A)
0x0218 (0x000430) 0x250D- f:00022 d: 269 | A = A + OR[269]
0x0219 (0x000432) 0xDC0F- f:00156 d: 15 | io 0017 (EXB), fn016 | Data output to C register (DOC)
0x021A (0x000434) 0x7413- f:00072 d: 19 | R = P + 19 (0x022D)
0x021B (0x000436) 0x2125- f:00020 d: 293 | A = OR[293]
0x021C (0x000438) 0xDA0F- f:00155 d: 15 | io 0017 (EXB), fn015 | Data output to B register (DOB)
0x021D (0x00043A) 0x7410- f:00072 d: 16 | R = P + 16 (0x022D)
0x021E (0x00043C) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x021F (0x00043E) 0xDE0F- f:00157 d: 15 | io 0017 (EXB), fn017 | Send control
0x0220 (0x000440) 0x740D- f:00072 d: 13 | R = P + 13 (0x022D)
0x0221 (0x000442) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0222 (0x000444) 0xCC0F- f:00146 d: 15 | io 0017 (EXB), fn006 | Send interface mask (MSKO)
0x0223 (0x000446) 0x211A- f:00020 d: 282 | A = OR[282]
0x0224 (0x000448) 0x1411- f:00012 d: 17 | A = A + 17 (0x0011)
0x0225 (0x00044A) 0x2908- f:00024 d: 264 | OR[264] = A
0x0226 (0x00044C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0227 (0x00044E) 0x0A09- f:00005 d: 9 | A = A < 9 (0x0009)
0x0228 (0x000450) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0229 (0x000452) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x022A (0x000454) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x022B (0x000456) 0x7424- f:00072 d: 36 | R = P + 36 (0x024F)
0x022C (0x000458) 0x0200- f:00001 d: 0 | EXIT
0x022D (0x00045A) 0x1190- f:00010 d: 400 | A = 400 (0x0190)
0x022E (0x00045C) 0x8405- f:00102 d: 5 | P = P + 5 (0x0233), A = 0
0x022F (0x00045E) 0x420F- f:00041 d: 15 | C = 1, io 0017 (EXB) = BZ
0x0230 (0x000460) 0x8003- f:00100 d: 3 | P = P + 3 (0x0233), C = 0
0x0231 (0x000462) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x0232 (0x000464) 0x7204- f:00071 d: 4 | P = P - 4 (0x022E)
0x0233 (0x000466) 0x8402- f:00102 d: 2 | P = P + 2 (0x0235), A = 0
0x0234 (0x000468) 0x7004- f:00070 d: 4 | P = P + 4 (0x0238)
0x0235 (0x00046A) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0236 (0x00046C) 0x2926- f:00024 d: 294 | OR[294] = A
0x0237 (0x00046E) 0x74B3- f:00072 d: 179 | R = P + 179 (0x02EA)
0x0238 (0x000470) 0x0200- f:00001 d: 0 | EXIT
0x0239 (0x000472) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x023A (0x000474) 0x2927- f:00024 d: 295 | OR[295] = A
0x023B (0x000476) 0x2127- f:00020 d: 295 | A = OR[295]
0x023C (0x000478) 0x8412- f:00102 d: 18 | P = P + 18 (0x024E), A = 0
0x023D (0x00047A) 0xC20F- f:00141 d: 15 | io 0017 (EXB), fn001 | Request data input from A register (DIA)
0x023E (0x00047C) 0x7611- f:00073 d: 17 | R = P - 17 (0x022D)
0x023F (0x00047E) 0xD00F- f:00150 d: 15 | io 0017 (EXB), fn010 | Read data bus status
0x0240 (0x000480) 0x2927- f:00024 d: 295 | OR[295] = A
0x0241 (0x000482) 0x2127- f:00020 d: 295 | A = OR[295]
0x0242 (0x000484) 0x1A00-0x8000 f:00015 d: 0 | A = A & 32768 (0x8000)
0x0244 (0x000488) 0x2908- f:00024 d: 264 | OR[264] = A
0x0245 (0x00048A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0246 (0x00048C) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x0247 (0x00048E) 0x8602- f:00103 d: 2 | P = P + 2 (0x0249), A # 0
0x0248 (0x000490) 0x7003- f:00070 d: 3 | P = P + 3 (0x024B)
0x0249 (0x000492) 0x7464- f:00072 d: 100 | R = P + 100 (0x02AD)
0x024A (0x000494) 0x7003- f:00070 d: 3 | P = P + 3 (0x024D)
0x024B (0x000496) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x024C (0x000498) 0x2927- f:00024 d: 295 | OR[295] = A
0x024D (0x00049A) 0x7212- f:00071 d: 18 | P = P - 18 (0x023B)
0x024E (0x00049C) 0x0200- f:00001 d: 0 | EXIT
0x024F (0x00049E) 0x0400- f:00002 d: 0 | I = 0
0x0250 (0x0004A0) 0x0000- f:00000 d: 0 | PASS
0x0251 (0x0004A2) 0x1002- f:00010 d: 2 | A = 2 (0x0002)
0x0252 (0x0004A4) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x0253 (0x0004A6) 0x211A- f:00020 d: 282 | A = OR[282]
0x0254 (0x0004A8) 0x1409- f:00012 d: 9 | A = A + 9 (0x0009)
0x0255 (0x0004AA) 0x2913- f:00024 d: 275 | OR[275] = A
0x0256 (0x0004AC) 0x1009- f:00010 d: 9 | A = 9 (0x0009)
0x0257 (0x0004AE) 0x2929- f:00024 d: 297 | OR[297] = A
0x0258 (0x0004B0) 0x2113- f:00020 d: 275 | A = OR[275]
0x0259 (0x0004B2) 0x292A- f:00024 d: 298 | OR[298] = A
0x025A (0x0004B4) 0x1064- f:00010 d: 100 | A = 100 (0x0064)
0x025B (0x0004B6) 0x292B- f:00024 d: 299 | OR[299] = A
0x025C (0x0004B8) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x025D (0x0004BA) 0x5800- f:00054 d: 0 | B = A
0x025E (0x0004BC) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x0260 (0x0004C0) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0261 (0x0004C2) 0x2006- f:00020 d: 6 | A = OR[6]
0x0262 (0x0004C4) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x0263 (0x0004C6) 0x2908- f:00024 d: 264 | OR[264] = A
0x0264 (0x0004C8) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0265 (0x0004CA) 0x2927- f:00024 d: 295 | OR[295] = A
0x0266 (0x0004CC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0267 (0x0004CE) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x0268 (0x0004D0) 0x211E- f:00020 d: 286 | A = OR[286]
0x0269 (0x0004D2) 0xCA0F- f:00145 d: 15 | io 0017 (EXB), fn005 | Load device address
0x026A (0x0004D4) 0x211A- f:00020 d: 282 | A = OR[282]
0x026B (0x0004D6) 0x1411- f:00012 d: 17 | A = A + 17 (0x0011)
0x026C (0x0004D8) 0x2908- f:00024 d: 264 | OR[264] = A
0x026D (0x0004DA) 0x3108- f:00030 d: 264 | A = (OR[264])
0x026E (0x0004DC) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x0270 (0x0004E0) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0271 (0x0004E2) 0x2127- f:00020 d: 295 | A = OR[295]
0x0272 (0x0004E4) 0x8602- f:00103 d: 2 | P = P + 2 (0x0274), A # 0
0x0273 (0x0004E6) 0x700D- f:00070 d: 13 | P = P + 13 (0x0280)
0x0274 (0x0004E8) 0x211A- f:00020 d: 282 | A = OR[282]
0x0275 (0x0004EA) 0x1411- f:00012 d: 17 | A = A + 17 (0x0011)
0x0276 (0x0004EC) 0x2908- f:00024 d: 264 | OR[264] = A
0x0277 (0x0004EE) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0278 (0x0004F0) 0x0E01- f:00007 d: 1 | A = A << 1 (0x0001)
0x0279 (0x0004F2) 0x0A08- f:00005 d: 8 | A = A < 8 (0x0008)
0x027A (0x0004F4) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x027B (0x0004F6) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x027C (0x0004F8) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x027D (0x0004FA) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x027E (0x0004FC) 0x2926- f:00024 d: 294 | OR[294] = A
0x027F (0x0004FE) 0x746B- f:00072 d: 107 | R = P + 107 (0x02EA)
0x0280 (0x000500) 0x742D- f:00072 d: 45 | R = P + 45 (0x02AD)
0x0281 (0x000502) 0x211A- f:00020 d: 282 | A = OR[282]
0x0282 (0x000504) 0x140E- f:00012 d: 14 | A = A + 14 (0x000E)
0x0283 (0x000506) 0x2908- f:00024 d: 264 | OR[264] = A
0x0284 (0x000508) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0285 (0x00050A) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x0286 (0x00050C) 0x2908- f:00024 d: 264 | OR[264] = A
0x0287 (0x00050E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0288 (0x000510) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x0289 (0x000512) 0x8602- f:00103 d: 2 | P = P + 2 (0x028B), A # 0
0x028A (0x000514) 0x7004- f:00070 d: 4 | P = P + 4 (0x028E)
0x028B (0x000516) 0x1002- f:00010 d: 2 | A = 2 (0x0002)
0x028C (0x000518) 0x2926- f:00024 d: 294 | OR[294] = A
0x028D (0x00051A) 0x745D- f:00072 d: 93 | R = P + 93 (0x02EA)
0x028E (0x00051C) 0x0200- f:00001 d: 0 | EXIT
0x028F (0x00051E) 0x1800-0x0201 f:00014 d: 0 | A = 513 (0x0201)
0x0291 (0x000522) 0x291D- f:00024 d: 285 | OR[285] = A
0x0292 (0x000524) 0x7436- f:00072 d: 54 | R = P + 54 (0x02C8)
0x0293 (0x000526) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0294 (0x000528) 0x2919- f:00024 d: 281 | OR[281] = A
0x0295 (0x00052A) 0x2119- f:00020 d: 281 | A = OR[281]
0x0296 (0x00052C) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x0297 (0x00052E) 0x2919- f:00024 d: 281 | OR[281] = A
0x0298 (0x000530) 0x211A- f:00020 d: 282 | A = OR[282]
0x0299 (0x000532) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x029A (0x000534) 0x2908- f:00024 d: 264 | OR[264] = A
0x029B (0x000536) 0x3108- f:00030 d: 264 | A = (OR[264])
0x029C (0x000538) 0x0A09- f:00005 d: 9 | A = A < 9 (0x0009)
0x029D (0x00053A) 0x2519- f:00022 d: 281 | A = A + OR[281]
0x029E (0x00053C) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x029F (0x00053E) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x02A0 (0x000540) 0x2119- f:00020 d: 281 | A = OR[281]
0x02A1 (0x000542) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x02A2 (0x000544) 0x8609- f:00103 d: 9 | P = P + 9 (0x02AB), A # 0
0x02A3 (0x000546) 0x211A- f:00020 d: 282 | A = OR[282]
0x02A4 (0x000548) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x02A5 (0x00054A) 0x2908- f:00024 d: 264 | OR[264] = A
0x02A6 (0x00054C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02A7 (0x00054E) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x02A8 (0x000550) 0x2919- f:00024 d: 281 | OR[281] = A
0x02A9 (0x000552) 0x7431- f:00072 d: 49 | R = P + 49 (0x02DA)
0x02AA (0x000554) 0x720A- f:00071 d: 10 | P = P - 10 (0x02A0)
0x02AB (0x000556) 0x7402- f:00072 d: 2 | R = P + 2 (0x02AD)
0x02AC (0x000558) 0x0200- f:00001 d: 0 | EXIT
0x02AD (0x00055A) 0x211A- f:00020 d: 282 | A = OR[282]
0x02AE (0x00055C) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x02AF (0x00055E) 0x2908- f:00024 d: 264 | OR[264] = A
0x02B0 (0x000560) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02B1 (0x000562) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x02B2 (0x000564) 0x2919- f:00024 d: 281 | OR[281] = A
0x02B3 (0x000566) 0x211A- f:00020 d: 282 | A = OR[282]
0x02B4 (0x000568) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x02B5 (0x00056A) 0x2908- f:00024 d: 264 | OR[264] = A
0x02B6 (0x00056C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02B7 (0x00056E) 0x0E01- f:00007 d: 1 | A = A << 1 (0x0001)
0x02B8 (0x000570) 0x0A08- f:00005 d: 8 | A = A < 8 (0x0008)
0x02B9 (0x000572) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x02BA (0x000574) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x02BB (0x000576) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x02BC (0x000578) 0x2119- f:00020 d: 281 | A = OR[281]
0x02BD (0x00057A) 0x1604- f:00013 d: 4 | A = A - 4 (0x0004)
0x02BE (0x00057C) 0x8402- f:00102 d: 2 | P = P + 2 (0x02C0), A = 0
0x02BF (0x00057E) 0x7004- f:00070 d: 4 | P = P + 4 (0x02C3)
0x02C0 (0x000580) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x02C1 (0x000582) 0x2919- f:00024 d: 281 | OR[281] = A
0x02C2 (0x000584) 0x7005- f:00070 d: 5 | P = P + 5 (0x02C7)
0x02C3 (0x000586) 0x2119- f:00020 d: 281 | A = OR[281]
0x02C4 (0x000588) 0x8602- f:00103 d: 2 | P = P + 2 (0x02C6), A # 0
0x02C5 (0x00058A) 0x7002- f:00070 d: 2 | P = P + 2 (0x02C7)
0x02C6 (0x00058C) 0x7350- f:00071 d: 336 | P = P - 336 (0x0176)
0x02C7 (0x00058E) 0x0200- f:00001 d: 0 | EXIT
0x02C8 (0x000590) 0x211A- f:00020 d: 282 | A = OR[282]
0x02C9 (0x000592) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x02CA (0x000594) 0x2913- f:00024 d: 275 | OR[275] = A
0x02CB (0x000596) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x02CC (0x000598) 0x2929- f:00024 d: 297 | OR[297] = A
0x02CD (0x00059A) 0x1800-0x002F f:00014 d: 0 | A = 47 (0x002F)
0x02CF (0x00059E) 0x292A- f:00024 d: 298 | OR[298] = A
0x02D0 (0x0005A0) 0x211D- f:00020 d: 285 | A = OR[285]
0x02D1 (0x0005A2) 0x292B- f:00024 d: 299 | OR[299] = A
0x02D2 (0x0005A4) 0x2113- f:00020 d: 275 | A = OR[275]
0x02D3 (0x0005A6) 0x292C- f:00024 d: 300 | OR[300] = A
0x02D4 (0x0005A8) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x02D5 (0x0005AA) 0x5800- f:00054 d: 0 | B = A
0x02D6 (0x0005AC) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x02D8 (0x0005B0) 0x7C09- f:00076 d: 9 | R = OR[9]
0x02D9 (0x0005B2) 0x0200- f:00001 d: 0 | EXIT
0x02DA (0x0005B4) 0x1002- f:00010 d: 2 | A = 2 (0x0002)
0x02DB (0x0005B6) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x02DC (0x0005B8) 0x1007- f:00010 d: 7 | A = 7 (0x0007)
0x02DD (0x0005BA) 0x2929- f:00024 d: 297 | OR[297] = A
0x02DE (0x0005BC) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x02DF (0x0005BE) 0x292A- f:00024 d: 298 | OR[298] = A
0x02E0 (0x0005C0) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x02E1 (0x0005C2) 0x5800- f:00054 d: 0 | B = A
0x02E2 (0x0005C4) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x02E4 (0x0005C8) 0x7C09- f:00076 d: 9 | R = OR[9]
0x02E5 (0x0005CA) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x02E6 (0x0005CC) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x02E7 (0x0005CE) 0x211E- f:00020 d: 286 | A = OR[286]
0x02E8 (0x0005D0) 0xCA0F- f:00145 d: 15 | io 0017 (EXB), fn005 | Load device address
0x02E9 (0x0005D2) 0x0200- f:00001 d: 0 | EXIT
0x02EA (0x0005D4) 0x211E- f:00020 d: 286 | A = OR[286]
0x02EB (0x0005D6) 0x1630- f:00013 d: 48 | A = A - 48 (0x0030)
0x02EC (0x0005D8) 0x8402- f:00102 d: 2 | P = P + 2 (0x02EE), A = 0
0x02ED (0x0005DA) 0x7005- f:00070 d: 5 | P = P + 5 (0x02F2)
0x02EE (0x0005DC) 0x1800-0x00A7 f:00014 d: 0 | A = 167 (0x00A7)
0x02F0 (0x0005E0) 0x2928- f:00024 d: 296 | OR[296] = A
0x02F1 (0x0005E2) 0x7008- f:00070 d: 8 | P = P + 8 (0x02F9)
0x02F2 (0x0005E4) 0x211E- f:00020 d: 286 | A = OR[286]
0x02F3 (0x0005E6) 0x1617- f:00013 d: 23 | A = A - 23 (0x0017)
0x02F4 (0x0005E8) 0x8402- f:00102 d: 2 | P = P + 2 (0x02F6), A = 0
0x02F5 (0x0005EA) 0x7004- f:00070 d: 4 | P = P + 4 (0x02F9)
0x02F6 (0x0005EC) 0x1800-0x00A8 f:00014 d: 0 | A = 168 (0x00A8)
0x02F8 (0x0005F0) 0x2928- f:00024 d: 296 | OR[296] = A
0x02F9 (0x0005F2) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x02FA (0x0005F4) 0x2929- f:00024 d: 297 | OR[297] = A
0x02FB (0x0005F6) 0x2128- f:00020 d: 296 | A = OR[296]
0x02FC (0x0005F8) 0x292A- f:00024 d: 298 | OR[298] = A
0x02FD (0x0005FA) 0x211A- f:00020 d: 282 | A = OR[282]
0x02FE (0x0005FC) 0x292B- f:00024 d: 299 | OR[299] = A
0x02FF (0x0005FE) 0x2126- f:00020 d: 294 | A = OR[294]
0x0300 (0x000600) 0x292C- f:00024 d: 300 | OR[300] = A
0x0301 (0x000602) 0x1129- f:00010 d: 297 | A = 297 (0x0129)
0x0302 (0x000604) 0x5800- f:00054 d: 0 | B = A
0x0303 (0x000606) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318)
0x0305 (0x00060A) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0306 (0x00060C) 0x2919- f:00024 d: 281 | OR[281] = A
0x0307 (0x00060E) 0x2119- f:00020 d: 281 | A = OR[281]
0x0308 (0x000610) 0x8602- f:00103 d: 2 | P = P + 2 (0x030A), A # 0
0x0309 (0x000612) 0x7002- f:00070 d: 2 | P = P + 2 (0x030B)
0x030A (0x000614) 0x7394- f:00071 d: 404 | P = P - 404 (0x0176)
0x030B (0x000616) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x030C (0x000618) 0xCE0F- f:00147 d: 15 | io 0017 (EXB), fn007 | Set interrupt mode
0x030D (0x00061A) 0x211E- f:00020 d: 286 | A = OR[286]
0x030E (0x00061C) 0xCA0F- f:00145 d: 15 | io 0017 (EXB), fn005 | Load device address
0x030F (0x00061E) 0x0200- f:00001 d: 0 | EXIT
0x0310 (0x000620) 0x0000- f:00000 d: 0 | PASS
0x0311 (0x000622) 0x0000- f:00000 d: 0 | PASS
0x0312 (0x000624) 0x0000- f:00000 d: 0 | PASS
0x0313 (0x000626) 0x0000- f:00000 d: 0 | PASS
|
;falta agregar signos
;imprime en binario ----------------------------------------------------
%macro PutBin 1
push eax
push ebx
push ecx
push edx
mov eax,%1
xor ecx, ecx
dec ecx
%%zero_loop:
inc ecx
rol eax,1
mov ebx, eax
and ebx, 00000001h
cmp ecx, 31 ;condicion de parada
jae %%end
cmp ebx,0
je %%zero_loop
PutCh '1'
%%print_loop:
inc ecx
rol eax,1
mov ebx, eax
and ebx, 00000001h
add bl, '0'
PutCh bl
cmp ecx, 31
jb %%print_loop
%%end:
PutCh 'b'
pop edx
pop ecx
pop ebx
pop eax
%endmacro
;imprime en octal-------------------------------------------------------
%macro PutOct 1
push eax
push ebx
push ecx
push edx
mov eax,%1
xor ecx, ecx
dec ecx
rol eax, 2
mov ebx, eax
and ebx,3
cmp ebx, 0
je %%zero_loop
add bl, '0'
PutCh bl
jmp %%print_loop
%%zero_loop:
inc ecx
rol eax,3
mov ebx, eax
and ebx, 00000007h
cmp ecx, 9 ;condicion de parada
jae %%end
cmp ebx,0
je %%zero_loop
add bl,'0'
PutCh bl
%%print_loop:
inc ecx
rol eax,3
mov ebx, eax
and ebx, 00000007h
add bl, '0'
PutCh bl
cmp ecx, 9
jb %%print_loop
%%end:
PutCh 'o'
pop edx
pop ecx
pop ebx
pop eax
%endmacro
;imprime en hexadecimal-------------------------------------------------
%macro PutHex 1
push eax
push ebx
push ecx
push edx
mov eax,%1
xor ecx, ecx
dec ecx
%%zero_loop:
inc ecx
rol eax,4
mov ebx, eax
and ebx, 0000000Fh
cmp ecx, 8 ;condicion de parada
jae %%end
cmp ebx,0
je %%zero_loop
printN ebx
cmp ecx, 7
jae %%end
%%print_loop:
inc ecx
rol eax,4
mov ebx, eax
and ebx, 0000000Fh
printN ebx
cmp ecx, 7
jb %%print_loop
%%end:
PutCh 'h'
pop edx
pop ecx
pop ebx
pop eax
%endmacro
%macro printN 1
push eax
push ebx
push ecx
push edx
mov ebx, %1
cmp bl, 9
jg %%leter
add bl, '0'
PutCh bl
jmp %%end
%%leter:
sub bl, 10
add bl, 'A'
PutCh bl
%%end:
pop edx
pop ecx
pop ebx
pop eax
%endmacro
|
;
; CPC Maths Routines
;
; August 2003 **_|warp6|_** <kbaccam /at/ free.fr>
;
; $Id: cos.asm,v 1.4 2016-06-22 19:50:48 dom Exp $
;
SECTION code_fp
INCLUDE "target/cpc/def/cpcfirm.def"
INCLUDE "target/cpc/def/cpcfp.def"
PUBLIC cos
PUBLIC cosc
EXTERN get_para
.cos call get_para
call firmware
.cosc defw CPCFP_FLO_COS
ret
|
;
; Generic graphics routines
; Self modifying code version
;
; Stefano Bodrato - 4/1/2007
;
;
; Invert pixel at (x,y) coordinate.
;
;
; $Id: xorpixl_smc.asm,v 1.2 2015/01/19 01:32:47 pauloscustodio Exp $
;
PUBLIC xorpixel
EXTERN pixel
EXTERN pixmode
.xorpixel push hl
ld hl,174 ; XOR (HL)
ld (pixmode),hl
pop hl
jp pixel
|
; A047590: Numbers that are congruent to {0, 6, 7} mod 8.
; 0,6,7,8,14,15,16,22,23,24,30,31,32,38,39,40,46,47,48,54,55,56,62,63,64,70,71,72,78,79,80,86,87,88,94,95,96,102,103,104,110,111,112,118,119,120,126,127,128,134,135,136,142,143,144,150,151,152,158,159
mov $1,$0
add $0,2
div $0,3
mul $0,5
add $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.