text
stringlengths
1
1.05M
ASAM1 AMODE 31 ASAM1 CSECT USING ASAM1,R15 * ************************************************* * SAMPLE PROGRAM ASAM1 * AUTHOR: DOUG STOUT * IBM CORPORATION * * A SIMPLE PROGRAM THAT: * - READS A QSAM FILE * - WRITES THE FIRST 80 BYTES OF EACH RECORD TO AN OUTPUT FILE * IN CHARACTER AND HEX * * PARAMETERS PASSED FROM CALLING PROGRAM: * NONE * * FILES: * 1. INPUT FILE IS QSAM AND HAS DD NAME = FILEIN * LRECL = 80 * 2. OUTPUT FILE IS QSAM OR SYSPRINT AND HAS DD NAME = FILEOUT * LRECL = 80 * ************************************************************ * AT ENTRY, R13 = REGISTER SAVE AREA * R14 = RETURN ADDR * R15 = ADDR OF THIS PROGRAM START STM R14,R12,12(R13) SAVE REGISTERS IN PASSED SAVE AREA DROP R15 NO LONGER NEEDED AS BASE REGISTER LR R12,R15 USE R12 AS THE BASE REGISTER USING ASAM1,R12 " LA R14,SAVEAREA R14 = ADDR OF NEW SAVE AREA ST R13,4(R14) STORE PREVIOUS SAVE AREA ADDR ST R14,8(R13) STORE NEW SAVE AREA ADDRESS LR R13,R14 R13 = ADDR OF NEW SAVE AREA B MAINLINE DS 0H DC CL32'******** PROGRAM ASAM1 *********' MAINLINE BAL R11,OPENFILS BAL R11,MAINLOOP BAL R11,CLOSFILS * MVC STATUS,=C'RETURNING TO CALLING PROGRAM ' * RETURN00 L R15,RETCODE L R13,4(R13) R13 = ADDR OF PREVIOUS SAVE AREA ST R15,16(R13) SAVE RETURN CODE LM R14,R12,12(R13) RESTORE REGISTERS (EXCEPT 13) BR R14 RETURN TO CALLER ******************************************* * PROCEDURE MAINLOOP * MAINLOOP ST R11,MAINLSAV SAVE RETURN ADDRESS * * READ INPUT RECORD MAINLTOP BAL R11,READIN * * CHECK FOR END-OF-FILE CLC EOFFLAG,=X'FF' END OF FILE? BE MAINLEX IF YES - EXIT MAIN LOOP * * CALL SUBPROGRAM TO GET HEX CHARACTERS MVC STATUS,=C'CALLING SUBPROGRAM ASAM2 ' LA R13,SAVEAREA **** LINK EP=ASAM2,(DATALEN,INREC,HEXTOP,HEXBOT),VL=1 * FOLLOWING LINES COMMENTED OUT WHEN LOAD CHANGED TO STATIC CALL ***** LOAD EP=ASAM2 ***** LTR R15,R15 ***** BNZ LOADERR ***** LA R13,SAVEAREA ***** LA R1,PARMLIST R1 = PARM LIST ***** LR R15,R0 R0 = ADD OF LOADED PROGRAM ***** BALR R14,R15 BRANCH TO SUBPROGRAM CALL ASAM2,(DATALEN,INREC,HEXTOP,HEXBOT),VL * * WRITE LINE: 'RECORD NUMBER NNNNNN' UNPK DIAGRECT,RECCOUNT FORMAT RECORD COUNT OI DIAGRECT+9,X'F0' MVC DIAGREC,OUTLINE1 REC NUM LINE BAL R11,WRITEOUT * * WRITE RULE LINES ....5...10...15...20... MVC DIAGREC,OUTLINE2 BAL R11,WRITEOUT MVC DIAGREC,OUTLINE3 BAL R11,WRITEOUT * * WRITE DATA LINE 1: (CHARACTER FORMAT) MVC DIAGREC,INREC BAL R11,WRITEOUT * * WRITE DATA LINE 2: (TOP HEX LINE) MVC DIAGREC,HEXTOP BAL R11,WRITEOUT * * WRITE DATA LINE 3: (BOTTOM HEX LINE) MVC DIAGREC,HEXBOT BAL R11,WRITEOUT * * WRITE BLANK LINE MVC DIAGREC,BLANKS BAL R11,WRITEOUT * * GO BACK TO TOP OF LOOP B MAINLTOP * LOADERR WTO '* ASAM1: ERROR LOADING PROGRAM ASAM2 ' MVI EOFFLAG,X'FF' MAINLEX L R11,MAINLSAV BR R11 RETURN TO MAINLINE LOGIC * ******************************************* * PROCEDURE OPENFILS * OPENFILS ST R11,OPENFSAV MVC STATUS,=C'IN OPENFILS SUBROUTINE ' SLR R15,R15 SET DEFAULT RETURN CODE TO ZERO OPEN (FILEOUT,OUTPUT) OPEN DDNAME LTR R15,R15 OPEN RC = 0 ? BNZ BADOPENI IF NO - THEN ERROR OPEN (FILEIN,INPUT) OPEN DDNAME LTR R15,R15 OPEN RC = 0 ? BNZ BADOPENI IF NO - THEN ERROR L R11,OPENFSAV BR R11 RETURN TO MAINLINE LOGIC BADOPENI WTO '* ASAM1: ERROR OPENING INPUT FILE ' ST R15,RETCODE B RETURN00 BADOPENO WTO '* ASAM1: ERROR OPENING OUTPUT FILE ' ST R15,RETCODE B RETURN00 ******************************************* * PROCEDURE CLOSFILS * CLOSFILS ST R11,CLOSFSAV SAVE RETURN ADDRESS MVC STATUS,=C'IN CLOSFILS PROCEDURE ' CLOSE FILEOUT CLOSE FILEIN L R11,CLOSFSAV BR R11 RETURN ******************************************* * PROCEDURE READIN * READIN ST R11,READISAV MVC STATUS,=C'IN READIN PROCEDURE ' SLR R15,R15 SET DEFAULT RETURN CODE TO ZERO GET FILEIN,INREC READ INPUT RECORD AP RECCOUNT,=PL1'1' INCREMENT RECORD COUNTER B READIEX READIEOF MVI EOFFLAG,X'FF' READIEX L R11,READISAV BR R11 * ******************************************* * PROCEDURE WRITEOUT * WRITEOUT ST R11,WRITOSAV MVC STATUS,=C'IN WRITEOUT PROCEDURE ' PUT FILEOUT,DIAGREC WRITE OUTPUT RECORD L R11,WRITOSAV BR R11 ******************************************************** * STORAGE AREAS * EYECATCH DC CL32'*** PROGRAM ASAM1 DATA AREAS ***' FILECC DC H'0' MAX RETURN CODE FROM FILE OPENS RECCOUNT DC PL4'0' INPUT RECORD COUNT PROCCNT DC PL4'0' PROCEDURE COUNT STATUS DC CL30' ' CURRENT PROGRAM STATUS EOFFLAG DC XL1'00' END OF INPUT FILE FLAG DATALEN DC F'80' LENGTH OF DATA PASSED TO SUBPGM INREC DC CL80' ' INPUT RECORD DIAGREC DC CL80' ' OUTPUT RECORD HEXTOP DC CL80' ' TOP ROW OF HEX DATA HEXBOT DC CL80' ' BOTTOM ROW OF HEX DATA RETCODE DC F'0' DEFAULT RETURN CODE IS ZERO MAINLSAV DC F'0' OPENFSAV DC F'0' CLOSFSAV DC F'0' READISAV DC F'0' WRITOSAV DC F'0' * * PARAMETER LIST FOR SUBPGM ASAM2 PARMLIST EQU * DC AL4(DATALEN) DC AL4(INREC) DC AL4(HEXTOP) DC AL4(HEXBOT) SET HIGH ORDER BIT ON * TO FLAG END OF PARM LIST OUTLINE1 DS 0CL80 DC CL14'RECORD NUMBER ' DIAGRECT DC CL10' ' DC 56C' ' * OUTLINE2 DS 0CL80 DC CL40'....0....1....1....2....2....3....3....4' DC CL40'....4....5....5....6....6....7....7....8' * OUTLINE3 DS 0CL80 DC CL40'....5....0....5....0....5....0....5....0' DC CL40'....5....0....5....0....5....0....5....0' * BLANKS DC 80C' ' * * LTORG SAVEAREA DC 18F'0' ******************************************************** * FILE DEFINITIONS * FILEOUT DCB DSORG=PS,RECFM=FB,MACRF=(PM),LRECL=80, X DDNAME=FILEOUT FILEIN DCB DSORG=PS,RECFM=FB,MACRF=(GM),LRECL=80, X DDNAME=FILEIN,EODAD=READIEOF * * REGISTER EQUATES * R0 EQU 0 R1 EQU 1 R2 EQU 2 R3 EQU 3 R4 EQU 4 R5 EQU 5 R6 EQU 6 R7 EQU 7 R8 EQU 8 R9 EQU 9 R10 EQU 10 R11 EQU 11 R12 EQU 12 R13 EQU 13 R14 EQU 14 R15 EQU 15 * END
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 4, 0x90 .globl _y8_EncryptStreamCTR32_AES_NI _y8_EncryptStreamCTR32_AES_NI: push %rbx sub $(128), %rsp movdqu (%r9), %xmm0 movslq %r8d, %r8 lea (15)(%r8), %r11 shr $(4), %r11 movq (8)(%r9), %rax movq (%r9), %rbx bswap %rax bswap %rbx mov %eax, %r10d add %r11, %rax adc $(0), %rbx bswap %rax bswap %rbx movq %rax, (8)(%r9) movq %rbx, (%r9) movl (12)(%rcx), %r11d pxor (%rcx), %xmm0 add $(16), %rcx movdqa %xmm0, (%rsp) movdqa %xmm0, (16)(%rsp) movdqa %xmm0, (32)(%rsp) movdqa %xmm0, (48)(%rsp) movdqa %xmm0, (64)(%rsp) movdqa %xmm0, (80)(%rsp) movdqa %xmm0, (96)(%rsp) movdqa %xmm0, (112)(%rsp) mov %rsp, %r9 cmp $(16), %r8 jle .Lshort123_inputgas_1 movdqa %xmm0, %xmm1 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm3 lea (1)(%r10d), %ebx lea (2)(%r10d), %eax lea (3)(%r10d), %r9d bswap %ebx bswap %eax bswap %r9d xor %r11d, %ebx pinsrd $(3), %ebx, %xmm1 xor %r11d, %eax pinsrd $(3), %eax, %xmm2 xor %r11d, %r9d pinsrd $(3), %r9d, %xmm3 movdqa %xmm1, (16)(%rsp) movdqa %xmm2, (32)(%rsp) movdqa %xmm3, (48)(%rsp) mov %rsp, %r9 movdqa (%rcx), %xmm4 movdqa (16)(%rcx), %xmm5 cmp $(64), %r8 jl .Lshort123_inputgas_1 jz .Lshort_inputgas_1 lea (4)(%r10d), %eax lea (5)(%r10d), %ebx bswap %eax bswap %ebx xor %r11d, %ebx xor %r11d, %eax movl %eax, (76)(%rsp) movl %ebx, (92)(%rsp) lea (6)(%r10d), %eax lea (7)(%r10d), %ebx bswap %eax bswap %ebx xor %r11d, %eax xor %r11d, %ebx movl %eax, (108)(%rsp) movl %ebx, (124)(%rsp) cmp $(128), %r8 jl .Lshort_inputgas_1 sub $(64), %rsp movdqa %xmm10, (%rsp) movdqa %xmm11, (16)(%rsp) movdqa %xmm12, (32)(%rsp) movdqa %xmm13, (48)(%rsp) push %rcx push %rdx sub $(128), %r8 .p2align 4, 0x90 .Lblk8_loopgas_1: add $(32), %rcx add $(8), %r10d sub $(4), %rdx movdqa (64)(%r9), %xmm6 movdqa (80)(%r9), %xmm7 movdqa (96)(%r9), %xmm8 movdqa (112)(%r9), %xmm9 mov %r10d, %eax aesenc %xmm4, %xmm0 lea (1)(%r10d), %ebx aesenc %xmm4, %xmm1 bswap %eax aesenc %xmm4, %xmm2 bswap %ebx aesenc %xmm4, %xmm3 xor %r11d, %eax aesenc %xmm4, %xmm6 xor %r11d, %ebx aesenc %xmm4, %xmm7 movl %eax, (12)(%r9) aesenc %xmm4, %xmm8 movl %ebx, (28)(%r9) aesenc %xmm4, %xmm9 movdqa (%rcx), %xmm4 lea (2)(%r10d), %eax aesenc %xmm5, %xmm0 lea (3)(%r10d), %ebx aesenc %xmm5, %xmm1 bswap %eax aesenc %xmm5, %xmm2 bswap %ebx aesenc %xmm5, %xmm3 xor %r11d, %eax aesenc %xmm5, %xmm6 xor %r11d, %ebx aesenc %xmm5, %xmm7 movl %eax, (44)(%r9) aesenc %xmm5, %xmm8 movl %ebx, (60)(%r9) aesenc %xmm5, %xmm9 movdqa (16)(%rcx), %xmm5 .p2align 4, 0x90 .Lcipher_loopgas_1: add $(32), %rcx sub $(2), %rdx aesenc %xmm4, %xmm0 aesenc %xmm4, %xmm1 aesenc %xmm4, %xmm2 aesenc %xmm4, %xmm3 aesenc %xmm4, %xmm6 aesenc %xmm4, %xmm7 aesenc %xmm4, %xmm8 aesenc %xmm4, %xmm9 movdqa (%rcx), %xmm4 aesenc %xmm5, %xmm0 aesenc %xmm5, %xmm1 aesenc %xmm5, %xmm2 aesenc %xmm5, %xmm3 aesenc %xmm5, %xmm6 aesenc %xmm5, %xmm7 aesenc %xmm5, %xmm8 aesenc %xmm5, %xmm9 movdqa (16)(%rcx), %xmm5 jnz .Lcipher_loopgas_1 lea (4)(%r10d), %eax aesenc %xmm4, %xmm0 lea (5)(%r10d), %ebx aesenc %xmm4, %xmm1 bswap %eax aesenc %xmm4, %xmm2 bswap %ebx aesenc %xmm4, %xmm3 xor %r11d, %eax aesenc %xmm4, %xmm6 xor %r11d, %ebx aesenc %xmm4, %xmm7 movl %eax, (76)(%r9) aesenc %xmm4, %xmm8 movl %ebx, (92)(%r9) aesenc %xmm4, %xmm9 lea (6)(%r10d), %eax aesenclast %xmm5, %xmm0 lea (7)(%r10d), %ebx aesenclast %xmm5, %xmm1 bswap %eax aesenclast %xmm5, %xmm2 bswap %ebx aesenclast %xmm5, %xmm3 xor %r11d, %eax aesenclast %xmm5, %xmm6 xor %r11d, %ebx aesenclast %xmm5, %xmm7 movl %eax, (108)(%r9) aesenclast %xmm5, %xmm8 movl %ebx, (124)(%r9) aesenclast %xmm5, %xmm9 movdqu (%rdi), %xmm10 movdqu (16)(%rdi), %xmm11 movdqu (32)(%rdi), %xmm12 movdqu (48)(%rdi), %xmm13 pxor %xmm10, %xmm0 pxor %xmm11, %xmm1 pxor %xmm12, %xmm2 pxor %xmm13, %xmm3 movdqu %xmm0, (%rsi) movdqu %xmm1, (16)(%rsi) movdqu %xmm2, (32)(%rsi) movdqu %xmm3, (48)(%rsi) movdqu (64)(%rdi), %xmm10 movdqu (80)(%rdi), %xmm11 movdqu (96)(%rdi), %xmm12 movdqu (112)(%rdi), %xmm13 pxor %xmm10, %xmm6 pxor %xmm11, %xmm7 pxor %xmm12, %xmm8 pxor %xmm13, %xmm9 movdqu %xmm6, (64)(%rsi) movdqu %xmm7, (80)(%rsi) movdqu %xmm8, (96)(%rsi) movdqu %xmm9, (112)(%rsi) movq (8)(%rsp), %rcx movq (%rsp), %rdx movdqa (%r9), %xmm0 movdqa (16)(%r9), %xmm1 movdqa (32)(%r9), %xmm2 movdqa (48)(%r9), %xmm3 movdqa (%rcx), %xmm4 movdqa (16)(%rcx), %xmm5 add $(128), %rdi add $(128), %rsi sub $(128), %r8 jge .Lblk8_loopgas_1 pop %rdx pop %rcx movdqa (%rsp), %xmm10 movdqa (16)(%rsp), %xmm11 movdqa (32)(%rsp), %xmm12 movdqa (48)(%rsp), %xmm13 add $(64), %rsp add $(128), %r8 jz .Lquitgas_1 .p2align 4, 0x90 .Lshort_inputgas_1: cmp $(64), %r8 jl .Lshort123_inputgas_1 mov %rcx, %rbx lea (-2)(%rdx), %r10 .p2align 4, 0x90 .Lcipher_loop4gas_1: add $(32), %rbx sub $(2), %r10 aesenc %xmm4, %xmm0 aesenc %xmm4, %xmm1 aesenc %xmm4, %xmm2 aesenc %xmm4, %xmm3 movdqa (%rbx), %xmm4 aesenc %xmm5, %xmm0 aesenc %xmm5, %xmm1 aesenc %xmm5, %xmm2 aesenc %xmm5, %xmm3 movdqa (16)(%rbx), %xmm5 jnz .Lcipher_loop4gas_1 movdqu (%rdi), %xmm6 movdqu (16)(%rdi), %xmm7 movdqu (32)(%rdi), %xmm8 movdqu (48)(%rdi), %xmm9 add $(64), %rdi aesenc %xmm4, %xmm0 aesenc %xmm4, %xmm1 aesenc %xmm4, %xmm2 aesenc %xmm4, %xmm3 aesenclast %xmm5, %xmm0 aesenclast %xmm5, %xmm1 aesenclast %xmm5, %xmm2 aesenclast %xmm5, %xmm3 pxor %xmm6, %xmm0 movdqu %xmm0, (%rsi) pxor %xmm7, %xmm1 movdqu %xmm1, (16)(%rsi) pxor %xmm8, %xmm2 movdqu %xmm2, (32)(%rsi) pxor %xmm9, %xmm3 movdqu %xmm3, (48)(%rsi) add $(64), %rsi add $(64), %r9 sub $(64), %r8 jz .Lquitgas_1 .Lshort123_inputgas_1: lea (,%rdx,4), %rbx lea (-160)(%rcx,%rbx,4), %rbx .Lsingle_blkgas_1: movdqa (%r9), %xmm0 add $(16), %r9 cmp $(12), %rdx jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesenc (-64)(%rbx), %xmm0 aesenc (-48)(%rbx), %xmm0 .Lkey_192_sgas_1: aesenc (-32)(%rbx), %xmm0 aesenc (-16)(%rbx), %xmm0 .Lkey_128_sgas_1: aesenc (%rbx), %xmm0 aesenc (16)(%rbx), %xmm0 aesenc (32)(%rbx), %xmm0 aesenc (48)(%rbx), %xmm0 aesenc (64)(%rbx), %xmm0 aesenc (80)(%rbx), %xmm0 aesenc (96)(%rbx), %xmm0 aesenc (112)(%rbx), %xmm0 aesenc (128)(%rbx), %xmm0 aesenclast (144)(%rbx), %xmm0 cmp $(16), %r8 jl .Lpartial_blockgas_1 movdqu (%rdi), %xmm1 add $(16), %rdi pxor %xmm1, %xmm0 movdqu %xmm0, (%rsi) add $(16), %rsi sub $(16), %r8 jz .Lquitgas_1 jmp .Lsingle_blkgas_1 .Lpartial_blockgas_1: pextrb $(0), %xmm0, %eax psrldq $(1), %xmm0 movzbl (%rdi), %edx inc %rdi xor %rdx, %rax movb %al, (%rsi) inc %rsi dec %r8 jnz .Lpartial_blockgas_1 .Lquitgas_1: pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 add $(128), %rsp pop %rbx ret
/* * (C) Copyright 1996-2012 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation nor * does it submit to any jurisdiction. */ #include "eckit/exception/Exceptions.h" #include "eckit/filesystem/PathName.h" #include "eckit/log/Log.h" #include "odc/Comparator.h" #include "odc/Reader.h" #include "odc/Writer.h" #include "odc/tools/CompactTool.h" using namespace std; using namespace eckit; namespace odc { namespace tool { CompactTool::CompactTool (int argc, char *argv[]) : Tool(argc, argv) { } void CompactTool::run() { if (parameters().size() != 3) { Log::error() << "Usage: "; usage(parameters(0), Log::error()); Log::error() << std::endl; std::stringstream ss; ss << "Expected exactly 3 command line parameters"; throw UserError(ss.str()); } PathName inFile = parameters(1); PathName outFile = parameters(2); odc::Reader in(inFile); odc::Writer<> out(outFile); odc::Reader::iterator it(in.begin()); odc::Reader::iterator end(in.end()); odc::Writer<>::iterator writer(out.begin()); writer->pass1(it, end); odc::Reader outReader(outFile); Log::info() << "Verifying." << std::endl; odc::Reader::iterator it1 = in.begin(); odc::Reader::iterator end1 = in.end(); odc::Reader::iterator it2 = outReader.begin(); odc::Reader::iterator end2 = outReader.end(); odc::Comparator comparator; comparator.compare(it1, end1, it2, end2, inFile, outFile); } } // namespace tool } // namespace odc
db 0 ; species ID placeholder db 90, 30, 15, 15, 40, 20 ; hp atk def spd sat sdf db NORMAL, NORMAL ; type db 170 ; catch rate db 39 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F75 ; gender ratio db 100 ; unknown 1 db 10 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/igglybuff/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_FAST ; growth rate dn EGG_NONE, EGG_NONE ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, ICY_WIND, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, FIRE_BLAST, DEFENSE_CURL, DREAM_EATER, DETECT, REST, ATTRACT, NIGHTMARE, FLASH, FLAMETHROWER ; end
start START 0 JSUB stackinit .stack initialized LDA #100 rp COMP #0 SUB #1 STA @stackptr JSUB stackpush JEQ hlt LDA #20 JSUB sie LDA c LDS #400 MULR S, A LDS #1000 ADDR S, A CLEAR S ADDR A, S DIV #4095 MUL #4095 SUBR A, S CLEAR A ADDR S, A CLEAR S STA c CLEAR A CLEAR S CLEAR X CLEAR T LDA @stackptr JSUB stackpop J rp hlt J hlt sie STL @stackptr JSUB stackpush STA @stackptr JSUB stackpush CLEAR A CLEAR S CLEAR T CLEAR X .----SIERPINSKI GASKET beg JSUB stackpop LDA @stackptr COMP #0 SUB #1 STA @stackptr JSUB stackpush JEQ fin .Now lets randomly select one of the .three triangle vertices CLEAR A CLEAR S LDA seed LDS a MULR S, A LDS c ADDR S, A CLEAR S ADDR A, S DIV #4095 MUL #4095 SUBR A, S CLEAR A ADDR S, A CLEAR S STA seed .Now that we have the random number .we check which vertex was selected COMP #1365 JGT two LDX #100 LDT #0 JSUB cal J rep two COMP #2730 JGT thr LDX #0 LDT #200 JSUB cal J rep thr LDX #200 LDT #200 JSUB cal rep CLEAR T CLEAR X .finally we draw the pixel LDA sty LDS stx SUB #1 MUL #200 ADDR A, S LDA screen STA @stackptr JSUB stackpush ADDR S, A STA screen LDA #255 STCH @screen JSUB stackpop LDA @stackptr STA screen CLEAR A CLEAR S J beg .----SIERPINSKI GASKET fin JSUB stackpop JSUB stackpop LDL @stackptr RSUB cal STL @stackptr JSUB stackpush .Calculating x coordinate LDA stx LDS stx SUBR X, A DIV #2 SUBR A, S STS stx LDA sty LDS sty SUBR T, A DIV #2 SUBR A, S STS sty JSUB stackpop LDL @stackptr RSUB stackinit LDA #stck STA stackptr RSUB stackpush STA help LDA stackptr ADD #3 STA stackptr LDA help RSUB stackpop STA help LDA stackptr SUB #3 STA stackptr LDA help RSUB .triangle data stx WORD 100 sty WORD 100 seed WORD 1 a WORD 400 c WORD 1000 m WORD 4095 .STACK DATA .data stackptr RESW 1 stck RESW 60 .a small helpful buffer help WORD 0 .SCREEN ADDRESS screen WORD X'00A000'
; A233820: Period 4: repeat [20, 5, 15, 10]. ; 20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5,15,10,20,5 mov $3,$0 add $0,7 mod $0,2 mov $1,$0 add $1,$0 mov $2,$3 sub $3,$3 add $3,$2 add $3,289 div $3,2 mov $4,$3 gcd $4,2 add $1,$4 mul $1,5
#include "CapacityLinkItem.hpp" #include <graph_analysis/gui/GraphWidget.hpp> #include <graph_analysis/WeightedEdge.hpp> #include <base-logging/Logging.hpp> #include <cmath> #include <iostream> #include <iomanip> #include <QSettings> #include <QFileDialog> #include <QCoreApplication> #include <QtCore/qmath.h> #include <QDebug> #include <moreorg/OrganizationModel.hpp> #include <moreorg/OrganizationModelAsk.hpp> #include <moreorg/ModelPool.hpp> #include "../TemplGui.hpp" #include "../../SpaceTime.hpp" using namespace graph_analysis::gui; namespace templ { namespace gui { namespace edge_items { // kiss: CapacityLinkItem::CapacityLinkItem(graph_analysis::gui::GraphWidget* graphWidget, const graph_analysis::Edge::Ptr& edge, QGraphicsItem* parent) : EdgeItemBase(graphWidget, edge, parent) , mArrowSize(10) , mMarkedAsInvalid(false) { QPen pen(Qt::black); pen.setWidth(3.0); mpFillBar = new QGraphicsRectItem(getEdgePath()->pos().x()-10, getEdgePath()->pos().y()+125, 10, 100, this); mpFillBar->setPen( pen ); mpFillBar->setBrush(QBrush(Qt::white)); double consumptionInPercent = 0; CapacityLink::Ptr capacityLink = dynamic_pointer_cast<CapacityLink>( getEdge() ); if(capacityLink) { consumptionInPercent = capacityLink->getConsumptionLevel(); } RoleInfoWeightedEdge::Ptr weightedEdge = dynamic_pointer_cast<RoleInfoWeightedEdge>(getEdge()); if(weightedEdge) { capacityLink = toCapacityLink(weightedEdge); consumptionInPercent = capacityLink->getConsumptionLevel(); std::set<RoleInfo::Tag> tags = { RoleInfo::INFEASIBLE }; Role::Set transitionRoles = weightedEdge->getRoles(tags); if(!transitionRoles.empty()) { mMarkedAsInvalid = true; } } if(capacityLink) { mpFillStatus = new QGraphicsRectItem(getEdgePath()->pos().x()-10, getEdgePath()->pos().y()+125, 10, consumptionInPercent*100, this); mpFillStatus->setPen(pen); mpFillStatus->setBrush(QBrush(Qt::black)); setFlag(ItemIsMovable, false); mpLabel = new QGraphicsTextItem("", this); // Make sure label is drawn on top of any edge that is might overlap with getEdgePath()->stackBefore(mpLabel); mpFillBar->stackBefore(mpLabel); mpFillStatus->stackBefore(mpLabel); } } CapacityLinkItem::~CapacityLinkItem() { delete mpLabel; } int CapacityLinkItem::type() const { return static_cast<int>(graph_analysis::gui::UserType) + 11; } void CapacityLinkItem::adjustEdgePositioning() { /// Allow setting via widget QSettings settings(QCoreApplication::organizationName(),"GUI"); QVariant v = settings.value("editor/edge/pen/default"); QPen pen; if(v == QVariant()) { pen.setColor(Qt::black); pen.setWidth(3.0); pen.setStyle(Qt::SolidLine); } else { pen = v.value<QPen>(); } if(mMarkedAsInvalid) { QVariant v = settings.value("editor/edge/pen/error"); if(v == QVariant()) { pen.setColor(Qt::red); pen.setWidth(3.0); pen.setStyle(Qt::DashLine); } else { pen = v.value<QPen>(); } } prepareGeometryChange(); drawBezierEdge(); drawArrowHead(mArrowSize*qSqrt(pen.width()), pen.brush(), QPen(pen.brush().color())); mpLabel->setPos(mpEdgePath->boundingRect().center() - mpLabel->boundingRect().center()); mpFillBar->setPos(mpLabel->pos().x(), mpLabel->pos().y() - mpFillBar->rect().height()); mpFillStatus->setPos(mpLabel->pos().x(), mpLabel->pos().y() - mpFillStatus->rect().height()); getEdgePath()->setPen(pen); } void CapacityLinkItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { } QRectF CapacityLinkItem::boundingRect() const { return childrenBoundingRect(); } void CapacityLinkItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { QString text(""); CapacityLink::Ptr capacityLink = dynamic_pointer_cast<CapacityLink>( getEdge() ); if(capacityLink) { int consumptionInPercent = capacityLink->getConsumptionLevel()*100; text += "Consumed capacity: " + QString::number(consumptionInPercent) + "%\n"; } text += QString(getEdge()->toString().c_str()); mpLabel->setHtml(QString("<div style=\"background-color:#ffffff; white-space: pre;\">") + text + QString("</div>")); } void CapacityLinkItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) { mpLabel->setPlainText(""); } EdgeItemBase* CapacityLinkItem::createNewItem(graph_analysis::gui::GraphWidget* graphWidget, const graph_analysis::Edge::Ptr& edge, QGraphicsItem* parent) const { return new CapacityLinkItem(graphWidget, edge, parent); } CapacityLink::Ptr CapacityLinkItem::toCapacityLink(const RoleInfoWeightedEdge::Ptr& roleInfo) { CapacityLink::Ptr capacityLink = make_shared<CapacityLink>(); SpaceTime::Network::tuple_t::Ptr from = dynamic_pointer_cast<SpaceTime::Network::tuple_t>(roleInfo->getSourceVertex()); SpaceTime::Network::tuple_t::Ptr to = dynamic_pointer_cast<SpaceTime::Network::tuple_t>(roleInfo->getTargetVertex()); if(!from || !to) { return capacityLink; } std::set<RoleInfo::Tag> tags = { RoleInfo::ASSIGNED, RoleInfo::AVAILABLE }; Role::Set fromRoles = from->getRoles(tags); Role::Set toRoles = to->getRoles(tags); Role::List transitionRoles = RoleInfo::getIntersection(fromRoles, toRoles); if(from->first() == to->first()) { capacityLink->addProvider( CapacityLink::getLocalTransitionRole(), std::numeric_limits<uint32_t>::max() ); } moreorg::ModelPool pool; for(const Role& r : transitionRoles) { pool[r.getModel()] = 1; } moreorg::OrganizationModel::Ptr om = TemplGui::getOrganizationModel(); moreorg::OrganizationModelAsk ask = moreorg::OrganizationModelAsk::getInstance(om, pool); for(const Role& r : transitionRoles) { using namespace moreorg::facades; Robot robot = Robot::getInstance(r.getModel(), ask); if(robot.isMobile()) { capacityLink->addProvider(r, robot.getTransportCapacity()); } else { capacityLink->addConsumer(r, robot.getTransportDemand()); } } return capacityLink; } } // end namespace edge_items } // end namespace gui } // end namespace templ
; =============================================================== ; Jan 2014 ; =============================================================== ; ; int putc_unlocked(int c, FILE *stream) ; ; Write char to stream. ; ; =============================================================== SECTION code_stdio PUBLIC asm_putc_unlocked EXTERN asm_fputc_unlocked defc asm_putc_unlocked = asm_fputc_unlocked ; enter : ix = FILE * ; e = char c ; ; exit : ix = FILE * ; ; success ; ; hl = char c ; carry reset ; ; fail ; ; hl = -1 ; carry set, errno set ; ; uses : all except ix
PAGE ,132 TITLE PARSE CODE AND CONTROL BLOCKS FOR ANSI.SYS ;****************** START OF SPECIFICATIONS ************************** ; MODULE NAME: PARSER.ASM ; DESCRIPTIVE NAME: PARSES THE DEVICE= STATEMENT IN CONFIG.SYS FOR ; ANSI.SYS ; FUNCTION: THE COMMAND LINE PASSED TO ANSI.SYS IN THE CONFIG.SYS ; STATEMENT IS PARSED TO CHECK FOR THE /X SWITCH. A FLAG ; IS CLEARED IF NOT FOUND. ; ENTRY POINT: PARSE_PARM ; INPUT: DS:SI POINTS TO EVERYTHING AFTER DEVICE= ; AT EXIT: ; NORMAL: SWITCH FLAGS WILL BE SET IF /X or /L IS FOUND ; ERROR: CARRY SET ; INTERNAL REFERENCES: ; ROUTINES: SYSLOADMSG - MESSAGE RETRIEVER LOADING CODE ; SYSDISPMSG - MESSAGE RETRIEVER DISPLAYING CODE ; PARM_ERROR - DISPLAYS ERROR MESSAGE ; SYSPARSE - PARSING CODE ; DATA AREAS: PARMS - PARSE CONTROL BLOCK FOR SYSPARSE ; EXTERNAL REFERENCES: ; ROUTINES: N/A ; DATA AREAS: SWITCH - BYTE FLAG FOR EXISTENCE OF SWITCH PARAMETER ; NOTES: ; REVISION HISTORY: ; A000 - DOS Version 4.00 ; Label: "DOS ANSI.SYS Device Driver" ; "Version 4.00 (C) Copyright 1988 Microsoft" ; "Licensed Material - Program Property of Microsoft" ;****************** END OF SPECIFICATIONS **************************** ;Modification history********************************************************** ; P1529 ANSI /x /y gives wrong error message 10/8/87 J.K. ; D397 /L option for "Enforcing" the line number 12/17/87 J.K. ; D479 An option to disable the extended keyboard functions 02/12/88 J.K. ;****************************************************************************** INCLUDE ANSI.INC ; ANSI equates and structures .XLIST INCLUDE SYSMSG.INC ; Message retriever code MSG_UTILNAME <ANSI> ; Let message retriever know its ANSI.SYS .LIST PUBLIC PARSE_PARM ; near procedure for parsing DEVICE= statement ; Set assemble switches for parse code that is not required!! DateSW EQU 0 TimeSW EQU 0 CmpxSW EQU 0 DrvSW EQU 0 QusSW EQU 0 NumSW EQU 0 KeySW EQU 0 Val1SW EQU 0 Val2SW EQU 0 Val3SW EQU 0 CODE SEGMENT PUBLIC BYTE ASSUME CS:CODE .XLIST MSG_SERVICES <MSGDATA> MSG_SERVICES <DISPLAYmsg,LOADmsg,CHARmsg> MSG_SERVICES <ANSI.CL1> MSG_SERVICES <ANSI.CL2> MSG_SERVICES <ANSI.CLA> INCLUDE VERSION.INC INCLUDE PARSE.ASM ; Parsing code .LIST EXTRN SWITCH_X:BYTE ; /X switch flag extrn Switch_L:Byte ; /L switch flag extrn Switch_K:Byte ; /K switch flag extrn Switch_S:Byte ; M008 ; /S or /SCREENSIZE switch flag ; PARM control blocks for ANSI ; Parsing DEVICE= statment from CONFIG.SYS ; DEVICE=[d:][path]ANSI.SYS [/X] [/K] [/L] [/S | /SCREENSIZE] ; M008 PARMS LABEL WORD DW PARMSX DB 0 ; no extra delimeters or EOLs. PARMSX LABEL BYTE DB 1,1 ; 1 valid positional operand DW FILENAME ; filename DB 1 ; 1 switche definition in the following DW Switches DB 0 ; no keywords FILENAME LABEL WORD DW 0200H ; file spec DW 0001H ; cap by file table DW RESULT_BUF ; result DW NOVALS ; no value checking done DB 0 ; no switch/keyword synonyms Switches LABEL WORD DW 0 ; switch with no value DW 0 ; no functions DW RESULT_BUF ; result DW NOVALS ; no value checking done DB 5 ;AN003; M008; 5 switch synonym X_SWITCH DB "/X",0 ; /X name L_SWITCH DB "/L",0 ; /L K_SWITCH DB "/K",0 ; /K SSIZE_SWITCH DB "/SCREENSIZE",0 ; M008; /SCREENSIZE S_SWITCH DB "/S",0 ; M008; /S NOVALS LABEL BYTE DB 0 ; no value checking done RESULT_BUF LABEL BYTE DB ? ; type returned (number, string, etc.) DB ? ; matched item tag (if applicable) SYNONYM_PTR DW 0 ; synonym ptr (if applicable) DD ? ; value SUBLIST LABEL DWORD ; list for substitution DB SUB_SIZE DB 0 DD ? DB 1 DB LEFT_ASCIIZ DB UNLIMITED DB 1 DB " " Old_SI dw ? Saved_Chr db 0 Continue_Flag db ON Parse_Err_Flag db OFF ; PROCEDURE_NAME: PARSE_PARM ; FUNCTION: ; THIS PROCEDURE PARSES THE DEVICE= PARAMETERS FROM THE INIT REQUEST ; BLOCK. ERROR MESSAGES ARE DISPLAYED ACCORDINGLY. ; AT ENTRY: DS:SI POINTS TO EVERYTHING AFTER THE DEVICE= STATEMENT ; AT EXIT: ; NORMAL: CARRY CLEAR - SWITCH FLAG BYTE SET TO 1 IF /X FOUND ; ERROR: CARRY SET PARSE_PARM PROC NEAR CALL SYSLOADMSG ; load message jnc plab01 CALL SYSDISPMSG ; display error message STC ; ensure carry still set jmp plab02 plab01: PUSH CS ; establish ES .. POP ES ; addressability to data LEA DI,PARMS ; point to PARMS control block XOR CX,CX ; clear both CX and DX for XOR DX,DX ; SYSPARSE CALL SYSPARSE ; move pointer past file spec mov Switch_L, OFF mov Switch_X, OFF while01: cmp Continue_Flag,ON jz plab_bogus ; M008; bogus label to avoid jmp jmp while01_end ; M008; out of short range. plab_bogus: ; M008 mov Old_SI, SI ;to be use by PARM_ERROR call SysParse cmp ax,RC_EOL jnz plab09 mov Continue_Flag, OFF jmp short while01 plab09: cmp ax,RC_NO_ERROR jz plab07 mov Continue_Flag, OFF mov Switch_X, OFF mov Switch_L, OFF mov Switch_K, OFF call Parm_Error mov Parse_Err_Flag,ON jmp short while01 plab07: cmp Synonym_ptr,offset X_SWITCH jnz plab05 mov Switch_X,ON jmp short plab04 plab05: cmp Synonym_ptr,offset L_SWITCH jnz plab03 mov Switch_L,ON jmp short plab04 plab03: ; M008 cmp Synonym_ptr, offset S_SWITCH ; M008 jnz plab11 ; M008 plab12: ; M008 mov Switch_S,ON ; M008 jmp short plab04 ; M008 plab11: ; M008 cmp Synonym_ptr, offset SSIZE_SWITCH; M008 jz plab12 ; M008 mov Switch_K,ON ; must be /K plab04: clc jmp while01 while01_end: cmp Parse_Err_Flag,ON jnz plab10 stc jmp short plab02 plab10: clc plab02: RET PARSE_PARM ENDP ; PROCEDURE_NAME: PARM_ERROR ; FUNCTION: ; LOADS AND DISPLAYS "Invalid parameter" MESSAGE ; AT ENTRY: ; DS:Old_SI -> parms that is invalid ; AT EXIT: ; NORMAL: ERROR MESSAGE DISPLAYED ; ERROR: N/A PARM_ERROR PROC NEAR PUSH CX PUSH SI PUSH ES PUSH DS ; PUSH CS ; POP DS ; establish addressability ; MOV BX,DX ; LES DX,[BX].RES_PTR ; find offending parameter push ds pop es mov si, cs:Old_SI ;Now es:dx -> offending parms push si ;Save it Get_CR: cmp byte ptr es:[si], 13 ;CR? je Got_CR inc si jmp Get_CR Got_CR: inc si ; The next char. mov al, byte ptr es:[si] mov cs:Saved_Chr, al ; Save the next char mov byte ptr es:[si], 0 ; and make it an ASCIIZ mov cs:Old_SI, si ; Set it again pop dx ; saved SI -> DX push cs pop ds ;for addressability LEA SI,SUBLIST ; ..and place the offset.. MOV [SI].SUB_PTR_O,DX ; ..in the SUBLIST.. MOV [SI].SUB_PTR_S,ES MOV AX,INVALID_PARM ; load 'Invalid parameter' message number MOV BX,STDERR ; to standard error MOV CX,ONE ; 1 substitution XOR DL,DL ; no input MOV DH,UTILITY_MSG_CLASS ; parse error CALL SYSDISPMSG ; display error message mov si, cs:Old_SI ;restore the original char. mov cl, cs:Saved_Chr mov byte ptr es:[si], cl POP DS POP ES POP SI POP CX RET PARM_ERROR ENDP include msgdcl.inc CODE ENDS END 
<% from pwnlib.shellcraft.i386.linux import syscall %> <%page args="n, groups"/> <%docstring> Invokes the syscall setgroups. See 'man 2 setgroups' for more information. Arguments: n(size_t): n groups(gid_t): groups </%docstring> ${syscall('SYS_setgroups', n, groups)}
; float log10(float x) SECTION code_fp_math48 PUBLIC cm48_sdccix_log10 EXTERN cm48_sdccix_log10_fastcall cm48_sdccix_log10: pop af pop hl pop de push de push hl push af jp cm48_sdccix_log10_fastcall
; A179805: a(0) = 1, a(1) = 3, a(2) = 6 and a(n) = 2*a(n-1) - a(n-2) for n > 3. ; 1,3,6,15,24,33,42,51,60,69,78,87,96,105,114,123,132,141,150,159,168,177,186,195,204,213,222,231,240,249,258,267,276,285,294,303,312,321,330,339,348,357,366,375,384,393,402,411,420,429,438,447,456,465,474,483,492,501,510,519,528,537,546,555,564,573,582,591,600,609,618,627,636,645,654,663,672,681,690,699,708,717,726,735,744,753,762,771,780,789,798,807,816,825,834,843,852,861,870,879,888,897,906,915,924,933,942,951,960,969,978,987,996,1005,1014,1023,1032,1041,1050,1059,1068,1077,1086,1095,1104,1113,1122,1131,1140,1149,1158,1167,1176,1185,1194,1203,1212,1221,1230,1239,1248,1257,1266,1275,1284,1293,1302,1311,1320,1329,1338,1347,1356,1365,1374,1383,1392,1401,1410,1419,1428,1437,1446,1455,1464,1473,1482,1491,1500,1509,1518,1527,1536,1545,1554,1563,1572,1581,1590,1599,1608,1617,1626,1635,1644,1653,1662,1671,1680,1689,1698,1707,1716,1725,1734,1743,1752,1761,1770,1779,1788,1797,1806,1815,1824,1833,1842,1851,1860,1869,1878,1887,1896,1905,1914,1923,1932,1941,1950,1959,1968,1977,1986,1995,2004,2013,2022,2031,2040,2049,2058,2067,2076,2085,2094,2103,2112,2121,2130,2139,2148,2157,2166,2175,2184,2193,2202,2211,2220,2229 mov $1,1 lpb $0 sub $0,1 mov $1,$2 mul $1,2 trn $1,6 add $2,3 add $1,$2 lpe
#include <ATen/Functions.h> #include <c10/core/MemoryFormat.h> #include "i_gelu_tpp.hpp" namespace intel_mlperf { at::Tensor i_gelu ( const at::Tensor& input, const at::Scalar& M, const at::Scalar& oscale, const at::Scalar& o_off) { auto sizes = input.sizes(); auto batch = sizes[0] * sizes[1]; auto line = sizes[2]; auto output = at::empty(sizes, at::TensorOptions().dtype<int8_t>() .memory_format(c10::MemoryFormat::Contiguous)); auto *in = input.data_ptr(); auto *out = output.data_ptr(); auto off = o_off.toChar(); # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<int32_t (*)[line]>(in); auto pout = reinterpret_cast<int8_t (*)[line]>(out); i_gelu_tpp<16>::ref(pout[b], pin[b], M.toFloat(), oscale.toFloat(), off, line); } return output; } at::Tensor i_gelu_ ( at::Tensor& self, const at::Scalar& M, const at::Scalar& oscale, const at::Scalar& o_off) { auto sizes = self.sizes(); auto batch = sizes[0] * sizes[1]; auto line = sizes[2]; auto *in = self.data_ptr(); auto *out = in; auto off = o_off.toChar(); # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<int32_t (*)[line]>(in); auto pout = reinterpret_cast<int8_t (*)[line]>(out); i_gelu_tpp<16>::ref(pout[b], pin[b], M.toFloat(), oscale.toFloat(), off, line); } return self; } at::Tensor i_identity( const at::Tensor& input, const c10::optional<at::Scalar>& M, const at::Scalar& oscale, const at::Scalar& o_off) { auto sizes = input.sizes(); auto batch = sizes[0] * sizes[1]; auto line = sizes[2]; auto output = at::empty(sizes, at::TensorOptions().dtype<int8_t>() .memory_format(c10::MemoryFormat::Contiguous)); auto *in = input.data_ptr(); auto *out = output.data_ptr(); auto off = o_off.toChar(); auto stype = input.scalar_type(); if (stype == c10::ScalarType::Float) { # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<float (*)[line]>(in); auto pout = reinterpret_cast<int8_t (*)[line]>(out); i_identity_tpp<16>::ref(pout[b], pin[b], oscale.toFloat(), off, line); } } else if (stype == c10::ScalarType::Char) { # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<int8_t (*)[line]>(in); auto pout = reinterpret_cast<int8_t (*)[line]>(out); i_identity_tpp<16>::ref(pout[b], pin[b], oscale.toFloat(), off, line); } } return output; } at::Tensor i_identity_cin( const at::Tensor& input, const at::Scalar& oscale) { auto sizes = input.sizes(); auto batch = sizes[0] * sizes[1]; auto line = sizes[2]; auto output = at::empty(sizes, at::TensorOptions().dtype<float>() .memory_format(c10::MemoryFormat::Contiguous)); auto *in = input.data_ptr(); auto *out = output.data_ptr(); # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<int8_t (*)[line]>(in); auto pout = reinterpret_cast<float (*)[line]>(out); i_identity_tpp<16>::ref_cin(pout[b], pin[b], oscale.toFloat(), line); } return output; } at::Tensor i_identity_( at::Tensor& self, const c10::optional<at::Scalar>& M, const at::Scalar& oscale, const at::Scalar& o_off) { auto sizes = self.sizes(); auto batch = sizes[0] * sizes[1]; auto line = sizes[2]; auto *in = self.data_ptr(); auto type = self.scalar_type(); auto *out = in; auto off = o_off.toChar(); if (type == at::ScalarType::Char) { # pragma omp parallel for for (auto b = 0; b < batch; ++b) { // Move out will cause Apple Clang crash auto pin = reinterpret_cast<int8_t (*)[line]>(in); auto pout = reinterpret_cast<int8_t (*)[line]>(out); i_identity_tpp<16>::ref(pout[b], pin[b], oscale.toFloat(), off, line); } } else { TORCH_CHECK(false, "Integer-8 inplace identity input must be integer-8."); } return self; } }
SECTION code_fp_math16 PUBLIC _f16_mul2 EXTERN cm16_sdcc_mul2 defc _f16_mul2 = cm16_sdcc_mul2
#include "light/platform/opengl/openglvertexarray.hpp" #include "core/logging.hpp" #include "glad/glad.h" namespace Light { GLenum Shader2OpenGLType(ShaderDataType type) { switch (type) { case ShaderDataType::Float: case ShaderDataType::Float2: case ShaderDataType::Float3: case ShaderDataType::Float4: return GL_FLOAT; case ShaderDataType::Int: case ShaderDataType::Int2: case ShaderDataType::Int3: case ShaderDataType::Int4: return GL_INT; case ShaderDataType::Mat3: case ShaderDataType::Mat4: return GL_FLOAT; case ShaderDataType::Bool: return GL_BOOL; default: LIGHT_CORE_ERROR("Unsupported Shader data type"); return -1; } } VertexArray* VertexArray::create() { return new OpenGLVertexArray(); } OpenGLVertexArray::OpenGLVertexArray() { glGenVertexArrays(1, &m_rendererId); } OpenGLVertexArray::~OpenGLVertexArray() = default; void OpenGLVertexArray::bind() const { glBindVertexArray(m_rendererId); } void OpenGLVertexArray::unbind() const { glBindVertexArray(0); } void OpenGLVertexArray::addVertexBuffer(const std::shared_ptr<VertexBuffer>& vbo) { if(vbo->getLayout().getElements().size() == 0) { LIGHT_CORE_ERROR("Buffer Layout not set!"); return; } glBindVertexArray(m_rendererId); vbo->bind(); const auto& layout = vbo->getLayout(); uint32_t index = 0; for(const auto& element: layout) { glEnableVertexAttribArray(index); glVertexAttribPointer(index, element.getComponentCount(), Shader2OpenGLType(element.getType()), element.isNormalized() ? GL_TRUE : GL_FALSE, layout.getStride(), INT2VOIDP(element.getOffset())); index++; } m_vertexBuffers.push_back(vbo); glBindVertexArray(0); } void OpenGLVertexArray::setIndexBuffer(const std::shared_ptr<IndexBuffer>& ibo) { glBindVertexArray(m_rendererId); ibo->bind(); m_indexBuffer = ibo; glBindVertexArray(0); } }
; A006579: Sum of gcd(n,k) for k = 1 to n-1. ; 0,1,2,4,4,9,6,12,12,17,10,28,12,25,30,32,16,45,18,52,44,41,22,76,40,49,54,76,28,105,30,80,72,65,82,132,36,73,86,140,40,153,42,124,144,89,46,192,84,145,114,148,52,189,134,204,128,113,58,300,60,121,210,192,160,249,66,196,156,281,70,348,72,145,250,220,196,297,78,352,216,161,82,436,212,169,198,332,88,477,234,268,212,185,238,464,96,301,342,420,100,393,102,396,480,209,106,540,108,457,254,512,112,441,290,340,408,233,310,780,220,241,282,364,300,693,126,448,296,545,130,708,348,265,594,524,136,537,138,796,324,281,382,864,368,289,518,436,148,825,150,588,540,665,394,844,156,313,366,848,424,729,162,484,780,329,166,1132,312,721,606,508,172,681,670,832,408,353,178,1332,180,793,422,716,472,729,506,556,864,809,190,1088,192,385,930,868,196,1125,198,1100,464,401,538,1116,524,409,738,992,568,1545,210,628,492,425,550,1404,576,433,506,1292,604,873,222,1232,1140,449,226,1252,228,985,1134,908,232,1341,602,700,548,1049,238,1920,240,781,810,724,952,969,678,972,576,1025 lpb $0,1 add $2,1 mov $3,$2 gcd $3,$0 sub $0,1 add $1,$3 lpe
CeladonGym_h: db GYM ; tileset db CELADON_GYM_HEIGHT, CELADON_GYM_WIDTH ; dimensions (y, x) dw CeladonGymBlocks, CeladonGymTextPointers, CeladonGymScript ; blocks, texts, scripts db $00 ; connections dw CeladonGymObject ; objects
global start extern long_mode_start section .text bits 32 start: mov esp, stack_top mov edi, ebx ; Move Multiboot info pointer to edi call check_multiboot call check_cpuid call check_long_mode call set_up_page_tables call enable_paging ; load the 64-bit GDT lgdt [gdt64.pointer] jmp gdt64.code:long_mode_start ; print `OK` to secreen mov dword [0xb8000], 0x2f4b2f4f hlt check_multiboot: cmp eax, 0x36d76289 jne .no_multiboot ret .no_multiboot: mov al, "0" jmp error check_cpuid: ; Check if CPUID is supported by attempting to flip the ID bit (bit 21) ; in the FLAGS register. If we can flip it, CPUID is available. ; Copy FLAGS in to EAX via stack pushfd pop eax ; Copy to ECX as well for comparing later on mov ecx, eax ; Flip the ID bit xor eax, 1 << 21 ; Copy EAX to FLAGS via the stack push eax popfd ; Copy FLAGS back to EAX (with the flipped bit if CPUID is supported) pushfd pop eax ; Restore FLAGS from the old version stored in ECX (i.e. flipping the ; ID bit back if it was ever flipped). push ecx popfd ; Compare EAX and ECX. If they are equal then that means the bit ; wasn't flipped, and CPUID isn't supported. cmp eax, ecx je .no_cpuid ret .no_cpuid: mov al, "1" jmp error check_long_mode: ; test if extended processor info in available mov eax, 0x80000000 ; implicit argument for cpuid cpuid ; get highest supported argument cmp eax, 0x80000001 ; it needs to be at lead 0x80000001 jb .no_long_mode ; if it's less, the CPU is too old for long mode ; use extended info to test if long mode is available mov eax, 0x80000001 ; argument for extended processor info cpuid ; returns various feature bits in ecx and edx test edx, 1 << 29 ; test if the LM-bit is set in the D-register jz .no_long_mode ; If it's not set, there is no long mode ret .no_long_mode: mov al, "2" jmp error set_up_page_tables: mov eax, p4_table or eax, 0b11 ; present + writable mov [p4_table + 511 * 8], eax ; map first P4 entry to P3 table mov eax, p3_table or eax, 0b11 ; present + writable mov [p4_table], eax ; map first P3 entry to p2 mov eax, p2_table or eax, 0b11 mov [p3_table], eax ; map each P2 entry to a huge 2MiB page mov ecx, 0 ; counter variable .map_p2_table: ; map ecx-th P2 entry to a huge page that starts at address 2MiB*ecx mov eax, 0x200000 ; 2MiB mul ecx ; start address of ecx-th page or eax, 0b10000011 ; present + writable + huge mov [p2_table + ecx * 8], eax ; map exc-th entry inc ecx ; increase counter cmp ecx, 512 ; if counter == 512, the whole P2 table is mapped jne .map_p2_table ; else map the next entry ; TODO map each P2 entry to a huge 2MiB page ret enable_paging: ; load P4 to cr3 register (cpu uses this to access the P4 table) mov eax, p4_table mov cr3, eax ; enable PAE-flag in cr4 (Physical Address Extension) mov eax, cr4 or eax, 1 << 5 mov cr4, eax ; set the long mode bit in the EFER MSR (model specific register) mov ecx, 0xC0000080 rdmsr or eax, 1 << 8 wrmsr ; enable pagin in the cr0 register mov eax, cr0 or eax, 1 << 31 mov cr0, eax ret ; Prints `ERR: ` and the given error code to screen and hangs. ; parameter: error code (in ascii) in al error: mov dword [0xb8000], 0x4f524f45 mov dword [0xb8004], 0x4f3a4f52 mov dword [0xb8008], 0x4f204f20 mov byte [0xb800a], al hlt section .bss align 4096 p4_table: resb 4096 p3_table: resb 4096 p2_table: resb 4096 stack_bottom: resb 4096*4 stack_top: section .rodata gdt64: dq 0 ; zero entry .code: equ $ - gdt64 dq (1<<43) | (1<<44) | (1<<47) | (1<<53) ; code segment .pointer: dw $ - gdt64 - 1 dq gdt64
#include "Runtime/MP1/CPlayerVisor.hpp" #include "Runtime/CSimplePool.hpp" #include "Runtime/CStateManager.hpp" #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/Camera/CGameCamera.hpp" #include "Runtime/Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CModel.hpp" #include "Runtime/GuiSys/CCompoundTargetReticle.hpp" #include "Runtime/GuiSys/CTargetingManager.hpp" #include "Runtime/World/CPlayer.hpp" #include "TCastTo.hpp" // Generated file, do not modify include path namespace urde::MP1 { CPlayerVisor::CPlayerVisor(CStateManager&) : x108_newScanPane(EFilterType::Blend, CGraphics::g_SpareTexture.get()) { x25_24_visorTransitioning = false; x25_25_ = false; xcc_scanFrameCorner = g_SimplePool->GetObj("CMDL_ScanFrameCorner"); xd8_scanFrameCenterSide = g_SimplePool->GetObj("CMDL_ScanFrameCenterSide"); xe4_scanFrameCenterTop = g_SimplePool->GetObj("CMDL_ScanFrameCenterTop"); xf0_scanFrameStretchSide = g_SimplePool->GetObj("CMDL_ScanFrameStretchSide"); xfc_scanFrameStretchTop = g_SimplePool->GetObj("CMDL_ScanFrameStretchTop"); // x108_newScanPane = g_SimplePool->GetObj("CMDL_NewScanPane"); x114_scanShield = g_SimplePool->GetObj("CMDL_ScanShield"); x124_scanIconNoncritical = g_SimplePool->GetObj("CMDL_ScanIconNoncritical"); x130_scanIconCritical = g_SimplePool->GetObj("CMDL_ScanIconCritical"); x13c_scanTargets.resize(64); x540_xrayPalette = g_SimplePool->GetObj("TXTR_XRayPalette"); x0_scanWindowSizes.push_back({}); x0_scanWindowSizes.push_back({g_tweakGui->GetScanWindowIdleWidth(), g_tweakGui->GetScanWindowIdleHeight()}); x0_scanWindowSizes.push_back({g_tweakGui->GetScanWindowActiveWidth(), g_tweakGui->GetScanWindowActiveHeight()}); } CPlayerVisor::~CPlayerVisor() { CSfxManager::SfxStop(x5c_visorLoopSfx); CSfxManager::SfxStop(x60_scanningLoopSfx); } int CPlayerVisor::FindEmptyInactiveScanTarget() const { for (size_t i = 0; i < x13c_scanTargets.size(); ++i) { const SScanTarget& tgt = x13c_scanTargets[i]; if (tgt.x4_timer == 0.f) return i; } return -1; } int CPlayerVisor::FindCachedInactiveScanTarget(TUniqueId uid) const { for (size_t i = 0; i < x13c_scanTargets.size(); ++i) { const SScanTarget& tgt = x13c_scanTargets[i]; if (tgt.x0_objId == uid && tgt.x4_timer > 0.f) return i; } return -1; } bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const { if (!x124_scanIconNoncritical.IsLoaded() || !x130_scanIconCritical.IsLoaded()) return false; if (!x114_scanShield.IsLoaded()) return false; CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); g_Renderer->SetViewportOrtho(true, 0.f, 4096.f); float vpScale = g_Viewport.xc_height / 448.f; CGraphics::SetModelMatrix(zeus::CTransform::Scale(x48_interpWindowDims.x() * 17.f * vpScale, 1.f, x48_interpWindowDims.y() * 17.f * vpScale)); x114_scanShield->Draw(CModelFlags(5, 0, 3, zeus::skClear)); const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); zeus::CTransform camMtx = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); CGraphics::SetViewPointMatrix(camMtx); zeus::CFrustum frustum; frustum.updatePlanes(camMtx, zeus::CProjection(zeus::SProjPersp( cam->GetFov(), g_Viewport.x8_width / float(g_Viewport.xc_height), 1.f, 100.f))); g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetPerspective(cam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, cam->GetNearClipDistance(), cam->GetFarClipDistance()); for (const SScanTarget& tgt : x13c_scanTargets) { if (tgt.x4_timer == 0.f) continue; if (TCastToConstPtr<CActor> act = mgr.GetObjectById(tgt.x0_objId)) { if (!act->GetMaterialList().HasMaterial(EMaterialTypes::Scannable)) continue; const CScannableObjectInfo* scanInfo = act->GetScannableObjectInfo(); const CModel* useModel; const zeus::CColor* useColor; const zeus::CColor* useDimColor; if (scanInfo->IsImportant()) { useModel = x130_scanIconCritical.GetObj(); useColor = &g_tweakGuiColors->GetScanIconCriticalColor(); useDimColor = &g_tweakGuiColors->GetScanIconCriticalDimColor(); } else { useModel = x124_scanIconNoncritical.GetObj(); useColor = &g_tweakGuiColors->GetScanIconNoncriticalColor(); useDimColor = &g_tweakGuiColors->GetScanIconNoncriticalDimColor(); } zeus::CVector3f scanPos = act->GetScanObjectIndicatorPosition(mgr); float scale = CCompoundTargetReticle::CalculateClampedScale( scanPos, 1.f, g_tweakTargeting->GetScanTargetClampMin(), g_tweakTargeting->GetScanTargetClampMax(), mgr); zeus::CTransform xf(zeus::CMatrix3f(scale) * camMtx.basis, scanPos); float scanRange = g_tweakPlayer->GetScanningRange(); float farRange = g_tweakPlayer->GetScanMaxLockDistance() - scanRange; float farT; if (farRange <= 0.f) farT = 1.f; else farT = zeus::clamp(0.f, 1.f - ((scanPos - camMtx.origin).magnitude() - scanRange) / farRange, 1.f); zeus::CColor iconColor = zeus::CColor::lerp(*useColor, *useDimColor, tgt.x8_inRangeTimer); float iconAlpha; if (mgr.GetPlayerState()->GetScanTime(scanInfo->GetScannableObjectId()) == 1.f) { iconAlpha = tgt.x4_timer * 0.25f; } else { float tmp = 1.f; if (mgr.GetPlayer().GetOrbitTargetId() == tgt.x0_objId) tmp = 0.75f * x2c_scanDimInterp + 0.25f; iconAlpha = tgt.x4_timer * tmp; } CGraphics::SetModelMatrix(xf); iconColor.a() *= iconAlpha * farT; useModel->Draw(CModelFlags(7, 0, 1, iconColor)); } } CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); return true; } void CPlayerVisor::UpdateScanObjectIndicators(const CStateManager& mgr, float dt) { bool inBoxExists = false; float dt2 = dt * 2.f; for (SScanTarget& tgt : x13c_scanTargets) { tgt.x4_timer = std::max(0.f, tgt.x4_timer - dt); if (mgr.GetPlayer().ObjectInScanningRange(tgt.x0_objId, mgr)) tgt.x8_inRangeTimer = std::max(0.f, tgt.x8_inRangeTimer - dt2); else tgt.x8_inRangeTimer = std::min(1.f, tgt.x8_inRangeTimer + dt2); if (TCastToConstPtr<CActor> act = mgr.GetObjectById(tgt.x0_objId)) { const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr); orbitPos = cam->ConvertToScreenSpace(orbitPos); orbitPos.x() = orbitPos.x() * g_Viewport.x8_width / 2.f + g_Viewport.x8_width / 2.f; orbitPos.y() = orbitPos.y() * g_Viewport.xc_height / 2.f + g_Viewport.xc_height / 2.f; bool inBox = mgr.GetPlayer().WithinOrbitScreenBox(orbitPos, mgr.GetPlayer().GetOrbitZone(), mgr.GetPlayer().GetOrbitType()); if (inBox != tgt.xc_inBox) { tgt.xc_inBox = inBox; if (inBox) x550_scanFrameColorImpulseInterp = 1.f; } inBoxExists |= inBox; } } if (inBoxExists) x54c_scanFrameColorInterp = std::min(x54c_scanFrameColorInterp + dt2, 1.f); else x54c_scanFrameColorInterp = std::max(0.f, x54c_scanFrameColorInterp - dt2); x550_scanFrameColorImpulseInterp = std::max(0.f, x550_scanFrameColorImpulseInterp - dt); dt += FLT_EPSILON; TAreaId playerArea = mgr.GetPlayer().GetAreaIdAlways(); for (TUniqueId id : mgr.GetPlayer().GetNearbyOrbitObjects()) { if (TCastToConstPtr<CActor> act = mgr.GetObjectById(id)) { if (act->GetAreaIdAlways() != playerArea) continue; if (!act->GetMaterialList().HasMaterial(EMaterialTypes::Scannable)) continue; int target = FindCachedInactiveScanTarget(id); if (target != -1) { SScanTarget& sTarget = x13c_scanTargets[target]; sTarget.x4_timer = std::min(sTarget.x4_timer + dt2, 1.f); continue; } target = FindEmptyInactiveScanTarget(); if (target != -1) { SScanTarget& sTarget = x13c_scanTargets[target]; sTarget.x0_objId = id; sTarget.x4_timer = dt; sTarget.x8_inRangeTimer = 1.f; sTarget.xc_inBox = false; } } } } void CPlayerVisor::UpdateScanWindow(float dt, const CStateManager& mgr) { UpdateScanObjectIndicators(mgr, dt); if (mgr.GetPlayer().GetScanningState() == CPlayer::EPlayerScanState::Scanning) { if (!x60_scanningLoopSfx) x60_scanningLoopSfx = CSfxManager::SfxStart(SFXui_scanning_lp, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); } else { CSfxManager::SfxStop(x60_scanningLoopSfx); x60_scanningLoopSfx.reset(); } EScanWindowState desiredState = GetDesiredScanWindowState(mgr); switch (x34_nextState) { case EScanWindowState::NotInScanVisor: if (desiredState != EScanWindowState::NotInScanVisor) { if (x30_prevState == EScanWindowState::NotInScanVisor) x48_interpWindowDims = x0_scanWindowSizes[int(desiredState)]; x50_nextWindowDims = x0_scanWindowSizes[int(desiredState)]; x40_prevWindowDims = x48_interpWindowDims; x30_prevState = x34_nextState; x34_nextState = desiredState; x38_windowInterpDuration = (desiredState == EScanWindowState::Scan) ? g_tweakGui->GetScanSidesEndTime() - x3c_windowInterpTimer : 0.f; x3c_windowInterpTimer = x38_windowInterpDuration; } break; case EScanWindowState::Idle: if (desiredState != EScanWindowState::Idle) { x50_nextWindowDims = (desiredState == EScanWindowState::NotInScanVisor) ? x48_interpWindowDims : x0_scanWindowSizes[int(desiredState)]; x40_prevWindowDims = x48_interpWindowDims; x30_prevState = x34_nextState; x34_nextState = desiredState; x38_windowInterpDuration = (desiredState == EScanWindowState::Scan) ? g_tweakGui->GetScanSidesEndTime() - x3c_windowInterpTimer : 0.f; x3c_windowInterpTimer = x38_windowInterpDuration; if (desiredState == EScanWindowState::Scan) CSfxManager::SfxStart(SFXui_into_scan_window, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); } break; case EScanWindowState::Scan: if (desiredState != EScanWindowState::Scan) { x50_nextWindowDims = (desiredState == EScanWindowState::NotInScanVisor) ? x48_interpWindowDims : x0_scanWindowSizes[int(desiredState)]; x40_prevWindowDims = x48_interpWindowDims; x30_prevState = x34_nextState; x34_nextState = desiredState; x38_windowInterpDuration = (desiredState == EScanWindowState::Idle) ? g_tweakGui->GetScanSidesEndTime() - x3c_windowInterpTimer : 0.f; x3c_windowInterpTimer = x38_windowInterpDuration; if (mgr.GetPlayerState()->GetVisorTransitionFactor() == 1.f) CSfxManager::SfxStart(SFXui_outof_scan_window, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); } break; default: break; } if (x30_prevState != x34_nextState) { x3c_windowInterpTimer = std::max(0.f, x3c_windowInterpTimer - dt); if (x3c_windowInterpTimer == 0.f) x30_prevState = x34_nextState; float t = 0.f; if (x38_windowInterpDuration > 0.f) { float scanSidesDuration = g_tweakGui->GetScanSidesDuration(); float scanSidesStart = g_tweakGui->GetScanSidesStartTime(); if (x34_nextState == EScanWindowState::Scan) t = (x3c_windowInterpTimer < scanSidesDuration) ? 0.f : (x3c_windowInterpTimer - scanSidesDuration) / scanSidesStart; else t = (x3c_windowInterpTimer > scanSidesStart) ? 1.f : x3c_windowInterpTimer / scanSidesStart; } x48_interpWindowDims = x50_nextWindowDims * (1.f - t) + x40_prevWindowDims * t; } } CPlayerVisor::EScanWindowState CPlayerVisor::GetDesiredScanWindowState(const CStateManager& mgr) const { if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan) { switch (mgr.GetPlayer().GetScanningState()) { case CPlayer::EPlayerScanState::Scanning: case CPlayer::EPlayerScanState::ScanComplete: return EScanWindowState::Scan; default: return EScanWindowState::Idle; } } return EScanWindowState::NotInScanVisor; } void CPlayerVisor::LockUnlockAssets() { #if 0 if (x1c_curVisor == CPlayerState::EPlayerVisor::Scan) x120_assetLockCountdown = 2; else if (x120_assetLockCountdown > 0) --x120_assetLockCountdown; if (x120_assetLockCountdown > 0) { xcc_scanFrameCorner.Lock(); xd8_scanFrameCenterSide.Lock(); xe4_scanFrameCenterTop.Lock(); xf0_scanFrameStretchSide.Lock(); xfc_scanFrameStretchTop.Lock(); //x108_newScanPane.Lock(); x114_scanShield.Lock(); x124_scanIconNoncritical.Lock(); x130_scanIconCritical.Lock(); } else { xcc_scanFrameCorner.Unlock(); xd8_scanFrameCenterSide.Unlock(); xe4_scanFrameCenterTop.Unlock(); xf0_scanFrameStretchSide.Unlock(); xfc_scanFrameStretchTop.Unlock(); //x108_newScanPane.Unlock(); x114_scanShield.Unlock(); x124_scanIconNoncritical.Unlock(); x130_scanIconCritical.Unlock(); } #endif } void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, const CTargetingManager* tgtMgr) const { SCOPED_GRAPHICS_DEBUG_GROUP("CPlayerVisor::DrawScanEffect", zeus::skMagenta); bool indicatorsDrawn = DrawScanObjectIndicators(mgr); if (tgtMgr && indicatorsDrawn) { CGraphics::SetDepthRange(DEPTH_TARGET_MANAGER, DEPTH_TARGET_MANAGER); tgtMgr->Draw(mgr, false); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); } float transFactor = mgr.GetPlayerState()->GetVisorTransitionFactor(); float scanSidesDuration = g_tweakGui->GetScanSidesDuration(); float scanSidesStart = g_tweakGui->GetScanSidesStartTime(); float t; if (x34_nextState == EScanWindowState::Scan) t = 1.f - ((x3c_windowInterpTimer < scanSidesDuration) ? 0.f : (x3c_windowInterpTimer - scanSidesDuration) / scanSidesStart); else t = (x3c_windowInterpTimer > scanSidesStart) ? 1.f : x3c_windowInterpTimer / scanSidesStart; float vpScale = g_Viewport.xc_height / 448.f; float divisor = (transFactor * ((1.f - t) * x58_scanMagInterp + t * g_tweakGui->GetScanWindowScanningAspect()) + (1.f - transFactor)); divisor = 1.f / divisor; float vpW = 169.218f * x48_interpWindowDims.x() * divisor; vpW = zeus::clamp(0.f, vpW, 640.f) * vpScale; float vpH = 152.218f * x48_interpWindowDims.y() * divisor; vpH = zeus::clamp(0.f, vpH, 448.f) * vpScale; SClipScreenRect rect; rect.x4_left = (g_Viewport.x8_width - vpW) / 2.f; rect.x8_top = (g_Viewport.xc_height - vpH) / 2.f; rect.xc_width = vpW; rect.x10_height = vpH; CGraphics::ResolveSpareTexture(rect); x64_scanDim.Draw(); g_Renderer->SetViewportOrtho(true, -1.f, 1.f); zeus::CTransform windowScale = zeus::CTransform::Scale(x48_interpWindowDims.x(), 1.f, x48_interpWindowDims.y()); zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale); CGraphics::SetModelMatrix(seventeenScale * windowScale); float uvX0 = rect.x4_left / float(g_Viewport.x8_width); float uvX1 = (rect.x4_left + rect.xc_width) / float(g_Viewport.x8_width); float uvY0 = rect.x8_top / float(g_Viewport.xc_height); float uvY1 = (rect.x8_top + rect.x10_height) / float(g_Viewport.xc_height); CTexturedQuadFilter::Vert rttVerts[4] = {{{-5.f, 0.f, 4.45f}, {uvX0, uvY0}}, {{5.f, 0.f, 4.45f}, {uvX1, uvY0}}, {{-5.f, 0.f, -4.45f}, {uvX0, uvY1}}, {{5.f, 0.f, -4.45f}, {uvX1, uvY1}}}; if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) { rttVerts[0].m_uv.y() = uvY1; rttVerts[1].m_uv.y() = uvY1; rttVerts[2].m_uv.y() = uvY0; rttVerts[3].m_uv.y() = uvY0; } const_cast<CTexturedQuadFilter&>(x108_newScanPane).drawVerts(zeus::CColor(1.f, transFactor), rttVerts); // No cull faces zeus::CColor frameColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanFrameInactiveColor(), g_tweakGuiColors->GetScanFrameActiveColor(), x54c_scanFrameColorInterp); frameColor.a() = transFactor; CModelFlags flags(5, 0, 0, frameColor + g_tweakGuiColors->GetScanFrameImpulseColor() * zeus::CColor(x550_scanFrameColorImpulseInterp, x550_scanFrameColorImpulseInterp)); flags.m_noCull = true; zeus::CTransform verticalFlip = zeus::CTransform::Scale(1.f, 1.f, -1.f); zeus::CTransform horizontalFlip = zeus::CTransform::Scale(-1.f, 1.f, 1.f); if (xe4_scanFrameCenterTop.IsLoaded()) { zeus::CTransform modelXf = seventeenScale * zeus::CTransform::Translate(windowScale * zeus::CVector3f(0.f, 0.f, 4.553f)); CGraphics::SetModelMatrix(modelXf); xe4_scanFrameCenterTop->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * modelXf); xe4_scanFrameCenterTop->Draw(flags); } if (xd8_scanFrameCenterSide.IsLoaded()) { zeus::CTransform modelXf = seventeenScale * zeus::CTransform::Translate(windowScale * zeus::CVector3f(-5.f, 0.f, 0.f)); CGraphics::SetModelMatrix(modelXf); xd8_scanFrameCenterSide->Draw(flags); CGraphics::SetModelMatrix(horizontalFlip * modelXf); xd8_scanFrameCenterSide->Draw(flags); } if (xcc_scanFrameCorner.IsLoaded()) { zeus::CTransform modelXf = seventeenScale * zeus::CTransform::Translate(windowScale * zeus::CVector3f(-5.f, 0.f, 4.553f)); CGraphics::SetModelMatrix(modelXf); xcc_scanFrameCorner->Draw(flags); CGraphics::SetModelMatrix(horizontalFlip * modelXf); xcc_scanFrameCorner->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * modelXf); xcc_scanFrameCorner->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * horizontalFlip * modelXf); xcc_scanFrameCorner->Draw(flags); } if (xfc_scanFrameStretchTop.IsLoaded()) { zeus::CTransform modelXf = seventeenScale * zeus::CTransform::Translate(-1.f, 0.f, 4.553f * windowScale.basis[2][2]) * zeus::CTransform::Scale(5.f * windowScale.basis[0][0] - 1.f - 1.884f, 1.f, 1.f); CGraphics::SetModelMatrix(modelXf); xfc_scanFrameStretchTop->Draw(flags); CGraphics::SetModelMatrix(horizontalFlip * modelXf); xfc_scanFrameStretchTop->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * modelXf); xfc_scanFrameStretchTop->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * horizontalFlip * modelXf); xfc_scanFrameStretchTop->Draw(flags); } if (xf0_scanFrameStretchSide.IsLoaded()) { zeus::CTransform modelXf = seventeenScale * zeus::CTransform::Translate(-5.f * windowScale.basis[0][0], 0.f, 1.f) * zeus::CTransform::Scale(1.f, 1.f, 4.553f * windowScale.basis[2][2] - 1.f - 1.886f); CGraphics::SetModelMatrix(modelXf); xf0_scanFrameStretchSide->Draw(flags); CGraphics::SetModelMatrix(horizontalFlip * modelXf); xf0_scanFrameStretchSide->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * modelXf); xf0_scanFrameStretchSide->Draw(flags); CGraphics::SetModelMatrix(verticalFlip * horizontalFlip * modelXf); xf0_scanFrameStretchSide->Draw(flags); } // cull faces } void CPlayerVisor::DrawXRayEffect(const CStateManager&) const { SCOPED_GRAPHICS_DEBUG_GROUP("CPlayerVisor::DrawXRayEffect", zeus::skMagenta); const_cast<CCameraBlurPass&>(x90_xrayBlur).Draw(); } void CPlayerVisor::DrawThermalEffect(const CStateManager&) const { // Empty } void CPlayerVisor::UpdateCurrentVisor(float transFactor) { switch (x1c_curVisor) { case CPlayerState::EPlayerVisor::XRay: x90_xrayBlur.SetBlur(EBlurType::Xray, 36.f * transFactor, 0.f); break; case CPlayerState::EPlayerVisor::Scan: { zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorHudLightMultiply(), zeus::skWhite, 1.f - transFactor); x64_scanDim.SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f, dimColor, -1); break; } default: break; } } void CPlayerVisor::FinishTransitionIn() { switch (x1c_curVisor) { case CPlayerState::EPlayerVisor::Combat: x90_xrayBlur.DisableBlur(0.f); break; case CPlayerState::EPlayerVisor::XRay: x90_xrayBlur.SetBlur(EBlurType::Xray, 36.f, 0.f); if (!x5c_visorLoopSfx) x5c_visorLoopSfx = CSfxManager::SfxStart(SFXui_visor_xray_lp, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); break; case CPlayerState::EPlayerVisor::Scan: { zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorScreenDimColor(), g_tweakGuiColors->GetScanVisorHudLightMultiply(), x2c_scanDimInterp); x64_scanDim.SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f, dimColor, -1); if (!x5c_visorLoopSfx) x5c_visorLoopSfx = CSfxManager::SfxStart(SFXui_visor_scan_lp, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); break; } case CPlayerState::EPlayerVisor::Thermal: if (!x5c_visorLoopSfx) x5c_visorLoopSfx = CSfxManager::SfxStart(SFXui_visor_thermal_lp, x24_visorSfxVol, 0.f, false, 0x7f, true, kInvalidAreaId); break; default: break; } } void CPlayerVisor::BeginTransitionIn(const CStateManager&) { switch (x1c_curVisor) { case CPlayerState::EPlayerVisor::XRay: x90_xrayBlur.SetBlur(EBlurType::Xray, 0.f, 0.f); // xc4_vpScaleX = 0.9f; // xc8_vpScaleY = 0.9f; CSfxManager::SfxStart(SFXui_into_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); break; case CPlayerState::EPlayerVisor::Scan: CSfxManager::SfxStart(SFXui_into_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); x64_scanDim.SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f, zeus::skWhite, -1); break; case CPlayerState::EPlayerVisor::Thermal: CSfxManager::SfxStart(SFXui_into_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); break; default: break; } } void CPlayerVisor::FinishTransitionOut(const CStateManager&) { switch (x1c_curVisor) { case CPlayerState::EPlayerVisor::XRay: x90_xrayBlur.DisableBlur(0.f); // xc4_vpScaleX = 1.f; // xc8_vpScaleY = 1.f; break; case CPlayerState::EPlayerVisor::Scan: x64_scanDim.DisableFilter(0.f); x34_nextState = EScanWindowState::NotInScanVisor; x30_prevState = EScanWindowState::NotInScanVisor; break; case CPlayerState::EPlayerVisor::Thermal: x90_xrayBlur.DisableBlur(0.f); break; default: break; } } void CPlayerVisor::BeginTransitionOut() { if (x5c_visorLoopSfx) { CSfxManager::SfxStop(x5c_visorLoopSfx); x5c_visorLoopSfx.reset(); } switch (x1c_curVisor) { case CPlayerState::EPlayerVisor::XRay: CSfxManager::SfxStart(SFXui_outof_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); break; case CPlayerState::EPlayerVisor::Scan: if (x60_scanningLoopSfx) { CSfxManager::SfxStop(x60_scanningLoopSfx); x60_scanningLoopSfx.reset(); } CSfxManager::SfxStart(SFXui_outof_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); break; case CPlayerState::EPlayerVisor::Thermal: CSfxManager::SfxStart(SFXui_outof_visor, x24_visorSfxVol, 0.f, false, 0x7f, false, kInvalidAreaId); break; default: break; } } void CPlayerVisor::Update(float dt, const CStateManager& mgr) { x90_xrayBlur.Update(dt); CPlayerState& playerState = *mgr.GetPlayerState(); CPlayerState::EPlayerVisor activeVisor = playerState.GetActiveVisor(mgr); CPlayerState::EPlayerVisor curVisor = playerState.GetCurrentVisor(); CPlayerState::EPlayerVisor transVisor = playerState.GetTransitioningVisor(); bool visorTransitioning = playerState.GetIsVisorTransitioning(); UpdateScanWindow(dt, mgr); if (x20_nextVisor != transVisor) x20_nextVisor = transVisor; LockUnlockAssets(); if (mgr.GetPlayer().GetScanningState() == CPlayer::EPlayerScanState::ScanComplete) x2c_scanDimInterp = std::max(0.f, x2c_scanDimInterp - 2.f * dt); else x2c_scanDimInterp = std::min(x2c_scanDimInterp + 2.f * dt, 1.f); if (visorTransitioning) { if (!x25_24_visorTransitioning) BeginTransitionOut(); if (x1c_curVisor != curVisor) { FinishTransitionOut(mgr); x1c_curVisor = curVisor; BeginTransitionIn(mgr); } UpdateCurrentVisor(playerState.GetVisorTransitionFactor()); } else { if (x25_24_visorTransitioning) { FinishTransitionIn(); } else if (curVisor == CPlayerState::EPlayerVisor::Scan) { zeus::CColor dimColor = zeus::CColor::lerp(g_tweakGuiColors->GetScanVisorScreenDimColor(), g_tweakGuiColors->GetScanVisorHudLightMultiply(), x2c_scanDimInterp); x64_scanDim.SetFilter(EFilterType::Multiply, EFilterShape::Fullscreen, 0.f, dimColor, -1); } } x25_24_visorTransitioning = visorTransitioning; if (x1c_curVisor != activeVisor) { if (x24_visorSfxVol != 0.f) { x24_visorSfxVol = 0.f; CSfxManager::SfxVolume(x5c_visorLoopSfx, x24_visorSfxVol); CSfxManager::SfxVolume(x60_scanningLoopSfx, x24_visorSfxVol); } } else { if (x24_visorSfxVol != 1.f) { x24_visorSfxVol = 1.f; CSfxManager::SfxVolume(x5c_visorLoopSfx, x24_visorSfxVol); CSfxManager::SfxVolume(x60_scanningLoopSfx, x24_visorSfxVol); } } float scanMag = g_tweakGui->GetScanWindowMagnification(); if (x58_scanMagInterp < scanMag) x58_scanMagInterp = std::min(x58_scanMagInterp + 2.f * dt, scanMag); else x58_scanMagInterp = std::max(x58_scanMagInterp - 2.f * dt, scanMag); } void CPlayerVisor::Draw(const CStateManager& mgr, const CTargetingManager* tgtManager) const { CGraphics::SetAmbientColor(zeus::skWhite); CGraphics::DisableAllLights(); switch (mgr.GetPlayerState()->GetActiveVisor(mgr)) { case CPlayerState::EPlayerVisor::XRay: DrawXRayEffect(mgr); break; case CPlayerState::EPlayerVisor::Thermal: DrawThermalEffect(mgr); break; case CPlayerState::EPlayerVisor::Scan: DrawScanEffect(mgr, tgtManager); break; default: break; } } void CPlayerVisor::Touch() { if (x124_scanIconNoncritical.IsLoaded()) x124_scanIconNoncritical->Touch(0); if (x130_scanIconCritical.IsLoaded()) x130_scanIconCritical->Touch(0); } float CPlayerVisor::GetDesiredViewportScaleX(const CStateManager& mgr) const { return mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Combat ? 1.f : xc4_vpScaleX; } float CPlayerVisor::GetDesiredViewportScaleY(const CStateManager& mgr) const { return mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Combat ? 1.f : xc8_vpScaleY; } } // namespace urde::MP1
@ This file was created from a .asm file @ using the ads2gas.pl script. .equ DO1STROUNDING, 0 .equ ARCH_ARM , 1 .equ ARCH_MIPS , 0 .equ ARCH_X86 , 0 .equ ARCH_X86_64 , 0 .equ ARCH_PPC32 , 0 .equ ARCH_PPC64 , 0 .equ HAVE_EDSP , 1 .equ HAVE_MEDIA , 1 .equ HAVE_NEON , 1 .equ HAVE_MIPS32 , 0 .equ HAVE_DSPR2 , 0 .equ HAVE_MMX , 0 .equ HAVE_SSE , 0 .equ HAVE_SSE2 , 0 .equ HAVE_SSE3 , 0 .equ HAVE_SSSE3 , 0 .equ HAVE_SSE4_1 , 0 .equ HAVE_AVX , 0 .equ HAVE_AVX2 , 0 .equ HAVE_ALTIVEC , 0 .equ HAVE_VPX_PORTS , 1 .equ HAVE_STDINT_H , 1 .equ HAVE_ALT_TREE_LAYOUT , 0 .equ HAVE_PTHREAD_H , 1 .equ HAVE_SYS_MMAN_H , 1 .equ HAVE_UNISTD_H , 1 .equ CONFIG_EXTERNAL_BUILD , 1 .equ CONFIG_INSTALL_DOCS , 0 .equ CONFIG_INSTALL_BINS , 1 .equ CONFIG_INSTALL_LIBS , 1 .equ CONFIG_INSTALL_SRCS , 0 .equ CONFIG_USE_X86INC , 1 .equ CONFIG_DEBUG , 0 .equ CONFIG_GPROF , 0 .equ CONFIG_GCOV , 0 .equ CONFIG_RVCT , 0 .equ CONFIG_GCC , 1 .equ CONFIG_MSVS , 0 .equ CONFIG_PIC , 1 .equ CONFIG_BIG_ENDIAN , 0 .equ CONFIG_CODEC_SRCS , 0 .equ CONFIG_DEBUG_LIBS , 0 .equ CONFIG_FAST_UNALIGNED , 1 .equ CONFIG_MEM_MANAGER , 0 .equ CONFIG_MEM_TRACKER , 0 .equ CONFIG_MEM_CHECKS , 0 .equ CONFIG_DEQUANT_TOKENS , 0 .equ CONFIG_DC_RECON , 0 .equ CONFIG_RUNTIME_CPU_DETECT , 1 .equ CONFIG_POSTPROC , 1 .equ CONFIG_VP9_POSTPROC , 0 .equ CONFIG_MULTITHREAD , 1 .equ CONFIG_INTERNAL_STATS , 0 .equ CONFIG_VP8_ENCODER , 1 .equ CONFIG_VP8_DECODER , 1 .equ CONFIG_VP9_ENCODER , 1 .equ CONFIG_VP9_DECODER , 1 .equ CONFIG_VP8 , 1 .equ CONFIG_VP9 , 1 .equ CONFIG_ENCODERS , 1 .equ CONFIG_DECODERS , 1 .equ CONFIG_STATIC_MSVCRT , 0 .equ CONFIG_SPATIAL_RESAMPLING , 1 .equ CONFIG_REALTIME_ONLY , 1 .equ CONFIG_ONTHEFLY_BITPACKING , 0 .equ CONFIG_ERROR_CONCEALMENT , 0 .equ CONFIG_SHARED , 0 .equ CONFIG_STATIC , 1 .equ CONFIG_SMALL , 0 .equ CONFIG_POSTPROC_VISUALIZER , 0 .equ CONFIG_OS_SUPPORT , 1 .equ CONFIG_UNIT_TESTS , 0 .equ CONFIG_WEBM_IO , 1 .equ CONFIG_DECODE_PERF_TESTS , 0 .equ CONFIG_MULTI_RES_ENCODING , 1 .equ CONFIG_TEMPORAL_DENOISING , 1 .equ CONFIG_EXPERIMENTAL , 0 .equ CONFIG_MULTIPLE_ARF , 0 .equ CONFIG_ALPHA , 0 .section .note.GNU-stack,"",%progbits
;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ PAGE ,132 TITLE DOS - Code Page Switching - Printer Device Driver ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; FILENAME: CPS Printer Device Driver Main Code ;; MODULE NAME: ;; TYPE: Assemble file (resident code) ;; LINK PROCEDURE: Link CPSPMnn+CPSFONT+CPSPInn into .EXE format. CPSPM01 ;; must be first. CPSPInn must be last. Everything ;; before CPSPInn will be resident. ;; INCLUDE FILES: ;; CPSPEQU.INC ;; ;; ;; This routine is structured as a DOS Device Driver. ;; IE it is installed via the CONFIG.SYS command: ;; ;; The following device commands are supported: ;; ;; 0 - INIT ;; -------- ;; ;; 8 - OUTPUT ;; 9 - OUTPUT ;; -------- ;; Supported in between Designate-start and the Designate_end commands. ;; ;; ;; 12 - IOCTL OUTPUT ;; ----------------- ;; CPS Function request : Major function = 05 -- printer device ;; Minor functions = 4CH -- designate start ;; 4DH -- designate end ;; 4AH -- invoke ;; 6AH -- query-invoked ;; 6BH -- query-list ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;*Modification history ******************************************************** ;AN001; p2685 Long delay on CHCP before failure message 12/10/87 J.K. ;****************************************************************************** ;; INCLUDE CPSPEQU.INC ;; ;; PUBLIC PRINTER_DESC_NUM ;; PUBLIC PRINTER_DESC_TBL ;; PUBLIC INIT_CHK,TABLE,DEVICE_NUM ;; WGR ;AN000; PUBLIC INVOKE ;; WGR ;AN000; PUBLIC BUF0,BUF1,BUF2,BUF3 ;; WGR ;AN000; PUBLIC HARD_SL1,RAM_SL1 ;; PUBLIC HARD_SL2,RAM_SL2 ;; PUBLIC HARD_SL3,RAM_SL3 ;; PUBLIC HARD_SL4,RAM_SL4 ;; PUBLIC RESERVED1,RESERVED2 ;; ;; EXTRN RESIDENT_END:WORD ;; EXTRN STACK_ALLOCATED:WORD ;; EXTRN FONT_PARSER:NEAR,FTABLE:WORD ;; EXTRN INIT:NEAR ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; CSEG SEGMENT PARA PUBLIC 'CODE' ;; ASSUME CS:CSEG ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ************************************ ;; ** ** ;; ** Resident Code ** ;; ** ** ;; ************************************ ;; ;; ;; DEVICE HEADER - must be at offset zero within device driver ;; (DHS is defined according to this structure) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; DEV_HDR0: DW OFFSET DEV_HDR1 ;; becomes pointer to next device header DW 0 ;; must be zero for no link DW 0e040H ;; attribute (Char device) ;; supports IOCTL calls DW OFFSET STRATEGY0 ;; pointer to device "strategy" routine DW OFFSET INTERRUPT0 ;; pointer to device "interrupt handler" DEV_NAME0: DB 'PRN ' ;; device name( length : NAME_LEN) ;; DEV_HDR1: DW OFFSET DEV_HDR2 ;; becomes pointer to next device header DW 0 ;; must be zero for no link DW 0e040H ;; attribute (Char device) ;; supports IOCTL calls DW OFFSET STRATEGY1 ;; pointer to device "strategy" routine DW OFFSET INTERRUPT1 ;; pointer to device "interrupt handler" DEV_NAME1: DB 'LPT1 ' ;; device name( length : NAME_LEN) ;; DEV_HDR2: DW OFFSET DEV_HDR3 ;; becomes pointer to next device header DW 0 ;; must be zero for no link DW 0e040H ;; attribute (Char device) ;; supports IOCTL calls DW OFFSET STRATEGY2 ;; pointer to device "strategy" routine DW OFFSET INTERRUPT2 ;; pointer to device "interrupt handler" DEV_NAME2: DB 'LPT2 ' ;; device name( length : NAME_LEN) ;; ;; DEV_HDR3: DD -1 ;; becomes pointer to next device header DW 0e040H ;; attribute (Char device) ;; supports IOCTL calls DW OFFSET STRATEGY3 ;; pointer to device "strategy" routine DW OFFSET INTERRUPT3 ;; pointer to device "interrupt handler" DEV_NAME3: DB 'LPT3 ' ;; device name( length : NAME_LEN) ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ***************************** ;; ** Resident Data Areas ** ;; ***************************** ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; PRN/LPTn printer data based on BUF ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INIT_CHK DW 0 ;; internal flag : error loc. in INIT ;; BUF0: BUF_DATA <,,,,,,,,,,> ;; PRN ;; BUF1: BUF_DATA <,,,,,,,,,,> ;; LPT1 ;; BUF2: BUF_DATA <,,,,,,,,,,> ;; LPT2 ;; BUF3: BUF_DATA <,,,,,,,,,,> ;; LPT3 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Hard/RAM slots table in the order of DEVICE parameters ; ; number of entries in all HARD_SLn is determined by the max. {HSLOTS} ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; HARD_SL1 : SLTS <,> ;; 1st hardware slots HARD_SL1B: SLTS <,> ;; HARD_SL1C: SLTS <,> ;; HARD_SL1D: SLTS <,> ;; HARD_SL1E: SLTS <,> ;; HARD_SL1F: SLTS <,> ;; HARD_SL1G: SLTS <,> ;; HARD_SL1H: SLTS <,> ;; HARD_SL1I: SLTS <,> ;; HARD_SL1J: SLTS <,> ;; HARD_SL1K: SLTS <,> ;; HARD_SL1L: SLTS <,> ;; HARD_SL1M: SLTS <,> ;; -- max. no. of code pages allowed ;;upto hardsl_max + 1 ;; ;; HARD_SL2 : SLTS <,> ;; 2nd hardware slots HARD_SL2B: SLTS <,> ;; HARD_SL2C: SLTS <,> ;; HARD_SL2D: SLTS <,> ;; HARD_SL2E: SLTS <,> ;; HARD_SL2F: SLTS <,> ;; HARD_SL2G: SLTS <,> ;; HARD_SL2H: SLTS <,> ;; HARD_SL2I: SLTS <,> ;; HARD_SL2J: SLTS <,> ;; HARD_SL2K: SLTS <,> ;; HARD_SL2L: SLTS <,> ;; HARD_SL2M: SLTS <,> ;; -- max. no. of code pages allowed ;;upto hardsl_max + 1 ;; ;; HARD_SL3 : SLTS <,> ;; 3rd hardware slots HARD_SL3B: SLTS <,> ;; HARD_SL3C: SLTS <,> ;; HARD_SL3D: SLTS <,> ;; HARD_SL3E: SLTS <,> ;; HARD_SL3F: SLTS <,> ;; HARD_SL3G: SLTS <,> ;; HARD_SL3H: SLTS <,> ;; HARD_SL3I: SLTS <,> ;; HARD_SL3J: SLTS <,> ;; HARD_SL3K: SLTS <,> ;; HARD_SL3L: SLTS <,> ;; HARD_SL3M: SLTS <,> ;; -- max. no. of code pages allowed ;;upto hardsl_max + 1 ;; ;; HARD_SL4 : SLTS <,> ;; 4TH hardware slots HARD_SL4B: SLTS <,> ;; HARD_SL4C: SLTS <,> ;; HARD_SL4D: SLTS <,> ;; HARD_SL4E: SLTS <,> ;; HARD_SL4F: SLTS <,> ;; HARD_SL4G: SLTS <,> ;; HARD_SL4H: SLTS <,> ;; HARD_SL4I: SLTS <,> ;; HARD_SL4J: SLTS <,> ;; HARD_SL4K: SLTS <,> ;; HARD_SL4L: SLTS <,> ;; HARD_SL4M: SLTS <,> ;; -- max. no. of code pages allowed ;;upto hardsl_max + 1 ;; ;; ;; RAM_SL1 : SLTS <,> ;; 1st ram slots RAM_SL1B: SLTS <,> ;; NOTE : must be only FOUR bytes for RAM_SL1C: SLTS <,> ;; codepage positioning RAM_SL1D: SLTS <,> ;; calculation as compared RAM_SL1E: SLTS <,> ;; with each entry in FTDL_OFF RAM_SL1F: SLTS <,> ;; RAM_SL1G: SLTS <,> ;; RAM_SL1H: SLTS <,> ;; RAM_SL1I: SLTS <,> ;; RAM_SL1J: SLTS <,> ;; RAM_SL1K: SLTS <,> ;; RAM_SL1L: SLTS <,> ;; -- max. no. of code pages allowed ;;upto ramsl_max, ;; ;; RAM_SL2 : SLTS <,> ;; 2nd ram slots RAM_SL2B: SLTS <,> ;; RAM_SL2C: SLTS <,> ;; RAM_SL2D: SLTS <,> ;; RAM_SL2E: SLTS <,> ;; RAM_SL2F: SLTS <,> ;; RAM_SL2G: SLTS <,> ;; RAM_SL2H: SLTS <,> ;; RAM_SL2I: SLTS <,> ;; RAM_SL2J: SLTS <,> ;; RAM_SL2K: SLTS <,> ;; RAM_SL2L: SLTS <,> ;; -- max. no. of code pages allowed ;;upto ramsl_max, ;; ;; RAM_SL3 : SLTS <,> ;; 3rd ram slots RAM_SL3B: SLTS <,> ;; RAM_SL3C: SLTS <,> ;; RAM_SL3D: SLTS <,> ;; RAM_SL3E: SLTS <,> ;; RAM_SL3F: SLTS <,> ;; RAM_SL3G: SLTS <,> ;; RAM_SL3H: SLTS <,> ;; RAM_SL3I: SLTS <,> ;; RAM_SL3J: SLTS <,> ;; RAM_SL3K: SLTS <,> ;; RAM_SL3L: SLTS <,> ;; -- max. no. of code pages allowed ;;upto ramsl_max, ;; ;; RAM_SL4 : SLTS <,> ;; 4th ram slots RAM_SL4B: SLTS <,> ;; RAM_SL4C: SLTS <,> ;; RAM_SL4D: SLTS <,> ;; RAM_SL4E: SLTS <,> ;; RAM_SL4F: SLTS <,> ;; RAM_SL4G: SLTS <,> ;; RAM_SL4H: SLTS <,> ;; RAM_SL4I: SLTS <,> ;; RAM_SL4J: SLTS <,> ;; RAM_SL4K: SLTS <,> ;; RAM_SL4L: SLTS <,> ;; -- max. no. of code pages allowed ;;upto ramsl_max, ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; hard/RAM buffered slots on codepages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HBUF_SL1 LABEL WORD ;; hardware slots' buffer for LPT1/PRN DW 0FFFFH ;; ---- only for CART-SLOTS DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto hardsl_max+1, there are as many HARD_SLn ;; HBUF_SL2 LABEL WORD ;; hardware slots' buffer for LPT2 DW 0FFFFH ;; ---- only for CART-SLOTS DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto hardsl_max+1, there are as many HARD_SLn ;; HBUF_SL3 LABEL WORD ;; hardware slots' buffer for LPT3 DW 0FFFFH ;; ---- only for CART-SLOTS DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto hardsl_max+1, there are as many HARD_SLn ;; ;; RBUF_SL1 LABEL WORD ;; ram slots' buffer for LPT1/PRN DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto ramsl_max, there are as many RAM_SLn ;; RBUF_SL2 LABEL WORD ;; ram slots' buffer for LPT2 DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto ramsl_max, there are as many RAM_SLn ;; RBUF_SL3 LABEL WORD ;; ram slots' buffer for LPT3 DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; DW 0FFFFH ;; ;;upto ramsl_max, there are as many RAM_SLn ;; FTDL_OFF1 LABEL WORD ;; offset of FTSTART for PRN/LPT1 DW 0 ;; NOTE : must be only two bytes for DW 0 ;; codepage positioning DW 0 ;; calculation as compared DW 0 ;; with each entry in RAM_SLOT DW 0 ;; or CART_SLOT DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; ;;upto the max. of {ramsl_max,hardsl_max} ;; FTDL_OFF2 LABEL WORD ;; offset of FTSTART for LPT2 DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; ;;upto the max. of {ramsl_max,hardsl_max} ;; FTDL_OFF3 LABEL WORD ;; offset of FTSTART for LPT3 DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; DW 0 ;; ;;upto the max. of {ramsl_max,hardsl_max} ;; ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Printer Description Tables ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ESC_CHAR EQU 27 ;; ;; db 'PRINTER_DESC' ;; ;; PRINTER_DESC_NUM DW 3 ;; number of PRINTER_DESCn ;; PRINTER_DESC_TBL LABEL WORD ;; DW OFFSET(PRINTER_DESC1) ;; DW OFFSET(PRINTER_DESC2) ;; DW OFFSET(PRINTER_DESC3) ;; DW OFFSET(PRINTER_DESC4) ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Printer Description Table for Proprinter (4201) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINTER_DESC1 : ;; ;; PDSH <,'4201 ',,,0,212,1,1,1> ;; followed by the rest in PDS ;; CLASS = 0 ;; FTSZPA = 212 ==> 212 x 16=3008 bytes ;; of font buffer ;; HSLOTS = 1 (check CTL4201_B) ;; HWCPMIN = 1 ;; RSLOTS = 1 (check CTL4201_B) ;; DW OFFSET(CTL4201_H) DW OFFSET(CTL4201_R) DW OFFSET(CTL4201_B) ;; (CTL_MAX = 32) ;; (32 bytes for each control) ;; (MUST BE ADJACENT...no blanks bet.:) CTL4201_H : DB 5,ESC_CHAR,'I',0,ESC_CHAR,"6" ;; selection control 1 CTL4201_R : DB 5,ESC_CHAR,'I',4,ESC_CHAR,"6" ;; selection control 2 db 26 dup (0) ;; for CTL4201_H db 26 dup (0) ;; for CTL4201_R ;; CTL4201_B DB CTL_MAX DUP (0) ;; max. two selection DB CTL_MAX DUP (0) ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Printer Description Table for 5202 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PRINTER_DESC2 : ;; PDSH <,'5202 ',,,1,2,2,1,0> ;; followed by the rest in PDS ;; CLASS = 1 (font buffers allowed ;; if there is cart-slot) ;; FTSZPA = 2 ==> 2 x 16 = 32 bytes ;; of font buffer ;; HSLOTS = 2 (check CTL5202_B) ;; HWCPMIN = 1 ;; RSLOTS = 0 (check CTL5202_B) ;; DW OFFSET(CTL5202_H) DW OFFSET(CTL5202_R) DW OFFSET(CTL5202_B) ;; ;; (CTL_MAX = 32) ;; (SEE CTL5202_OFFS) ;; (32 bytes for each control) CTL5202_H : DB 12,ESC_CHAR,91,84,5,0,00,00,0FFH,0FFH,00 ;; selection control 1 dB ESC_CHAR,"6" ;; DB 12,ESC_CHAR,91,84,5,0,00,00,0FFH,0FFH,00 ;; selection control 2 dB ESC_CHAR,"6" ;; db 19 dup (0) ;; for CTL5202_H selection 1 db 19 dup (0) ;; for CTL5202_H selection 2 CTL5202_R : DB 0 ;; ;; CTL5202_B DB CTL_MAX DUP (0) ;; max. two selection DB CTL_MAX DUP (0) ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Printer Description Table for RESERVED PRINTER (res1) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINTER_DESC3 : ;; ;; PDSH <,'4208 ',,,1,2,2,1,0> ;; followed by the rest in PDS ;; CLASS = 1 ;; FTSZPA = 2 ;; HSLOTS = 2 ;; HWCPMIN = 1 ;; RSLOTS = 0 ;; DW OFFSET(CTL4208_H) DW OFFSET(CTL4208_R) DW OFFSET(CTL4208_B) ;; (CTL_MAX = 32) ;; (32 bytes for each control) ;; (MUST BE ADJACENT...no blanks bet.:) CTL4208_H : DB 0Bh,ESC_CHAR,49h,0Ah ;; selection control 1 DB ESC_CHAR,49h,03 DB ESC_CHAR,49h,02 DB ESC_CHAR,36h db 20 dup (0) CTL4208_R : DB 0Bh,ESC_CHAR,49h,0Eh ;; selection control 2 DB ESC_CHAR,49h,7 DB ESC_CHAR,49h,6 DB ESC_CHAR,36h db 20 dup (0) ;; for CTLres1_H and CTRLres1_R ;; CTL4208_B DB CTL_MAX DUP (0) ;; max. two selection DB CTL_MAX DUP (0) ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Printer Description Table for RESERVED PRINTER (res2) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINTER_DESC4 : ;; ;; PDSH <,'nnnnnnnn',,,0,0,1,1,1> ;; followed by the rest in PDS ;; CLASS = 0 ;; FTSZPA = 0 ;; HSLOTS = 1 ;; HWCPMIN = 1 ;; RSLOTS = 1 ;; DW OFFSET(CTLres2_H) DW OFFSET(CTLres2_R) DW OFFSET(CTLres2_B) ;; (CTL_MAX = 32) ;; (32 bytes for each control) ;; (MUST BE ADJACENT...no blanks bet.:) CTLres2_H : DB 0 ;; selection control 1 CTLres2_R : DB 32 dup (0) ;; selection control 2 db 32 dup (0) ;; for CTLres2_H and CTRLres2_R ;; CTLres2_B DB CTL_MAX DUP (0) ;; max. two selection DB CTL_MAX DUP (0) ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; TEMP_SI DW ? ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; The request header for IOCTL call ;; to the Normal device driver ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; REQ_NORM1 GIH <,,,,,> ;; for LPT1/PRN GB2S <,> ;; REQ_NORM2 GIH <,,,,,> ;; for LPT2 GB2S <,> ;; REQ_NORM3 GIH <,,,,,> ;; for LPT3 GB2S <,> ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; ;; PARSER'S TABLES ;; ;; -- TABLE is the first table of the results of the parsing. ;; The first word (number of devices) will be set to 0 if ;; syntax error is detected in the DEVICE command line. ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; TABLE STRUCTURE FOR RETURNING VALUES TO THE INIT MODULE WGR ; (ADAPTED FROM VERSION 1.0 DISPLAY.SYS) WGR ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TABLE LABEL BYTE ; table header ;AN000; DEVICE_NUM DW ZERO ; initialized to zero devices ;AN000; DW TABLE1_1 ; pointer to table 2 for device 1 ;AN000; DW TABLE2_1 ; pointer to table 2 for device 2 ;AN000; DW TABLE3_1 ; pointer to table 2 for device 3 ;AN000; DW TABLE4_1 ; pointer to table 2 for device 4 ;AN000; ;AN000; TABLE1_1 LABEL WORD ;AN000; DW FOUR ; 4 pointer follow ;AN000; DW TABLE1_2 ; pointer to table 3 (device name) ;AN000; DW TABLE1_3 ; pointer to table 4 (device id) ;AN000; DW TABLE1_4 ; pointer to table 5 (hwcp's) ;AN000; DW TABLE1_5 ; pointer to table 6 (num desg's and fonts) ;AN000; DW -1 ; reserved ;AN000; ;AN000; TABLE1_2 LABEL WORD ; device name (ie. PRN) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE1_3 LABEL WORD ; device id. (eg. 4201,5202..) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE1_4 LABEL WORD ; hardware code pages (10 max.) ;AN000; DW ZERO ; number ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; ;AN000; TABLE1_5 LABEL WORD ; Designates and fonts ;AN000; DW ZERO ; values given (0 - 2 valid) ;AN000; DW -1 ; n value ;AN000; DW -1 ; m value ;AN000; ;AN000; TABLE2_1 LABEL WORD ;AN000; DW FOUR ; 4 pointer follow ;AN000; DW TABLE2_2 ; pointer to table 3 (device name) ;AN000; DW TABLE2_3 ; pointer to table 4 (device id) ;AN000; DW TABLE2_4 ; pointer to table 5 (hwcp's) ;AN000; DW TABLE2_5 ; pointer to table 6 (num desg's and fonts) ;AN000; DW -1 ; reserved ;AN000; ;AN000; TABLE2_2 LABEL WORD ; device name (ie. PRN) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE2_3 LABEL WORD ; device id. (eg. 4201,5202..) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE2_4 LABEL WORD ; hardware code pages (10 max.) ;AN000; DW ZERO ; number ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; ;AN000; TABLE2_5 LABEL WORD ; Designates and fonts ;AN000; DW ZERO ; values given (0 - 2 valid) ;AN000; DW -1 ; n value ;AN000; DW -1 ; m value ;AN000; ;AN000; TABLE3_1 LABEL WORD ;AN000; DW FOUR ; 4 pointer follow ;AN000; DW TABLE3_2 ; pointer to table 3 (device name) ;AN000; DW TABLE3_3 ; pointer to table 4 (device id) ;AN000; DW TABLE3_4 ; pointer to table 5 (hwcp's) ;AN000; DW TABLE3_5 ; pointer to table 6 (num desg's and fonts) ;AN000; DW -1 ; reserved ;AN000; ;AN000; TABLE3_2 LABEL WORD ; device name (ie. PRN) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE3_3 LABEL WORD ; device id. (eg. 4201,5202..) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE3_4 LABEL WORD ; hardware code pages (10 max.) ;AN000; DW ZERO ; number ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; ;AN000; TABLE3_5 LABEL WORD ; Designates and fonts ;AN000; DW ZERO ; values given (0 - 2 valid) ;AN000; DW 0 ; n value ;AN000; DW 0 ; m value ;AN000; ;AN000; TABLE4_1 LABEL WORD ;AN000; DW FOUR ; 4 pointer follow ;AN000; DW TABLE4_2 ; pointer to table 3 (device name) ;AN000; DW TABLE4_3 ; pointer to table 4 (device id) ;AN000; DW TABLE4_4 ; pointer to table 5 (hwcp's) ;AN000; DW TABLE4_5 ; pointer to table 6 (num desg's and fonts) ;AN000; DW -1 ; reserved ;AN000; ;AN000; TABLE4_2 LABEL WORD ; device name (ie. PRN) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE4_3 LABEL WORD ; device id. (eg. 4201,5202..) ;AN000; DW ZERO ; length ;AN000; DB " " ; value ;AN000; ;AN000; TABLE4_4 LABEL WORD ; hardware code pages (10 max.) ;AN000; DW ZERO ; number ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; DW -1 ; value ;AN000; ;AN000; TABLE4_5 LABEL WORD ; Designates and fonts ;AN000; DW ZERO ; values given (0 - 2 valid) ;AN000; DW 0 ; n value ;AN000; DW 0 ; m value ;AN000; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; reserved1 DW ? ;; reserved for debugging used reserved2 dw ? ;; ;; ;;;;;;;;ASSUME DS:NOTHING ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; PRN Device "strategy" entry point ;; ;; Retain the Request Header address for use by Interrupt routine ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STRATEGY0 PROC FAR ;; PUSH BX ;; PUSH BX ;; LEA BX, BUF0 ;; BUF = BUF0 CS:[BX] POP buf.RH_PTRO ;; offset of request header MOV buf.RH_PTRS,ES ;; segment POP BX ;; RET ;; STRATEGY0 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT1 Device "strategy" entry point ;; ;; Retain the Request Header address for use by Interrupt routine ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STRATEGY1 PROC FAR ;; PUSH BX ;; PUSH BX ;; LEA BX, BUF1 ;; BUF = BUF1 CS:[BX] POP buf.RH_PTRO ;; offset of request header MOV buf.RH_PTRS,ES ;; segment POP BX ;; RET ;; STRATEGY1 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT2 Device "strategy" entry point ;; ;; Retain the Request Header address for use by Interrupt routine ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STRATEGY2 PROC FAR ;; PUSH BX ;; PUSH BX ;; LEA BX, BUF2 ;; BUF = BUF2 CS:[BX] POP buf.RH_PTRO ;; offset of request header MOV buf.RH_PTRS,ES ;; segment POP BX ;; RET ;; STRATEGY2 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT3 Device "strategy" entry point ;; ;; Retain the Request Header address for use by Interrupt routine ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STRATEGY3 PROC FAR ;; PUSH BX ;; PUSH BX ;; LEA BX, BUF3 ;; BUF = BUF3 CS:[BX] POP buf.RH_PTRO ;; offset of request header MOV buf.RH_PTRS,ES ;; segment POP BX ;; RET ;; STRATEGY3 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Table of command / functions supported by LPTn ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CMD_CODES code supported by LPTn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CMD_CODES LABEL BYTE ;; DB CMD_INI ;; Initialization DB CMD_WRT ;; output DB 09 ;; output DB 12 ;; output CMD_INDX EQU ($-CMD_CODES) ;; number of entries in CMD_CODES ;; ;; Write (CMD_WRT) has exceptional ;; support by LPTn ;; ;; Generic IOCTL (CMD_GIO) leads to ;; GIO_CODES ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GIO_CODES code supported by LPTn ;; -- command = CMD_GIO and ;; major function = MAF_PTR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GIO_CODES LABEL BYTE ;; minor GIO functions supported : DB MIF_DST ;; - designate start DB MIF_DEN ;; - designate end DB MIF_IVK ;; - invoke DB MIF_QIV ;; - query-invoked DB MIF_QLS ;; - query-list GIO_INDX EQU ($-GIO_CODES) ;; number of entries in GIO_CODES ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Cases supported by LPTn ;; -- first section matched with ;; CMD_CODES upto CMD_INDX ;; ;; -- 2nd section matched with ;; GIO_CODES for GIO_INDEX more ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CASES LABEL WORD ;; in CMD_CODES order ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; DW OFFSET INIT ;; 0 - Initialization DW OFFSET WRITE ;; DW OFFSET WRITE ;; DW OFFSET WRITE ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; in GIO_CODES order ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; DW OFFSET DESIGNATE_START ;; DW OFFSET DESIGNATE_END ;; DW OFFSET INVOKE ;; DW OFFSET Q_INVOKED ;; DW OFFSET Q_LIST ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Memory Allocation ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; MEM_REQUEST DW -1 ;; flag used for first time memory ;; allocation for each device ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; PRN Device "interrupt" entry point ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INTERRUPT0 PROC FAR ;; device interrupt entry point ;; PUSH DS ;; save all registers Revised PUSH ES ;; PUSH AX ;; PUSH BX ;; PUSH CX ;; PUSH DX ;; PUSH DI ;; PUSH SI ;; ;; BP isn't used, so it isn't saved push cs ;; pop ds ;; ;; CMP STACK_ALLOCATED,0AAH ;; JNE PRN_NO_STACK ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; STACK RECODING SEPT 28/86 ; ; GORDON GIDDINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV AX,STACK_SIZE ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; MOV CS:TEMP_SI,SI ;G; MOV SI,RESIDENT_END ;G; SUB SI,STACK_SIZE ;G; ;G; mov reserved1,AX ;G; mov reserved2,SI ;G; ;G; CLI ;G; MOV DX,SS ;G; MOV CX,SP ;G; MOV SS,SI ;G; MOV SP,AX ;G; STI ;G; MOV SI,CS:TEMP_SI ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSH DX ;; SAVE OLD SS ONTO STACK PUSH CX ;; " " SP " " ;; PRN_NO_STACK : ;; ;; ;; MOV DI,OFFSET IRPT_CMD_EXIT ;; return addr from command processor ;; PUSH DI ;; push return address onto stack ;; command routine issues "RET" ;; LEA BX, BUF0 ;; PRN BUF = BUF0 , CS:BX ;; MOV MEM_REQUEST,-1 ;; to be set to zero only once ;; CMP BUF.BFLAG,-1 ;; JNE PRN_INITED ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV BUF.BFLAG,BF_PRN ;; INITIALIZE PRN BUFFER ;; MOV DI,OFFSET DEV_HDR0 ;; PRN Device header MOV BUF.DEV_HDRO,DI ;; MOV BUF.DEV_HDRS,CS ;; must be CS ;; MOV DI,OFFSET HBUF_SL1 ;; PRN/LPT1 buffer for Hardware-slots MOV BUF.HRBUFO,DI ;; ;; MOV DI,OFFSET RBUF_SL1 ;; PRN/LPT1 buffer for RAM-slots MOV BUF.RMBUFO,DI ;; ;; MOV DI,OFFSET FTDL_OFF1 ;; MOV BUF.FTDLO,DI ;; ;; MOV DI,OFFSET REQ_NORM1 ;; PRN/LPT1 request header MOV BUF.RNORMO,DI ;; ;; MOV BUF.FSELEN,0 ;; selection control length ;; mov buf.prn_bufo,offset buf0;; ;; JMP COMMON_INTR ;; common interrupt handler ;; PRN_INITED : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FONT BUFFER TO BE CREATED ? CMP BUF.BFLAG,BF_PRN ;; JNE PRN_MEM_DONE ;; ;; OR BUF.BFLAG,BF_MEM_DONE ;; do it only once. ;; CMP BUF.STATE,CPSW ;; JNE PRN_MEM_DONE ;; create only if state is CPSW ;; PRN_MEM_CREATE : ;; XOR AX,AX ;; THEN CREATE MOV MEM_REQUEST,AX ;; to set to zero only once for each ;; LPTn or PRN PRN_MEM_DONE : ;; JMP COMMON_INTR ;; common interrupt handler ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT1 Device "interrupt" entry point ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INTERRUPT1 PROC FAR ;; device interrupt entry point ;; PUSH DS ;; save all registers Revised PUSH ES ;; PUSH AX ;; PUSH BX ;; PUSH CX ;; PUSH DX ;; PUSH DI ;; PUSH SI ;; ;; BP isn't used, so it isn't saved push cs ;; pop ds ;; ;; CMP STACK_ALLOCATED,0AAH ;; JNE LPT1_NO_STACK ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; STACK RECODING SEPT 28/86 ; ; GORDON GIDDINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV AX,STACK_SIZE ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; MOV CS:TEMP_SI,SI ;G; MOV SI,RESIDENT_END ;G; SUB SI,STACK_SIZE ;G; ;G; mov reserved1,AX ;G; mov reserved2,SI ;G; ;G; CLI ;G; MOV DX,SS ;G; MOV CX,SP ;G; MOV SS,SI ;G; MOV SP,AX ;G; STI ;G; MOV SI,CS:TEMP_SI ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSH DX ;; SAVE OLD SS ONTO STACK PUSH CX ;; " " SP " " ;; LPT1_NO_STACK : ;; ;; MOV DI,OFFSET IRPT_CMD_EXIT ;; return addr from command processor ;; PUSH DI ;; push return address onto stack ;; command routine issues "RET" LEA BX, BUF1 ;; LPT1 BUF = BUF1 , CS:BX ;; MOV MEM_REQUEST,-1 ;; to be set to zero only once ;; CMP BUF.BFLAG,-1 ;; JNE LPT1_INITED ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV BUF.BFLAG,BF_LPT1 ;; INITIALIZE LPT1 BUFFER ;; MOV DI,OFFSET DEV_HDR1 ;; LPT1 Device header MOV BUF.DEV_HDRO,DI ;; MOV BUF.DEV_HDRS,CS ;; must be CS ;;.................................... LEA DI,BUF.RNORMO ;; duplicate common infor. between PUSH CS ;; PRN and LPT1 POP ES ;; LEA CX,BUF.BUFEND ;; SUB CX,DI ;; LEA SI, BUF0 ;; LEA SI,[SI].RNORMO ;; REP MOVS ES:BYTE PTR[DI],CS:[SI] ;; JMP COMMON_INTR ;; common interrupt handler ;; LPT1_INITED : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FONT MEMORY TO BE CREATED ? CMP BUF.BFLAG,BF_LPT1 ;; JNE LPT1_MEM_DONE ;; ;; OR BUF.BFLAG,BF_MEM_DONE ;; no more next time ;; CMP BUF.STATE,CPSW ;; JNE LPT1_MEM_DONE ;; do it only if state is CPSW ;; LPT1_MEM_CREATE : ;; XOR AX,AX ;; THEN CREATE MEMORY MOV MEM_REQUEST,AX ;; to set to zero only once for each ;; LPT1_MEM_DONE : ;; ;; JMP COMMON_INTR ;; common interrupt handler ;; INTERRUPT1 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT2 Device "interrupt" entry point ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INTERRUPT2 PROC FAR ;; device interrupt entry point ;; PUSH DS ;; save all registers Revised PUSH ES ;; PUSH AX ;; PUSH BX ;; PUSH CX ;; PUSH DX ;; PUSH DI ;; PUSH SI ;; ;; BP isn't used, so it isn't saved push cs ;; pop ds ;; ;; CMP STACK_ALLOCATED,0AAH ;; JNE LPT2_NO_STACK ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; STACK RECODING SEPT 28/86 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV AX,STACK_SIZE ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; MOV CS:TEMP_SI,SI ;G; MOV SI,RESIDENT_END ;G; SUB SI,STACK_SIZE ;G; ;G; mov reserved1,AX ;G; mov reserved2,SI ;G; ;G; CLI ;G; MOV DX,SS ;G; MOV CX,SP ;G; MOV SS,SI ;G; MOV SP,AX ;G; STI ;G; MOV SI,CS:TEMP_SI ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSH DX ;; SAVE OLD SS ONTO STACK PUSH CX ;; " " SP " " ;; LPT2_NO_STACK : ;; ;; MOV DI,OFFSET IRPT_CMD_EXIT ;; return addr from command processor ;; PUSH DI ;; push return address onto stack ;; command routine issues "RET" ;; LEA BX, BUF2 ;; LPT2 BUF = BUF2 , CS:BX ;; MOV MEM_REQUEST,-1 ;; to be set to zero only once ;; CMP BUF.BFLAG,-1 ;; JNE LPT2_INITED ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV BUF.BFLAG,BF_LPT2 ;; initialise LPT2 buffer ;; MOV DI,OFFSET DEV_HDR2 ;; LPT2 Device header MOV BUF.DEV_HDRO,DI ;; MOV BUF.DEV_HDRS,CS ;; must be CS ;; MOV DI,OFFSET HBUF_SL2 ;; LPT2 buffer for Hardware-slots MOV BUF.HRBUFO,DI ;; ;; MOV DI,OFFSET RBUF_SL2 ;; LPT2 buffer for RAM-slots MOV BUF.RMBUFO,DI ;; ;; MOV DI,OFFSET FTDL_OFF2 ;; MOV BUF.FTDLO,DI ;; ;; ;; MOV DI,OFFSET REQ_NORM2 ;; LPT2 request header MOV BUF.RNORMO,DI ;; ;; MOV BUF.FSELEN,0 ;; selection control length ;; mov buf.prn_bufo,offset buf2;; ;; JMP COMMON_INTR ;; common interrupt handler ;; LPT2_INITED : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FONT BUFFER TO BE CREATED ? CMP BUF.BFLAG,BF_LPT2 ;; JNE LPT2_MEM_DONE ;; ;; OR BUF.BFLAG,BF_MEM_DONE ;; ;; CMP BUF.STATE,CPSW ;; JNE LPT2_MEM_DONE ;; ;; XOR AX,AX ;; MOV MEM_REQUEST,AX ;; to set to zero only once for each ;; LPTn or PRN LPT2_MEM_DONE : ;; ;; JMP COMMON_INTR ;; common interrupt handler ;; INTERRUPT2 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LPT3 Device "interrupt" entry point ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INTERRUPT3 PROC FAR ;; device interrupt entry point ;; PUSH DS ;; save all registers Revised PUSH ES ;; PUSH AX ;; PUSH BX ;; PUSH CX ;; PUSH DX ;; PUSH DI ;; PUSH SI ;; ;; BP isn't used, so it isn't saved push cs ;; pop ds ;; ;; CMP STACK_ALLOCATED,0AAH ;; JNE LPT3_NO_STACK ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; STACK RECODING SEPT 28/86 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV AX,STACK_SIZE ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; SHL AX,1 ;G; MOV CS:TEMP_SI,SI ;G; MOV SI,RESIDENT_END ;G; SUB SI,STACK_SIZE ;G; ;G; mov reserved1,AX ;G; mov reserved2,SI ;G; ;G; CLI ;G; MOV DX,SS ;G; MOV CX,SP ;G; MOV SS,SI ;G; MOV SP,AX ;G; STI ;G; MOV SI,CS:TEMP_SI ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUSH DX ;; SAVE OLD SS ONTO STACK PUSH CX ;; " " SP " " ;; LPT3_NO_STACK : ;; ;; MOV DI,OFFSET IRPT_CMD_EXIT ;; return addr from command processor ;; PUSH DI ;; push return address onto stack ;; command routine issues "RET" ;; LEA BX, BUF3 ;; LPT3 BUF = BUF3 , CS:BX ;; MOV MEM_REQUEST,-1 ;; to be set to zero only once ;; CMP BUF.BFLAG,-1 ;; JNE LPT3_INITED ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV BUF.BFLAG,BF_LPT3 ;; INITIALIZE LPT3 BUFFER ;; MOV DI,OFFSET DEV_HDR3 ;; LPT3 Device header MOV BUF.DEV_HDRO,DI ;; MOV BUF.DEV_HDRS,CS ;; must be CS ;; MOV DI,OFFSET HBUF_SL3 ;; LPT3 buffer for Hardware-slots MOV BUF.HRBUFO,DI ;; ;; MOV DI,OFFSET RBUF_SL3 ;; LPT3 buffer for RAM-slots MOV BUF.RMBUFO,DI ;; ;; MOV DI,OFFSET FTDL_OFF3 ;; MOV BUF.FTDLO,DI ;; ;; ;; MOV DI,OFFSET REQ_NORM3 ;; LPT3 request header MOV BUF.RNORMO,DI ;; ;; MOV BUF.FSELEN,0 ;; selection control length ;; mov buf.prn_bufo,offset buf3;; ;; JMP COMMON_INTR ;; common interrupt handler ;; LPT3_INITED : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FONT BUFFER TO BE CREATED ? CMP BUF.BFLAG,BF_LPT3 ;; JNE LPT3_MEM_DONE ;; ;; OR BUF.BFLAG,BF_MEM_DONE ;; no more next time ;; CMP BUF.STATE,CPSW ;; JNE LPT3_MEM_DONE ;; ;; XOR AX,AX ;; MOV MEM_REQUEST,AX ;; to set to zero only once for each ;; LPTn or PRN LPT3_MEM_DONE : ;; ;; JMP COMMON_INTR ;; common interrupt handler ;; INTERRUPT3 ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Common interrupt entry : ; at entry, BUFn (CS:BX) of LPTn is defined ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COMMON_INTR : ;; CLD ;; all moves forward ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Check if header link has to be set ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LDS SI,DWORD PTR BUF.DEV_HDRO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; device header : DS:[SI] CMP BUF.LPT_STRAO, -1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JNE DOSLPT_FOUND ;; has been linked to DOS LPTn CMP BUF.LPT_STRAS, -1 ;; JNE DOSLPT_FOUND ;; has been linked to DOS LPTn LDS SI,DWORD PTR BUF.DEV_HDRO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; next device header : ES:[DI] LES DI,DWORD PTR HP.DH_NEXTO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PUSH ES ;; POP AX ;; AND AX,AX ;; JNZ L1 ;; JMP DOSLPT_FOUND ;; link not yet set up ;; ;$SEARCH WHILE ;; pointer to next device header is NOT L1: PUSH ES ;; -1 POP AX ;; CMP AX,-1 ;; ;$LEAVE E, AND ;; leave if both offset and segment are JNE NOT0FFFF CMP DI,-1 ;; 0FFFFH ;$LEAVE E ;; JE L2 NOT0FFFF: ;; PUSH DI ;; PUSH SI ;; MOV CX,NAME_LEN ;; LEA DI,NHD.DH_NAME ;; LEA SI,HP.DH_NAME ;; REPE CMPSB ;; POP SI ;; POP DI ;; AND CX,CX ;; ;$EXITIF Z ;; exit if name is found in linked hd. JNZ L3 ;; name is not found ;; ;; name is found in the linked header MOV AX,NHD.DH_STRAO ;; get the STRATEGY address ; ADD AX,DI ;; MOV BUF.LPT_STRAO,AX ;; MOV AX,ES ;; ; JNC X1 ;; ; ADD AX,1000H ;; carrier overflow X1: MOV BUF.LPT_STRAS,AX ;; ;; MOV AX,NHD.DH_INTRO ;; get the INTERRUPT address ; ADD AX,DI ;; MOV BUF.LPT_INTRO,AX ;; MOV AX,ES ;; ; JNC X2 ;; ; ADD AX,1000H ;; carrier overflow X2: MOV BUF.LPT_INTRS,AX ;; ;; ;; ;$ORELSE ;; find next header to have the same ;; device name JMP L4 ;; L3: ;; LES DI,DWORD PTR NHD.DH_NEXTO ; ;; ;$ENDLOOP ;; JMP L1 ;; L2: ;; ;$ENDSRCH ;; L4: ;; ;; DOSLPT_FOUND : ;; device header link has been ;; established ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; COMMAND REQUEST ; ES:DI Request Header , and ; ; CMD_CODES, GIO_CODES ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; LES DI,dword ptr buf.rh_ptro ;; get RH address passed to ;; MOV AL,RH.RHC_CMD ;; CMP AL,CMD_GIO ;; JE GIO_COMMAND ;; ;; PUSH CS ;; non-GIO command POP ES ;; MOV DI,OFFSET CMD_CODES ;; MOV CX,CMD_INDX ;; ;; find if command is in CMD_CODES ? REPNE SCASB ;; JNE UN_SUP ;; MOV SI,CMD_INDX ;; the command is supported : SUB SI,CX ;; DEC SI ;; index to CASES JMP SUPPORTED ;; ;; UN_SUP: JMP NORM_DRIVER ;; to be handled by DOS normal driver ;; GIO_COMMAND : ;; Check if it is valid GIO ;; GIO_CASES : ;; supported GIO command MOV AL,RH.GIH_MIF ;; ;; use minor function to locate PUSH CS ;; POP ES ;; MOV DI,OFFSET GIO_CODES ;; MOV CX,GIO_INDX ;; ;; find if command is in GIO_CODES ? REPNE SCASB ;; JNE NORM_DRIVER ;; MOV SI,GIO_INDX ;; the command is supported : SUB SI,CX ;; DEC SI ;; index to CASES ADD SI,CMD_INDX ;; ;; SUPPORTED : ;; command/functions supported by LPTn ;; ADD SI,SI ;; double to index to WORD-offset ;; XOR AX,AX ;; initialize return to "no error" ;; LES DI,dword ptr buf.rh_ptro ;; get RH address again ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; At entry to command processing routine: ; ; ES:DI = Request Header address ; CS:BX = Buffer for lptn ; CS = code segment address ; AX = 0 ; ; top of stack is return address, IRPT_CMD_EXIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; JMP CS:CASES[SI] ;; call routine to handle the command ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; IRPT_CMD_EXIT: ;; return from command routine ;; AX = value to OR into status word LES DI,dword ptr buf.rh_ptro ;; restore ES:DI as Request Header ptr MOV AX,RH.RHC_STA ;; OR AH,STAT_DONE ;; add "done" bit to status word MOV RH.RHC_STA,AX ;; store status into request header ;; ;; ;; *** USING INTERNATL STACK ? *** ;; CMP STACK_ALLOCATED,-1 ;; JE RET0_NO_STACK ;; ;; CMP STACK_ALLOCATED,0 ;; JNE RET0_IN_STACK ;; ;; MOV STACK_ALLOCATED,0AAH ;; NEXT interrupt will start using JMP RET0_NO_STACK ;; internal STACK ;; RET0_IN_STACK : ;; use internal STACK !!!! POP CX ;get old SP from stack POP DX ;get old SS from stack CLI ;disable interrupts while changing SS:SP MOV SS,DX ;restore stack segment register MOV SP,CX ;restore stack pointer register STI ;enable interrupts ;; ;; RET0_NO_STACK : ;; ;; POP SI ;; restore registers POP DI ;; POP DX ;; POP CX ;; POP BX ;; POP AX ;; POP ES ;; POP DS ;; RET ;; ;; INTERRUPT0 ENDP ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Command not supported by CPSW device driver ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; NORM_DRIVER PROC ;; LPT OUTPUT to the DOS LPTn ;; PUSH BX ;; **** BUF. is changed **** PUSH BX ;; POP SI ;; LES BX,DWORD PTR BUF.RH_PTRO ;; pass the request header to the CALL DWORD PTR CS:[SI].LPT_STRAO ;; LPTn strategy routine. ;; POP BX ;; CALL DWORD PTR BUF.LPT_INTRO ;; interrupt the DOS LPTn RET ;; ;; NORM_DRIVER ENDP ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Command Code - lpt_output ======= ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; WRITE PROC ;; LPT OUTPUT to the DOS LPTn ;; ;; ;; LES DI,dword ptr buf.rh_ptro ;; restore ES:DI as Request Header ptr ;; MOV AX,BUF.STATE ;; CMP AX,NORMAL ;; JNE WRT_NOT_NORMAL ;; JMP WRT_NORMAL ;; ;; WRT_NOT_NORMAL : ;; CMP AX,DESG_END ;; JNE WRT_FONT ;; JMP NO_MORE_FTBLK ;; ignore the write ;; WRT_FONT : ;; CMP AX,DESG_WR ;; JE WRT_DESIGNATE ;; JMP WRT_NORMAL ;; ;;------------------------- WRT_DESIGNATE : ;; DESIGNATE WRITE MOV AX,BUF.STATUS ;; AND AX,FAIL ;; JZ WRT_DESG_GOOD ;; JMP WRT_IGNORE ;; already failed ;; WRT_DESG_GOOD : ;; MOV SI,OFFSET FTABLE ;; PUSH CS ;; POP DS ;; ;; MOV DS:[SI].FLAG,0 ;; no restart MOV AX,RH.RH3_CNT ;; MOV DS:[SI].BUFFER_LEN,AX ;; length of request packet ;; PUSH SI ;; LEA SI,[SI].BUFFER_ADDR ;; packet address MOV AX,RH.RH3_DTAO ;; MOV DS:[SI],AX ;; INC SI ;; INC SI ;; MOV AX,RH.RH3_DTAS ;; MOV DS:[SI],AX ;; POP SI ;; ;; FP_CALL : ;; ************************** CALL FONT_PARSER ;; ** Parse the Font File ** FP_RETURN : ;; ************************** ;; ;; -- only for the RAM slot -- ;; ;; PROCESS THE RETURNED FONT : ;; SI = FTABLE MOV ES,BUF.FTSTART ;; ES = the start of the font buffer, ;; its entry corresponds to the ;; positioning of codepage in slot MOV DI,BUF.FTSLOTO ;; DI = start of the slot of codepages ;; CX = slot size of the font downloaded MOV CX,BUF.RBUFMX ;; --- if there is no designate MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JZ CHECK_RETURN ;; MOV CX,BUF.HSLMX ;; -- with/without designate, <>0 ;; CHECK_RETURN : ;; ;; MOV DX,CS:[SI].NUM_FTBLK ;; DX = number fo code pages loaded ;; ADD SI,TYPE FBUFS ;; SI = points to FTBLK ;;................................... PARSE_FTBLK : ;; **** LOOP **** ;; ;; AND DX,DX ;; JNZ SKIP_SLOT ;; JMP NO_MORE_FTBLK ;; **** LOOP EXIT (FTBLK end) **** ;;................................... ;; **** LOOP (on each FTBLK) **** ;; ;; skip on the slot until the codepage SKIP_SLOT : ;; is one of the downloaded. AND CX,CX ;; JNZ LOCATE_SLOT ;; XOR AX,AX ;; PUSH AX ;; POP ES ;; ES = 0, no font storage(less buffer) JMP SLOT_FOUND ;; ;; LOCATE_SLOT: ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_load ;; Jnz SLOT_FOUND ;; INC DI ;;######## NEXT SLOT ############ INC DI ;; INC DI ;; INC DI ;; next slot PUSH ES ;; POP AX ;; ADD AX,BUF.FTSZPA ;; PUSH AX ;; POP ES ;; next buffer DEC CX ;;#################################### JMP SKIP_SLOT ;; ;; SLOT_FOUND : ;; MOV AX,CS:[SI].FTB_STATUS ;; CMP AX,0FFF0H ;; JNB CHECK_FSTAT ;; ;; OR BUF.STATUS,FAIL ;; ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,AX ;; JMP WRITE_RET ;; **** LOOP EXIT (fail) **** ;; CHECK_FSTAT : ;; CMP AX,FSTAT_FONT ;; JNE NEXT_FTBLK ;; ;; MOV AX,CS:[SI].FTB_DLEN ;; AND AX,AX ;; JNZ FONT_RETURNED ;; ;; NEXT_FTBLK : ;; **** NEXT IN LOOP **** ;; ADD SI,TYPE FTBLK ;; SI = points to FTBLK DEC DX ;; INC DI ;;######## NEXT SLOT ############ INC DI ;; INC DI ;; INC DI ;; next slot PUSH ES ;; POP AX ;; ADD AX,BUF.FTSZPA ;; PUSH AX ;; POP ES ;; next buffer DEC CX ;;#################################### JMP PARSE_FTBLK ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FONT_RETURNED : ;; ;; ********************************* ;; * ANY SELECTION CONTROL TO BE * ;; * STORED ? * ;; ********************************* ;; ;; ;; SI = points to FTBLK ;; ES = font buffer segment / 0 ;; BX = LPT buffer ;; DI = SLOT pointer PUSH CX ;; ;; ;; MOV AX,CS:[SI].FTB_SELECT ;; AND AX,AX ;; JNZ SELECT_NOT0 ;; CMP BUF.PCLASS,1 ;; JNE SELECT_0 ;; JMP SELECT_BAD ;; CLASS 1 printer CANNOT have SELECT=0 ;; SELECT_0: ;; ;; POP CX ;; JMP STORE_FONT ;; ;; SELECT_NOT0 : ;; ;; CMP BUF.PCLASS,1 ;; JNE NOT_CLASS1 ;; JMP SELECT_CLASS1 ;; ;; not_class1 : ;; MOV AX,CS:[SI].FTB_SELLEN ;; has this FTBLK already passed the AND AX,AX ;; select ? JNZ SELECT_NOT_PASSED ;; ;; POP CX ;; JMP STORE_FONT ;; ;; SELECT_NOT_PASSED : ;; CMP AX,BUF.FSELMAX ;; JNA SELECT_NOT_LONG ;; JMP SELECT_BAD ;; cannot be more than buffer size ;; ;; SELECT_NOT_LONG : ;; MOV AX,CS:[SI].FTB_SELECT ;; CMP AX,1 ;; JE SELECT_1 ;; JMP SELECT_BAD ;; ;; SELECT_1 : ;; MOV CX,BUF.FSELEN ;; +++ SELECT = 1 +++ AND CX,CX ;; JZ CTL_NOT_COPIED ;; MOV AX,CS:[DI].SLT_AT ;; == copy control only from one FTBLK AND AX,AT_SELECT ;; JNZ CTL_NOT_COPIED ;; JMP SKIP_SELECT ;; ;; CTL_NOT_COPIED : ;; ;; OR CS:[DI].SLT_AT,AT_SELECT;; the FTBLK where control is copied ;; from ;; MOV CX,CS:[SI].FTB_SELLEN ;; CMP CX,CS:[SI].FTB_DLEN ;; JNA STORE_SELECT ;; ;; MOV CX,CS:[SI].FTB_DLEN ;; ;; STORE_SELECT: ;; PUSH CX ;; CX is the length to be copied. ;; PUSH ES ;; PUSH DS ;; PUSH SI ;; PUSH DI ;; ;; MOV AX,CS:[SI].FTB_DAHI ;; PUSH AX ;; POP DS ;; MOV SI,CS:[SI].FTB_DALO ;; ;; PUSH CS ;; POP ES ;; ;; MOV DI,BUF.PDESCO ;; MOV DI,CS:[DI].SELB_O ;; ADD DI,BUF.FSELEN ;; ;; REP MOVSB ;; ;; ;; POP DI ;; POP SI ;; POP DS ;; POP ES ;; ;; POP CX ;; SUB CS:[SI].FTB_DLEN,CX ;; SUB CS:[SI].FTB_SELLEN,CX ;; == less control bytes to be copied ADD CS:[SI].FTB_DALO,CX ;; ADD BUF.FSELEN,CX ;; ;; POP CX ;; ;; ;; any data left for font ? CMP BUF.PCLASS,1 ;; JNE MORE_FONT ;; ;; JMP NEXT_FTBLK ;; == CLASS 1 printer ingnores fonts ;; MORE_FONT : ;; more font data ? ;; JMP STORE_FONT ;; ;; SELECT_CLASS1: ;; +++ PRINTER CLASS = 1 ;; MOV AX,CS:[SI].FTB_SELECT ;; CMP AX,2 ;; JE GOOD_CLASS1 ;; JMP SELECT_BAD ;; ;; select type = 2 only GOOD_CLASS1 : ;; POP CX ;; ;; PUSH ES ;; STACKS... PUSH DX ;; PUSH DI ;; MOV AX,DI ;; SUB AX,BUF.FTSLOTO ;; SHR AX,1 ;; PUSH AX ;; stack 1 -- offest MOV DI,BUF.FTDLO ;; ADD DI,AX ;; ;; MOV AX,CS:WORD PTR [DI] ;; length copied to font buffer ;; POP DX ;; stack -1 SHR DX,1 ;; PUSH DI ;; STACK +1 -- to font buffer length MOV DI,BUF.FTSTART ;; CTL_ADDR : ;; AND DX,DX ;; JZ CTL_LOCATED ;; ADD DI,BUF.FTSZPA ;; DEC DX ;; JNZ CTL_ADDR ;; ;; CTL_LOCATED : ;; PUSH DI ;; POP ES ;; XOR DI,DI ;; start of the font buffer MOV CX,CS:[SI].FTB_SELLEN ;; AND AX,AX ;; JNZ HASBEEN_COPIED ;; MOV ES:BYTE PTR [DI],CL ;; 1st byte is the length INC AX ;; ;; HASBEEN_COPIED : ;; ;; ADD DI,AX ;; DEC AX ;; CMP AX,CX ;; all copied ? JB COPY_SELECT ;; ;; POP DI ;; STACK -1 ;; POP DI ;; STACKS... POP DX ;; POP ES ;; MOV CX,CS:[SI].FTB_DLEN ;; all font data for this code page is SUB CS:[SI].FTB_DLEN,CX ;; discarded ADD CS:[SI].FTB_DALO,CX ;; ;; JMP NEXT_FTBLK ;; ;; COPY_SELECT : ;; ;; SUB CX,AX ;; CMP CX,CS:[SI].FTB_DLEN ;; JNA FONT_SELECT ;; ;; MOV CX,CS:[SI].FTB_DLEN ;; ;; FONT_SELECT : ;; ;; PUSH CX ;; STACK +2 ;; PUSH DS ;; STACK +3 PUSH SI ;; STACK +4 ;; MOV AX,CS:[SI].FTB_DAHI ;; PUSH AX ;; POP DS ;; MOV SI,CS:[SI].FTB_DALO ;; ;; PUSH DI ;; STACK +5 ;; REP MOVSB ;; ;; POP DI ;; STACK -5 POP SI ;; STACK -4 POP DS ;; STACK -3 ;; POP CX ;; STACK -2 ADD CX,DI ;; POP DI ;; STACK -1 MOV CS:WORD PTR [DI],CX ;; ;; MOV CX,CS:[SI].FTB_DLEN ;; all font data for this code page is SUB CS:[SI].FTB_DLEN,CX ;; discarded ADD CS:[SI].FTB_DALO,CX ;; ;; POP DI ;; POP DX ;; POP ES ;; ;; JMP NEXT_FTBLK ;; ;; ;; SKIP_SELECT : ;; ++ SKIP SELECT ++ ;; MOV CX,CS:[SI].FTB_SELLEN ;; CMP CX,CS:[SI].FTB_DLEN ;; JNA SKIP_ALL_SELLEN ;; MOV CX,CS:[SI].FTB_DLEN ;; ;; SKIP_ALL_SELLEN : ;; SUB CS:[SI].FTB_DLEN,CX ;; SUB CS:[SI].FTB_SELLEN,CX ;; == less control bytes to be skipped ADD CS:[SI].FTB_DALO,CX ;; ;; POP CX ;; JMP STORE_FONT ;; ;; SELECT_BAD : ;; ++ BAD SELECT ++ ;; POP CX ;; ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,STAT_BADATA ;; ;; OR BUF.STATUS,FAIL ;; ;; JMP WRITE_RET ;; ;; ;; ;; ************************************* ;; * FONT TO BE STORED OR DOWNLOADED ? * ;; ************************************* ;; ;; SI = points to FTBLK ;; ES = font buffer segment / 0 ;; BX = LPT buffer ;; DI = SLOT pointer STORE_FONT : ;; ;; CMP CS:[SI].FTB_DLEN,0 ;; any font data left ? JNZ HAS_FONT_DATA ;; JMP NEXT_FTBLK ;; ;; HAS_FONT_DATA : ;; PUSH ES ;; POP AX ;; AND AX,AX ;; JNZ STORE_FONT_BUFFER ;; JMP FONT_DOWNLOAD ;; ;; ;; ;; STORE_FONT_BUFFER : ;; ***************************** PUSH DI ;; ** STORE TO FONT BUFFER ** ;; ***************************** PUSH CX ;; PUSH DS ;; ES = font buffer segment ;; ;; -- determine where is the infor : MOV AX,DI ;; SUB AX,BUF.FTSLOTO ;; relative to the start of the slot SHR AX,1 ;; '' '' '' " of FTDL_OFF ;; ;; ADD AX,BUF.FTDLO ;; MOV DI,AX ;; ;; ;;................................... MOV CX,CS:[SI].FTB_DLEN ;; length of font data ;; MOV AX,CS:WORD PTR [DI] ;; current destination ;; ADD AX,CX ;; PUSH AX ;; STACK A (next destination) ;; ADD AX,CS:[SI].FTB_DLEFT ;; enough room in font buffer ? CMP AX,BUF.FTSIZE ;; JNA ROOM_FOR_FONT ;; ;; POP AX ;; STACK A POP DS ;; POP CX ;; **** LOOP EXIT (no room) **** POP DI ;; ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,STAT_BADATA ;; ;; OR BUF.STATUS,FAIL ;; ;; JMP WRITE_RET ;; ;; ROOM_FOR_FONT : ;; ;; PUSH DI ;; STACK B ;; MOV DI,CS:WORD PTR [DI] ;; current destination ;; PUSH SI ;; STACK C PUSH DS ;; STACK D ;; MOV AX,CS:[SI].FTB_DAHI ;; PUSH AX ;; POP DS ;; source : FTB_DA MOV SI,CS:[SI].FTB_DALO ;; ;; REP MOVSB ;; ;; POP DS ;; STACK D POP SI ;; STACK C POP DI ;; STACK B POP AX ;; STACK A MOV CS:WORD PTR [DI],AX ;; next detination/current length ;; POP DS ;; POP CX ;; POP DI ;; ;; OR CS:[DI].SLT_AT,AT_FONT ;; font buffer has been overwritten ;; JMP NEXT_FTBLK ;; ;; FONT_DOWNLOAD : ;; *********************************** ;; * DOWNLOAD FONT TO THE DEVICE : * PUSH ES ;; *********************************** PUSH DI ;; LES DI,dword ptr buf.rh_ptro ;; -- the logic can only support one ;; physical device slot that can be ;; downloaded.) MOV AX,CS:[SI].FTB_DLEN ;; MOV RH.RH3_CNT,AX ;; MOV AX,CS:[SI].FTB_DALO ;; MOV RH.RH3_DTAO,AX ;; MOV AX,CS:[SI].FTB_DAHI ;; MOV RH.RH3_DTAS,AX ;; ;; MOV RH.RHC_CMD,CMD_WRT ;; 06/25 MODE.COM ;; PUSH SI ;; PUSH ES ;; PUSH BX ;; **** BUF. is changed **** PUSH BX ;; POP SI ;; LES BX,DWORD PTR BUF.RH_PTRO ;; pass the request header to the ;; FDL_CALL_STR : ;; CALL DWORD PTR CS:[SI].LPT_STRAO ;; LPTn strategy routine. POP BX ;; POP ES ;; POP SI ;; ;; FDL_CALL_ITR : ;; CALL DWORD PTR BUF.LPT_INTRO ;; interrupt the DOS LPTn ;; FDL_ITR_RETURN : ;; MOV AX,rh.RHC_STA ;; ;; and ax,stat_error ;; jz fdl_good1 ;; mov ax,stat_deverr ;; mov rh.rhc_sta,ax ;; ;; fdl_good1 : ;; POP DI ;; POP ES ;; ;; AND AX,STAT_ERROR ;; any error returned by normal device? JNZ FDL_BAD ;; OR CS:[DI].SLT_AT,AT_RAM1 ;; JMP NEXT_FTBLK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FDL_BAD : ;; **** LOOP EXIT (bad) **** OR BUF.STATUS,FAIL ;; ;; JMP WRITE_RET ;; ;; WRT_NORMAL : ;; ;; JMP NORM_DRIVER ;; ;; WRT_ignore : ;; ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,STAT_DEVERR ;; JMP WRITE_RET ;; ;; NO_MORE_FTBLK : ;; ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,0 ;; ;; WRITE_RET : ;; RET ;; ;; WRITE ENDP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Generic IOCTL Designate Start ====== ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DESIGNATE_START PROC ;; MOV AX,BUF.STATE ;; CMP AX,NORMAL ;; JNE DS_00 ;G; ALL OF THESE EXTRA JUMPS ARE JMP DST_NORMAL ;; DUE TO SIZE OF FOLLOWING CODE!!!!! DS_00: CMP AX,CPSW ;; WGR ;AN000; JE DS_01 ;G; CMP AX,LOCKED ;; WGR ;AN000; JE DS_03 ;; WGR ;AN000; JMP DST_CMDERR ;G; DS_01: CALL CHECK_PRINT_ACTIVE ;G; THIS WILL FIND OUT IF THE JNC DS_02 ;G; DS_03: ;; WGR ;AN000; JMP DST_DEVERR ;G; PRINT.COM IS ACTIVE, CY=1 MEANS YES ;G; DS_02: LDS SI,RH.GIH_GBA ;; GIOB = DS:[SI] MOV AX,GIOB.GB1_FLAG ;; AND AX,DSF_CARTCP ;; JNZ dst_deverr ;; DO NOT SUPPORT CARTRIDGE FLAG !!!! ;; ;; ****************************** ;; ** DESIGNATE / REFRESH ? ** ;; ****************************** ;; check the LENGTH in BUFFER1 ;; MOV CX,GIOB.GB1_LEN ;; AND CX,CX ;; JNZ DST_NOT_NULL ;; ;; mov cs:init_chk,0fefeh ;; ;; JMP DST_REFRESH ;; null lenght ==> refresh ;; DST_NOT_NULL : ;; MOV AX,CX ;; SHR AX,1 ;; divide by 2 MOV CX,AX ;; MOV AX,STAT_CMDERR ;; error if LEN < 2 AND CX,CX ;; JZ DST_RET ;; DEC CX ;; JNZ NO_REFRESH ;; ;; MOV AX,GIOB.GB1_NUM ;; AND AX,AX ;; MOV AX,STAT_BADATA ;; JNZ DST_RET ;; error, as no code pages followed ;; mov cs:init_chk,0ffeeh ;; ;; ;; JMP DST_REFRESH ;; null length => REFRESH font from ;; font buffer to device ;; ********************************* ;; ** DESIGNATE FOR CARTRIDGE ? ** NO_REFRESH : ;; ********************************* ;; CX = number of codepages designated CMP BUF.PCLASS,1 ;; CLASS 1 Printer ? JNE DST_RAM ;; JMP DST_CART ;; ;; DST_RAM : ;; ;; MOV AX,DSF_CARTCP ;; RAM-code pages NOT AX ;; AND BUF.STATUS,AX ;; not CARTCP MOV DI,BUF.RMBUFO ;; DI MOV DX,BUF.RSLMX ;; DX = number of designate allowed ;; (limited by available slots) MOV AX,STAT_TOMANY ;; CMP CX,DX ;; more codepages than supported ? JA DST_RET ;; ;; JMP DST_DESIGNATE ;; ;; DST_NORMAL : ;; push cs ;; pop ds ;; JMP NORM_DRIVER ;; ;; DST_DEVERR : ;; MOV AX,STAT_DEVERR ;; JMP DST_RET ;G; ;; DST_CMDERR : ;G; MOV AX,STAT_CMDERR ;G; DST_RET : ;; JMP DST_RETURN ;; ;; DST_CART: ;; MOV AX,DSF_CARTCP ;; Hardware code pages OR BUF.STATUS,AX ;; MOV DI,BUF.HRBUFO ;; DI MOV DX,BUF.HSLMX ;; DX = number of slots available MOV AX,DX ;; SUB AX,BUF.HARDMX ;; no. of designate allowed ;; CMP CX,AX ;; more codepages than supported ? MOV AX,STAT_TOMANY ;; JA DST_RET ;; ;;--------------------------------------------------------------------------- ;; ************************************* DST_DESIGNATE : ;; * any duplicated codepages in MODE ?* ;; * define the slot-buffer * ;; ************************************* ;; ;; -- Use the buffer to hold the code ;; page value in the MODE with the ;; position correspondence : ;; 1. reset the buffer to all 0FFFFH ;; 2. if the code page in MODE does not ;; replicate with any in the buffer, ;; then store the code page value in ;; the buffer. ;; 3. proceed to the next code page in ;; the MODE to check with what is ;; already copied to the buffer. ;; 4. designate will fail if there is a ;; replication : i.e. a repetition ;; in the MODE command. ;; 5. skip the buffer corresponding to ;; HWCP codepages ;;------------------------------------- ;; PUSH DI ;; (the start of RAM/Hardware buffer) PUSH DX ;; count of buffer size MOV AX,0FFFFH ;; RESET_BUF: ;; MOV CS:[DI],AX ;; reset all buffer to 0FFFFH INC DI ;; INC DI ;; DEC DX ;; JNZ RESET_BUF ;; POP DX ;; POP DI ;; ;; PUSH BX ;; PUSH DI ;; (the start of RAM/Hardware buffer) PUSH DX ;; count of buffer size PUSH SI ;; first code page in GB1 PUSH CX ;; number of codepages in GB1 ;; PUSH SI ;; ;; MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JZ FILL_BUFFER ;; ;; for cartridge designation MOV SI,BUF.HARDSO ;; SKIP_HWCP: ;; MOV AX,CS:[SI].SLT_AT ;; AND AX,AT_HWCP ;; JZ FILL_BUFFER ;; INC SI ;; skip the hwcp slots, they cannot be INC SI ;; designated INC SI ;; INC SI ;; INC DI ;; INC DI ;; JMP SKIP_HWCP ;; ;; FILL_BUFFER : ;; ;; POP SI ;; ;; PUSH DI ;; POP BX ;; BX = the positioned buffer ;; DST_BUFLP : ;; **** LOOP **** MOV AX,GIOB.GB1_CP ;; (use GIOB only for codepages) CMP AX,0FFFFH ;; JZ DST_BUFNXT ;; ;; PUSH CX ;; ;; compare code page with SLOT-BUFFER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SCAN THE BUFFER FOR DUPLICATION PUSH DX ;; POP CX ;; no. of buffer entries ;; PUSH ES ;; PUSH DI ;; PUSH CS ;; POP ES ;; REPNE SCASW ;; scan codepage vs. buffer POP DI ;; POP ES ;; ;; POP CX ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; JNE BUF_DEFINE ;; ;; ;; **** EXIT FROM LOOP **** ;; POP CX ;; number of codepages in GB1 POP SI ;; first code page in GB1 POP DX ;; count of buffer size POP DI ;; (the start of RAM/Hardware buffer) POP BX ;; ;; MOV AX,STAT_DUPLCP ;; Duplicated code page JMP DST_RETURN ;; ;; ;; BUF_DEFINE : ;; MOV CS:[BX],AX ;; no duplicated cp in MODE list ;; ;; ;; **** NEXT IN LOOP **** DST_BUFNXT: ;; INC SI ;; (use GIOB only for codepages) INC SI ;; INC BX ;; INC BX ;; XOR AX,AX ;; DEC CX ;; JNZ DST_BUFLP ;; ;; ;; POP CX ;; number of codepages in GB1 POP SI ;; first code page in GB1 POP DX ;; count of buffer size POP DI ;; (the start of RAM/Hardware buffer) POP BX ;; ;; ;; ;;----------------------------------------------------------------------------- ;;************************************* ;;* any duplicated codepages bet MODE * ;;* and code pages in the slot ? * ;;************************************* ;; -- for each code page in the slot, ;; check for any duplication to ;; code pages in buffer, if the code ;; page in the slot is not to be ;; replaced. ;; -- the designate fails if there is ;; duplication. ;; -- copy the codepage in the slot to ;; the buffer if is not to be ;; replaced. Mark the slot to be ;; AT_OLD. ;; -- if the code page is tobe replaced ;; mark the STATUS with REPLX. ;;------------------------------------- ;; MOV CX,DX ;; both slots & buffer of same size ;; --exclude the hwcp which is not ;; designatable MOV SI,BUF.HARDSO ;; SI = hardware slot ;; MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JNZ CMP_CP ;; MOV SI,BUF.RAMSO ;; SI = RAM slot CMP_CP: ;; MOV BUF.FTSLOTO,SI ;; ;; PUSH DI ;; (the start of RAM/Hardware buffer) PUSH DX ;; count of buffer size PUSH SI ;; first entry in RAM/hardware slot PUSH CX ;; slot size PUSH BX ;; ;; PUSH DI ;; POP BX ;; BX = the positioned buffer DST_SLTLP : ;; ;; **** LOOP **** ;; MOV AX,AT_OLD ;; =**= NOT AX ;; assumed the codepage in slot is new, AND CS:[SI].SLT_AT,AX ;; to be downloaded if buffer <> 0FFFFH ;; AND CS:[SI].SLT_AT,AT_NO_LOAD; -- codepage not to be loaded AND CS:[SI].SLT_AT,AT_NO_font; -- no font has been loaded ;; MOV AX,CS:[SI].SLT_CP ;; CMP AX,0FFFFH ;; JZ DST_SLTNXT ;; ;; PUSH CX ;; MOV CX,CS:[BX] ;; CMP CX,0FFFFH ;; if this slot to be replaced ? POP CX ;; JNZ DST_SLTREPLACED ;; YES, the buffer is not empty ;; ;; compare code page with SLOT-BUFFER PUSH CX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; SCAN THE BUFFER FOR DUPLICATION PUSH DX ;; POP CX ;; no. of buffer entries ;; PUSH ES ;; PUSH DI ;; PUSH CS ;; POP ES ;; REPNE SCASW ;; scan codepage vs. buffer POP DI ;; POP ES ;; ;; POP CX ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; JNE SLT_BUF_DEF ;; ;; ;; **** LOOP EXIT **** ;; POP BX ;; POP CX ;; number of codepages in slots POP SI ;; first entry in RAM/hardware slots POP DX ;; count of buffer size POP DI ;; (the start of RAM/Hardware buffer) ;; MOV AX,STAT_DUPLCP ;; Duplicated code page JMP DST_RETURN ;; ;; ;; SLT_BUF_DEF: ;; MOV CS:[BX],AX ;; no duplicated cp, there was no cp in ;; =**= OR CS:[SI].SLT_AT,AT_OLD ;; mark old so as no new font download ;; JMP DST_SLTNXT ;; the MODE command for this position ;; DST_SLTREPLACED : ;; PUSH BX ;; POP AX ;; save the buffer slot-position POP BX ;; OR BUF.STATUS,REPLX ;; there are codepage in slots replaced PUSH BX ;; PUSH AX ;; POP BX ;; gets back the buffer position ;; ;; **** NEXT IN LOOP **** ;; DST_SLTNXT: ;; INC SI ;; will take whatever is in buffer INC SI ;; INC SI ;; INC SI ;; INC BX ;; position slot in buffer INC BX ;; XOR AX,AX ;; DEC CX ;; JNZ DST_SLTLP ;; ;; ;; POP BX ;; POP CX ;; slot size POP SI ;; first entry in RAM/hardware slots POP DX ;; count of buffer size POP DI ;; (the start of RAM/Hardware buffer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;************************************ ;;* prepare the FTABLE * ;;************************************ ;; ;; -- CX slot / buffer size ;; SI slot ;; DI buffer ;;------------------------------------ PUSH BX ;; STACK +1 PUSH SI ;; STACK +2 ;; =**= MOV AX,FAIL ;; NOT AX ;; AND BUF.STATUS,AX ;; assume it is successful ;; ;; PREPARE_FTB : ;; Prepare for Font Parser LEA BX,FTABLE ;; MOV CS:[BX].FLAG,FLAG_RESTART; MOV CS:[BX].BUFFER_LEN,0 ;; no data packet MOV CS:[BX].NUM_FTBLK,0 ;; ;; ADD BX,TYPE FBUFS ;; points to the first FTBLK. XOR DX,DX ;; DX = FTBLK entries (no code page yet) ;; ;; GET_CODEPAGE : ;; **** LOOP **** AND CX,CX ;; JZ NO_MORE_SLOT ;; MOV AX,CS:[SI].SLT_AT ;; AND AX,AT_OLD ;; JZ NEW_CODEPAGE ;; ;; MOV AX,CS:[SI].SLT_AT ;; AND AX,AT_HWCP ;; JZ GET_NEXT ;; not NEW and not HWCP AND CS:[SI].SLT_AT, NOT AT_OLD ;; also load for HWCP ;; NEW_CODEPAGE : ;; MOV AX,CS:[DI] ;; -- SLOT_AT is not old ;; -- code page in buffer is not 0FFFFH CMP AX,0FFFFH ;; JE GET_NEXT ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; INC DX ;; LOAD FONT as : MOV AX,CS:[DI] ;; codepage in buffer is new code page ;; OR CS:[SI].SLT_AT,AT_LOAD ;; set the attribute indicating load ;; MOV CS:[BX].FTB_CP,AX ;; ;; ADD BX,type ftblk ;; next FTBLK ;; ;; GET_NEXT : ;; **** NEXT IN LOOP **** INC DI ;; INC DI ;; next in buffer INC SI ;; INC SI ;; INC SI ;; INC SI ;; next in slot DEC CX ;; JMP GET_CODEPAGE ;; ;; NO_MORE_SLOT : ;; **** EXIT LOOP **** AND DX,DX ;; JNZ DEFINE_DID ;; JMP NO_FONT_DOWNL ;; ;; ;; ********************************** ;; ** NEXT STATE = DESIGNATE_WRITE ** ;; ********************************** ;; DEFINE_DID : ;; POP SI ;; STACK -2 POP BX ;; STACK -1 ;; PUSH BX ;; STACK +1 PUSH SI ;; STACK +2 ;; PUSH DI ;; STACK +3 PUSH CX ;; STACK +4 PUSH ES ;; STACK +5 PUSH DS ;; STACK +6 ;; PUSH CS ;; POP ES ;; PUSH CS ;; POP DS ;; ;; MOV SI,BX ;; GET THE DEVICE_ID FROM LPTn BUFFER LEA SI,[SI].PAR_EXTRACTO ;; MOV SI,CS:[SI].PAR_DIDO ;; LEA SI,[SI].PAR_DID ;; ;; LEA DI,FTABLE ;; MOV CS:[DI].NUM_FTBLK,DX ;; ;; ADD DI,TYPE FBUFS ;; LEA DI,[DI].FTB_TID ;; ;; SET_DID : ;; MOV CX,8 ;; PUSH SI ;; PUSH DI ;; ;; REP MOVSB ;; ;; POP DI ;; POP SI ;; ;; ADD DI,TYPE FTBLK ;; next DID DEC DX ;; JNZ SET_DID ;; ;; POP DS ;; STACK -6 POP ES ;; STACK -5 POP CX ;; STACK -4 POP DI ;; STACK -3 ;; CALL FONT_PARSER ;; restart font parser ;; LEA BX,FTABLE ;; ADD BX,TYPE FBUFS ;; CMP CS:[BX].FTB_STATUS,FSTAT_SEARCH ;; JE FONT_DOWNL ;; MOV AX,STAT_DEVERR ;; POP SI ;; STACK -2 POP BX ;; STACK -1 JMP DST_RETURN ;; there is no designate_end if fails ;; FONT_DOWNL : ;; POP SI ;; STACK -2 POP BX ;; STACK -1 MOV BUF.STATE,DESG_WR ;; enter DESIGNATE_WRITE state MOV BUF.FSELEN,0 ;; for font selection control loading ;; PUSH CX ;; init the font buffer address of PUSH DI ;; each codepage PUSH SI ;; MOV DI,BUF.FTDLO ;; ;; MOV CX,BUF.RSLMX ;; MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JZ FTDL_LOOP ;; MOV CX,BUF.HSLMX ;; ;; FTDL_LOOP : ;; AND CX,CX ;; JZ FTDL_DONE ;; mov ax,cs:[si].slt_at ;; and ax,at_load ;; jz ftdl_next ;; ;; MOV CS:WORD PTR[DI],0 ;; the font length in font buffer is 0 ;; ftdl_next : ;; INC SI ;; INC SI ;; INC SI ;; INC SI ;; INC DI ;; INC DI ;; DEC CX ;; JMP FTDL_LOOP ;; FTDL_DONE : ;; POP SI ;; POP DI ;; POP CX ;; ;; JMP CHECK_OTHER ;; ;; ;; ******************************* ;; ** NEXT STATE = DSIGNATE_END ** ;; ******************************* NO_FONT_DOWNL : ;; POP SI ;; STACK -2 POP BX ;; STACK -1 MOV BUF.STATE,DESG_END ;; proper designate end, ignore write ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_OTHER : ;; ;; MOV DX,BUF.STATUS ;; MOV AX,REPLX ;; NOT AX ;; AND AX,DX ;; reset the bit for "replaced" MOV BUF.STATUS,AX ;; ;; XOR AX,AX ;; AND DX,REPLX ;; JMP DST_RETURN ;; ;; only for the FIFO JMP DST_RETURN ;; ;; ;; DST_REFRESH: ;; ****************************** ;; ** REFRESH FONT TO DEVICE ** ;; ****************************** ;; -- if there is RAM buffer on device ;; -- if there is font assumed to be ;; on the device, then ;; -- load the font to the device, ;; but no change in slot attributes ;; OR BUF.STATUS,REFRESH ;; -- STATE = CPSW (for Designate_end) ;; MOV CX,BUF.RSLMX ;; AND CX,CX ;; JNZ DST_CHECK_FBUFFER ;; JMP DST_REF_INVK ;; invoke any active code page ;; DST_CHECK_FBUFFER: ;; MOV DI,BUF.RAMSO ;; ;; DST_RAMLP: ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_RAM1 ;; JNZ DST_RAM_LOCATED ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ DST_RAMLP ;; JMP DST_REF_INVK ;; there was no font loaded ;; DST_RAM_LOCATED: ;; CMP BUF.RBUFMX,0 ;; ANY FONT BUFFER TO BE COPIED FROM ? JA DST_HAS_BUFFER ;; MOV AX,STAT_NOBUFF ;; mov cs:init_chk,ax ;; JMP DST_RETURN ;; ERROR !!! ;; DST_HAS_BUFFER : ;; SUB DI,BUF.RAMSO ;; relative to .RAMSO SHR DI,1 ;; relative to .FTLDO PUSH DI ;; ;; SHR DI,1 ;; the nth MOV CX,DI ;; MOV AX,BUF.FTSTART ;; ;; DST_LOCATE_FT: ;; AND CX,CX ;; JZ DST_FT_LOCATED ;; ADD AX,BUF.FTSZPA ;; DEC CX ;; JNZ DST_LOCATE_FT ;; ;; DST_FT_LOCATED: ;; ;; POP DI ;; ADD DI,BUF.FTDLO ;; MOV CX,CS:WORD PTR [DI] ;; ;;.................................... ;; DOWNLOAD THE FONT TO DEVICE MOV SI,BUF.RNORMO ;; MOV CS:[SI].RHC_LEN,20 ;; MOV CS:[SI].RHC_CMD,CMD_WRT ;; MOV CS:[SI].RH3_CNT,CX ;; MOV CS:[SI].RH3_DTAO,0 ;; MOV CS:[SI].RH3_DTAS,AX ;; ;; PUSH BX ;; ;; PUSH BX ;; POP DI ;; save BX in DI PUSH CS ;; POP ES ;; MOV BX,SI ;; ES:BX = REQ_NORMn (CS:[SI]) ;; CALL DWORD PTR CS:[DI].LPT_STRAO ;; CALL DWORD PTR CS:[DI].LPT_INTRO ;; POP BX ;; ;; MOV AX,CS:[SI].RHC_STA ;; ;; and ax,stat_error ;; jz fdl_good2 ;; mov ax,stat_deverr ;; ;; fdl_good2 : ;; PUSH AX ;; AND AX,STAT_ERROR ;; POP AX ;; JZ DST_REF_INVK ;; ;; ;; DST_RETURN : ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,AX ;; ;; push cs ;; pop ds ;; ;; RET ;; ;; ;; DST_REF_INVK : ;; INVOKE FOR REFRESH ;; ;; ************************************ ;; * INVOKE HIERIECHY : RAM, HARDWARE * ;; ************************************ ;; MOV DI,BUF.RAMSO ;; check with the ram-slots (DI) MOV CX,BUF.RSLMX ;; CX = size AND CX,CX ;; JZ DST_HWCP_CHK ;; ;; DST_RAM_CMP: ;; there are RAM-slots DST_RAM_LP: ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_ACT ;; JNZ DST_IVK_CP ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ DST_RAM_LP ;; ;; DST_HWCP_CHK : ;; MOV DI,BUF.HARDSO ;; check with the HWCP-slots (DI) MOV CX,BUF.Hslmx ;; CX = size AND CX,CX ;; JNZ dst_HWCP_cmp ;; JMP DST_NO_IVK ;; ;; DST_HWCP_CMP : ;; DST_HWCP_LP: ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_ACT ;; JZ DST_HWCP_NEXT ;; JMP DST_IVK_CP ;; ;; DST_HWCP_NEXT : ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ DST_HWCP_LP ;; ;; DST_NO_IVK: ;; XOR AX,AX ;; JMP DST_RETURN ;; ;; DST_IVK_CP : ;; PUSH SI ;; ;; MOV SI,BUF.RNORMO ;; MOV AX,SI ;; ADD AX,TYPE GIH ;; points to buffer ;; PUSH AX ;; LEA SI,[SI].GIH_GBA ;; MOV CS:WORD PTR [SI],AX INC SI ;; INC SI ;; MOV CS:WORD PTR [SI],CS ;; POP SI ;; MOV CS:[SI].GB2_LEN,2 ;; MOV AX,CS:[DI].SLT_CP ;; MOV CS:[SI].GB2_CP,AX ;; ;; POP SI ;; PUSH CS ;; define RH = ES:[DI] POP ES ;; MOV DI,BUF.RNORMO ;; ;; push cs ;; pop ds ;; ;; JMP INVOKE ;; ;; DESIGNATE_START ENDP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Generic IOCTL Designate End ====== ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DESIGNATE_END PROC ;; ;; MOV AX,BUF.STATE ;; CMP AX,LOCKED ;; WGR ;AN000; JNE DE_01 ;; WGR ;AN000; MOV AX,STAT_BADDEN ;; WGR ;AN000; JMP DE_11 ;; WGR ;AN000; DE_01: ;; WGR ;AN000; CMP AX,CPSW ;; JNE DEN_NOT_CPSW ;; MOV AX,BUF.STATUS ;; any refresh ? AND AX,REFRESH ;; JNZ DEN_REFRESH ;; MOV AX,STAT_BADDEN ;; JMP DEN_FAIL ;; ;; DEN_REFRESH : ;; AND BUF.STATUS,NOT REFRESH ;; XOR AX,AX ;; JMP DEN_RET ;; ;; DEN_NOT_CPSW : ;; CMP AX,NORMAL ;; JNE den_NOT_NORMAL ;; JMP NORM_DRIVER ;; not in the code page switching stage ;; den_NOT_NORMAL : ;; CMP AX,DESG_END ;; JNE den_other ;; JMP den_ENDED ;; end with no error check ;; den_other : ;; CMP AX,DESG_WR ;; JE den_write ;; MOV AX,STAT_BADDEN ;; JMP DEN_FAIL ;; no designate start ;;------------------------- den_write : ;; DESIGNATE WRITE ended ;; MOV AX,BUF.STATUS ;; AND AX,FAIL ;; JZ DEN_FTABLE ;; failed in the middle of desig-write XOR AX,AX ;; JMP DEN_FAIL ;; ignore the DEN ;; DEN_FTABLE : ;; ;; LEA DI,FTABLE ;; ADD DI,TYPE FBUFS ;; MOV AX,CS:[DI].FTB_STATUS ;; CMP AX,FSTAT_COMPLETE ;; JE DEN_ENDED ;; ;; CMP AX,FSTAT_FONT ;; JE DEN_FONT ;; MOV AX,STAT_bffDEN ;; bad font file JMP DEN_FAIL ;; the font data was not complete ;; DEN_FONT : ;; MOV AX,CS:[DI].FTB_DLEFT ;; AND AX,AX ;; JZ DEN_ENDED ;; MOV AX,STAT_BffDEN ;; JMP DEN_FAIL ;; ;; DEN_ENDED : ;; good designate-end ;; MOV DI,BUF.HARDSO ;; to hardware slot MOV SI,BUF.HRBUFO ;; to hardware-buffer HARD_HWCPE: ;; MOV AX,CS:[DI].SLT_AT ;; skip the HWCP AND AX,AT_HWCP ;; JZ HARD_CARTE ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; INC SI ;; INC SI ;; JMP HARD_HWCPE ;; HARD_CARTE: ;; MOV CX,BUF.HSLMX ;; size of both hardware slot/buffer SUB CX,BUF.HARDMX ;; slots that can be designated???????? MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JZ ASSIGN_RAM ;; ;; ;; MOV AX,STAT_TOMANY ;; AND CX,CX ;; any cart-slot to be designated ? JNZ ASSIGN_CP_CART ;; JMP DEN_FAIL ;; ;; ;; ASSIGN_CP_CART : ;; JMP ASSIGN_CP ;; ;; ASSIGN_RAM: ;; MOV DI,BUF.RAMSO ;; to RAM slot MOV SI,BUF.RMBUFO ;; to RAM-buffer MOV CX,BUF.RSLMX ;; size of both RAM slot/buffer ;; MOV AX,STAT_TOMANY ;; AND CX,CX ;; any cart-slot to be designated ? JNZ ASSIGN_CP ;; JMP DEN_FAIL ;; ;; ASSIGN_CP: ;; MOV AX,AT_LOAD ;; OR AX,AT_FONT ;; OR AX,AT_SELECT ;; NOT AX ;; AND CS:[DI].SLT_AT,AX ;; reset load, font, select attributes ;; MOV AX,CS:[SI] ;; code page assigned MOV CS:[DI].SLT_CP,AX ;; ;; CMP AX,0FFFFH ;; JNE SLOT_OCC ;; MOV AX,AT_OCC ;; NOT AX ;; empty AND CS:[DI].SLT_AT,AX ;; JMP ASSIGN_NEXT ;; SLOT_OCC: ;; OR CS:[DI].SLT_AT,AT_OCC ;; occupied ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_OLD ;; JNZ ASSIGN_NEXT ;; ;; NOT_ACTIVE: ;; this newly designated is not active MOV AX,AT_ACT ;; NOT AX ;; AND CS:[DI].SLT_AT,AX ;; not active CMP BUF.RBUFMX,0 ;; JE ASSIGN_NEXT ;; AND CS:[DI].SLT_AT,NOT AT_RAM1;; not loaded to physical RAM until ;; the code page is selected ASSIGN_NEXT : ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; INC SI ;; INC SI ;; DEC CX ;; AND CX,CX ;; JNE ASSIGN_CP ;; ;; MOV CX,BUF.FSELEN ;; COPY SELECT-CONTROL for CLASS 0 AND CX,CX ;; JZ DEN_NO_SELECT ;; ;; PUSH ES ;; PUSH DS ;; PUSH SI ;; PUSH DI ;; ;; PUSH CS ;; POP ES ;; PUSH CS ;; POP DS ;; ;; PUSH DX ;; MOV DI,BUF.PDESCO ;; MOV SI,CS:[DI].SELB_O ;; PUSH DI ;; MOV DI,CS:[DI].SELH_O ;; XOR DX,DX ;; MOV DL,CS:BYTE PTR [SI] ;; ADD DX,DI ;; INC DX ;; of the length byte ;; REP MOVSB ;; ;; POP DI ;; MOV CS:[DI].SELR_O,DX ;; POP DX ;; ;; POP DI ;; POP SI ;; POP DS ;; POP ES ;; ;; MOV BUF.FSELEN,0 ;; ;; DEN_NO_SELECT : ;; XOR AX,AX ;; clear status JMP DEN_RET ;; ;; DEN_FAIL : ;;------------------------------------ PUSH AX ;; ANY FONT BUFFER DESTROYED ? ;; MOV AX,BUF.STATUS ;; AND AX,DSF_CARTCP ;; JZ DEN_RAM_FAIL ;; ;; MOV DI,BUF.FTSLOTO ;; MOV CX,BUF.HSLMX ;; JMP DEN_FAIL_LOOP ;; ;; DEN_RAM_FAIL : ;; MOV DI,BUF.RAMSO ;; to RAM slot MOV CX,BUF.RSLMX ;; size of both RAM slot/buffer MOV DX,BUF.RBUFMX ;; ;; AND DX,DX ;; JZ DEN_FAIL_RET ;; ;; DEN_FAIL_LOOP : ;; AND CX,CX ;; JZ DEN_FAIL_RET ;; ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_LOAD ;; JZ DEN_FAIL_NEXT ;; ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_HWCP ;; JNZ DEN_FAIL_NEXT ;; ;; MOV CS:[DI].SLT_CP,0FFFFH ;; those slot whose font has been or MOV CS:[DI].SLT_AT,0 ;; to be loaded will be wiped out by ;; a failing designate DEN_FAIL_NEXT : ;; ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNE DEN_FAIL_LOOP ;; ;; DEN_FAIL_RET : ;; ;; POP AX ;; ;; MOV BUF.FSELEN,0 ;; ;; ;;------------------------------------- DEN_RET : ;; MOV BUF.STATE,CPSW ;; end of designate cycle ;; DE_11: ;; WGR ;AN000; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,AX ;; ;; RET ;; ;; DESIGNATE_END ENDP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Generic IOCTL Invoke ========== ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INVOKE PROC ;; ALSO JUMP FROM REFRESH ;; MOV AX,BUF.STATE ;; CMP AX,CPSW ;; JE IVK_PROCESS ;; CMP AX,LOCKED ;; WGR ;AN000; JE IVK_PROCESS ;; WGR ;AN000; JMP IVK_CMDERR ;G; IVK_PROCESS: ;;------------------------- ;G; CALL CHECK_PRINT_ACTIVE ;G; THIS WILL FIND OUT IF THE JNC IVK_PROCESS_CONT ;G; PRINT.COM IS PRESENTLY ACTIVE! JMP IVK_DEVERR ;G; If so, THEN DEVICE_ERROR ;G; IVK_PROCESS_CONT: ;G; push ds ;; LDS SI,RH.GIH_GBA ;; MOV CX,GIOB.GB2_LEN ;; MOV AX,STAT_CMDERR ;; CMP CX,2 ;; JE IVK_GOODN ;; pop ds ;; JMP IVK_RET ;; IVK_GOODN: ;; MOV DX,GIOB.GB2_CP ;; DX = the codepage to be invoked CMP DX,0FFFFH ;; JNE IVK_GOODCP ;; pop ds ;; JMP IVK_RET ;; IVK_GOODCP: ;; ;; ************************************ ;; * INVOKE HIERIECHY : RAM, HARDWARE * ;; ************************************ pop ds ;; ;; MOV DI,BUF.RAMSO ;; check with the ram-slots (DI) MOV CX,BUF.RSLMX ;; CX = size AND CX,CX ;; JZ HWCP_CHK ;; ;; RAM_CMP: ;; there are RAM-slots PUSH CX ;; stack 1 = size PUSH DI ;; POP SI ;; start of the slot compared with (SI) RAM_LP: ;; MOV AX,CS:[DI].SLT_CP ;; CMP AX,DX ;; JE IVK_RAMCP ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ RAM_LP ;; ;; POP CX ;; stack -1 ;; code page not found in ram-slots HWCP_CHK : ;; MOV DI,BUF.HARDSO ;; check with the HWCP-slots (DI) MOV CX,BUF.Hslmx ;; CX = size AND CX,CX ;; JNZ HWCP_cmp ;; JMP NO_INVOKE ;; ;; HWCP_CMP : ;; PUSH CX ;; stack 1 = size of HWCP PUSH DI ;; POP SI ;; start of the slot compared with (SI) HWCP_LP: ;; MOV AX,CS:[DI].SLT_CP ;; CMP AX,DX ;; JNE HWCP_NEXT ;; JMP IVK_HWCPCP ;; ;; HWCP_NEXT : ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ HWCP_LP ;; POP CX ;; stack -1 ;; JMP NO_INVOKE ;; ;; ********************************** ;; ** RAM CODEPAGE TO BE INVOKED ** ;; ********************************** ;; -- determine if any font to be ;; downloaded for the first time ;; select of the font. ;; -- send selection control to invoke ;; ;; CX = inverse order of slot cp found IVK_RAMCP : ;; code page found in RAM slots ;; set up the pointer to first controls ;; DI = where slot found ;; ;;------------------------------------- ;; **** LOAD THE FONT FIRST if **** ;; -- there are font buffers created ;; -- the slot's font has not been ;; loaded CMP CS:[BX].STATE,LOCKED ;; WGR are we locked? ;AN000; JNE IR_0 ;; WGR no..continue ;AN000; MOV CS:[BX].SAVED_CP,DX ;; WGR yes...save the code page ;AN000; CMP BX,OFFSET BUF1 ;; WGR if this is lpt1..then ;AN000; JNE NEXT_1 ;; WGR ;AN000; LEA SI,BUF0 ;; WGR copy to PRN buffer. ;AN000; MOV CS:[SI].SAVED_CP,DX ;; WGR ;AN000; JMP ALL_RESET ;; WGR ;AN000; NEXT_1: ;; WGR ;AN000; CMP BX,OFFSET BUF0 ;; WGR if this is PRN..then.. ;AN000; JNE NEXT_2 ;; WGR ;AN000; LEA SI,BUF1 ;; WGR copy to lpt1 buffer. ;AN000; MOV CS:[SI].SAVED_CP,DX ;; WGR ;AN000; NEXT_2: ;; WGR ;AN000; JMP ALL_RESET ;; WGR exit invoke with good status ;AN000; IR_0: ;; WGR ;AN000; ; test cs:[di].SLT_AT, AT_ACT ;AN001;If it is currently active, then do nothing ; jnz Next_2 ;AN001; CMP BUF.RBUFMX,0 ;; JE INVK_RAM_PHYSICAL ;; ;; MOV AX,CS:[DI].SLT_AT ;; AND AX,AT_RAM1 ;; supports only ONE physical ram JNZ INVK_RAM_PHYSICAL ;; ;; OR BUF.STATUS,LOADED ;; font has not been loaded ;; ;; POP DX ;; stack -1 PUSH DX ;; stack 1 (size) ;; ;; PUSH CX ;; PUSH SI ;; PUSH DI ;; ;; SUB DX,CX ;; MOV AX,BUF.FTSTART ;; LOCATE_FONT : ;; AND DX,DX ;; JZ FONT_LOCATED ;; ADD AX,BUF.FTSZPA ;; DEC DX ;; JMP LOCATE_FONT ;; ;; FONT_LOCATED : ;; ;; AX = FONT LOCATION (AX:0) SUB DI,BUF.RAMSO ;; SHR DI,1 ;; offset to the start of .FTDLEN ;; add DI,buf.ftdlo ;; length of font data mov cx,cs:word ptr [di] ;; ;Before sending data, let's check the status of the printer call Prt_status_check ;AN001;Check the printer status jz Send_Ram_Data ;AN001;O.K.? pop di ;AN001;Balance the stack pop si ;AN001; pop cx ;AN001; jmp Ram_Prt_Status_Err ;AN001;return with error. Send_Ram_Data: MOV SI,BUF.RNORMO ;; MOV CS:[SI].RHC_LEN,20 ;; MOV CS:[SI].RHC_CMD,CMD_WRT ;; MOV CS:[SI].RH3_CNT,CX ;; MOV CS:[SI].RH3_DTAO,0 ;; MOV CS:[SI].RH3_DTAS,AX ;; ;; PUSH BX ;; ;; PUSH BX ;; POP DI ;; save BX in DI PUSH CS ;; POP ES ;; MOV BX,SI ;; ES:BX = REQ_NORMn (CS:[SI]) ;; CALL DWORD PTR CS:[DI].LPT_STRAO ;; CALL DWORD PTR CS:[DI].LPT_INTRO ;; POP BX ;; ;; MOV AX,CS:[SI].RHC_STA ;; ;; POP DI ;; POP SI ;; POP CX ;; ;; AND AX,STAT_ERROR ;; any error returned by normal device? JZ INVK_RAM_PHYSICAL ;; ;; Ram_Prt_Status_err: POP CX ;; stack -1 JMP IVK_DEVERR ;; ;;------------------------------------- ;; **** SEND THE SELECTION CONTROL **** ;; INVK_RAM_PHYSICAL : ;; ;; POP DX ;; stack -1 PUSH DX ;; stack 1 (size) ;; PUSH DI ;; stack 2 PUSH SI ;; stack 3 PUSH ES ;; stack 4 ;; ;; ;; **** SUPPORT ONLY ONE PHYSICAL RAM ;; MOV DI,BUF.PDESCO ;; MOV DI,CS:[DI].SELR_O ;; the RAM-select controls XOR AX,AX ;; JMP CTL_DEF ;; ;; ;; ******************************* ;; ** INVOKE HARDWARE CODEPAGE ** ;; ******************************* ;; -- check if it is CLASS 1 device, ;; If so then send slection control ;; from the font buffer at FTSTART ;; ;; CX=inverse order of slot cp found IVK_HWCPCP: ;; code page found in HWCP slots ;; set up the pointer to first controls CMP CS:[BX].STATE,LOCKED ;; WGR are we locked? ;AN000; JNE IR_1 ;; WGR no..continue ;AN000; MOV CS:[BX].SAVED_CP,DX ;; WGR yes...save the code page ;AN000; CMP BX,OFFSET BUF1 ;; WGR if this is lpt1..then ;AN000; JNE NEXT_3 ;; WGR ;AN000; LEA SI,BUF0 ;; WGR copy to PRN buffer. ;AN000; MOV CS:[SI].SAVED_CP,DX ;; WGR ;AN000; JMP ALL_RESET ;; WGR ;AN000; NEXT_3: ;; WGR ;AN000; CMP BX,OFFSET BUF0 ;; WGR if this is PRN..then.. ;AN000; JNE NEXT_4 ;; WGR ;AN000; LEA SI,BUF1 ;; WGR copy to lpt1 buffer. ;AN000; MOV CS:[SI].SAVED_CP,DX ;; WGR ;AN000; NEXT_4: ;; WGR ;AN000; JMP ALL_RESET ;; WGR exit invoke with good status ;AN000; IR_1: ;; WGR ;AN000; ; test cs:[di].SLT_AT, AT_ACT ;AN001;If it is currently active, then do nothing ; jnz Next_4 ;AN001; POP DX ;; stack -1 PUSH DX ;; stack 1 (size) ;; PUSH DI ;; stack 2 PUSH SI ;; stack 3 PUSH ES ;; stack 4 ;; SUB DX,CX ;; the slot's order in HWCP-slots(0-n) ;; CMP BUF.PCLASS,1 ;; JNE SELECT_SLOT ;; ;; MOV AX,BUF.FTSTART ;; ***** CLASS 1 CODEPAGE SELECT **** AND DX,DX ;; JZ ADJUST_DI ;; ;; SELECTCP_LP : ;; ADD AX,BUF.FTSZPA ;; ;; DEC DX ;; JNZ SELECTCP_LP ;; ;; ADJUST_DI : ;; mov DI,AX ;; PUSH CS ;; POP AX ;; SUB DI,AX ;; SHL DI,1 ;; SHL DI,1 ;; SHL DI,1 ;; SHL DI,1 ;; JMP CTL_DEF ;; ;; ;; ** SELECT HARDWARE PHYSICAL SLOT ** SELECT_SLOT : ;; MOV DI,BUF.PDESCO ;; MOV DI,CS:[DI].SELH_O ;; the HARDWARE-select controls XOR AX,AX ;; JMP RCTL_NXT ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RCTL_NXT: ;; locate the right control sequence AND DX,DX ;; JZ CTL_DEF ;; MOV AL,CS:[DI] ;; ADD DI,AX ;; DEC DX ;; JMP RCTL_NXT ;; ;; ;; ******************************** ;; ** SEND OUT SELECTION CONTROL ** ;; ******************************** ;; ;; code page is to be invoked CTL_DEF : ;; DI points to the control sequence ;Check the status of the printer before writing. call Prt_status_check ;AN001;Check the printer status jz Ctl_Def_Send ;AN001;O.K.? jmp Ctl_Dev_Err ;AN001;Error. Ctl_Def_Send: MOV SI,BUF.RNORMO ;; MOV CS:[SI].RHC_LEN,20 ;; MOV CS:[SI].RHC_CMD,CMD_WRT ;; ;; XOR CX,CX ;; MOV CL,CS:[DI] ;; ;; CTL_NEXT_BYTE : ;; ;; CMP BUF.PCLASS,1 ;; JE CTL_CLASS1 ;; ;; MOV CS:[SI].RH3_CNT,CX ;; send all at once MOV CX,1 ;; sent only once. JMP CTL_COMMON ;; ;; CTL_CLASS1 : ;; sent byte by byte to overcome MOV CS:[SI].RH3_CNT,1 ;; DOS timeout on kingman printer CTL_COMMON : ;; INC DI ;; MOV CS:[SI].RH3_DTAO,DI ;; PUSH CS ;; POP AX ;; MOV CS:[SI].RH3_DTAS,AX ;; ;; PUSH DI ;; PUSH BX ;; ;; PUSH BX ;; POP DI ;; save BX in DI PUSH CS ;; POP ES ;; MOV BX,SI ;; ES:BX = REQ_NORMn (CS:[SI]) ;; CALL DWORD PTR CS:[DI].LPT_STRAO ;; CALL DWORD PTR CS:[DI].LPT_INTRO ;; POP BX ;; POP DI ;; ;; MOV AX,CS:[SI].RHC_STA ;; ;; AND AX,STAT_ERROR ;; any error returned by normal device? JNZ CTL_DEV_ERR ;; DEC CX ;; JNZ CTL_NEXT_BYTE ;; ;; POP ES ;; stack -4 POP SI ;; stack -3 POP DI ;; stack -2 JMP IVK_CP ;; ;; CTL_DEV_ERR : ;; POP ES ;; stack -4 POP SI ;; stack -3 POP DI ;; stack -2 POP CX ;; stack -1 JMP IVK_DEVERR ;; ;; ;; ********************************** ;; ** ADJUST WHICH CODEPAGE TO BE ** ;; ** ACTIVE ** ;; ********************************** ;; ;; -- set the attribute bit of the ;; slot (SLT_AT) to active for ;; the code page just invoked. ;; -- reset others to non-active. ;; ;; IVK_CP: ;; SI = start of the slots compared ;; DI = where code page was found POP CX ;; stack -1 PUSH SI ;; stack 1 = start of slots compared mov AX,BUF.STATUS ;; AND AX,LOADED ;; MOV AX,AT_ACT ;; JZ NO_LOAD ;; OR AX,AT_RAM1 ;; reset loaded to physical RAM #1, ;; this is reset only when there is ;; font loading in this round of invoke NO_LOAD: ;; (for RAM codepages only) NOT AX ;; NXT_CP: ;; AND CS:[SI].SLT_AT,AX ;; not active (and not loaded) INC SI ;; INC SI ;; INC SI ;; INC SI ;; DEC CX ;; JNZ NXT_CP ;; OR CS:[DI].SLT_AT,AT_ACT ;; the codepage found becomes active MOV AX,BUF.STATUS ;; AND AX,LOADED ;; JZ HWCP_RESET ;; OR CS:[DI].SLT_AT,AT_RAM1 ;; the font has just been loaded AND BUF.STATUS,NOT LOADED ;; ;; HWCP_RESET : ;; ;; POP SI ;; stack -1 (slot : ATs adjusted ) PUSH SI ;; stack 1 = start of slots compared ;; MOV DI,BUF.HARDSO ;; CMP SI,DI ;; JE RAM_RESET ;; ;; HWCP's AT to be reset MOV CX,BUF.HSLMX ;; AND CX,CX ;; JZ RAM_RESET ;; MOV AX,AT_ACT ;; NOT AX ;; RESET_HWCP : ;; AND CS:[DI].SLT_AT,AX ;; HWCP is not active INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ RESET_HWCP ;; ;; ;; RAM_RESET: ;; ;; POP SI ;; stack -1 (slot : ATs adjusted ) PUSH SI ;; stack 1 = start of slots compared ;; MOV DI,BUF.RAMSO ;; CMP SI,DI ;; JE ALL_RESET ;; ;; HWCP's AT to be reset MOV CX,BUF.RSLMX ;; AND CX,CX ;; HWCP's no. JZ ALL_RESET ;; MOV AX,AT_ACT ;; NOT AX ;; RESET_RAM : ;; AND CS:[DI].SLT_AT,AX ;; HWCP is not active INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ RESET_RAM ;; ;; ALL_RESET : ;; POP SI ;; stack -1 ;; XOR AX,AX ;; JMP IVK_RET ;; ;; NO_INVOKE : ;; ;; MOV AX,STAT_NOCPIV ;; JMP IVK_RET ;; ;; IVK_DEVERR : ;; MOV AX,STAT_DEVERR ;; JMP IVK_RET ;G; ;; IVK_CMDERR : ;G; MOV AX,STAT_CMDERR ;G; ;; IVK_RET : ;; LES DI,dword ptr buf.rh_ptro;; MOV RH.RHC_STA,AX ;; ;; RET ;; ;; INVOKE ENDP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Prt_Status_Check proc near ;AN001; ;Check the printer device status ;Out) if Zero flag set - Ok. ; All registers saved. push es ;AN001; push si ;AN001; mov si, BUF.RNORMO ;AN001; mov cs:[si].RHC_LEN, 13 ;AN001; mov cs:[si].RHC_CMD, 10 ;AN001;device driver status check push di ;AN001; push bx ;AN001; push bx ;AN001; pop di ;AN001; push cs ;AN001; pop es ;AN001;ES:BX -> REQ_NORMn (was cs:si) mov bx, si ;AN001; call dword ptr cs:[di].LPT_STRAO ;AN001;Strategy call dword ptr cs:[di].LPT_INTRO ;AN001;Intrrupt test cs:[si].RHC_STA, STAT_ERROR ;AN001; pop bx ;AN001; pop di ;AN001; pop si ;AN001; pop es ;AN001; ret ;AN001; Prt_Status_Check endp ;AN001; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Generic IOCTL Query Invoked ======= ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Q_INVOKED PROC ;; push ds ;; ;; MOV AX,BUF.STATE ;; ??????????????? CMP AX,LOCKED ;; WGR ;AN000; JNE QI_0 ;; WGR ;AN000; MOV AX,BUF.SAVED_CP ;; WGR ;AN000; LDS SI,RH.GIH_GBA ;; WGR ;AN000; CMP AX,-1 ;; WGR ;AN000; JE QIV_NOACT ;; WGR ;AN000; JMP QI_1 ;; WGR ;AN000; QI_0: ;; WGR ;AN000; CMP AX,CPSW ;; reject only in NORMAL !!!! JNE QIV_CMDERR ;G; ;;------------------------- LDS SI,RH.GIH_GBA ;; ;; MOV DI,BUF.RAMSO ;; MOV CX,BUF.RSLMX ;; AND CX,CX ;; JZ QIV_HARD ;; ;; QIV_RAMLP : ;; MOV AX,CS:[DI].SLT_AT ;; check the RAM slots AND AX,AT_ACT ;; JNZ QIV_FOUND ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ QIV_RAMLP ;; ;; QIV_HARD : ;; MOV DI,BUF.HARDSO ;; MOV CX,BUF.HSLMX ;; AND CX,CX ;; JZ QIV_NOACT ;; ;; QIV_HARDLP : ;; MOV AX,CS:[DI].SLT_AT ;; check the RAM slots AND AX,AT_ACT ;; JNZ QIV_FOUND ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; DEC CX ;; JNZ QIV_HARDLP ;; ;; QIV_NOACT : ;; ;; MOV AX,STAT_NOCPIV ;; JMP QIV_RET ;; ;; ;; QIV_FOUND : ;; MOV AX,CS:[DI].SLT_CP ;; QI_1: ;; WGR ;AN000; MOV GIOB.GB2_LEN,2 ;; MOV GIOB.GB2_CP,AX ;; ;; XOR AX,AX ;; JMP QIV_RET ;; ;; QIV_DEVERR : ;; MOV AX,STAT_DEVERR ;; JMP QIV_RET ;G; ;; QIV_CMDERR : ;G; MOV AX,STAT_CMDERR ;G; ;; QIV_RET : ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,AX ;; ;; pop ds ;; ;; RET ;; ;; Q_INVOKED ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;==== Generic IOCTL Query List ======= ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Q_LIST PROC ;; ;; push ds ;; ;; MOV AX,BUF.STATE ;; ???????????????? CMP AX,CPSW ;; reject only in NORMAL JE QLS_CPSW ;; CMP AX,LOCKED ;; WGR ;AN000; JE QLS_CPSW ;; WGR ;AN000; JMP QLS_CMDERR ;G; QLS_CPSW : ;;------------------------- LDS SI,RH.GIH_GBA ;; PUSH SI ;; stack 1 -- GB3 (SI) ;; MOV DI,BUF.HARDSO ;; MOV CX,BUF.HARDMX ;; MOV DX,BUF.HSLMX ;; DX = number of entries LEA SI,[SI].GB3_GBL ;; MOV GIOB.GBL_LEN,CX ;; ;; QL_HARDLP: ;; AND CX,CX ;; JZ QL_PREPARE ;; MOV AX,CS:[DI].SLT_CP ;; MOV GIOB.GBL_CP,AX ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; INC SI ;; INC SI ;; DEC CX ;; JMP QL_HARDLP ;; ;; QL_PREPARE: ;; MOV CX,BUF.HSLMX ;; SUB CX,BUF.HARDMX ;; less the no. of HWCP MOV DX,BUF.RSLMX ;; ADD DX,CX ;; DX = total number of entries INC SI ;; INC SI ;; MOV GIOB.GBL_LEN,DX ;; QL_CARTLP: ;; AND CX,CX ;; JZ QL_RAM_PREP ;; MOV AX,CS:[DI].SLT_CP ;; MOV GIOB.GBL_CP,AX ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; INC SI ;; INC SI ;; DEC CX ;; JMP QL_CARTLP ;; ;; ;; QL_RAM_PREP: ;; MOV DI,BUF.RAMSO ;; MOV CX,BUF.RSLMX ;; ;; QL_RAMLP : ;; AND CX,CX ;; JZ QL_DONE ;; MOV AX,CS:[DI].SLT_CP ;; MOV GIOB.GBL_CP,AX ;; INC DI ;; INC DI ;; INC DI ;; INC DI ;; INC SI ;; INC SI ;; DEC CX ;; JMP QL_RAMLP ;; ;; QL_DONE: ;; POP SI ;; stack -1 mov dx,buf.hslmx ;; add DX,BUF.RSLMX ;; INC DX ;; INC DX ;; MOV CX,1 ;; SHL DX,CL ;; MOV GIOB.GB3_LEN,DX ;; ;; XOR AX,AX ;; CMP DX,GB3_MINILEN ;; min. GBL length JA QLS_RET ;; MOV AX,STAT_NOCP ;; JMP QLS_RET ;; ;; QLS_DEVERR : ;; MOV AX,STAT_DEVERR ;; JMP QLS_RET ;G; ;; QLS_CMDERR : ;G; MOV AX,STAT_CMDERR ;G; ;; QLS_RET : ;; LES DI,dword ptr buf.rh_ptro ;; MOV RH.RHC_STA,AX ;; ;; pop ds ;; RET ;; ;; Q_LIST ENDP ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; CHECK_PRINT_ACTIVE ; ; THIS ROUTINE IS CALLED BEFORE THE INVOKE, DESIGNATE ; COMMANDS ARE OPERATED ON. THIS IS TO PREVENT CONFLICT ; BETWEEN THE BACKGROUND PRINTING AND THE DOWNLOAD SEQUENCE. ; ; INPUT: ; CS:[BX].DEV_HDRO OFFSET AND SEGMENT OF ACTIVE DEVICE ; CS:[BX].DEV_HDRS ; ; WARNING: IF ANOTHER DEVICE DRIVER IS TO TAKE THE LPTx, THEN ; THIS WILL not FIND OUT THAT THE PRINTER.SYS IS ACTIVE. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CHECK_PRINT_ACTIVE PROC ;G; PUSH AX ;G; SAVE THE REGISTERS............ PUSH SI ;G; PUSH DI ;G; PUSH DS ;G; PUSH ES ;G; ;G; MOV DI,BUF.DEV_HDRS ;G; SETUP ES: = ACTIVE DEVICE SEGMENT MOV ES,DI ;G; & MOV DI,BUF.DEV_HDRO ;G; SETUP DI: = ACTIVE DEVICE OFFSET ;G; MOV AX,0106H ;G; PRINT (GET LIST DEVICE) CLC ;G; JNC CPA_5 ;G; CY=0 IF NOT LOADED/NOT ACTIVE ;G; CMP SI,DI ;G; ES:DI POINTS TO THE ACTIVE DEVICE JNE CPA_5 ;G; MOV SI,DS ;G; MOV DI,ES ;G; CMP SI,DI ;G; JNE CPA_5 ;G; STC ;G; OTHERWISE, THIS DEVICE IS PRESENTLY JMP CPA_6 ;G; UNDER PRINT!!! PREVENT DATASTREAM ;G; CONFLICT IN THIS CASE. ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G; PRINT.COM IS ASLEEP OR IS NOT ;G; PRESENTLY LOADED. THE PRINTER.SYS CPA_5: CLC ;G; CAN CONTINUE IT PROCESS! CPA_6: POP ES ;G; RESTORE REGISTERS..... POP DS ;G; POP DI ;G; POP SI ;G; POP AX ;G; RET ;G; CHECK_PRINT_ACTIVE ENDP ;G; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CSEG ENDS END 
; ; written by Waleed Hasan ; ; Fixed list of pages (were off by 4) ; Graham R. Cobb 19 May 2002 XLIB findlib .findlib pop hl ; ret addr pop de ; &signature to look for push de push hl ; ;ASM entry point ; i/p : DE = points to signature to look for (zero terminated) ; o/p : HL = library page ; = -1 if not found ; .findlib_asm ; save old bank2 values ld c,3 ; c=3 in l,(c) inc c ; c=4 in h,(c) push hl ; REGISTER_WRITE(REG_BANK2_HI, 0x00); xor a out (c),a ; c=4 ; for(i=0; i<25; i++) ld hl,_pages dec c ; c=3 .PagLoop ; REGISTER_WRITE(REG_BANK2_LO, pages[i]); ld a,(hl) and a ; is it pages end-marker? jr z,LibNotFound out (c),a ; c=3 push hl ; save pages[] push de ; we should save &sig ld hl,$A003 ; &SIGnature in library ; de already = &sig .SigLoop ld a,(de) and a ; end of seg? jr z,LibFound ; yes - we found it! cp (hl) jr nz,ChkNxtPag inc hl ; next SIG char inc de ; next sig char jr SigLoop .LibFound ; we found the library pop de ; &sig pop hl ; the page in ld a,(hl) sub 4 ; Page[i]-4 ld h,0 ld l,a jr end .ChkNxtPag pop de ; &sig pop hl ; get pages[] inc hl ; next page jr PagLoop .LibNotFound ld hl,-1 ; page not found .end pop de ; restore old bank2 values ld c,3 ; c=3 out (c),e inc c ; c=4 out (c),d ret ._pages ; We first search the pages loaded by Adder defb 26,27,28 defb 47,77,81,92,102 defb 124,125,126 defb 136,137,138,139,140,141 ; Then a couple of pages that Adder does not load today but might in ; the future defb 142,143 defb 127,69,70,71,84,85,86,97 ; Web/Calc/Clock pages ; We check the standard addin slots last because addins copied ; using Adder are not deleted until overwritten defb 128,129,130,131,132,133,134,135 defb 0 ; pages end-marker
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sparse_112_dot_product.h" #include <vespa/eval/eval/fast_value.hpp> #include <vespa/vespalib/util/typify.h> #include <vespa/vespalib/util/require.h> #include <vespa/eval/eval/visit_stuff.h> #include <algorithm> namespace vespalib::eval { using namespace tensor_function; using namespace operation; using namespace instruction; namespace { template <typename T, size_t N> ConstArrayRef<T> as_car(std::array<T, N> &array) { return {array.data(), array.size()}; } template <typename T, size_t N> ConstArrayRef<const T *> as_ccar(std::array<T *, N> &array) { return {array.data(), array.size()}; } template <typename T> ConstArrayRef<T> as_car(T &value) { return {&value, 1}; } constexpr std::array<size_t, 2> both_dims = { 0, 1 }; template <typename CT> double my_sparse_112_dot_product_fallback(const Value::Index &a_idx, const Value::Index &b_idx, const Value::Index &c_idx, const CT *a_cells, const CT *b_cells, const CT *c_cells) __attribute__((noinline)); template <typename CT> double my_sparse_112_dot_product_fallback(const Value::Index &a_idx, const Value::Index &b_idx, const Value::Index &c_idx, const CT *a_cells, const CT *b_cells, const CT *c_cells) { double result = 0.0; size_t a_space = 0; size_t b_space = 0; size_t c_space = 0; std::array<string_id, 2> c_addr; std::array<string_id*, 2> c_addr_ref = {&c_addr[0], &c_addr[1]}; auto outer = a_idx.create_view({}); auto inner = b_idx.create_view({}); auto model = c_idx.create_view({&both_dims[0], 2}); outer->lookup({}); while (outer->next_result(as_car(c_addr_ref[0]), a_space)) { inner->lookup({}); while (inner->next_result(as_car(c_addr_ref[1]), b_space)) { model->lookup(as_ccar(c_addr_ref)); if (model->next_result({}, c_space)) { result += (a_cells[a_space] * b_cells[b_space] * c_cells[c_space]); } } } return result; } template <typename CT> double my_fast_sparse_112_dot_product(const FastAddrMap *a_map, const FastAddrMap *b_map, const FastAddrMap *c_map, const CT *a_cells, const CT *b_cells, const CT *c_cells) { double result = 0.0; std::array<string_id, 2> c_addr; const auto &a_labels = a_map->labels(); for (size_t a_space = 0; a_space < a_labels.size(); ++a_space) { if (a_cells[a_space] != 0.0) { // handle pseudo-sparse input c_addr[0] = a_labels[a_space]; const auto &b_labels = b_map->labels(); for (size_t b_space = 0; b_space < b_labels.size(); ++b_space) { if (b_cells[b_space] != 0.0) { // handle pseudo-sparse input c_addr[1] = b_labels[b_space]; auto c_space = c_map->lookup(as_car(c_addr)); if (c_space != FastAddrMap::npos()) { result += (a_cells[a_space] * b_cells[b_space] * c_cells[c_space]); } } } } } return result; } template <typename CT> void my_sparse_112_dot_product_op(InterpretedFunction::State &state, uint64_t) { const auto &a_idx = state.peek(2).index(); const auto &b_idx = state.peek(1).index(); const auto &c_idx = state.peek(0).index(); const CT *a_cells = state.peek(2).cells().unsafe_typify<CT>().cbegin(); const CT *b_cells = state.peek(1).cells().unsafe_typify<CT>().cbegin(); const CT *c_cells = state.peek(0).cells().unsafe_typify<CT>().cbegin(); double result = __builtin_expect(are_fast(a_idx, b_idx, c_idx), true) ? my_fast_sparse_112_dot_product<CT>(&as_fast(a_idx).map, &as_fast(b_idx).map, &as_fast(c_idx).map, a_cells, b_cells, c_cells) : my_sparse_112_dot_product_fallback<CT>(a_idx, b_idx, c_idx, a_cells, b_cells, c_cells); state.pop_pop_pop_push(state.stash.create<DoubleValue>(result)); } struct MyGetFun { template <typename CT> static auto invoke() { return my_sparse_112_dot_product_op<CT>; } }; using MyTypify = TypifyValue<TypifyCellType>; // Try to collect input nodes and organize them into a dot product // between (n sparse non-overlapping single-dimension tensors) and (a // sparse n-dimensional tensor) all having the same cell type. struct InputState { std::vector<const TensorFunction *> single; const TensorFunction *multi = nullptr; bool collision = false; void collect(const TensorFunction &node) { const auto &type = node.result_type(); if (type.is_sparse()) { if (type.dimensions().size() == 1) { single.push_back(&node); } else { if (multi) { collision = true; } else { multi = &node; } } } } void finalize() { std::sort(single.begin(), single.end(), [](const auto *a, const auto *b) { return (a->result_type().dimensions()[0].name < b->result_type().dimensions()[0].name); }); } bool verify(size_t n) const { if (collision || (single.size() != n) || (multi == nullptr) || (multi->result_type().dimensions().size() != n)) { return false; } const auto &multi_type = multi->result_type(); for (size_t i = 0; i < n; ++i) { const auto &single_type = single[i]->result_type(); if ((single_type.cell_type() != multi_type.cell_type()) || (single_type.dimensions()[0].name != multi_type.dimensions()[i].name)) { return false; } } return true; } }; // Try to find inputs that form a 112 dot product. struct FindInputs { const TensorFunction *a = nullptr; const TensorFunction *b = nullptr; const TensorFunction *c = nullptr; bool try_match(const TensorFunction &one, const TensorFunction &two) { auto join = as<Join>(two); if (join && (join->function() == Mul::f)) { InputState state; state.collect(one); state.collect(join->lhs()); state.collect(join->rhs()); state.finalize(); if (state.verify(2)) { a = state.single[0]; b = state.single[1]; c = state.multi; return true; } } return false; } }; } // namespace <unnamed> Sparse112DotProduct::Sparse112DotProduct(const TensorFunction &a_in, const TensorFunction &b_in, const TensorFunction &c_in) : tensor_function::Node(DoubleValue::shared_type()), _a(a_in), _b(b_in), _c(c_in) { } InterpretedFunction::Instruction Sparse112DotProduct::compile_self(const ValueBuilderFactory &, Stash &) const { REQUIRE_EQ(_a.get().result_type().cell_type(), _b.get().result_type().cell_type()); REQUIRE_EQ(_a.get().result_type().cell_type(), _c.get().result_type().cell_type()); auto op = typify_invoke<1,MyTypify,MyGetFun>(_a.get().result_type().cell_type()); return InterpretedFunction::Instruction(op); } void Sparse112DotProduct::push_children(std::vector<Child::CREF> &children) const { children.emplace_back(_a); children.emplace_back(_b); children.emplace_back(_c); } void Sparse112DotProduct::visit_children(vespalib::ObjectVisitor &visitor) const { ::visit(visitor, "a", _a.get()); ::visit(visitor, "b", _b.get()); ::visit(visitor, "c", _c.get()); } const TensorFunction & Sparse112DotProduct::optimize(const TensorFunction &expr, Stash &stash) { auto reduce = as<Reduce>(expr); if (reduce && (reduce->aggr() == Aggr::SUM) && expr.result_type().is_double()) { auto join = as<Join>(reduce->child()); if (join && (join->function() == Mul::f)) { FindInputs inputs; if (inputs.try_match(join->lhs(), join->rhs()) || inputs.try_match(join->rhs(), join->lhs())) { return stash.create<Sparse112DotProduct>(*inputs.a, *inputs.b, *inputs.c); } } } return expr; } } // namespace
TITLE Trim Trailing Characters (Trim.asm) ; Test the Trim procedure. Trim removes trailing all ; occurences of a selected character from the end of ; a string. ; Last update: 11/24/01 INCLUDE Irvine32.inc Str_trim PROTO, pString:PTR BYTE, ; points to string char:BYTE ; character to remove Str_length PROTO, pString:PTR BYTE ; pointer to string ShowString PROTO, pString:PTR BYTE .data ; Test data: string_1 BYTE 0 ; case 1 string_2 BYTE "#",0 ; case 2 string_3 BYTE "Hello###",0 ; case 3 string_4 BYTE "Hello",0 ; case 4 string_5 BYTE "H#",0 ; case 5 string_6 BYTE "#H",0 ; case 6 .code main PROC call Clrscr INVOKE Str_trim,ADDR string_1,'#' INVOKE ShowString,ADDR string_1 INVOKE Str_trim,ADDR string_2,'#' INVOKE ShowString,ADDR string_2 INVOKE Str_trim,ADDR string_3,'#' INVOKE ShowString,ADDR string_3 INVOKE Str_trim,ADDR string_4,'#' INVOKE ShowString,ADDR string_4 INVOKE Str_trim,ADDR string_5,'#' INVOKE ShowString,ADDR string_5 INVOKE Str_trim,ADDR string_6,'#' INVOKE ShowString,ADDR string_6 exit main ENDP ;----------------------------------------------------------- ShowString PROC USES edx, pString:PTR BYTE ; Display a string surrounded by brackets. ;----------------------------------------------------------- .data lbracket BYTE "[",0 rbracket BYTE "]",0 .code mov edx,OFFSET lbracket call WriteString mov edx,pString call WriteString mov edx,OFFSET rbracket call WriteString call Crlf ret ShowString ENDP END main
dex txa eor #$ff
SECTION code_stdio PUBLIC __stdio_parse_mode __stdio_parse_mode: ; parse the fopen mode string ; valid characters include "rwabx+" ; ; enter : de = char *mode ; ; exit : de = char *mode_ptr (address of non-matching char) ; ; success, mode string valid ; ; c = flags = 0TXC BAWR ; carry reset ; ; fail, mode string invalid ; ; carry set ; ; note : 0TXC BAWR, O_RDWR = O_RDONLY | O_WRONLY ; ; R = $01 = O_RDONLY = open for reading ; W = $02 = O_WRONLY = open for writing ; A = $04 = O_APPEND = append writes ; B = $08 = O_BINARY = binary mode (many drivers ignore this) ; ; C = $10 = O_CREAT = create file if it does not exist ; X = $20 = O_EXCL = if file already exists return error ; T = $40 = O_TRUNC = if file exists reduce it to zero length ; ; uses : af, bc, de, hl ld c,0 flags_loop: ld b,6 ld hl,mode_table ld a,(de) or a jr z, check_validity ; if end of permission string reached match_loop: cp (hl) inc hl jr z, found_flag inc hl djnz match_loop ; no match invalid: scf ret found_flag: ld a,(hl) or c ld c,a inc de jr flags_loop check_validity: ; c = flags = 1TXC BAWR ld a,c xor $80 ; complete mode string has bit 7 set ld c,a ret p scf ret mode_table: defb 'r', $81 ; bit 7 set indicates mode string is complete defb 'w', $d2 ; bit 7 set indicates mode string is complete defb 'a', $96 ; bit 7 set indicates mode string is complete defb '+', $03 defb 'b', $08 defb 'x', $20
; A304506: a(n) = 2*(3*n+1)*(9*n+8). ; 16,136,364,700,1144,1696,2356,3124,4000,4984,6076,7276,8584,10000,11524,13156,14896,16744,18700,20764,22936,25216,27604,30100,32704,35416,38236,41164,44200,47344,50596,53956,57424,61000,64684,68476,72376,76384,80500,84724,89056,93496,98044,102700,107464,112336,117316,122404,127600,132904,138316,143836,149464,155200,161044,166996,173056,179224,185500,191884,198376,204976,211684,218500,225424,232456,239596,246844,254200,261664,269236,276916,284704,292600,300604,308716,316936,325264,333700,342244,350896,359656,368524,377500,386584,395776,405076,414484,424000,433624,443356,453196,463144,473200,483364,493636,504016,514504,525100,535804,546616,557536,568564,579700,590944,602296,613756,625324,637000,648784,660676,672676,684784,697000,709324,721756,734296,746944,759700,772564,785536,798616,811804,825100,838504,852016,865636,879364,893200,907144,921196,935356,949624,964000,978484,993076,1007776,1022584,1037500,1052524,1067656,1082896,1098244,1113700,1129264,1144936,1160716,1176604,1192600,1208704,1224916,1241236,1257664,1274200,1290844,1307596,1324456,1341424,1358500,1375684,1392976,1410376,1427884,1445500,1463224,1481056,1498996,1517044,1535200,1553464,1571836,1590316,1608904,1627600,1646404,1665316,1684336,1703464,1722700,1742044,1761496,1781056,1800724,1820500,1840384,1860376,1880476,1900684,1921000,1941424,1961956,1982596,2003344,2024200,2045164,2066236,2087416,2108704,2130100,2151604,2173216,2194936,2216764,2238700,2260744,2282896,2305156,2327524,2350000,2372584,2395276,2418076,2440984,2464000,2487124,2510356,2533696,2557144,2580700,2604364,2628136,2652016,2676004,2700100,2724304,2748616,2773036,2797564,2822200,2846944,2871796,2896756,2921824,2947000,2972284,2997676,3023176,3048784,3074500,3100324,3126256,3152296,3178444,3204700,3231064,3257536,3284116,3310804,3337600,3364504 mov $1,9 mul $1,$0 add $1,11 mul $1,$0 div $1,2 mul $1,12 add $1,16
; void dzx7_standard_back(void *src, void *dst) SECTION code_clib SECTION code_compress_zx7 PUBLIC _dzx7_standard_back EXTERN asm_dzx7_standard_back _dzx7_standard_back: pop af pop de pop hl push hl push de push af jp asm_dzx7_standard_back
.byte $00 ; Unknown purpose .byte OBJ_ROTODISCCLOCKWISE, $11, $14 .byte OBJ_GREENCHEEP, $17, $13 .byte OBJ_GREENCHEEP, $1F, $17 .byte OBJ_ROTODISCCLOCKWISE, $25, $14 .byte OBJ_GREENCHEEP, $29, $13 .byte OBJ_BOOMBOOMFLY, $5C, $28 .byte $FF ; Terminator
// Copyright (c) 2016 - 2018 Niobio developers - Derived work from -Karbowanec- // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "ChangeLanguageDialog.h" #include "ui_changelanguagedialog.h" #include "Settings.h" namespace WalletGui { ChangeLanguageDialog::ChangeLanguageDialog(QWidget* _parent) : QDialog(_parent), m_ui(new Ui::ChangeLanguageDialog) { m_ui->setupUi(this); } ChangeLanguageDialog::~ChangeLanguageDialog() { } void ChangeLanguageDialog::initLangList() { QString currentlang = Settings::instance().getLanguage(); int index = 0; if(currentlang.compare("uk") == 0) { index = 1; } else if(currentlang.compare("ru") == 0) { index = 2; } else if(currentlang.compare("pl") == 0) { index = 3; } else if(currentlang.compare("be") == 0) { index = 4; } else if(currentlang.compare("de") == 0) { index = 5; } else if(currentlang.compare("es") == 0) { index = 6; } else if (currentlang.compare("pt") == 0) { index = 7; } m_ui->ChangeLangComboBox->setCurrentIndex(index); } QString ChangeLanguageDialog::getLang() const { QString lang; int n = m_ui->ChangeLangComboBox->currentIndex(); if (n == 1) { lang = "uk"; } else if (n == 2) { lang = "ru"; } else if (n == 3) { lang = "pl"; } else if (n == 4) { lang = "be"; } else if (n == 5) { lang = "de"; } else if (n == 6) { lang = "es"; } else if (n == 7) { lang = "pt"; } else { lang = "en"; } return lang; } }
org 100h start: mov ax, 5522h mov cx, 1234h xchg cx,ax mov al, 0 mov ah,4Ch int 21h
#include "mediapipe/framework/calculator_framework.h" #include "mediapipe/framework/port/status.h" #include "mediapipe/framework/formats/landmark.pb.h" #include "mediapipe/framework/formats/detection.pb.h" #include "mediapipe/framework/formats/matrix.h" #include <vector> namespace mediapipe{ namespace{ constexpr char LandmarksHistory[] = "DOUBLE_LANDMARKS_HISTORY"; constexpr char LandmarkMatrix[] = "MATRIX"; } class LandmarkHistoryToTensorCalculator : public CalculatorBase { public: LandmarkHistoryToTensorCalculator(){}; ~LandmarkHistoryToTensorCalculator(){}; static ::mediapipe::Status GetContract(CalculatorContract* cc){ cc->Inputs().Tag(LandmarksHistory).Set<std::vector<std::vector<double>>>(); cc->Outputs().Tag(LandmarkMatrix).Set<Matrix>(); return ::mediapipe::OkStatus(); } ::mediapipe::Status Open(CalculatorContext* cc){ return ::mediapipe::OkStatus(); } ::mediapipe::Status Process(CalculatorContext* cc){ std::vector<std::vector<double>> frames = cc->Inputs().Tag(LandmarksHistory).Get<std::vector<std::vector<double>>>(); Matrix bob; bob.resize(60, 42); for(int i = 0; i < frames.size(); i++){ auto frame = frames.at(i); for(int j = 0; j < frame.size(); j++){ bob(i, j) = frame.at(j); } } // for(int i = 0; i < 21; i++){ // bob(0, i*2) = hand.landmark(i).x(); // bob(0, i*2+1) = hand.landmark(i).y(); // } std::unique_ptr<Matrix> output_stream_collection = std::make_unique<Matrix>(bob); cc -> Outputs().Tag(LandmarkMatrix).Add(output_stream_collection.release(), cc->InputTimestamp()); return ::mediapipe::OkStatus(); } ::mediapipe::Status Close(CalculatorContext* cc){ return ::mediapipe::OkStatus(); } private: }; REGISTER_CALCULATOR(LandmarkHistoryToTensorCalculator); }
; $Id: bs3-cmn-RegCtxSaveEx.asm $ ;; @file ; BS3Kit - Bs3RegCtxSaveEx. ; ; ; 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" ;********************************************************************************************************************************* ;* External Symbols * ;********************************************************************************************************************************* BS3_EXTERN_DATA16 g_bBs3CurrentMode %if ARCH_BITS != 64 BS3_EXTERN_DATA16 g_uBs3CpuDetected %endif TMPL_BEGIN_TEXT BS3_EXTERN_CMN Bs3Panic BS3_EXTERN_CMN Bs3RegCtxSave BS3_EXTERN_CMN Bs3SwitchTo16Bit %if TMPL_BITS != 64 BS3_EXTERN_CMN Bs3SwitchTo16BitV86 %endif %if TMPL_BITS != 32 BS3_EXTERN_CMN Bs3SwitchTo32Bit %endif %if TMPL_BITS != 64 BS3_EXTERN_CMN Bs3SwitchTo64Bit %endif %if TMPL_BITS == 16 BS3_EXTERN_CMN Bs3SelRealModeDataToProtFar16 BS3_EXTERN_CMN Bs3SelProtFar16DataToRealMode BS3_EXTERN_CMN Bs3SelRealModeDataToFlat BS3_EXTERN_CMN Bs3SelProtFar16DataToFlat %else BS3_EXTERN_CMN Bs3SelFlatDataToProtFar16 %endif %if TMPL_BITS == 32 BS3_EXTERN_CMN Bs3SelFlatDataToRealMode %endif BS3_BEGIN_TEXT16 %if TMPL_BITS != 16 extern _Bs3RegCtxSave_c16 extern _Bs3SwitchTo%[TMPL_BITS]Bit_c16 %endif BS3_BEGIN_TEXT32 %if TMPL_BITS != 32 extern _Bs3RegCtxSave_c32 extern _Bs3SwitchTo%[TMPL_BITS]Bit_c32 %endif %if TMPL_BITS == 16 extern _Bs3SwitchTo16BitV86_c32 %endif BS3_BEGIN_TEXT64 %if TMPL_BITS != 64 extern _Bs3RegCtxSave_c64 extern _Bs3SwitchTo%[TMPL_BITS]Bit_c64 %endif TMPL_BEGIN_TEXT ;; ; Saves the current register context. ; ; @param pRegCtx ; @param bBitMode (8) ; @param cbExtraStack (16) ; @uses xAX, xDX, xCX ; BS3_PROC_BEGIN_CMN Bs3RegCtxSaveEx, BS3_PBC_NEAR ; Far stub generated by the makefile/bs3kit.h. TONLY16 CPU 8086 BS3_CALL_CONV_PROLOG 3 push xBP mov xBP, xSP %if ARCH_BITS == 64 push rcx ; Save pRegCtx %endif ; ; Get the CPU bitcount part of the current mode. ; mov dl, [BS3_DATA16_WRT(g_bBs3CurrentMode)] and dl, BS3_MODE_CODE_MASK %if TMPL_BITS == 16 push dx ; bp - 2: previous CPU mode (16-bit) %endif ; ; Reserve extra stack space. Make sure we've got 20h here in case we ; are saving a 64-bit context. ; TONLY16 mov ax, [xBP + xCB + cbCurRetAddr + sCB + xCB] TNOT16 movzx eax, word [xBP + xCB + cbCurRetAddr + sCB + xCB] %ifdef BS3_STRICT cmp xAX, 4096 jb .extra_stack_ok call Bs3Panic .extra_stack_ok: %endif cmp xAX, 20h jae .at_least_20h_extra_stack add xAX, 20h .at_least_20h_extra_stack: sub xSP, xAX ; ; Are we just saving the mode we're already in? ; mov al, [xBP + xCB + cbCurRetAddr + sCB] and al, BS3_MODE_CODE_MASK cmp dl, al jne .not_the_same_mode %if TMPL_BITS == 16 push word [xBP + xCB + cbCurRetAddr + 2] push word [xBP + xCB + cbCurRetAddr] %elif TMPL_BITS == 32 push dword [xBP + xCB + cbCurRetAddr] %endif call Bs3RegCtxSave ; 64-bit: rcx is untouched thus far. ; ; Return - no need to pop xAX and xDX as the last two ; operations preserves all registers. ; .return: mov xSP, xBP pop xBP BS3_CALL_CONV_EPILOG 3 BS3_HYBRID_RET ; ; Turns out we have to do switch to a different bitcount before saving. ; .not_the_same_mode: cmp al, BS3_MODE_CODE_16 je .code_16 TONLY16 CPU 386 %if TMPL_BITS != 32 cmp al, BS3_MODE_CODE_32 je .code_32 %endif %if TMPL_BITS != 64 cmp al, BS3_MODE_CODE_V86 je .code_v86 cmp al, BS3_MODE_CODE_64 jne .bad_input_mode jmp .code_64 %endif ; Bad input (al=input, dl=current). .bad_input_mode: call Bs3Panic ; ; Save a 16-bit context. ; ; Convert pRegCtx to 16:16 protected mode and make sure we're in the ; 16-bit code segment. ; .code_16: %if TMPL_BITS == 16 %ifdef BS3_STRICT cmp dl, BS3_MODE_CODE_V86 jne .bad_input_mode %endif push word [xBP + xCB + cbCurRetAddr + 2] push word [xBP + xCB + cbCurRetAddr] call Bs3SelRealModeDataToProtFar16 add sp, 4h push dx ; Parameter #0 for _Bs3RegCtxSave_c16 push ax %else %if TMPL_BITS == 32 push dword [xBP + xCB + cbCurRetAddr] %endif call Bs3SelFlatDataToProtFar16 ; 64-bit: BS3_CALL not needed, ecx not touched thus far. mov [xSP], eax ; Parameter #0 for _Bs3RegCtxSave_c16 jmp .code_16_safe_segment BS3_BEGIN_TEXT16 BS3_SET_BITS TMPL_BITS .code_16_safe_segment: %endif call Bs3SwitchTo16Bit BS3_SET_BITS 16 call _Bs3RegCtxSave_c16 %if TMPL_BITS == 16 call _Bs3SwitchTo16BitV86_c16 %else call _Bs3SwitchTo%[TMPL_BITS]Bit_c16 %endif BS3_SET_BITS TMPL_BITS jmp .supplement_and_return TMPL_BEGIN_TEXT TONLY16 CPU 386 %if TMPL_BITS != 64 ; ; Save a v8086 context. ; .code_v86: %if TMPL_BITS == 16 %ifdef BS3_STRICT cmp dl, BS3_MODE_CODE_16 jne .bad_input_mode %endif push word [xBP + xCB + cbCurRetAddr + 2] push word [xBP + xCB + cbCurRetAddr] call Bs3SelProtFar16DataToRealMode add sp, 4h push dx ; Parameter #0 for _Bs3RegCtxSave_c16 push ax %else push dword [xBP + xCB + cbCurRetAddr] call Bs3SelFlatDataToRealMode mov [xSP], eax ; Parameter #0 for _Bs3RegCtxSave_c16 jmp .code_v86_safe_segment BS3_BEGIN_TEXT16 BS3_SET_BITS TMPL_BITS .code_v86_safe_segment: %endif call Bs3SwitchTo16BitV86 BS3_SET_BITS 16 call _Bs3RegCtxSave_c16 call _Bs3SwitchTo%[TMPL_BITS]Bit_c16 BS3_SET_BITS TMPL_BITS jmp .supplement_and_return TMPL_BEGIN_TEXT %endif %if TMPL_BITS != 32 ; ; Save a 32-bit context. ; .code_32: %if TMPL_BITS == 16 push word [xBP + xCB + cbCurRetAddr + 2] push word [xBP + xCB + cbCurRetAddr] test dl, BS3_MODE_CODE_V86 jnz .code_32_from_v86 call Bs3SelProtFar16DataToFlat jmp .code_32_flat_ptr .code_32_from_v86: call Bs3SelRealModeDataToFlat .code_32_flat_ptr: add sp, 4h push dx ; Parameter #0 for _Bs3RegCtxSave_c32 push ax %else mov [rsp], ecx ; Parameter #0 for _Bs3RegCtxSave_c16 %endif call Bs3SwitchTo32Bit BS3_SET_BITS 32 call _Bs3RegCtxSave_c32 %if TMPL_BITS == 16 cmp byte [bp - 2], BS3_MODE_CODE_V86 je .code_32_back_to_v86 call _Bs3SwitchTo16Bit_c32 BS3_SET_BITS TMPL_BITS jmp .supplement_and_return .code_32_back_to_v86: BS3_SET_BITS 32 call _Bs3SwitchTo16BitV86_c32 BS3_SET_BITS TMPL_BITS jmp .return %else call _Bs3SwitchTo64Bit_c32 BS3_SET_BITS TMPL_BITS jmp .supplement_and_return %endif %endif %if TMPL_BITS != 64 ; ; Save a 64-bit context. ; CPU x86-64 .code_64: %if TMPL_BITS == 16 %ifdef BS3_STRICT cmp dl, BS3_MODE_CODE_16 jne .bad_input_mode %endif push word [xBP + xCB + cbCurRetAddr + 2] push word [xBP + xCB + cbCurRetAddr] call Bs3SelProtFar16DataToFlat add sp, 4h mov cx, dx ; Parameter #0 for _Bs3RegCtxSave_c64 shl ecx, 16 mov cx, ax %else mov ecx, [xBP + xCB + cbCurRetAddr] ; Parameter #0 for _Bs3RegCtxSave_c64 %endif call Bs3SwitchTo64Bit ; (preserves all 32-bit GPRs) BS3_SET_BITS 64 call _Bs3RegCtxSave_c64 ; No BS3_CALL as rcx is already ready. call _Bs3SwitchTo%[TMPL_BITS]Bit_c64 BS3_SET_BITS TMPL_BITS jmp .return %endif ; ; Supplement the state out of the current context and then return. ; .supplement_and_return: %if ARCH_BITS == 16 CPU 8086 ; Skip 286 and older. Also make 101% sure we not in real mode or v8086 mode. cmp byte [BS3_DATA16_WRT(g_uBs3CpuDetected)], BS3CPU_80386 jb .return ; Just skip if 286 or older. test byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_CODE_V86 jnz .return cmp byte [BS3_DATA16_WRT(g_bBs3CurrentMode)], BS3_MODE_RM jne .return ; paranoia CPU 386 %endif ; Load the context pointer into a suitable register. %if ARCH_BITS == 64 %define pRegCtx rcx mov rcx, [xBP - xCB] %elif ARCH_BITS == 32 %define pRegCtx ecx mov ecx, [xBP + xCB + cbCurRetAddr] %else %define pRegCtx es:bx push es push bx les bx, [xBP + xCB + cbCurRetAddr] %endif %if ARCH_BITS == 64 ; If we're in 64-bit mode we can capture and restore the high bits. test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_AMD64 jz .supplemented_64bit_registers mov [pRegCtx + BS3REGCTX.r8], r8 mov [pRegCtx + BS3REGCTX.r9], r9 mov [pRegCtx + BS3REGCTX.r10], r10 mov [pRegCtx + BS3REGCTX.r11], r11 mov [pRegCtx + BS3REGCTX.r12], r12 mov [pRegCtx + BS3REGCTX.r13], r13 mov [pRegCtx + BS3REGCTX.r14], r14 mov [pRegCtx + BS3REGCTX.r15], r15 shr rax, 32 mov [pRegCtx + BS3REGCTX.rax + 4], eax mov rax, rbx shr rax, 32 mov [pRegCtx + BS3REGCTX.rbx + 4], eax mov rax, rcx shr rax, 32 mov [pRegCtx + BS3REGCTX.rcx + 4], eax mov rax, rdx shr rax, 32 mov [pRegCtx + BS3REGCTX.rdx + 4], eax mov rax, rsp shr rax, 32 mov [pRegCtx + BS3REGCTX.rsp + 4], eax mov rax, rbp shr rax, 32 mov [pRegCtx + BS3REGCTX.rbp + 4], eax mov rax, rsi shr rax, 32 mov [pRegCtx + BS3REGCTX.rsi + 4], eax mov rax, rdi shr rax, 32 mov [pRegCtx + BS3REGCTX.rdi + 4], eax and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_AMD64 .supplemented_64bit_registers: %endif ; The rest requires ring-0 (at least during restore). mov ax, ss test ax, 3 jnz .done_supplementing ; Do control registers. test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW | BS3REG_CTX_F_NO_CR4 jz .supplemented_control_registers mov sAX, cr0 mov [pRegCtx + BS3REGCTX.cr0], sAX mov sAX, cr2 mov [pRegCtx + BS3REGCTX.cr2], sAX mov sAX, cr3 mov [pRegCtx + BS3REGCTX.cr3], sAX and byte [pRegCtx + BS3REGCTX.fbFlags], ~(BS3REG_CTX_F_NO_CR2_CR3 | BS3REG_CTX_F_NO_CR0_IS_MSW) %if ARCH_BITS != 64 test byte [1 + BS3_DATA16_WRT(g_uBs3CpuDetected)], (BS3CPU_F_CPUID >> 8) jz .supplemented_control_registers %endif mov sAX, cr4 mov [pRegCtx + BS3REGCTX.cr4], sAX and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_CR4 .supplemented_control_registers: ; Supply tr and ldtr if necessary test byte [pRegCtx + BS3REGCTX.fbFlags], BS3REG_CTX_F_NO_TR_LDTR jz .done_supplementing str [pRegCtx + BS3REGCTX.tr] sldt [pRegCtx + BS3REGCTX.ldtr] and byte [pRegCtx + BS3REGCTX.fbFlags], ~BS3REG_CTX_F_NO_TR_LDTR .done_supplementing: TONLY16 pop bx TONLY16 pop es jmp .return %undef pRegCtx BS3_PROC_END_CMN Bs3RegCtxSaveEx
#include<Test_Threads.hpp> #include<Test_Blas2_team_gemv.hpp>
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x910f, %rcx nop nop nop nop nop and %rax, %rax mov $0x6162636465666768, %r15 movq %r15, %xmm2 vmovups %ymm2, (%rcx) xor %rsi, %rsi lea addresses_WT_ht+0x1ae2f, %rdx nop nop sub $27969, %rax movb $0x61, (%rdx) sub $31448, %rax lea addresses_D_ht+0xbe91, %rdx nop nop nop nop sub $25637, %rbx movups (%rdx), %xmm3 vpextrq $0, %xmm3, %r12 and %r15, %r15 lea addresses_WC_ht+0x790f, %rbx clflush (%rbx) nop nop nop add %rsi, %rsi movb (%rbx), %al nop add $334, %rcx lea addresses_UC_ht+0x1190f, %rsi lea addresses_D_ht+0x33bf, %rdi nop nop nop nop nop and %rax, %rax mov $30, %rcx rep movsw nop nop and %rbx, %rbx lea addresses_D_ht+0x1790f, %r15 clflush (%r15) nop nop add $47699, %rcx movups (%r15), %xmm3 vpextrq $0, %xmm3, %rdi nop nop add $46293, %rbx lea addresses_normal_ht+0x528f, %rdi nop nop nop add $8377, %rbx movb (%rdi), %dl nop nop sub $31728, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r8 push %rax push %rdx // Store lea addresses_WC+0x19d0f, %r8 nop nop and %r12, %r12 mov $0x5152535455565758, %rdx movq %rdx, %xmm4 movups %xmm4, (%r8) sub $45434, %r12 // Faulty Load lea addresses_WC+0x1c10f, %r13 nop nop nop dec %r11 mov (%r13), %dx lea oracles, %r11 and $0xff, %rdx shlq $12, %rdx mov (%r11,%rdx,1), %rdx pop %rdx pop %rax pop %r8 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'dst': {'same': True, 'congruent': 0, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
global _fatal_error _fatal_error: push bp mov bp, sp mov ax, word [bp+4] call os_fatal_error pop bp ret
; A044685: Numbers n such that string 5,8 occurs in the base 9 representation of n but not of n+1. ; 53,134,215,296,377,458,485,539,620,701,782,863,944,1025,1106,1187,1214,1268,1349,1430,1511,1592,1673,1754,1835,1916,1943,1997,2078,2159,2240,2321,2402,2483,2564,2645,2672,2726,2807 mov $2,$0 add $2,1 mov $5,$0 lpb $2 mov $0,$5 sub $2,1 sub $0,$2 mov $3,$0 add $3,1 lpb $0 mov $0,0 add $3,3 mod $3,10 lpb $3 mov $3,2 lpe lpe mov $4,$3 add $4,1 add $1,$4 lpe sub $1,2 mul $1,27 add $1,53 mov $0,$1
; A218471: a(n) = n*(7*n-3)/2. ; 0,2,11,27,50,80,117,161,212,270,335,407,486,572,665,765,872,986,1107,1235,1370,1512,1661,1817,1980,2150,2327,2511,2702,2900,3105,3317,3536,3762,3995,4235,4482,4736,4997,5265,5540,5822,6111,6407,6710,7020,7337,7661,7992,8330,8675,9027,9386,9752,10125,10505,10892,11286,11687,12095,12510,12932,13361,13797,14240,14690,15147,15611,16082,16560,17045,17537,18036,18542,19055,19575,20102,20636,21177,21725,22280,22842,23411,23987,24570,25160,25757,26361,26972,27590,28215,28847,29486,30132,30785,31445,32112,32786,33467,34155,34850,35552,36261,36977,37700,38430,39167,39911,40662,41420,42185,42957,43736,44522,45315,46115,46922,47736,48557,49385,50220,51062,51911,52767,53630,54500,55377,56261,57152,58050,58955,59867,60786,61712,62645,63585,64532,65486,66447,67415,68390,69372,70361,71357,72360,73370,74387,75411,76442,77480,78525,79577,80636,81702,82775,83855,84942,86036,87137,88245,89360,90482,91611,92747,93890,95040,96197,97361,98532,99710,100895,102087,103286,104492,105705,106925,108152,109386,110627,111875,113130,114392,115661,116937,118220,119510,120807,122111,123422,124740,126065,127397,128736,130082,131435,132795,134162,135536,136917,138305,139700,141102,142511,143927,145350,146780,148217,149661,151112,152570,154035,155507,156986,158472,159965,161465,162972,164486,166007,167535,169070,170612,172161,173717,175280,176850,178427,180011,181602,183200,184805,186417,188036,189662,191295,192935,194582,196236,197897,199565,201240,202922,204611,206307,208010,209720,211437,213161,214892,216630 mul $0,14 sub $0,3 pow $0,2 mov $1,$0 div $1,56
; A277813: a(n) = A115384(A277812(n)) = index of the row where n is located in array A277880. ; 1,2,1,3,2,1,4,5,3,2,6,1,7,8,4,9,5,3,10,2,11,12,6,1,13,14,7,15,8,4,16,17,9,5,18,3,19,20,10,2,21,22,11,23,12,6,24,1,25,26,13,27,14,7,28,29,15,8,30,4,31,32,16,33,17,9,34,5,35,36,18,3,37,38,19,39,20,10,40,2,41,42,21,43,22,11,44,45,23,12,46,6,47,48,24,1,49,50,25,51 add $0,1 seq $0,1969 ; Evil numbers: nonnegative integers with an even number of 1's in their binary expansion. lpb $0 dif $0,2 lpe div $0,4 add $0,1
; 16.8 signed binary math lib for AVR's with RAM V1.0 ; ALL code by Rolf R Bakke, April 2010 ;Uses no AVR registers exept r16 .def a=r16 .def Op1_2=r17 .def Op1_1=r18 .def Op1_0=r19 .def Op2_2=r20 .def Op2_1=r21 .def Op2_0=r22 .def Result2=r23 .def Result1=r24 .def Result0=r25 .def Sign=r26 .equ Op1Index=B16_WorkAdd+0 ;Operand #1 index .equ Op2Index=B16_WorkAdd+1 ;Operand #2 index .equ ZaddLow=b16_WorkAdd+2 .equ ZaddHigh=b16_WorkAdd+3 .equ b168Temp0=b16_WorkAdd+4 .equ b168Temp1=b16_WorkAdd+5 .equ b168Temp2=b16_WorkAdd+6 .equ RegSave=B16_WorkAdd+7 b16_sr: ;sts RegSave+0,Result0 ; sts RegSave+1,Result1 sts RegSave+2,Result2 sts RegSave+3,Op1_0 sts RegSave+4,Op1_1 sts RegSave+5,Op1_2 sts RegSave+6,Op2_0 sts RegSave+7,Op2_1 sts RegSave+8,Op2_2 sts RegSave+9,zl sts RegSave+10,zh ; sts RegSave+11, Sign ret b16_lr: ; lds Result0,RegSave+0 ; lds Result1,RegSave+1 lds Result2,RegSave+2 lds Op1_0,RegSave+3 lds Op1_1,RegSave+4 lds Op1_2,RegSave+5 lds Op2_0,RegSave+6 lds Op2_1,RegSave+7 lds Op2_2,RegSave+8 lds zl,RegSave+9 lds zh,RegSave+10 ; lds Sign, RegSave+11 ret b16_clr_c: rcall b16_getregadd clr a st z+,a st z+,a st z+,a st z,a ret b16_neg_c: ;negate rcall b16_pre2 mov Op2_0, Op1_0 mov Op2_1, Op1_1 mov Op2_2, Op1_2 clr Op1_0 clr Op1_1 clr Op1_2 sub Op1_0, Op2_0 sbc Op1_1, Op2_1 sbc Op1_2, Op2_2 rcall b16_post1 ret b16_cmp_c: ;Only use breq, brne, brge and brlt after the compare (OK) rcall b16_pre1 cp Op1_0,Op2_0 cpc Op1_1,Op2_1 cpc Op1_2,Op2_2 ret b16_move_c: ;(OK) lds a,Op2Index rcall b16_load_c lds a,Op1Index rcall b16_store_c ret b16_store_c: rcall b16_getregadd lds a,b168temp2 st z+,a lds a,b168temp1 st z+,a lds a,b168temp0 st z+,a ret b16_load_c: rcall b16_getregadd ld a,z+ sts b168temp2, a ld a,z+ sts b168temp1, a ld a,z+ sts b168temp0, a ret ; -*- 16.8 signed binary addition -*- (ok) ; sum augend addend ; Result = Operand#1 + Operand#2 b16_add_c: rcall b16_pre1 add Op1_0, Op2_0 adc Op1_1, Op2_1 adc Op1_2, Op2_2 rjmp b16_post1 ; -*- 16.8 signed binary subtraction -*- (OK) ; difference minuend subtrahend ; Result = Operand#1 - Operand#2 b16_sub_c: rcall b16_pre1 sub Op1_0, Op2_0 sbc Op1_1, Op2_1 sbc Op1_2, Op2_2 rjmp b16_post1 ; -*- 16.8 signed binary multiply -*- (OK) ; product multiplicand multiplier ; Result = Operand#1 * Operand#2 b16_mul_c: rcall b16_pre1 mov Sign, Op1_2 ;calculate result sign eor Sign, Op2_2 tst Op1_2 ;Op1=ABS(Op1) brpl b16_mu1 com Op1_0 com Op1_1 com Op1_2 ldi a,1 add Op1_0, a clr a adc Op1_1, a adc Op1_2, a b16_mu1:tst Op2_2 ;Op2=ABS(Op2) brpl b16_mu2 com Op2_0 com Op2_1 com Op2_2 ldi a,1 add Op2_0, a clr a adc Op2_1, a adc Op2_2, a b16_mu2: clr Result0 clr Result1 clr Result2 mul Op1_0, Op2_0 ;Mul #1 push r0 add Result0, r1 clr a adc Result1, a adc Result2, a mul Op1_0, Op2_1 ;mul #2 add Result0, r0 adc Result1, r1 adc Result2, a mul Op1_0, Op2_2 ;mul #3 add Result1, r0 adc Result2, r1 mul Op1_1, Op2_0 ;mul #4 add Result0, r0 adc Result1, r1 adc Result2, a mul Op1_1, Op2_1 ;mul #5 add Result1, r0 adc Result2, r1 mul Op1_1, Op2_2 ;mul #6 add Result2, r0 mul Op1_2, Op2_0 ;mul #7 add Result1, r0 adc Result2, r1 mul Op1_2, Op2_1 ;mul #8 add Result2, r0 pop r0 ;round off lsl r0 adc Result0, a adc result1, a adc result2, a tst Sign ;negate result if sign set. brpl b16_mu3 com Result0 com Result1 com Result2 ldi a,1 add Result0, a clr a adc Result1, a adc Result2, a b16_mu3:lds zl, ZaddLow lds zh, ZaddHigh st z+,Result2 st z+,Result1 st z+,Result0 ret b16_fdiv_c: ;Fast divide by 2n (OK) rcall b16_pre2 lds a,Op2Index b16_f0: asr Op1_2 ror Op1_1 ror Op1_0 dec a brne b16_f0 adc Op1_0, a ;round off adc Op1_1, a adc Op1_2, a rjmp b16_post1 /* b16_fmul_c: ;Fast multiply by 2n (OK) rcall b16_pre2 lds a,Op2Index b16_u0: lsl Op1_0 rol Op1_1 rol Op1_2 dec a brne b16_u0 rjmp b16_post1 */ ;---- subroutines b16_GetOp1: ld Op1_2,z+ ld Op1_1,z+ ld Op1_0,z+ ret b16_GetOp2: ld Op2_2,z+ ld Op2_1,z+ ld Op2_0,z+ ret b16_getregadd: ldi zl,low(b16_regadd) ldi zh,high(b16_regadd) lsl a lsl a add zl,a clr a adc zh,a ret b16_pre1: ;common header for add,sub,mul,cmp rcall b16_pre2 lds a,Op2Index rcall b16_getregadd rcall b16_GetOp2 ret b16_post1: ;common footer for add,sub,fmul,fdiv, neg lds zl, ZaddLow lds zh, ZaddHigh st z+,Op1_2 st z+,Op1_1 st z+,Op1_0 ret b16_pre2: ;common header for fmul,fdiv,neg lds a,Op1Index rcall b16_getregadd sts ZaddLow, zl sts ZaddHigh, zh rcall b16_GetOp1 ret
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include <gtest/gtest.h> #include <QPushButton> #include <QAction> #include <QtTest> #include <Tests/UI/UIFixture.h> #include <Tests/UI/MenuUIFixture.h> #include <Tests/UI/ModalPopupHandler.h> #include <EMotionFX/CommandSystem/Source/CommandManager.h> #include <EMotionFX/Source/Actor.h> #include <Editor/ColliderContainerWidget.h> #include <EMotionStudio/EMStudioSDK/Source/EMStudioManager.h> #include <Editor/Plugins/SimulatedObject/SimulatedObjectWidget.h> #include <Editor/Plugins/SimulatedObject/SimulatedObjectColliderWidget.h> #include <Editor/InputDialogValidatable.h> #include <Editor/Plugins/SkeletonOutliner/SkeletonOutlinerPlugin.h> #include <Tests/TestAssetCode/SimpleActors.h> #include <Tests/TestAssetCode/ActorFactory.h> #include <Tests/TestAssetCode/TestActorAssets.h> #include <Tests/PhysicsSetupUtils.h> #include <Editor/ReselectingTreeView.h> #include <AzQtComponents/Components/Widgets/CardHeader.h> namespace EMotionFX { class CanAddSimulatedObjectFixture : public UIFixture { public: void TearDown() override { QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); UIFixture::TearDown(); } void RecursiveGetAllChildren(QTreeView* treeView, const QModelIndex& index, QModelIndexList& outIndicies) { outIndicies.push_back(index); for (int i = 0; i < treeView->model()->rowCount(index); ++i) { RecursiveGetAllChildren(treeView, treeView->model()->index(i, 0, index), outIndicies); } } void CreateSimulateObject(const char* objectName) { // Select the newly created actor { AZStd::string result; EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand("Select -actorID 0", result)) << result.c_str(); } // Change the Editor mode to Simulated Objects EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects"); // Find the Simulated Object Manager and its button m_simulatedObjectWidget = static_cast<EMotionFX::SimulatedObjectWidget*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SimulatedObjectWidget::CLASS_ID)); ASSERT_TRUE(m_simulatedObjectWidget) << "Simulated Object plugin not found!"; QPushButton* addSimulatedObjectButton = m_simulatedObjectWidget->GetDockWidget()->findChild<QPushButton*>("addSimulatedObjectButton"); // Send the left button click directly to the button QTest::mouseClick(addSimulatedObjectButton, Qt::LeftButton); // In the Input Dialog set the name of the object and close the dialog EMStudio::InputDialogValidatable* inputDialog = qobject_cast<EMStudio::InputDialogValidatable*>(FindTopLevelWidget("EMFX.SimulatedObjectActionManager.SimulatedObjectDialog")); ASSERT_NE(inputDialog, nullptr) << "Cannot find input dialog."; inputDialog->SetText(objectName); inputDialog->accept(); // There is one and only one simulated objects ASSERT_EQ(m_actorAsset->GetActor()->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 1); // Check it has the correct name EXPECT_STREQ(m_actorAsset->GetActor()->GetSimulatedObjectSetup()->GetSimulatedObject(0)->GetName().c_str(), objectName); } void AddCapsuleColliderToJointIndex(int index) { m_skeletonTreeView->selectionModel()->clearSelection(); // Find the indexed joint in the TreeView and select it SelectIndexes(m_indexList, m_skeletonTreeView, index, index); // Open the Right Click Context Menu const QRect rect = m_skeletonTreeView->visualRect(m_indexList[index-1]); EXPECT_TRUE(rect.isValid()); BringUpContextMenu(m_skeletonTreeView, rect); QMenu* contextMenu = m_skeletonOutliner->GetDockWidget()->findChild<QMenu*>("contextMenu"); // Trace down the sub Menus to Add Collider and select it QAction* simulatedObjectColliderAction = GetNamedAction(m_skeletonOutliner->GetDockWidget(), "Add collider"); ASSERT_TRUE(simulatedObjectColliderAction); QMenu* simulatedObjectColliderMenu = simulatedObjectColliderAction->menu(); const QList<QAction*> addSelectedColliderMenuActions = simulatedObjectColliderMenu->actions(); auto addCapsuleColliderAction = AZStd::find_if(addSelectedColliderMenuActions.begin(), addSelectedColliderMenuActions.end(), [](const QAction* action) { return action->text() == "Capsule"; }); ASSERT_NE(addCapsuleColliderAction, addSelectedColliderMenuActions.end()); size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders( m_actorAsset->GetActor(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); (*addCapsuleColliderAction)->trigger(); // Delete the context menu, otherwise there it will still be around during this frame as the Qt event loop has not been run. delete contextMenu; const size_t numCapsuleCollidersAfterAdd = PhysicsSetupUtils::CountColliders( m_actorAsset->GetActor(), PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); ASSERT_EQ(numCapsuleCollidersAfterAdd, numCapsuleColliders + 1); m_skeletonTreeView->selectionModel()->clearSelection(); } protected: AZ::Data::Asset<Integration::ActorAsset> m_actorAsset; EMotionFX::SimulatedObjectWidget* m_simulatedObjectWidget = nullptr; EMotionFX::SkeletonOutlinerPlugin* m_skeletonOutliner = nullptr; ReselectingTreeView* m_skeletonTreeView = nullptr; const QAbstractItemModel* m_skeletonModel; QModelIndexList m_indexList; }; #if AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS TEST_F(CanAddSimulatedObjectFixture, DISABLED_CanAddSimulatedObject) #else TEST_F(CanAddSimulatedObjectFixture, CanAddSimulatedObject) #endif // AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_EDITOR_TESTS { RecordProperty("test_case_id", "C13048820"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1, "CanAddSimulatedObjectActor"); CreateSimulateObject("New simulated object"); } TEST_F(UIFixture, CanAddSimulatedObjectWithJoints) { RecordProperty("test_case_id", "C13048818"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); AZ::Data::Asset<Integration::ActorAsset> actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 2, "CanAddSimulatedObjectWithJointsActor"); Actor* actor = actorAsset->GetActor(); ActorInstance* actorInstance = ActorInstance::Create(actor); EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects"); { AZStd::string result; EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(AZStd::string{"Select -actorInstanceID "} + AZStd::to_string(actorInstance->GetID()), result)) << result.c_str(); } auto simulatedObjectWidget = static_cast<EMotionFX::SimulatedObjectWidget*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SimulatedObjectWidget::CLASS_ID)); ASSERT_TRUE(simulatedObjectWidget) << "Simulated Object plugin not found!"; auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); QTreeView* treeView = skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); const QAbstractItemModel* model = treeView->model(); const QModelIndex rootJointIndex = model->index(0, 0); ASSERT_TRUE(rootJointIndex.isValid()) << "Unable to find a model index for the root joint of the actor"; treeView->selectionModel()->select(rootJointIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); treeView->scrollTo(rootJointIndex); BringUpContextMenu(treeView, treeView->visualRect(rootJointIndex)); QMenu* contextMenu = skeletonOutliner->GetDockWidget()->findChild<QMenu*>("EMFX.SkeletonOutlinerPlugin.ContextMenu"); EXPECT_TRUE(contextMenu); QAction* addSelectedJointAction; EXPECT_TRUE(UIFixture::GetActionFromContextMenu(addSelectedJointAction, contextMenu, "Add to simulated object")); QMenu* addSelectedJointMenu = addSelectedJointAction->menu(); EXPECT_TRUE(addSelectedJointMenu); QAction* newSimulatedObjectAction; EXPECT_TRUE(UIFixture::GetActionFromContextMenu(newSimulatedObjectAction, addSelectedJointMenu, "New simulated object...")); // Handle the add children dialog box. ModalPopupHandler messageBoxPopupHandler; messageBoxPopupHandler.WaitForPopupPressDialogButton<QMessageBox*>(QDialogButtonBox::No); newSimulatedObjectAction->trigger(); EMStudio::InputDialogValidatable* inputDialog = qobject_cast<EMStudio::InputDialogValidatable*>(FindTopLevelWidget("EMFX.SimulatedObjectActionManager.SimulatedObjectDialog")); ASSERT_NE(inputDialog, nullptr) << "Cannot find input dialog."; inputDialog->SetText("New simulated object"); inputDialog->accept(); ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 1); const auto simulatedObject = actor->GetSimulatedObjectSetup()->GetSimulatedObject(0); EXPECT_STREQ(simulatedObject->GetName().c_str(), "New simulated object"); EXPECT_EQ(simulatedObject->GetNumSimulatedRootJoints(), 1); EXPECT_EQ(simulatedObject->GetNumSimulatedJoints(), 1); EXPECT_STREQ(actor->GetSkeleton()->GetNode(simulatedObject->GetSimulatedJoint(0)->GetSkeletonJointIndex())->GetName(), "rootJoint"); EXPECT_STREQ(actor->GetSkeleton()->GetNode(simulatedObject->GetSimulatedRootJoint(0)->GetSkeletonJointIndex())->GetName(), "rootJoint"); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); actorInstance->Destroy(); } TEST_F(CanAddSimulatedObjectFixture, CanAddSimulatedObjectWithJointsAndName) { RecordProperty("test_case_id", "C13048820a"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); CreateSimulateObject("sim1"); // Get the Skeleton Outliner and find the model relating to its treeview auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); QTreeView* treeView = skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); const QAbstractItemModel* model = treeView->model(); // Find the 3rd joint in the TreeView and select it const QModelIndex jointIndex = model->index(0, 3); ASSERT_TRUE(jointIndex.isValid()) << "Unable to find a model index for the root joint of the actor"; treeView->selectionModel()->select(jointIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); treeView->scrollTo(jointIndex); // Open the Right Click Context Menu const QRect rect = treeView->visualRect(jointIndex); EXPECT_TRUE(rect.isValid()); BringUpContextMenu(treeView, rect); // Trace down the sub Menus to <New simulated object> and select it QMenu* contextMenu = skeletonOutliner->GetDockWidget()->findChild<QMenu*>("EMFX.SkeletonOutlinerPlugin.ContextMenu"); EXPECT_TRUE(contextMenu); QAction* simulatedObjectAction; EXPECT_TRUE(UIFixture::GetActionFromContextMenu(simulatedObjectAction, contextMenu, "Add to simulated object")); QMenu* simulatedObjectMenu = simulatedObjectAction->menu(); EXPECT_TRUE(simulatedObjectMenu); QAction* newSimulatedObjectAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(newSimulatedObjectAction, simulatedObjectMenu, "New simulated object...")); // Handle the add children dialog box. ModalPopupHandler messageBoxPopupHandler; messageBoxPopupHandler.WaitForPopupPressDialogButton<QMessageBox*>(QDialogButtonBox::No); newSimulatedObjectAction->trigger(); // Set the name in the Dialog Box and test it. EMStudio::InputDialogValidatable* inputDialog = qobject_cast<EMStudio::InputDialogValidatable*>(FindTopLevelWidget("EMFX.SimulatedObjectActionManager.SimulatedObjectDialog")); ASSERT_NE(inputDialog, nullptr) << "Cannot find input dialog."; inputDialog->SetText("sim2"); inputDialog->accept(); ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 2); const auto simulatedObject = actor->GetSimulatedObjectSetup()->GetSimulatedObject(1); EXPECT_STREQ(simulatedObject->GetName().c_str(), "sim2"); } TEST_F(CanAddSimulatedObjectFixture, CanAddColliderToSimulatedObject) { RecordProperty("test_case_id", "C13048816"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); CreateSimulateObject("sim1"); // Get the Skeleton Outliner and find the model relating to its treeview auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); QTreeView* treeView = skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); const QAbstractItemModel* model = treeView->model(); // Find the 3rd joint in the TreeView and select it const QModelIndex jointIndex = model->index(0, 3); ASSERT_TRUE(jointIndex.isValid()) << "Unable to find a model index for the root joint of the actor"; treeView->selectionModel()->select(jointIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); treeView->scrollTo(jointIndex); // Open the Right Click Context Menu const QRect rect = treeView->visualRect(jointIndex); EXPECT_TRUE(rect.isValid()); BringUpContextMenu(treeView, rect); // Trace down the sub Menus to Add Collider and select it QMenu* contextMenu = skeletonOutliner->GetDockWidget()->findChild<QMenu*>("EMFX.SkeletonOutlinerPlugin.ContextMenu"); EXPECT_TRUE(contextMenu); QAction* addSelectedAddColliderAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addSelectedAddColliderAction, contextMenu, "Add collider")); QMenu* addSelectedColliderMenu = addSelectedAddColliderAction->menu(); QAction* addCapsuleColliderAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addCapsuleColliderAction, addSelectedColliderMenu, "Capsule")); size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); EXPECT_EQ(numCapsuleColliders, 0); addCapsuleColliderAction->trigger(); // Check that a collider has been added. size_t numCollidersAfterAddCapsule = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); ASSERT_EQ(numCollidersAfterAddCapsule, numCapsuleColliders + 1) << "Capsule collider not added."; QAction* addSphereColliderAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addSphereColliderAction, addSelectedColliderMenu, "Sphere")); const size_t numSphereColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere); EXPECT_EQ(numSphereColliders, 0); addSphereColliderAction->trigger(); // Check that a second collider has been added. const size_t numCollidersAfterAddSphere = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere); ASSERT_EQ(numCollidersAfterAddSphere, numSphereColliders + 1) << "Sphere collider not added."; } TEST_F(CanAddSimulatedObjectFixture, CanRemoveSimulatedObject) { RecordProperty("test_case_id", "C13048821"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 1, "CanRemoveSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); CreateSimulateObject("TestObject1"); // Get the Simulated Object and find the model relating to its treeview EMotionFX::SimulatedObjectWidget* simulatedObjectWidget = static_cast<EMotionFX::SimulatedObjectWidget*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SimulatedObjectWidget::CLASS_ID)); ASSERT_TRUE(simulatedObjectWidget); QTreeView* treeView = simulatedObjectWidget->GetDockWidget()->findChild<QTreeView*>("EMFX.SimulatedObjectWidget.TreeView"); ASSERT_TRUE(treeView); const SimulatedObjectModel* model = reinterpret_cast<SimulatedObjectModel*>(treeView->model()); const QModelIndex index = model->index(0, 0); treeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); treeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); treeView->scrollTo(index); BringUpContextMenu(treeView, treeView->visualRect(index)); QMenu* contextMenu = simulatedObjectWidget->GetDockWidget()->findChild<QMenu*>("EMFX.SimulatedObjectWidget.ContextMenu"); EXPECT_TRUE(contextMenu); QAction* removeObjectAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(removeObjectAction, contextMenu, "Remove object")); removeObjectAction->trigger(); ASSERT_EQ(actor->GetSimulatedObjectSetup()->GetNumSimulatedObjects(), 0); } TEST_F(CanAddSimulatedObjectFixture, CanAddColliderToSimulatedObjectFromInspector) { RecordProperty("test_case_id", "C20385259"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); CreateSimulateObject("sim1"); // Get the Skeleton Outliner and find the model relating to its treeview auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); ASSERT_TRUE(skeletonOutliner); QTreeView* treeView = skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); ASSERT_TRUE(treeView); const QAbstractItemModel* model = treeView->model(); QModelIndexList indexList; RecursiveGetAllChildren(treeView, model->index(0, 0), indexList); SelectIndexes(indexList, treeView, 3, 3); QDockWidget* simulatedObjectInspectorDock = EMStudio::GetMainWindow()->findChild<QDockWidget*>("EMFX.SimulatedObjectWidget.SimulatedObjectInspectorDock"); ASSERT_TRUE(simulatedObjectInspectorDock); QPushButton* addColliderButton = simulatedObjectInspectorDock->findChild<QPushButton*>("EMFX.SimulatedObjectColliderWidget.AddColliderButton"); ASSERT_TRUE(addColliderButton); // Send the left button click directly to the button QTest::mouseClick(addColliderButton, Qt::LeftButton); const size_t numCapsuleColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); EXPECT_EQ(numCapsuleColliders, 0); const size_t numSphereColliders = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere); EXPECT_EQ(numSphereColliders, 0); QMenu* contextMenu = addColliderButton->findChild<QMenu*>("EMFX.AddColliderButton.ContextMenu"); EXPECT_TRUE(contextMenu); QAction* addCapsuleAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addCapsuleAction, contextMenu, "Add capsule")); addCapsuleAction->trigger(); const size_t numCollidersAfterAddCapsule = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Capsule); ASSERT_EQ(numCollidersAfterAddCapsule, numCapsuleColliders + 1) << "Capsule collider not added."; QAction* addSphereAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(addSphereAction, contextMenu, "Add sphere")); addSphereAction->trigger(); const size_t numCollidersAfterAddSphere = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider, false, Physics::ShapeType::Sphere); ASSERT_EQ(numCollidersAfterAddSphere, numSphereColliders + 1) << "Sphere collider not added."; } TEST_F(CanAddSimulatedObjectFixture, CanAddMultipleJointsToSimulatedObject) { RecordProperty("test_case_id", "C13048818"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 7, "CanAddSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); CreateSimulateObject("ANY"); // Get the Skeleton Outliner and find the model relating to its treeview auto skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); ASSERT_TRUE(skeletonOutliner) << "Can't find SkeletonOutlinerPlugin"; QTreeView* treeView = skeletonOutliner->GetDockWidget()->findChild<QTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); ASSERT_TRUE(treeView) << "Skeleton Treeview not found"; const QAbstractItemModel* model = treeView->model(); QModelIndexList indexList; RecursiveGetAllChildren(treeView, model->index(0, 0), indexList); SelectIndexes(indexList, treeView, 3, 5); // Open the Right Click Context Menu const QRect rect = treeView->visualRect(indexList[4]); EXPECT_TRUE(rect.isValid()); BringUpContextMenu(treeView, rect); // Trace down the sub Menus to <New simulated object> and select it QMenu* contextMenu = skeletonOutliner->GetDockWidget()->findChild<QMenu*>("EMFX.SkeletonOutlinerPlugin.ContextMenu"); EXPECT_TRUE(contextMenu) << "Context Menu not found"; QAction* simulatedObjectAction; EXPECT_TRUE(UIFixture::GetActionFromContextMenu(simulatedObjectAction, contextMenu, "Add to simulated object")); QMenu* simulatedObjectMenu = simulatedObjectAction->menu(); EXPECT_TRUE(simulatedObjectMenu) << "Simulated Object Menu not found"; QAction* newSimulatedObjectAction; ASSERT_TRUE(UIFixture::GetActionFromContextMenu(newSimulatedObjectAction, simulatedObjectMenu, "ANY")) << "Can't find named simulated object in menu"; // Handle the add children dialog box. ModalPopupHandler messageBoxPopupHandler; messageBoxPopupHandler.WaitForPopupPressDialogButton<QMessageBox*>(QDialogButtonBox::No); newSimulatedObjectAction->trigger(); const EMotionFX::SimulatedObject* simulatedObject = actor->GetSimulatedObjectSetup()->GetSimulatedObject(0); EXPECT_EQ(simulatedObject->GetNumSimulatedRootJoints(), 1); EXPECT_EQ(simulatedObject->GetNumSimulatedJoints(), 3); } TEST_F(CanAddSimulatedObjectFixture, CanRemoveColliderFromSimulatedObject) { RecordProperty("test_case_id", "C13048817"); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); m_actorAsset = TestActorAssets::CreateActorAssetAndRegister<SimpleJointChainActor>(actorAssetId, 5, "CanAddSimulatedObjectActor"); Actor* actor = m_actorAsset->GetActor(); EMStudio::GetMainWindow()->ApplicationModeChanged("SimulatedObjects"); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); CreateSimulateObject("sim1"); m_skeletonOutliner = static_cast<EMotionFX::SkeletonOutlinerPlugin*>(EMStudio::GetPluginManager()->FindActivePlugin(EMotionFX::SkeletonOutlinerPlugin::CLASS_ID)); m_skeletonTreeView = m_skeletonOutliner->GetDockWidget()->findChild<ReselectingTreeView*>("EMFX.SkeletonOutlinerPlugin.SkeletonOutlinerTreeView"); m_skeletonModel = m_skeletonTreeView->model(); m_indexList.clear(); m_skeletonTreeView->RecursiveGetAllChildren(m_skeletonTreeView->model()->index(0, 0), m_indexList); // Add colliders to two joints. AddCapsuleColliderToJointIndex(3); AddCapsuleColliderToJointIndex(4); const size_t numCollidersAfterAdd = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider); EXPECT_EQ(numCollidersAfterAdd, 2); m_indexList.clear(); m_skeletonTreeView->RecursiveGetAllChildren(m_skeletonTreeView->model()->index(0, 0), m_indexList); // Reselect joint 3 and pop up the context menu for it. m_skeletonTreeView->selectionModel()->clearSelection(); SelectIndexes(m_indexList, m_skeletonTreeView, 3, 3); // Open the Right Click Context Menu const QRect rect = m_skeletonTreeView->visualRect(m_indexList[2]); EXPECT_TRUE(rect.isValid()); BringUpContextMenu(m_skeletonTreeView, rect); const QList<QMenu*> contextMenus = m_skeletonOutliner->GetDockWidget()->findChildren<QMenu*>("EMFX.SkeletonOutlinerPlugin.ContextMenu"); EXPECT_NE(contextMenus.size(), 0) << "Unable to find Skeketon Outliner context menu."; // There will be several existing menus, as the Qt event loop has not yet been run, so we need to find the latest and use that. QMenu* contextMenu = *(contextMenus.end() - 1); QAction* removeAction = contextMenu->findChild<QAction*>("EMFX.SimulatedObjectWidget.RemoveCollidersAction"); ASSERT_TRUE(removeAction); removeAction->trigger(); // Check that one of the colliders is now gone. const size_t numCollidersAfterFirstRemove = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider); ASSERT_EQ(numCollidersAfterFirstRemove, numCollidersAfterAdd - 1) << "RemoveCollider action in Simulated Object Inspector failed."; // Now do the same thing using the Simulated Object Inspector context menu. const SimulatedObjectColliderWidget* simulatedObjectColliderWidget = GetSimulatedObjectColliderWidget(); ASSERT_TRUE(simulatedObjectColliderWidget) << "SimulatedObjectColliderWidget not found."; // Select the second collider that was made earlier. m_skeletonTreeView->selectionModel()->clearSelection(); SelectIndexes(m_indexList, m_skeletonTreeView, 4, 4); const ColliderContainerWidget* colliderContainerWidget = simulatedObjectColliderWidget->findChild< ColliderContainerWidget*>(); ASSERT_TRUE(colliderContainerWidget) << "ColliderContainerWidget not found."; // Get the collider widget card from the container. const ColliderWidget* colliderWidget = colliderContainerWidget->findChild<ColliderWidget*>(); ASSERT_TRUE(colliderWidget) << "ColliderWidget not found."; const AzQtComponents::CardHeader* cardHeader = colliderWidget->findChild<AzQtComponents::CardHeader*>(); ASSERT_TRUE(cardHeader) << "ColliderWidget CardHeader not found."; const QFrame* frame = cardHeader->findChild<QFrame*>("Background"); ASSERT_TRUE(frame) << "ColliderWidget CardHeader Background Frame not found."; QPushButton* contextMenubutton = frame->findChild< QPushButton*>("ContextMenu"); ASSERT_TRUE(contextMenubutton) << "ColliderWidget ContextMenu not found."; // Pop up the context menu. QTest::mouseClick(contextMenubutton, Qt::LeftButton); // Find the delete collider button and press it. const QMenu* collilderWidgetContextMenu = colliderWidget->findChild<QMenu*>("EMFX.ColliderContainerWidget.ContextMenu"); QAction* delAction = collilderWidgetContextMenu->findChild<QAction*>("EMFX.ColliderContainerWidget.DeleteColliderAction"); delAction->trigger(); // Check that we have the number of colliders we started we expect. const size_t numCollidersAfterSecondRemove = PhysicsSetupUtils::CountColliders(actor, PhysicsSetup::SimulatedObjectCollider); ASSERT_EQ(numCollidersAfterSecondRemove, numCollidersAfterAdd - 2); } } // namespace EMotionFX
; =============================================================== ; Dec 2012 by Einar Saukas & Urusergi ; "Turbo" version (89 bytes, 25% faster) ; =============================================================== ; ; void dzx7_turbo(void *src, void *dst) ; ; Decompress the compressed block at address src to address dst. ; ; =============================================================== INCLUDE "clib_target_cfg.asm" SECTION code_compress_zx7 PUBLIC asm_dzx7_turbo asm_dzx7_turbo: ; enter : hl = void *src ; de = void *dst ; ; uses : af, bc, de, hl ld a, $80 dzx7t_copy_byte_loop: ldi ; copy literal byte dzx7t_main_loop: add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? jr nc, dzx7t_copy_byte_loop ; next bit indicates either literal or sequence ; determine number of bits used for length (Elias gamma coding) push de ld bc, 1 ld d, b dzx7t_len_size_loop: inc d add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? jr nc, dzx7t_len_size_loop jp dzx7t_len_value_start ; determine length dzx7t_len_value_loop: add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? rl c rl b jr c, dzx7t_exit ; check end marker dzx7t_len_value_start: dec d jr nz, dzx7t_len_value_loop inc bc ; adjust length ; determine offset ld e, (hl) ; load offset flag (1 bit) + offset value (7 bits) inc hl IF __z80_cpu_info & $02 defb $cb, $33 ; opcode for undocumented instruction "SLL E" aka "SLS E" ELSE sla e inc e ENDIF jr nc, dzx7t_offset_end ; if offset flag is set, load 4 extra bits add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? rl d ; insert first bit into D add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? rl d ; insert second bit into D add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? rl d ; insert third bit into D add a, a ; check next bit call z, dzx7t_load_bits ; no more bits left? ccf jr c, dzx7t_offset_end inc d ; equivalent to adding 128 to DE dzx7t_offset_end: rr e ; insert inverted fourth bit into E ; copy previous sequence ex (sp), hl ; store source, restore destination push hl ; store destination sbc hl, de ; HL = destination - offset - 1 pop de ; DE = destination ldir dzx7t_exit: pop hl ; restore source address (compressed data) jp nc, dzx7t_main_loop dzx7t_load_bits: ld a, (hl) ; load another group of 8 bits inc hl rla ret
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // // File: ILStubCache.cpp // // #include "common.h" #include "ilstubcache.h" #include "dllimport.h" #include <formattype.h> #include "jitinterface.h" #include "sigbuilder.h" #include "ngenhash.inl" #include "compile.h" #include "eventtrace.h" const char* FormatSig(MethodDesc* pMD, LoaderHeap *pHeap, AllocMemTracker *pamTracker); ILStubCache::ILStubCache(LoaderHeap *pHeap) : CClosedHashBase( #ifdef _DEBUG 3, #else 17, // CClosedHashTable will grow as necessary #endif sizeof(ILCHASHENTRY), FALSE ), m_crst(CrstStubCache, CRST_UNSAFE_ANYMODE), m_heap(pHeap), m_pStubMT(NULL) { WRAPPER_NO_CONTRACT; } void ILStubCache::Init(LoaderHeap* pHeap) { LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK(NULL == m_heap); m_heap = pHeap; } #ifndef DACCESS_COMPILE void CreateModuleIndependentSignature(LoaderHeap* pCreationHeap, AllocMemTracker* pamTracker, Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, SigTypeContext *pTypeContext, PCCOR_SIGNATURE* ppNewSig, DWORD* pcbNewSig) { CONTRACTL { STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pSigModule, NULL_NOT_OK)); PRECONDITION(CheckPointer(ppNewSig, NULL_NOT_OK)); PRECONDITION(CheckPointer(pcbNewSig, NULL_NOT_OK)); } CONTRACTL_END; SigPointer sigPtr(pSig, cbSig); SigBuilder sigBuilder; sigPtr.ConvertToInternalSignature(pSigModule, pTypeContext, &sigBuilder); DWORD cbNewSig; PVOID pConvertedSig = sigBuilder.GetSignature(&cbNewSig); PVOID pNewSig = pamTracker->Track(pCreationHeap->AllocMem(S_SIZE_T(cbNewSig))); memcpy(pNewSig, pConvertedSig, cbNewSig); *ppNewSig = (PCCOR_SIGNATURE)pNewSig; *pcbNewSig = cbNewSig; } // static MethodDesc* ILStubCache::CreateAndLinkNewILStubMethodDesc(LoaderAllocator* pAllocator, MethodTable* pMT, DWORD dwStubFlags, Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, SigTypeContext *pTypeContext, ILStubLinker* pStubLinker) { CONTRACT (MethodDesc*) { STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pMT, NULL_NOT_OK)); POSTCONDITION(CheckPointer(RETVAL)); } CONTRACT_END; AllocMemTracker amTracker; MethodDesc *pStubMD = ILStubCache::CreateNewMethodDesc(pAllocator->GetHighFrequencyHeap(), pMT, dwStubFlags, pSigModule, pSig, cbSig, pTypeContext, &amTracker); amTracker.SuppressRelease(); pStubLinker->SetStubMethodDesc(pStubMD); ILStubResolver *pResolver = pStubMD->AsDynamicMethodDesc()->GetILStubResolver(); pResolver->SetStubMethodDesc(pStubMD); { UINT maxStack; size_t cbCode = pStubLinker->Link(&maxStack); DWORD cbSig = pStubLinker->GetLocalSigSize(); COR_ILMETHOD_DECODER * pILHeader = pResolver->AllocGeneratedIL(cbCode, cbSig, maxStack); BYTE * pbBuffer = (BYTE *)pILHeader->Code; BYTE * pbLocalSig = (BYTE *)pILHeader->LocalVarSig; _ASSERTE(cbSig == pILHeader->cbLocalVarSig); size_t numEH = pStubLinker->GetNumEHClauses(); if (numEH > 0) { pStubLinker->WriteEHClauses(pResolver->AllocEHSect(numEH)); } pStubLinker->GenerateCode(pbBuffer, cbCode); pStubLinker->GetLocalSig(pbLocalSig, cbSig); pResolver->SetJitFlags(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_IL_STUB)); } pResolver->SetTokenLookupMap(pStubLinker->GetTokenLookupMap()); RETURN pStubMD; } // static MethodDesc* ILStubCache::CreateNewMethodDesc(LoaderHeap* pCreationHeap, MethodTable* pMT, DWORD dwStubFlags, Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, SigTypeContext *pTypeContext, AllocMemTracker* pamTracker) { CONTRACT (MethodDesc*) { STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pMT, NULL_NOT_OK)); POSTCONDITION(CheckPointer(RETVAL)); } CONTRACT_END; // @TODO: reuse the same chunk for multiple methods MethodDescChunk* pChunk = MethodDescChunk::CreateChunk(pCreationHeap, 1, mcDynamic, TRUE /* fNonVtableSlot */, TRUE /* fNativeCodeSlot */, FALSE /* fComPlusCallInfo */, pMT, pamTracker); // Note: The method desc memory is zero initialized DynamicMethodDesc* pMD = (DynamicMethodDesc*)pChunk->GetFirstMethodDesc(); pMD->SetMemberDef(0); pMD->SetSlot(MethodTable::NO_SLOT); // we can't ever use the slot for dynamic methods // the no metadata part of the method desc pMD->m_pszMethodName.SetValue((PTR_CUTF8)"IL_STUB"); pMD->m_dwExtendedFlags = mdPublic | DynamicMethodDesc::nomdILStub; pMD->SetTemporaryEntryPoint(pMT->GetLoaderAllocator(), pamTracker); // // convert signature to a compatible signature if needed // PCCOR_SIGNATURE pNewSig; DWORD cbNewSig; // If we are in the same module and don't have any generics, we can use the incoming signature. // Note that pTypeContext may be non-empty and the signature can still have no E_T_(M)VAR in it. // We could do a more precise check if we cared. if (pMT->GetModule() == pSigModule && (pTypeContext == NULL || pTypeContext->IsEmpty())) { pNewSig = pSig; cbNewSig = cbSig; } else { CreateModuleIndependentSignature(pCreationHeap, pamTracker, pSigModule, pSig, cbSig, pTypeContext, &pNewSig, &cbNewSig); } pMD->SetStoredMethodSig(pNewSig, cbNewSig); SigPointer sigPtr(pNewSig, cbNewSig); ULONG callConvInfo; IfFailThrow(sigPtr.GetCallingConvInfo(&callConvInfo)); if (!(callConvInfo & CORINFO_CALLCONV_HASTHIS)) { pMD->m_dwExtendedFlags |= mdStatic; pMD->SetStatic(); } pMD->m_pResolver = (ILStubResolver*)pamTracker->Track(pCreationHeap->AllocMem(S_SIZE_T(sizeof(ILStubResolver)))); #ifdef _DEBUG // Poison the ILStubResolver storage memset((void*)pMD->m_pResolver, 0xCC, sizeof(ILStubResolver)); #endif // _DEBUG pMD->m_pResolver = new (pMD->m_pResolver) ILStubResolver(); pMD->GetILStubResolver()->SetLoaderHeap(pCreationHeap); #ifdef FEATURE_ARRAYSTUB_AS_IL if (SF_IsArrayOpStub(dwStubFlags)) { pMD->GetILStubResolver()->SetStubType(ILStubResolver::ArrayOpStub); } else #endif #ifdef FEATURE_MULTICASTSTUB_AS_IL if (SF_IsMulticastDelegateStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdMulticastStub; pMD->GetILStubResolver()->SetStubType(ILStubResolver::MulticastDelegateStub); } else #endif if (SF_IsWrapperDelegateStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdWrapperDelegateStub; pMD->GetILStubResolver()->SetStubType(ILStubResolver::WrapperDelegateStub); } else #ifdef FEATURE_INSTANTIATINGSTUB_AS_IL if (SF_IsUnboxingILStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdUnboxingILStub; pMD->GetILStubResolver()->SetStubType(ILStubResolver::UnboxingILStub); } else if (SF_IsInstantiatingStub(dwStubFlags)) { pMD->GetILStubResolver()->SetStubType(ILStubResolver::InstantiatingStub); } else #endif if (SF_IsTailCallStoreArgsStub(dwStubFlags)) { pMD->GetILStubResolver()->SetStubType(ILStubResolver::TailCallStoreArgsStub); } else if (SF_IsTailCallCallTargetStub(dwStubFlags)) { pMD->GetILStubResolver()->SetStubType(ILStubResolver::TailCallCallTargetStub); } else #ifdef FEATURE_COMINTEROP if (SF_IsCOMStub(dwStubFlags)) { // mark certain types of stub MDs with random flags so ILStubManager recognizes them if (SF_IsReverseStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdReverseStub; ILStubResolver::ILStubType type = ILStubResolver::COMToCLRInteropStub; pMD->GetILStubResolver()->SetStubType(type); } else { ILStubResolver::ILStubType type = ILStubResolver::CLRToCOMInteropStub; pMD->GetILStubResolver()->SetStubType(type); } } else #endif if (SF_IsStructMarshalStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdStructMarshalStub; pMD->GetILStubResolver()->SetStubType(ILStubResolver::StructMarshalInteropStub); } else { // mark certain types of stub MDs with random flags so ILStubManager recognizes them if (SF_IsReverseStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdReverseStub | DynamicMethodDesc::nomdUnmanagedCallersOnlyStub; pMD->GetILStubResolver()->SetStubType(ILStubResolver::NativeToCLRInteropStub); } else { if (SF_IsDelegateStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdDelegateStub; } else if (SF_IsCALLIStub(dwStubFlags)) { pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdCALLIStub; } pMD->GetILStubResolver()->SetStubType(ILStubResolver::CLRToNativeInteropStub); } } // if we made it this far, we can set a more descriptive stub name #ifdef FEATURE_ARRAYSTUB_AS_IL if (SF_IsArrayOpStub(dwStubFlags)) { switch(dwStubFlags) { case ILSTUB_ARRAYOP_GET: pMD->m_pszMethodName.SetValue((PTR_CUTF8)"IL_STUB_Array_Get"); break; case ILSTUB_ARRAYOP_SET: pMD->m_pszMethodName.SetValue((PTR_CUTF8)"IL_STUB_Array_Set"); break; case ILSTUB_ARRAYOP_ADDRESS: pMD->m_pszMethodName.SetValue((PTR_CUTF8)"IL_STUB_Array_Address"); break; default: _ASSERTE(!"Unknown array il stub"); } } else #endif { pMD->m_pszMethodName.SetValue(pMD->GetILStubResolver()->GetStubMethodName()); } #ifdef _DEBUG pMD->m_pszDebugMethodName = RelativePointer<PTR_CUTF8>::GetValueAtPtr(PTR_HOST_MEMBER_TADDR(DynamicMethodDesc, pMD, m_pszMethodName)); pMD->m_pszDebugClassName = ILStubResolver::GetStubClassName(pMD); // must be called after type is set pMD->m_pszDebugMethodSignature = FormatSig(pMD, pCreationHeap, pamTracker); pMD->m_pDebugMethodTable.SetValue(pMT); #endif // _DEBUG RETURN pMD; } // // This will get or create a MethodTable in the Module/AppDomain on which // we can place a new IL stub MethodDesc. // MethodTable* ILStubCache::GetOrCreateStubMethodTable(Module* pModule) { CONTRACT (MethodTable*) { THROWS; GC_TRIGGERS; MODE_ANY; INJECT_FAULT(COMPlusThrowOM()); POSTCONDITION(CheckPointer(RETVAL)); } CONTRACT_END; #ifdef _DEBUG if (pModule->IsSystem() || pModule->GetDomain()->AsAppDomain()->IsCompilationDomain()) { // in the shared domain and compilation AD we are associated with the module CONSISTENCY_CHECK(pModule->GetILStubCache() == this); } else { // otherwise we are associated with the LoaderAllocator LoaderAllocator* pStubLoaderAllocator = LoaderAllocator::GetLoaderAllocator(this); CONSISTENCY_CHECK(pStubLoaderAllocator == pModule->GetLoaderAllocator()); } #endif // _DEBUG if (NULL == m_pStubMT) { CrstHolder ch(&m_crst); if (NULL == m_pStubMT) { AllocMemTracker amt; MethodTable* pNewMT = CreateMinimalMethodTable(pModule, m_heap, &amt); amt.SuppressRelease(); VolatileStore<MethodTable*>(&m_pStubMT, pNewMT); } } RETURN m_pStubMT; } #endif // DACCESS_COMPILE // // NGEN'ed IL stubs // // - We will never NGEN a CALLI pinvoke or vararg pinvoke // // - We will always place the IL stub MethodDesc on the same MethodTable that the // PInvoke or COM Interop call declaration lives on. // // - We will not pre-populate our runtime ILStubCache with compile-time // information (i.e. NGENed stubs are only reachable from the same NGEN image.) // // JIT'ed IL stubs // // - The ILStubCache is per-BaseDomain // // - Each BaseDomain's ILStubCache will lazily create a "minimal MethodTable" to // serve as the home for IL stub MethodDescs // // - The created MethodTables will use the Module belonging to one of the // following, based on what type of interop stub we need to create first. // // - If that stub is for a static-sig-based pinvoke, we will use the // Module belonging to that pinvoke's MethodDesc. // // - If that stub is for a CALLI or vararg pinvoke, we will use the // Module belonging to the VASigCookie that the caller supplied to us. // // It's important to point out that the Module we latch onto here has no knowledge // of the MethodTable that we've just "added" to it. There only exists a "back // pointer" to the Module from the MethodTable itself. So we're really only using // that module to answer the question of what BaseDomain the MethodTable lives in. // So as long as the BaseDomain for that module is the same as the BaseDomain the // ILStubCache lives in, I think we have a fairly consistent story here. // // We're relying on the fact that a VASigCookie may only mention types within the // corresponding module used to qualify the signature and the fact that interop // stubs may only reference CoreLib code or code related to a type mentioned in // the signature. Both of these are true unless the sig is allowed to contain // ELEMENT_TYPE_INTERNAL, which may refer to any type. // // We can only access E_T_INTERNAL through LCG, which does not permit referring // to types in other BaseDomains. // // // Places for improvement: // // - allow NGEN'ing of CALLI pinvoke and vararg pinvoke // // - pre-populate the per-BaseDomain cache with IL stubs from NGEN'ed image // MethodDesc* ILStubCache::GetStubMethodDesc( MethodDesc *pTargetMD, ILStubHashBlob* pParams, DWORD dwStubFlags, Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, AllocMemTracker* pamTracker, bool& bILStubCreator, MethodDesc *pLastMD) { CONTRACT (MethodDesc*) { STANDARD_VM_CHECK; POSTCONDITION(CheckPointer(RETVAL)); } CONTRACT_END; MethodDesc* pMD = NULL; bool bFireETWCacheHitEvent = true; #ifndef DACCESS_COMPILE ILStubHashBlob* pBlob = NULL; INDEBUG(LPCSTR pszResult = "[hit cache]"); if (SF_IsSharedStub(dwStubFlags)) { CrstHolder ch(&m_crst); // Try to find the stub ILCHASHENTRY* phe = NULL; phe = (ILCHASHENTRY*)Find((LPVOID)pParams); if (phe) { pMD = phe->m_pMethodDesc; if (pMD == pLastMD) bFireETWCacheHitEvent = false; } } if (!pMD) { // // Couldn't find it, let's make a new one. // Module *pContainingModule = pSigModule; if (pTargetMD != NULL) { // loader module may be different from signature module for generic targets pContainingModule = pTargetMD->GetLoaderModule(); } MethodTable *pStubMT = GetOrCreateStubMethodTable(pContainingModule); SigTypeContext typeContext; if (pTargetMD != NULL) { SigTypeContext::InitTypeContext(pTargetMD, &typeContext); } pMD = ILStubCache::CreateNewMethodDesc(m_heap, pStubMT, dwStubFlags, pSigModule, pSig, cbSig, &typeContext, pamTracker); if (SF_IsSharedStub(dwStubFlags)) { size_t cbSizeOfBlob = pParams->m_cbSizeOfBlob; AllocMemHolder<ILStubHashBlob> pBlobHolder( m_heap->AllocMem(S_SIZE_T(cbSizeOfBlob)) ); CrstHolder ch(&m_crst); ILCHASHENTRY* phe = NULL; bool bNew; phe = (ILCHASHENTRY*)FindOrAdd((LPVOID)pParams, bNew); bILStubCreator |= bNew; if (NULL != phe) { if (bNew) { pBlobHolder.SuppressRelease(); phe->m_pMethodDesc = pMD; pBlob = pBlobHolder; phe->m_pBlob = pBlob; _ASSERTE(pParams->m_cbSizeOfBlob == cbSizeOfBlob); memcpy(pBlob, pParams, cbSizeOfBlob); INDEBUG(pszResult = "[missed cache]"); bFireETWCacheHitEvent = false; } else { INDEBUG(pszResult = "[hit cache][wasted new MethodDesc due to race]"); } pMD = phe->m_pMethodDesc; } else { pMD = NULL; } } else { INDEBUG(pszResult = "[cache disabled for COM->CLR field access stubs]"); } } if (!pMD) { // Couldn't grow hash table due to lack of memory. COMPlusThrowOM(); } #ifdef _DEBUG CQuickBytes qbManaged; PrettyPrintSig(pSig, cbSig, "*", &qbManaged, pSigModule->GetMDImport(), NULL); LOG((LF_STUBS, LL_INFO1000, "ILSTUBCACHE: ILStubCache::GetStubMethodDesc %s StubMD: %p module: %p blob: %p sig: %s\n", pszResult, pMD, pSigModule, pBlob, qbManaged.Ptr())); #endif // _DEBUG #endif // DACCESS_COMPILE RETURN pMD; } void ILStubCache::DeleteEntry(void* pParams) { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; CrstHolder ch(&m_crst); ILCHASHENTRY* phe = NULL; phe = (ILCHASHENTRY*)Find((LPVOID)pParams); if (phe) { #ifdef _DEBUG LOG((LF_STUBS, LL_INFO1000, "ILSTUBCACHE: ILStubCache::DeleteEntry StubMD: %p\n", phe->m_pMethodDesc)); #endif Delete(pParams); } } void ILStubCache::AddMethodDescChunkWithLockTaken(MethodDesc *pMD) { CONTRACTL { STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pMD)); } CONTRACTL_END; #ifndef DACCESS_COMPILE CrstHolder ch(&m_crst); pMD->GetMethodTable()->GetClass()->AddChunkIfItHasNotBeenAdded(pMD->GetMethodDescChunk()); #endif // DACCESS_COMPILE } //--------------------------------------------------------- // Destructor //--------------------------------------------------------- ILStubCache::~ILStubCache() { } //***************************************************************************** // Hash is called with a pointer to an element in the table. You must override // this method and provide a hash algorithm for your element type. //***************************************************************************** unsigned int ILStubCache::Hash( // The key value. void const* pData) // Raw data to hash. { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; const ILStubHashBlob* pBlob = (const ILStubHashBlob *)pData; size_t cb = pBlob->m_cbSizeOfBlob - sizeof(ILStubHashBlobBase); int hash = 0; for (size_t i = 0; i < cb; i++) { hash = _rotl(hash,1) + pBlob->m_rgbBlobData[i]; } return hash; } //***************************************************************************** // Compare is used in the typical memcmp way, 0 is eqaulity, -1/1 indicate // direction of miscompare. In this system everything is always equal or not. //***************************************************************************** unsigned int ILStubCache::Compare( // 0, -1, or 1. void const* pData, // Raw key data on lookup. BYTE* pElement) // The element to compare data against. { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; const ILStubHashBlob* pBlob1 = (const ILStubHashBlob*)pData; const ILStubHashBlob* pBlob2 = (const ILStubHashBlob*)GetKey(pElement); size_t cb1 = pBlob1->m_cbSizeOfBlob - sizeof(ILStubHashBlobBase); size_t cb2 = pBlob2->m_cbSizeOfBlob - sizeof(ILStubHashBlobBase); if (cb1 != cb2) { return 1; // not equal } else { // @TODO: use memcmp for (size_t i = 0; i < cb1; i++) { if (pBlob1->m_rgbBlobData[i] != pBlob2->m_rgbBlobData[i]) { return 1; // not equal } } return 0; // equal } } //***************************************************************************** // Return true if the element is free to be used. //***************************************************************************** CClosedHashBase::ELEMENTSTATUS ILStubCache::Status( // The status of the entry. BYTE* pElement) // The element to check. { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; MethodDesc* pMD = ((ILCHASHENTRY*)pElement)->m_pMethodDesc; if (pMD == NULL) { return FREE; } else if (pMD == (MethodDesc*)(-((INT_PTR)1))) { return DELETED; } else { return USED; } } //***************************************************************************** // Sets the status of the given element. //***************************************************************************** void ILStubCache::SetStatus( BYTE* pElement, // The element to set status for. CClosedHashBase::ELEMENTSTATUS eStatus) // New status. { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; ILCHASHENTRY* phe = (ILCHASHENTRY*)pElement; switch (eStatus) { case FREE: phe->m_pMethodDesc = NULL; break; case DELETED: phe->m_pMethodDesc = (MethodDesc*)(-((INT_PTR)1)); break; default: _ASSERTE(!"MLCacheEntry::SetStatus(): Bad argument."); } } //***************************************************************************** // Returns the internal key value for an element. //***************************************************************************** void* ILStubCache::GetKey( // The data to hash on. BYTE* pElement) // The element to return data ptr for. { CONTRACTL { NOTHROW; GC_NOTRIGGER; MODE_ANY; } CONTRACTL_END; ILCHASHENTRY* phe = (ILCHASHENTRY*)pElement; return (void *)(phe->m_pBlob); } #ifdef FEATURE_PREJIT // ============================================================================ // Stub method hash entry methods // ============================================================================ PTR_MethodDesc StubMethodHashEntry::GetMethod() { LIMITED_METHOD_DAC_CONTRACT; return pMD; } PTR_MethodDesc StubMethodHashEntry::GetStubMethod() { LIMITED_METHOD_DAC_CONTRACT; return pStubMD; } #ifndef DACCESS_COMPILE void StubMethodHashEntry::SetMethodAndStub(MethodDesc *pMD, MethodDesc *pStubMD) { LIMITED_METHOD_CONTRACT; this->pMD = pMD; this->pStubMD = pStubMD; } // ============================================================================ // Stub method hash table methods // ============================================================================ /* static */ StubMethodHashTable *StubMethodHashTable::Create(LoaderAllocator *pAllocator, Module *pModule, DWORD dwNumBuckets, AllocMemTracker *pamTracker) { CONTRACTL { THROWS; GC_NOTRIGGER; INJECT_FAULT(COMPlusThrowOM();); } CONTRACTL_END LoaderHeap *pHeap = pAllocator->GetLowFrequencyHeap(); StubMethodHashTable *pThis = (StubMethodHashTable *)pamTracker->Track(pHeap->AllocMem((S_SIZE_T)sizeof(StubMethodHashTable))); new (pThis) StubMethodHashTable(pModule, pHeap, dwNumBuckets); return pThis; } // Calculate a hash value for a key static DWORD Hash(MethodDesc *pMD) { LIMITED_METHOD_CONTRACT; DWORD dwHash = 0x87654321; #define INST_HASH_ADD(_value) dwHash = ((dwHash << 5) + dwHash) ^ (_value) INST_HASH_ADD(pMD->GetMemberDef()); Instantiation inst = pMD->GetClassInstantiation(); for (DWORD i = 0; i < inst.GetNumArgs(); i++) { TypeHandle thArg = inst[i]; if (thArg.GetMethodTable()) { INST_HASH_ADD(thArg.GetCl()); Instantiation sArgInst = thArg.GetInstantiation(); for (DWORD j = 0; j < sArgInst.GetNumArgs(); j++) { TypeHandle thSubArg = sArgInst[j]; if (thSubArg.GetMethodTable()) INST_HASH_ADD(thSubArg.GetCl()); else INST_HASH_ADD(thSubArg.GetSignatureCorElementType()); } } else INST_HASH_ADD(thArg.GetSignatureCorElementType()); } return dwHash; } MethodDesc *StubMethodHashTable::FindMethodDesc(MethodDesc *pMD) { CONTRACTL { NOTHROW; GC_NOTRIGGER; FORBID_FAULT; } CONTRACTL_END MethodDesc *pMDResult = NULL; DWORD dwHash = Hash(pMD); StubMethodHashEntry_t* pSearch; LookupContext sContext; for (pSearch = BaseFindFirstEntryByHash(dwHash, &sContext); pSearch != NULL; pSearch = BaseFindNextEntryByHash(&sContext)) { if (pSearch->GetMethod() == pMD) { pMDResult = pSearch->GetStubMethod(); break; } } return pMDResult; } // Add method desc to the hash table; must not be present already void StubMethodHashTable::InsertMethodDesc(MethodDesc *pMD, MethodDesc *pStubMD) { CONTRACTL { THROWS; GC_NOTRIGGER; INJECT_FAULT(COMPlusThrowOM();); PRECONDITION(CheckPointer(pMD)); PRECONDITION(CheckPointer(pStubMD)); } CONTRACTL_END StubMethodHashEntry_t *pNewEntry = (StubMethodHashEntry_t *)BaseAllocateEntry(NULL); pNewEntry->SetMethodAndStub(pMD, pStubMD); DWORD dwHash = Hash(pMD); BaseInsertEntry(dwHash, pNewEntry); } #ifdef FEATURE_NATIVE_IMAGE_GENERATION // Save the hash table and any method descriptors referenced by it void StubMethodHashTable::Save(DataImage *image, CorProfileData *pProfileData) { WRAPPER_NO_CONTRACT; BaseSave(image, pProfileData); } void StubMethodHashTable::Fixup(DataImage *image) { WRAPPER_NO_CONTRACT; BaseFixup(image); } void StubMethodHashTable::FixupEntry(DataImage *pImage, StubMethodHashEntry_t *pEntry, void *pFixupBase, DWORD cbFixupOffset) { WRAPPER_NO_CONTRACT; pImage->FixupField(pFixupBase, cbFixupOffset + offsetof(StubMethodHashEntry_t, pMD), pEntry->GetMethod()); pImage->FixupField(pFixupBase, cbFixupOffset + offsetof(StubMethodHashEntry_t, pStubMD), pEntry->GetStubMethod()); } bool StubMethodHashTable::ShouldSave(DataImage *pImage, StubMethodHashEntry_t *pEntry) { STANDARD_VM_CONTRACT; MethodDesc *pMD = pEntry->GetMethod(); if (pMD->GetClassification() == mcInstantiated) { // save entries only for "accepted" methods if (!pImage->GetPreloader()->IsMethodInTransitiveClosureOfInstantiations(CORINFO_METHOD_HANDLE(pMD))) return false; } // Save the entry only if the native code was successfully generated for the stub if (pImage->GetCodeAddress(pEntry->GetStubMethod()) == NULL) return false; return true; } #endif // FEATURE_NATIVE_IMAGE_GENERATION #endif // !DACCESS_COMPILE #ifdef DACCESS_COMPILE void StubMethodHashTable::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) { SUPPORTS_DAC; BaseEnumMemoryRegions(flags); } void StubMethodHashTable::EnumMemoryRegionsForEntry(StubMethodHashEntry_t *pEntry, CLRDataEnumMemoryFlags flags) { SUPPORTS_DAC; if (pEntry->GetMethod().IsValid()) pEntry->GetMethod()->EnumMemoryRegions(flags); } #endif // DACCESS_COMPILE #endif // FEATURE_PREJIT
; A113582: Triangle T(n,m) read by rows: T(n,m) = (n - m)*(n - m + 1)*m*(m + 1)/4 + 1. ; Submitted by Jamie Morken(s1) ; 1,1,1,1,2,1,1,4,4,1,1,7,10,7,1,1,11,19,19,11,1,1,16,31,37,31,16,1,1,22,46,61,61,46,22,1,1,29,64,91,101,91,64,29,1,1,37,85,127,151,151,127,85,37,1,1,46,109,169,211,226,211,169,109,46,1,1,56,136,217,281,316,316,281,217,136,56,1,1,67,166,271,361,421,442,421,361,271,166,67,1,1,79,199,331,451,541,589,589,541 lpb $0 add $1,$2 trn $1,$0 mul $1,$0 add $2,1 add $2,$1 trn $0,$2 mul $1,$2 lpe mov $0,$1 div $0,4 add $0,1
_usertests: file format elf32-i386 Disassembly of section .text: 00000000 <opentest>: // simple file system tests void opentest(void) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 28 sub $0x28,%esp int fd; printf(stdout, "open test\n"); 6: a1 b4 5e 00 00 mov 0x5eb4,%eax b: c7 44 24 04 76 41 00 movl $0x4176,0x4(%esp) 12: 00 13: 89 04 24 mov %eax,(%esp) 16: e8 7d 3d 00 00 call 3d98 <printf> fd = open("echo", 0); 1b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 22: 00 23: c7 04 24 60 41 00 00 movl $0x4160,(%esp) 2a: e8 19 3c 00 00 call 3c48 <open> 2f: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 32: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 36: 79 1a jns 52 <opentest+0x52> printf(stdout, "open echo failed!\n"); 38: a1 b4 5e 00 00 mov 0x5eb4,%eax 3d: c7 44 24 04 81 41 00 movl $0x4181,0x4(%esp) 44: 00 45: 89 04 24 mov %eax,(%esp) 48: e8 4b 3d 00 00 call 3d98 <printf> exit(); 4d: e8 b6 3b 00 00 call 3c08 <exit> } close(fd); 52: 8b 45 f4 mov -0xc(%ebp),%eax 55: 89 04 24 mov %eax,(%esp) 58: e8 d3 3b 00 00 call 3c30 <close> fd = open("doesnotexist", 0); 5d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 64: 00 65: c7 04 24 94 41 00 00 movl $0x4194,(%esp) 6c: e8 d7 3b 00 00 call 3c48 <open> 71: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 74: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 78: 78 1a js 94 <opentest+0x94> printf(stdout, "open doesnotexist succeeded!\n"); 7a: a1 b4 5e 00 00 mov 0x5eb4,%eax 7f: c7 44 24 04 a1 41 00 movl $0x41a1,0x4(%esp) 86: 00 87: 89 04 24 mov %eax,(%esp) 8a: e8 09 3d 00 00 call 3d98 <printf> exit(); 8f: e8 74 3b 00 00 call 3c08 <exit> } printf(stdout, "open test ok\n"); 94: a1 b4 5e 00 00 mov 0x5eb4,%eax 99: c7 44 24 04 bf 41 00 movl $0x41bf,0x4(%esp) a0: 00 a1: 89 04 24 mov %eax,(%esp) a4: e8 ef 3c 00 00 call 3d98 <printf> } a9: c9 leave aa: c3 ret 000000ab <writetest>: void writetest(void) { ab: 55 push %ebp ac: 89 e5 mov %esp,%ebp ae: 83 ec 28 sub $0x28,%esp int fd; int i; printf(stdout, "small file test\n"); b1: a1 b4 5e 00 00 mov 0x5eb4,%eax b6: c7 44 24 04 cd 41 00 movl $0x41cd,0x4(%esp) bd: 00 be: 89 04 24 mov %eax,(%esp) c1: e8 d2 3c 00 00 call 3d98 <printf> fd = open("small", O_CREATE|O_RDWR); c6: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) cd: 00 ce: c7 04 24 de 41 00 00 movl $0x41de,(%esp) d5: e8 6e 3b 00 00 call 3c48 <open> da: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0){ dd: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) e1: 78 21 js 104 <writetest+0x59> printf(stdout, "creat small succeeded; ok\n"); e3: a1 b4 5e 00 00 mov 0x5eb4,%eax e8: c7 44 24 04 e4 41 00 movl $0x41e4,0x4(%esp) ef: 00 f0: 89 04 24 mov %eax,(%esp) f3: e8 a0 3c 00 00 call 3d98 <printf> } else { printf(stdout, "error: creat small failed!\n"); exit(); } for(i = 0; i < 100; i++){ f8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) ff: e9 9f 00 00 00 jmp 1a3 <writetest+0xf8> printf(stdout, "small file test\n"); fd = open("small", O_CREATE|O_RDWR); if(fd >= 0){ printf(stdout, "creat small succeeded; ok\n"); } else { printf(stdout, "error: creat small failed!\n"); 104: a1 b4 5e 00 00 mov 0x5eb4,%eax 109: c7 44 24 04 ff 41 00 movl $0x41ff,0x4(%esp) 110: 00 111: 89 04 24 mov %eax,(%esp) 114: e8 7f 3c 00 00 call 3d98 <printf> exit(); 119: e8 ea 3a 00 00 call 3c08 <exit> } for(i = 0; i < 100; i++){ if(write(fd, "aaaaaaaaaa", 10) != 10){ 11e: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 125: 00 126: c7 44 24 04 1b 42 00 movl $0x421b,0x4(%esp) 12d: 00 12e: 8b 45 f0 mov -0x10(%ebp),%eax 131: 89 04 24 mov %eax,(%esp) 134: e8 ef 3a 00 00 call 3c28 <write> 139: 83 f8 0a cmp $0xa,%eax 13c: 74 21 je 15f <writetest+0xb4> printf(stdout, "error: write aa %d new file failed\n", i); 13e: a1 b4 5e 00 00 mov 0x5eb4,%eax 143: 8b 55 f4 mov -0xc(%ebp),%edx 146: 89 54 24 08 mov %edx,0x8(%esp) 14a: c7 44 24 04 28 42 00 movl $0x4228,0x4(%esp) 151: 00 152: 89 04 24 mov %eax,(%esp) 155: e8 3e 3c 00 00 call 3d98 <printf> exit(); 15a: e8 a9 3a 00 00 call 3c08 <exit> } if(write(fd, "bbbbbbbbbb", 10) != 10){ 15f: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 166: 00 167: c7 44 24 04 4c 42 00 movl $0x424c,0x4(%esp) 16e: 00 16f: 8b 45 f0 mov -0x10(%ebp),%eax 172: 89 04 24 mov %eax,(%esp) 175: e8 ae 3a 00 00 call 3c28 <write> 17a: 83 f8 0a cmp $0xa,%eax 17d: 74 21 je 1a0 <writetest+0xf5> printf(stdout, "error: write bb %d new file failed\n", i); 17f: a1 b4 5e 00 00 mov 0x5eb4,%eax 184: 8b 55 f4 mov -0xc(%ebp),%edx 187: 89 54 24 08 mov %edx,0x8(%esp) 18b: c7 44 24 04 58 42 00 movl $0x4258,0x4(%esp) 192: 00 193: 89 04 24 mov %eax,(%esp) 196: e8 fd 3b 00 00 call 3d98 <printf> exit(); 19b: e8 68 3a 00 00 call 3c08 <exit> printf(stdout, "creat small succeeded; ok\n"); } else { printf(stdout, "error: creat small failed!\n"); exit(); } for(i = 0; i < 100; i++){ 1a0: ff 45 f4 incl -0xc(%ebp) 1a3: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) 1a7: 0f 8e 71 ff ff ff jle 11e <writetest+0x73> if(write(fd, "bbbbbbbbbb", 10) != 10){ printf(stdout, "error: write bb %d new file failed\n", i); exit(); } } printf(stdout, "writes ok\n"); 1ad: a1 b4 5e 00 00 mov 0x5eb4,%eax 1b2: c7 44 24 04 7c 42 00 movl $0x427c,0x4(%esp) 1b9: 00 1ba: 89 04 24 mov %eax,(%esp) 1bd: e8 d6 3b 00 00 call 3d98 <printf> close(fd); 1c2: 8b 45 f0 mov -0x10(%ebp),%eax 1c5: 89 04 24 mov %eax,(%esp) 1c8: e8 63 3a 00 00 call 3c30 <close> fd = open("small", O_RDONLY); 1cd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1d4: 00 1d5: c7 04 24 de 41 00 00 movl $0x41de,(%esp) 1dc: e8 67 3a 00 00 call 3c48 <open> 1e1: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0){ 1e4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1e8: 78 3e js 228 <writetest+0x17d> printf(stdout, "open small succeeded ok\n"); 1ea: a1 b4 5e 00 00 mov 0x5eb4,%eax 1ef: c7 44 24 04 87 42 00 movl $0x4287,0x4(%esp) 1f6: 00 1f7: 89 04 24 mov %eax,(%esp) 1fa: e8 99 3b 00 00 call 3d98 <printf> } else { printf(stdout, "error: open small failed!\n"); exit(); } i = read(fd, buf, 2000); 1ff: c7 44 24 08 d0 07 00 movl $0x7d0,0x8(%esp) 206: 00 207: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 20e: 00 20f: 8b 45 f0 mov -0x10(%ebp),%eax 212: 89 04 24 mov %eax,(%esp) 215: e8 06 3a 00 00 call 3c20 <read> 21a: 89 45 f4 mov %eax,-0xc(%ebp) if(i == 2000){ 21d: 81 7d f4 d0 07 00 00 cmpl $0x7d0,-0xc(%ebp) 224: 74 1c je 242 <writetest+0x197> 226: eb 4c jmp 274 <writetest+0x1c9> close(fd); fd = open("small", O_RDONLY); if(fd >= 0){ printf(stdout, "open small succeeded ok\n"); } else { printf(stdout, "error: open small failed!\n"); 228: a1 b4 5e 00 00 mov 0x5eb4,%eax 22d: c7 44 24 04 a0 42 00 movl $0x42a0,0x4(%esp) 234: 00 235: 89 04 24 mov %eax,(%esp) 238: e8 5b 3b 00 00 call 3d98 <printf> exit(); 23d: e8 c6 39 00 00 call 3c08 <exit> } i = read(fd, buf, 2000); if(i == 2000){ printf(stdout, "read succeeded ok\n"); 242: a1 b4 5e 00 00 mov 0x5eb4,%eax 247: c7 44 24 04 bb 42 00 movl $0x42bb,0x4(%esp) 24e: 00 24f: 89 04 24 mov %eax,(%esp) 252: e8 41 3b 00 00 call 3d98 <printf> } else { printf(stdout, "read failed\n"); exit(); } close(fd); 257: 8b 45 f0 mov -0x10(%ebp),%eax 25a: 89 04 24 mov %eax,(%esp) 25d: e8 ce 39 00 00 call 3c30 <close> if(unlink("small") < 0){ 262: c7 04 24 de 41 00 00 movl $0x41de,(%esp) 269: e8 ea 39 00 00 call 3c58 <unlink> 26e: 85 c0 test %eax,%eax 270: 78 1c js 28e <writetest+0x1e3> 272: eb 34 jmp 2a8 <writetest+0x1fd> } i = read(fd, buf, 2000); if(i == 2000){ printf(stdout, "read succeeded ok\n"); } else { printf(stdout, "read failed\n"); 274: a1 b4 5e 00 00 mov 0x5eb4,%eax 279: c7 44 24 04 ce 42 00 movl $0x42ce,0x4(%esp) 280: 00 281: 89 04 24 mov %eax,(%esp) 284: e8 0f 3b 00 00 call 3d98 <printf> exit(); 289: e8 7a 39 00 00 call 3c08 <exit> } close(fd); if(unlink("small") < 0){ printf(stdout, "unlink small failed\n"); 28e: a1 b4 5e 00 00 mov 0x5eb4,%eax 293: c7 44 24 04 db 42 00 movl $0x42db,0x4(%esp) 29a: 00 29b: 89 04 24 mov %eax,(%esp) 29e: e8 f5 3a 00 00 call 3d98 <printf> exit(); 2a3: e8 60 39 00 00 call 3c08 <exit> } printf(stdout, "small file test ok\n"); 2a8: a1 b4 5e 00 00 mov 0x5eb4,%eax 2ad: c7 44 24 04 f0 42 00 movl $0x42f0,0x4(%esp) 2b4: 00 2b5: 89 04 24 mov %eax,(%esp) 2b8: e8 db 3a 00 00 call 3d98 <printf> } 2bd: c9 leave 2be: c3 ret 000002bf <writetest1>: void writetest1(void) { 2bf: 55 push %ebp 2c0: 89 e5 mov %esp,%ebp 2c2: 83 ec 28 sub $0x28,%esp int i, fd, n; printf(stdout, "big files test\n"); 2c5: a1 b4 5e 00 00 mov 0x5eb4,%eax 2ca: c7 44 24 04 04 43 00 movl $0x4304,0x4(%esp) 2d1: 00 2d2: 89 04 24 mov %eax,(%esp) 2d5: e8 be 3a 00 00 call 3d98 <printf> fd = open("big", O_CREATE|O_RDWR); 2da: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 2e1: 00 2e2: c7 04 24 14 43 00 00 movl $0x4314,(%esp) 2e9: e8 5a 39 00 00 call 3c48 <open> 2ee: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 2f1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 2f5: 79 1a jns 311 <writetest1+0x52> printf(stdout, "error: creat big failed!\n"); 2f7: a1 b4 5e 00 00 mov 0x5eb4,%eax 2fc: c7 44 24 04 18 43 00 movl $0x4318,0x4(%esp) 303: 00 304: 89 04 24 mov %eax,(%esp) 307: e8 8c 3a 00 00 call 3d98 <printf> exit(); 30c: e8 f7 38 00 00 call 3c08 <exit> } for(i = 0; i < MAXFILE; i++){ 311: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 318: eb 50 jmp 36a <writetest1+0xab> ((int*)buf)[0] = i; 31a: b8 a0 86 00 00 mov $0x86a0,%eax 31f: 8b 55 f4 mov -0xc(%ebp),%edx 322: 89 10 mov %edx,(%eax) if(write(fd, buf, 512) != 512){ 324: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 32b: 00 32c: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 333: 00 334: 8b 45 ec mov -0x14(%ebp),%eax 337: 89 04 24 mov %eax,(%esp) 33a: e8 e9 38 00 00 call 3c28 <write> 33f: 3d 00 02 00 00 cmp $0x200,%eax 344: 74 21 je 367 <writetest1+0xa8> printf(stdout, "error: write big file failed\n", i); 346: a1 b4 5e 00 00 mov 0x5eb4,%eax 34b: 8b 55 f4 mov -0xc(%ebp),%edx 34e: 89 54 24 08 mov %edx,0x8(%esp) 352: c7 44 24 04 32 43 00 movl $0x4332,0x4(%esp) 359: 00 35a: 89 04 24 mov %eax,(%esp) 35d: e8 36 3a 00 00 call 3d98 <printf> exit(); 362: e8 a1 38 00 00 call 3c08 <exit> if(fd < 0){ printf(stdout, "error: creat big failed!\n"); exit(); } for(i = 0; i < MAXFILE; i++){ 367: ff 45 f4 incl -0xc(%ebp) 36a: 8b 45 f4 mov -0xc(%ebp),%eax 36d: 3d 8b 00 00 00 cmp $0x8b,%eax 372: 76 a6 jbe 31a <writetest1+0x5b> printf(stdout, "error: write big file failed\n", i); exit(); } } close(fd); 374: 8b 45 ec mov -0x14(%ebp),%eax 377: 89 04 24 mov %eax,(%esp) 37a: e8 b1 38 00 00 call 3c30 <close> fd = open("big", O_RDONLY); 37f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 386: 00 387: c7 04 24 14 43 00 00 movl $0x4314,(%esp) 38e: e8 b5 38 00 00 call 3c48 <open> 393: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 396: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 39a: 79 1a jns 3b6 <writetest1+0xf7> printf(stdout, "error: open big failed!\n"); 39c: a1 b4 5e 00 00 mov 0x5eb4,%eax 3a1: c7 44 24 04 50 43 00 movl $0x4350,0x4(%esp) 3a8: 00 3a9: 89 04 24 mov %eax,(%esp) 3ac: e8 e7 39 00 00 call 3d98 <printf> exit(); 3b1: e8 52 38 00 00 call 3c08 <exit> } n = 0; 3b6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(;;){ i = read(fd, buf, 512); 3bd: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 3c4: 00 3c5: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 3cc: 00 3cd: 8b 45 ec mov -0x14(%ebp),%eax 3d0: 89 04 24 mov %eax,(%esp) 3d3: e8 48 38 00 00 call 3c20 <read> 3d8: 89 45 f4 mov %eax,-0xc(%ebp) if(i == 0){ 3db: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3df: 75 2e jne 40f <writetest1+0x150> if(n == MAXFILE - 1){ 3e1: 81 7d f0 8b 00 00 00 cmpl $0x8b,-0x10(%ebp) 3e8: 0f 85 8b 00 00 00 jne 479 <writetest1+0x1ba> printf(stdout, "read only %d blocks from big", n); 3ee: a1 b4 5e 00 00 mov 0x5eb4,%eax 3f3: 8b 55 f0 mov -0x10(%ebp),%edx 3f6: 89 54 24 08 mov %edx,0x8(%esp) 3fa: c7 44 24 04 69 43 00 movl $0x4369,0x4(%esp) 401: 00 402: 89 04 24 mov %eax,(%esp) 405: e8 8e 39 00 00 call 3d98 <printf> exit(); 40a: e8 f9 37 00 00 call 3c08 <exit> } break; } else if(i != 512){ 40f: 81 7d f4 00 02 00 00 cmpl $0x200,-0xc(%ebp) 416: 74 21 je 439 <writetest1+0x17a> printf(stdout, "read failed %d\n", i); 418: a1 b4 5e 00 00 mov 0x5eb4,%eax 41d: 8b 55 f4 mov -0xc(%ebp),%edx 420: 89 54 24 08 mov %edx,0x8(%esp) 424: c7 44 24 04 86 43 00 movl $0x4386,0x4(%esp) 42b: 00 42c: 89 04 24 mov %eax,(%esp) 42f: e8 64 39 00 00 call 3d98 <printf> exit(); 434: e8 cf 37 00 00 call 3c08 <exit> } if(((int*)buf)[0] != n){ 439: b8 a0 86 00 00 mov $0x86a0,%eax 43e: 8b 00 mov (%eax),%eax 440: 3b 45 f0 cmp -0x10(%ebp),%eax 443: 74 2c je 471 <writetest1+0x1b2> printf(stdout, "read content of block %d is %d\n", n, ((int*)buf)[0]); 445: b8 a0 86 00 00 mov $0x86a0,%eax } else if(i != 512){ printf(stdout, "read failed %d\n", i); exit(); } if(((int*)buf)[0] != n){ printf(stdout, "read content of block %d is %d\n", 44a: 8b 10 mov (%eax),%edx 44c: a1 b4 5e 00 00 mov 0x5eb4,%eax 451: 89 54 24 0c mov %edx,0xc(%esp) 455: 8b 55 f0 mov -0x10(%ebp),%edx 458: 89 54 24 08 mov %edx,0x8(%esp) 45c: c7 44 24 04 98 43 00 movl $0x4398,0x4(%esp) 463: 00 464: 89 04 24 mov %eax,(%esp) 467: e8 2c 39 00 00 call 3d98 <printf> n, ((int*)buf)[0]); exit(); 46c: e8 97 37 00 00 call 3c08 <exit> } n++; 471: ff 45 f0 incl -0x10(%ebp) } 474: e9 44 ff ff ff jmp 3bd <writetest1+0xfe> if(i == 0){ if(n == MAXFILE - 1){ printf(stdout, "read only %d blocks from big", n); exit(); } break; 479: 90 nop n, ((int*)buf)[0]); exit(); } n++; } close(fd); 47a: 8b 45 ec mov -0x14(%ebp),%eax 47d: 89 04 24 mov %eax,(%esp) 480: e8 ab 37 00 00 call 3c30 <close> if(unlink("big") < 0){ 485: c7 04 24 14 43 00 00 movl $0x4314,(%esp) 48c: e8 c7 37 00 00 call 3c58 <unlink> 491: 85 c0 test %eax,%eax 493: 79 1a jns 4af <writetest1+0x1f0> printf(stdout, "unlink big failed\n"); 495: a1 b4 5e 00 00 mov 0x5eb4,%eax 49a: c7 44 24 04 b8 43 00 movl $0x43b8,0x4(%esp) 4a1: 00 4a2: 89 04 24 mov %eax,(%esp) 4a5: e8 ee 38 00 00 call 3d98 <printf> exit(); 4aa: e8 59 37 00 00 call 3c08 <exit> } printf(stdout, "big files ok\n"); 4af: a1 b4 5e 00 00 mov 0x5eb4,%eax 4b4: c7 44 24 04 cb 43 00 movl $0x43cb,0x4(%esp) 4bb: 00 4bc: 89 04 24 mov %eax,(%esp) 4bf: e8 d4 38 00 00 call 3d98 <printf> } 4c4: c9 leave 4c5: c3 ret 000004c6 <createtest>: void createtest(void) { 4c6: 55 push %ebp 4c7: 89 e5 mov %esp,%ebp 4c9: 83 ec 28 sub $0x28,%esp int i, fd; printf(stdout, "many creates, followed by unlink test\n"); 4cc: a1 b4 5e 00 00 mov 0x5eb4,%eax 4d1: c7 44 24 04 dc 43 00 movl $0x43dc,0x4(%esp) 4d8: 00 4d9: 89 04 24 mov %eax,(%esp) 4dc: e8 b7 38 00 00 call 3d98 <printf> name[0] = 'a'; 4e1: c6 05 a0 a6 00 00 61 movb $0x61,0xa6a0 name[2] = '\0'; 4e8: c6 05 a2 a6 00 00 00 movb $0x0,0xa6a2 for(i = 0; i < 52; i++){ 4ef: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 4f6: eb 30 jmp 528 <createtest+0x62> name[1] = '0' + i; 4f8: 8b 45 f4 mov -0xc(%ebp),%eax 4fb: 83 c0 30 add $0x30,%eax 4fe: a2 a1 a6 00 00 mov %al,0xa6a1 fd = open(name, O_CREATE|O_RDWR); 503: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 50a: 00 50b: c7 04 24 a0 a6 00 00 movl $0xa6a0,(%esp) 512: e8 31 37 00 00 call 3c48 <open> 517: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 51a: 8b 45 f0 mov -0x10(%ebp),%eax 51d: 89 04 24 mov %eax,(%esp) 520: e8 0b 37 00 00 call 3c30 <close> printf(stdout, "many creates, followed by unlink test\n"); name[0] = 'a'; name[2] = '\0'; for(i = 0; i < 52; i++){ 525: ff 45 f4 incl -0xc(%ebp) 528: 83 7d f4 33 cmpl $0x33,-0xc(%ebp) 52c: 7e ca jle 4f8 <createtest+0x32> name[1] = '0' + i; fd = open(name, O_CREATE|O_RDWR); close(fd); } name[0] = 'a'; 52e: c6 05 a0 a6 00 00 61 movb $0x61,0xa6a0 name[2] = '\0'; 535: c6 05 a2 a6 00 00 00 movb $0x0,0xa6a2 for(i = 0; i < 52; i++){ 53c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 543: eb 1a jmp 55f <createtest+0x99> name[1] = '0' + i; 545: 8b 45 f4 mov -0xc(%ebp),%eax 548: 83 c0 30 add $0x30,%eax 54b: a2 a1 a6 00 00 mov %al,0xa6a1 unlink(name); 550: c7 04 24 a0 a6 00 00 movl $0xa6a0,(%esp) 557: e8 fc 36 00 00 call 3c58 <unlink> fd = open(name, O_CREATE|O_RDWR); close(fd); } name[0] = 'a'; name[2] = '\0'; for(i = 0; i < 52; i++){ 55c: ff 45 f4 incl -0xc(%ebp) 55f: 83 7d f4 33 cmpl $0x33,-0xc(%ebp) 563: 7e e0 jle 545 <createtest+0x7f> name[1] = '0' + i; unlink(name); } printf(stdout, "many creates, followed by unlink; ok\n"); 565: a1 b4 5e 00 00 mov 0x5eb4,%eax 56a: c7 44 24 04 04 44 00 movl $0x4404,0x4(%esp) 571: 00 572: 89 04 24 mov %eax,(%esp) 575: e8 1e 38 00 00 call 3d98 <printf> } 57a: c9 leave 57b: c3 ret 0000057c <dirtest>: void dirtest(void) { 57c: 55 push %ebp 57d: 89 e5 mov %esp,%ebp 57f: 83 ec 18 sub $0x18,%esp printf(stdout, "mkdir test\n"); 582: a1 b4 5e 00 00 mov 0x5eb4,%eax 587: c7 44 24 04 2a 44 00 movl $0x442a,0x4(%esp) 58e: 00 58f: 89 04 24 mov %eax,(%esp) 592: e8 01 38 00 00 call 3d98 <printf> if(mkdir("dir0") < 0){ 597: c7 04 24 36 44 00 00 movl $0x4436,(%esp) 59e: e8 cd 36 00 00 call 3c70 <mkdir> 5a3: 85 c0 test %eax,%eax 5a5: 79 1a jns 5c1 <dirtest+0x45> printf(stdout, "mkdir failed\n"); 5a7: a1 b4 5e 00 00 mov 0x5eb4,%eax 5ac: c7 44 24 04 3b 44 00 movl $0x443b,0x4(%esp) 5b3: 00 5b4: 89 04 24 mov %eax,(%esp) 5b7: e8 dc 37 00 00 call 3d98 <printf> exit(); 5bc: e8 47 36 00 00 call 3c08 <exit> } if(chdir("dir0") < 0){ 5c1: c7 04 24 36 44 00 00 movl $0x4436,(%esp) 5c8: e8 ab 36 00 00 call 3c78 <chdir> 5cd: 85 c0 test %eax,%eax 5cf: 79 1a jns 5eb <dirtest+0x6f> printf(stdout, "chdir dir0 failed\n"); 5d1: a1 b4 5e 00 00 mov 0x5eb4,%eax 5d6: c7 44 24 04 49 44 00 movl $0x4449,0x4(%esp) 5dd: 00 5de: 89 04 24 mov %eax,(%esp) 5e1: e8 b2 37 00 00 call 3d98 <printf> exit(); 5e6: e8 1d 36 00 00 call 3c08 <exit> } if(chdir("..") < 0){ 5eb: c7 04 24 5c 44 00 00 movl $0x445c,(%esp) 5f2: e8 81 36 00 00 call 3c78 <chdir> 5f7: 85 c0 test %eax,%eax 5f9: 79 1a jns 615 <dirtest+0x99> printf(stdout, "chdir .. failed\n"); 5fb: a1 b4 5e 00 00 mov 0x5eb4,%eax 600: c7 44 24 04 5f 44 00 movl $0x445f,0x4(%esp) 607: 00 608: 89 04 24 mov %eax,(%esp) 60b: e8 88 37 00 00 call 3d98 <printf> exit(); 610: e8 f3 35 00 00 call 3c08 <exit> } if(unlink("dir0") < 0){ 615: c7 04 24 36 44 00 00 movl $0x4436,(%esp) 61c: e8 37 36 00 00 call 3c58 <unlink> 621: 85 c0 test %eax,%eax 623: 79 1a jns 63f <dirtest+0xc3> printf(stdout, "unlink dir0 failed\n"); 625: a1 b4 5e 00 00 mov 0x5eb4,%eax 62a: c7 44 24 04 70 44 00 movl $0x4470,0x4(%esp) 631: 00 632: 89 04 24 mov %eax,(%esp) 635: e8 5e 37 00 00 call 3d98 <printf> exit(); 63a: e8 c9 35 00 00 call 3c08 <exit> } printf(stdout, "mkdir test\n"); 63f: a1 b4 5e 00 00 mov 0x5eb4,%eax 644: c7 44 24 04 2a 44 00 movl $0x442a,0x4(%esp) 64b: 00 64c: 89 04 24 mov %eax,(%esp) 64f: e8 44 37 00 00 call 3d98 <printf> } 654: c9 leave 655: c3 ret 00000656 <exectest>: void exectest(void) { 656: 55 push %ebp 657: 89 e5 mov %esp,%ebp 659: 83 ec 18 sub $0x18,%esp printf(stdout, "exec test\n"); 65c: a1 b4 5e 00 00 mov 0x5eb4,%eax 661: c7 44 24 04 84 44 00 movl $0x4484,0x4(%esp) 668: 00 669: 89 04 24 mov %eax,(%esp) 66c: e8 27 37 00 00 call 3d98 <printf> if(exec("echo", echoargv) < 0){ 671: c7 44 24 04 a0 5e 00 movl $0x5ea0,0x4(%esp) 678: 00 679: c7 04 24 60 41 00 00 movl $0x4160,(%esp) 680: e8 bb 35 00 00 call 3c40 <exec> 685: 85 c0 test %eax,%eax 687: 79 1a jns 6a3 <exectest+0x4d> printf(stdout, "exec echo failed\n"); 689: a1 b4 5e 00 00 mov 0x5eb4,%eax 68e: c7 44 24 04 8f 44 00 movl $0x448f,0x4(%esp) 695: 00 696: 89 04 24 mov %eax,(%esp) 699: e8 fa 36 00 00 call 3d98 <printf> exit(); 69e: e8 65 35 00 00 call 3c08 <exit> } } 6a3: c9 leave 6a4: c3 ret 000006a5 <pipe1>: // simple fork and pipe read/write void pipe1(void) { 6a5: 55 push %ebp 6a6: 89 e5 mov %esp,%ebp 6a8: 83 ec 38 sub $0x38,%esp int fds[2], pid; int seq, i, n, cc, total; if(pipe(fds) != 0){ 6ab: 8d 45 d8 lea -0x28(%ebp),%eax 6ae: 89 04 24 mov %eax,(%esp) 6b1: e8 62 35 00 00 call 3c18 <pipe> 6b6: 85 c0 test %eax,%eax 6b8: 74 19 je 6d3 <pipe1+0x2e> printf(1, "pipe() failed\n"); 6ba: c7 44 24 04 a1 44 00 movl $0x44a1,0x4(%esp) 6c1: 00 6c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 6c9: e8 ca 36 00 00 call 3d98 <printf> exit(); 6ce: e8 35 35 00 00 call 3c08 <exit> } pid = fork(); 6d3: e8 28 35 00 00 call 3c00 <fork> 6d8: 89 45 e0 mov %eax,-0x20(%ebp) seq = 0; 6db: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) if(pid == 0){ 6e2: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 6e6: 0f 85 83 00 00 00 jne 76f <pipe1+0xca> close(fds[0]); 6ec: 8b 45 d8 mov -0x28(%ebp),%eax 6ef: 89 04 24 mov %eax,(%esp) 6f2: e8 39 35 00 00 call 3c30 <close> for(n = 0; n < 5; n++){ 6f7: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 6fe: eb 64 jmp 764 <pipe1+0xbf> for(i = 0; i < 1033; i++) 700: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 707: eb 14 jmp 71d <pipe1+0x78> buf[i] = seq++; 709: 8b 45 f4 mov -0xc(%ebp),%eax 70c: 8b 55 f0 mov -0x10(%ebp),%edx 70f: 81 c2 a0 86 00 00 add $0x86a0,%edx 715: 88 02 mov %al,(%edx) 717: ff 45 f4 incl -0xc(%ebp) pid = fork(); seq = 0; if(pid == 0){ close(fds[0]); for(n = 0; n < 5; n++){ for(i = 0; i < 1033; i++) 71a: ff 45 f0 incl -0x10(%ebp) 71d: 81 7d f0 08 04 00 00 cmpl $0x408,-0x10(%ebp) 724: 7e e3 jle 709 <pipe1+0x64> buf[i] = seq++; if(write(fds[1], buf, 1033) != 1033){ 726: 8b 45 dc mov -0x24(%ebp),%eax 729: c7 44 24 08 09 04 00 movl $0x409,0x8(%esp) 730: 00 731: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 738: 00 739: 89 04 24 mov %eax,(%esp) 73c: e8 e7 34 00 00 call 3c28 <write> 741: 3d 09 04 00 00 cmp $0x409,%eax 746: 74 19 je 761 <pipe1+0xbc> printf(1, "pipe1 oops 1\n"); 748: c7 44 24 04 b0 44 00 movl $0x44b0,0x4(%esp) 74f: 00 750: c7 04 24 01 00 00 00 movl $0x1,(%esp) 757: e8 3c 36 00 00 call 3d98 <printf> exit(); 75c: e8 a7 34 00 00 call 3c08 <exit> } pid = fork(); seq = 0; if(pid == 0){ close(fds[0]); for(n = 0; n < 5; n++){ 761: ff 45 ec incl -0x14(%ebp) 764: 83 7d ec 04 cmpl $0x4,-0x14(%ebp) 768: 7e 96 jle 700 <pipe1+0x5b> if(write(fds[1], buf, 1033) != 1033){ printf(1, "pipe1 oops 1\n"); exit(); } } exit(); 76a: e8 99 34 00 00 call 3c08 <exit> } else if(pid > 0){ 76f: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) 773: 0f 8e f9 00 00 00 jle 872 <pipe1+0x1cd> close(fds[1]); 779: 8b 45 dc mov -0x24(%ebp),%eax 77c: 89 04 24 mov %eax,(%esp) 77f: e8 ac 34 00 00 call 3c30 <close> total = 0; 784: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) cc = 1; 78b: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp) while((n = read(fds[0], buf, cc)) > 0){ 792: eb 68 jmp 7fc <pipe1+0x157> for(i = 0; i < n; i++){ 794: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 79b: eb 3d jmp 7da <pipe1+0x135> if((buf[i] & 0xff) != (seq++ & 0xff)){ 79d: 8b 45 f0 mov -0x10(%ebp),%eax 7a0: 05 a0 86 00 00 add $0x86a0,%eax 7a5: 8a 00 mov (%eax),%al 7a7: 0f be c0 movsbl %al,%eax 7aa: 33 45 f4 xor -0xc(%ebp),%eax 7ad: 25 ff 00 00 00 and $0xff,%eax 7b2: 85 c0 test %eax,%eax 7b4: 0f 95 c0 setne %al 7b7: ff 45 f4 incl -0xc(%ebp) 7ba: 84 c0 test %al,%al 7bc: 74 19 je 7d7 <pipe1+0x132> printf(1, "pipe1 oops 2\n"); 7be: c7 44 24 04 be 44 00 movl $0x44be,0x4(%esp) 7c5: 00 7c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 7cd: e8 c6 35 00 00 call 3d98 <printf> 7d2: e9 b4 00 00 00 jmp 88b <pipe1+0x1e6> } else if(pid > 0){ close(fds[1]); total = 0; cc = 1; while((n = read(fds[0], buf, cc)) > 0){ for(i = 0; i < n; i++){ 7d7: ff 45 f0 incl -0x10(%ebp) 7da: 8b 45 f0 mov -0x10(%ebp),%eax 7dd: 3b 45 ec cmp -0x14(%ebp),%eax 7e0: 7c bb jl 79d <pipe1+0xf8> if((buf[i] & 0xff) != (seq++ & 0xff)){ printf(1, "pipe1 oops 2\n"); return; } } total += n; 7e2: 8b 45 ec mov -0x14(%ebp),%eax 7e5: 01 45 e4 add %eax,-0x1c(%ebp) cc = cc * 2; 7e8: d1 65 e8 shll -0x18(%ebp) if(cc > sizeof(buf)) 7eb: 8b 45 e8 mov -0x18(%ebp),%eax 7ee: 3d 00 20 00 00 cmp $0x2000,%eax 7f3: 76 07 jbe 7fc <pipe1+0x157> cc = sizeof(buf); 7f5: c7 45 e8 00 20 00 00 movl $0x2000,-0x18(%ebp) exit(); } else if(pid > 0){ close(fds[1]); total = 0; cc = 1; while((n = read(fds[0], buf, cc)) > 0){ 7fc: 8b 45 d8 mov -0x28(%ebp),%eax 7ff: 8b 55 e8 mov -0x18(%ebp),%edx 802: 89 54 24 08 mov %edx,0x8(%esp) 806: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 80d: 00 80e: 89 04 24 mov %eax,(%esp) 811: e8 0a 34 00 00 call 3c20 <read> 816: 89 45 ec mov %eax,-0x14(%ebp) 819: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 81d: 0f 8f 71 ff ff ff jg 794 <pipe1+0xef> total += n; cc = cc * 2; if(cc > sizeof(buf)) cc = sizeof(buf); } if(total != 5 * 1033){ 823: 81 7d e4 2d 14 00 00 cmpl $0x142d,-0x1c(%ebp) 82a: 74 20 je 84c <pipe1+0x1a7> printf(1, "pipe1 oops 3 total %d\n", total); 82c: 8b 45 e4 mov -0x1c(%ebp),%eax 82f: 89 44 24 08 mov %eax,0x8(%esp) 833: c7 44 24 04 cc 44 00 movl $0x44cc,0x4(%esp) 83a: 00 83b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 842: e8 51 35 00 00 call 3d98 <printf> exit(); 847: e8 bc 33 00 00 call 3c08 <exit> } close(fds[0]); 84c: 8b 45 d8 mov -0x28(%ebp),%eax 84f: 89 04 24 mov %eax,(%esp) 852: e8 d9 33 00 00 call 3c30 <close> wait(); 857: e8 b4 33 00 00 call 3c10 <wait> } else { printf(1, "fork() failed\n"); exit(); } printf(1, "pipe1 ok\n"); 85c: c7 44 24 04 e3 44 00 movl $0x44e3,0x4(%esp) 863: 00 864: c7 04 24 01 00 00 00 movl $0x1,(%esp) 86b: e8 28 35 00 00 call 3d98 <printf> 870: eb 19 jmp 88b <pipe1+0x1e6> exit(); } close(fds[0]); wait(); } else { printf(1, "fork() failed\n"); 872: c7 44 24 04 ed 44 00 movl $0x44ed,0x4(%esp) 879: 00 87a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 881: e8 12 35 00 00 call 3d98 <printf> exit(); 886: e8 7d 33 00 00 call 3c08 <exit> } printf(1, "pipe1 ok\n"); } 88b: c9 leave 88c: c3 ret 0000088d <preempt>: // meant to be run w/ at most two CPUs void preempt(void) { 88d: 55 push %ebp 88e: 89 e5 mov %esp,%ebp 890: 83 ec 38 sub $0x38,%esp int pid1, pid2, pid3; int pfds[2]; printf(1, "preempt: "); 893: c7 44 24 04 fc 44 00 movl $0x44fc,0x4(%esp) 89a: 00 89b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8a2: e8 f1 34 00 00 call 3d98 <printf> pid1 = fork(); 8a7: e8 54 33 00 00 call 3c00 <fork> 8ac: 89 45 f4 mov %eax,-0xc(%ebp) if(pid1 == 0) 8af: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8b3: 75 02 jne 8b7 <preempt+0x2a> for(;;) ; 8b5: eb fe jmp 8b5 <preempt+0x28> pid2 = fork(); 8b7: e8 44 33 00 00 call 3c00 <fork> 8bc: 89 45 f0 mov %eax,-0x10(%ebp) if(pid2 == 0) 8bf: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8c3: 75 02 jne 8c7 <preempt+0x3a> for(;;) ; 8c5: eb fe jmp 8c5 <preempt+0x38> pipe(pfds); 8c7: 8d 45 e4 lea -0x1c(%ebp),%eax 8ca: 89 04 24 mov %eax,(%esp) 8cd: e8 46 33 00 00 call 3c18 <pipe> pid3 = fork(); 8d2: e8 29 33 00 00 call 3c00 <fork> 8d7: 89 45 ec mov %eax,-0x14(%ebp) if(pid3 == 0){ 8da: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 8de: 75 4c jne 92c <preempt+0x9f> close(pfds[0]); 8e0: 8b 45 e4 mov -0x1c(%ebp),%eax 8e3: 89 04 24 mov %eax,(%esp) 8e6: e8 45 33 00 00 call 3c30 <close> if(write(pfds[1], "x", 1) != 1) 8eb: 8b 45 e8 mov -0x18(%ebp),%eax 8ee: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 8f5: 00 8f6: c7 44 24 04 06 45 00 movl $0x4506,0x4(%esp) 8fd: 00 8fe: 89 04 24 mov %eax,(%esp) 901: e8 22 33 00 00 call 3c28 <write> 906: 83 f8 01 cmp $0x1,%eax 909: 74 14 je 91f <preempt+0x92> printf(1, "preempt write error"); 90b: c7 44 24 04 08 45 00 movl $0x4508,0x4(%esp) 912: 00 913: c7 04 24 01 00 00 00 movl $0x1,(%esp) 91a: e8 79 34 00 00 call 3d98 <printf> close(pfds[1]); 91f: 8b 45 e8 mov -0x18(%ebp),%eax 922: 89 04 24 mov %eax,(%esp) 925: e8 06 33 00 00 call 3c30 <close> for(;;) ; 92a: eb fe jmp 92a <preempt+0x9d> } close(pfds[1]); 92c: 8b 45 e8 mov -0x18(%ebp),%eax 92f: 89 04 24 mov %eax,(%esp) 932: e8 f9 32 00 00 call 3c30 <close> if(read(pfds[0], buf, sizeof(buf)) != 1){ 937: 8b 45 e4 mov -0x1c(%ebp),%eax 93a: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 941: 00 942: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 949: 00 94a: 89 04 24 mov %eax,(%esp) 94d: e8 ce 32 00 00 call 3c20 <read> 952: 83 f8 01 cmp $0x1,%eax 955: 74 16 je 96d <preempt+0xe0> printf(1, "preempt read error"); 957: c7 44 24 04 1c 45 00 movl $0x451c,0x4(%esp) 95e: 00 95f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 966: e8 2d 34 00 00 call 3d98 <printf> 96b: eb 77 jmp 9e4 <preempt+0x157> return; } close(pfds[0]); 96d: 8b 45 e4 mov -0x1c(%ebp),%eax 970: 89 04 24 mov %eax,(%esp) 973: e8 b8 32 00 00 call 3c30 <close> printf(1, "kill... "); 978: c7 44 24 04 2f 45 00 movl $0x452f,0x4(%esp) 97f: 00 980: c7 04 24 01 00 00 00 movl $0x1,(%esp) 987: e8 0c 34 00 00 call 3d98 <printf> kill(pid1); 98c: 8b 45 f4 mov -0xc(%ebp),%eax 98f: 89 04 24 mov %eax,(%esp) 992: e8 a1 32 00 00 call 3c38 <kill> kill(pid2); 997: 8b 45 f0 mov -0x10(%ebp),%eax 99a: 89 04 24 mov %eax,(%esp) 99d: e8 96 32 00 00 call 3c38 <kill> kill(pid3); 9a2: 8b 45 ec mov -0x14(%ebp),%eax 9a5: 89 04 24 mov %eax,(%esp) 9a8: e8 8b 32 00 00 call 3c38 <kill> printf(1, "wait... "); 9ad: c7 44 24 04 38 45 00 movl $0x4538,0x4(%esp) 9b4: 00 9b5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 9bc: e8 d7 33 00 00 call 3d98 <printf> wait(); 9c1: e8 4a 32 00 00 call 3c10 <wait> wait(); 9c6: e8 45 32 00 00 call 3c10 <wait> wait(); 9cb: e8 40 32 00 00 call 3c10 <wait> printf(1, "preempt ok\n"); 9d0: c7 44 24 04 41 45 00 movl $0x4541,0x4(%esp) 9d7: 00 9d8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 9df: e8 b4 33 00 00 call 3d98 <printf> } 9e4: c9 leave 9e5: c3 ret 000009e6 <exitwait>: // try to find any races between exit and wait void exitwait(void) { 9e6: 55 push %ebp 9e7: 89 e5 mov %esp,%ebp 9e9: 83 ec 28 sub $0x28,%esp int i, pid; for(i = 0; i < 100; i++){ 9ec: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 9f3: eb 52 jmp a47 <exitwait+0x61> pid = fork(); 9f5: e8 06 32 00 00 call 3c00 <fork> 9fa: 89 45 f0 mov %eax,-0x10(%ebp) if(pid < 0){ 9fd: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) a01: 79 16 jns a19 <exitwait+0x33> printf(1, "fork failed\n"); a03: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) a0a: 00 a0b: c7 04 24 01 00 00 00 movl $0x1,(%esp) a12: e8 81 33 00 00 call 3d98 <printf> return; a17: eb 48 jmp a61 <exitwait+0x7b> } if(pid){ a19: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) a1d: 74 20 je a3f <exitwait+0x59> if(wait() != pid){ a1f: e8 ec 31 00 00 call 3c10 <wait> a24: 3b 45 f0 cmp -0x10(%ebp),%eax a27: 74 1b je a44 <exitwait+0x5e> printf(1, "wait wrong pid\n"); a29: c7 44 24 04 5a 45 00 movl $0x455a,0x4(%esp) a30: 00 a31: c7 04 24 01 00 00 00 movl $0x1,(%esp) a38: e8 5b 33 00 00 call 3d98 <printf> return; a3d: eb 22 jmp a61 <exitwait+0x7b> } } else { exit(); a3f: e8 c4 31 00 00 call 3c08 <exit> void exitwait(void) { int i, pid; for(i = 0; i < 100; i++){ a44: ff 45 f4 incl -0xc(%ebp) a47: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) a4b: 7e a8 jle 9f5 <exitwait+0xf> } } else { exit(); } } printf(1, "exitwait ok\n"); a4d: c7 44 24 04 6a 45 00 movl $0x456a,0x4(%esp) a54: 00 a55: c7 04 24 01 00 00 00 movl $0x1,(%esp) a5c: e8 37 33 00 00 call 3d98 <printf> } a61: c9 leave a62: c3 ret 00000a63 <mem>: void mem(void) { a63: 55 push %ebp a64: 89 e5 mov %esp,%ebp a66: 83 ec 28 sub $0x28,%esp void *m1, *m2; int pid, ppid; printf(1, "mem test\n"); a69: c7 44 24 04 77 45 00 movl $0x4577,0x4(%esp) a70: 00 a71: c7 04 24 01 00 00 00 movl $0x1,(%esp) a78: e8 1b 33 00 00 call 3d98 <printf> ppid = getpid(); a7d: e8 06 32 00 00 call 3c88 <getpid> a82: 89 45 f0 mov %eax,-0x10(%ebp) if((pid = fork()) == 0){ a85: e8 76 31 00 00 call 3c00 <fork> a8a: 89 45 ec mov %eax,-0x14(%ebp) a8d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) a91: 0f 85 aa 00 00 00 jne b41 <mem+0xde> m1 = 0; a97: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) while((m2 = malloc(10001)) != 0){ a9e: eb 0e jmp aae <mem+0x4b> *(char**)m2 = m1; aa0: 8b 45 e8 mov -0x18(%ebp),%eax aa3: 8b 55 f4 mov -0xc(%ebp),%edx aa6: 89 10 mov %edx,(%eax) m1 = m2; aa8: 8b 45 e8 mov -0x18(%ebp),%eax aab: 89 45 f4 mov %eax,-0xc(%ebp) printf(1, "mem test\n"); ppid = getpid(); if((pid = fork()) == 0){ m1 = 0; while((m2 = malloc(10001)) != 0){ aae: c7 04 24 11 27 00 00 movl $0x2711,(%esp) ab5: e8 c7 35 00 00 call 4081 <malloc> aba: 89 45 e8 mov %eax,-0x18(%ebp) abd: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) ac1: 75 dd jne aa0 <mem+0x3d> *(char**)m2 = m1; m1 = m2; } while(m1){ ac3: eb 19 jmp ade <mem+0x7b> m2 = *(char**)m1; ac5: 8b 45 f4 mov -0xc(%ebp),%eax ac8: 8b 00 mov (%eax),%eax aca: 89 45 e8 mov %eax,-0x18(%ebp) free(m1); acd: 8b 45 f4 mov -0xc(%ebp),%eax ad0: 89 04 24 mov %eax,(%esp) ad3: e8 70 34 00 00 call 3f48 <free> m1 = m2; ad8: 8b 45 e8 mov -0x18(%ebp),%eax adb: 89 45 f4 mov %eax,-0xc(%ebp) m1 = 0; while((m2 = malloc(10001)) != 0){ *(char**)m2 = m1; m1 = m2; } while(m1){ ade: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) ae2: 75 e1 jne ac5 <mem+0x62> m2 = *(char**)m1; free(m1); m1 = m2; } m1 = malloc(1024*20); ae4: c7 04 24 00 50 00 00 movl $0x5000,(%esp) aeb: e8 91 35 00 00 call 4081 <malloc> af0: 89 45 f4 mov %eax,-0xc(%ebp) if(m1 == 0){ af3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) af7: 75 24 jne b1d <mem+0xba> printf(1, "couldn't allocate mem?!!\n"); af9: c7 44 24 04 81 45 00 movl $0x4581,0x4(%esp) b00: 00 b01: c7 04 24 01 00 00 00 movl $0x1,(%esp) b08: e8 8b 32 00 00 call 3d98 <printf> kill(ppid); b0d: 8b 45 f0 mov -0x10(%ebp),%eax b10: 89 04 24 mov %eax,(%esp) b13: e8 20 31 00 00 call 3c38 <kill> exit(); b18: e8 eb 30 00 00 call 3c08 <exit> } free(m1); b1d: 8b 45 f4 mov -0xc(%ebp),%eax b20: 89 04 24 mov %eax,(%esp) b23: e8 20 34 00 00 call 3f48 <free> printf(1, "mem ok\n"); b28: c7 44 24 04 9b 45 00 movl $0x459b,0x4(%esp) b2f: 00 b30: c7 04 24 01 00 00 00 movl $0x1,(%esp) b37: e8 5c 32 00 00 call 3d98 <printf> exit(); b3c: e8 c7 30 00 00 call 3c08 <exit> } else { wait(); b41: e8 ca 30 00 00 call 3c10 <wait> } } b46: c9 leave b47: c3 ret 00000b48 <sharedfd>: // two processes write to the same file descriptor // is the offset shared? does inode locking work? void sharedfd(void) { b48: 55 push %ebp b49: 89 e5 mov %esp,%ebp b4b: 83 ec 48 sub $0x48,%esp int fd, pid, i, n, nc, np; char buf[10]; printf(1, "sharedfd test\n"); b4e: c7 44 24 04 a3 45 00 movl $0x45a3,0x4(%esp) b55: 00 b56: c7 04 24 01 00 00 00 movl $0x1,(%esp) b5d: e8 36 32 00 00 call 3d98 <printf> unlink("sharedfd"); b62: c7 04 24 b2 45 00 00 movl $0x45b2,(%esp) b69: e8 ea 30 00 00 call 3c58 <unlink> fd = open("sharedfd", O_CREATE|O_RDWR); b6e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) b75: 00 b76: c7 04 24 b2 45 00 00 movl $0x45b2,(%esp) b7d: e8 c6 30 00 00 call 3c48 <open> b82: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ b85: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) b89: 79 19 jns ba4 <sharedfd+0x5c> printf(1, "fstests: cannot open sharedfd for writing"); b8b: c7 44 24 04 bc 45 00 movl $0x45bc,0x4(%esp) b92: 00 b93: c7 04 24 01 00 00 00 movl $0x1,(%esp) b9a: e8 f9 31 00 00 call 3d98 <printf> b9f: e9 9a 01 00 00 jmp d3e <sharedfd+0x1f6> return; } pid = fork(); ba4: e8 57 30 00 00 call 3c00 <fork> ba9: 89 45 e4 mov %eax,-0x1c(%ebp) memset(buf, pid==0?'c':'p', sizeof(buf)); bac: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) bb0: 75 07 jne bb9 <sharedfd+0x71> bb2: b8 63 00 00 00 mov $0x63,%eax bb7: eb 05 jmp bbe <sharedfd+0x76> bb9: b8 70 00 00 00 mov $0x70,%eax bbe: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) bc5: 00 bc6: 89 44 24 04 mov %eax,0x4(%esp) bca: 8d 45 d6 lea -0x2a(%ebp),%eax bcd: 89 04 24 mov %eax,(%esp) bd0: e8 9b 2e 00 00 call 3a70 <memset> for(i = 0; i < 1000; i++){ bd5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) bdc: eb 38 jmp c16 <sharedfd+0xce> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ bde: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) be5: 00 be6: 8d 45 d6 lea -0x2a(%ebp),%eax be9: 89 44 24 04 mov %eax,0x4(%esp) bed: 8b 45 e8 mov -0x18(%ebp),%eax bf0: 89 04 24 mov %eax,(%esp) bf3: e8 30 30 00 00 call 3c28 <write> bf8: 83 f8 0a cmp $0xa,%eax bfb: 74 16 je c13 <sharedfd+0xcb> printf(1, "fstests: write sharedfd failed\n"); bfd: c7 44 24 04 e8 45 00 movl $0x45e8,0x4(%esp) c04: 00 c05: c7 04 24 01 00 00 00 movl $0x1,(%esp) c0c: e8 87 31 00 00 call 3d98 <printf> break; c11: eb 0c jmp c1f <sharedfd+0xd7> printf(1, "fstests: cannot open sharedfd for writing"); return; } pid = fork(); memset(buf, pid==0?'c':'p', sizeof(buf)); for(i = 0; i < 1000; i++){ c13: ff 45 f4 incl -0xc(%ebp) c16: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp) c1d: 7e bf jle bde <sharedfd+0x96> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ printf(1, "fstests: write sharedfd failed\n"); break; } } if(pid == 0) c1f: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) c23: 75 05 jne c2a <sharedfd+0xe2> exit(); c25: e8 de 2f 00 00 call 3c08 <exit> else wait(); c2a: e8 e1 2f 00 00 call 3c10 <wait> close(fd); c2f: 8b 45 e8 mov -0x18(%ebp),%eax c32: 89 04 24 mov %eax,(%esp) c35: e8 f6 2f 00 00 call 3c30 <close> fd = open("sharedfd", 0); c3a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) c41: 00 c42: c7 04 24 b2 45 00 00 movl $0x45b2,(%esp) c49: e8 fa 2f 00 00 call 3c48 <open> c4e: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ c51: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) c55: 79 19 jns c70 <sharedfd+0x128> printf(1, "fstests: cannot open sharedfd for reading\n"); c57: c7 44 24 04 08 46 00 movl $0x4608,0x4(%esp) c5e: 00 c5f: c7 04 24 01 00 00 00 movl $0x1,(%esp) c66: e8 2d 31 00 00 call 3d98 <printf> c6b: e9 ce 00 00 00 jmp d3e <sharedfd+0x1f6> return; } nc = np = 0; c70: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) c77: 8b 45 ec mov -0x14(%ebp),%eax c7a: 89 45 f0 mov %eax,-0x10(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ c7d: eb 36 jmp cb5 <sharedfd+0x16d> for(i = 0; i < sizeof(buf); i++){ c7f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) c86: eb 25 jmp cad <sharedfd+0x165> if(buf[i] == 'c') c88: 8d 55 d6 lea -0x2a(%ebp),%edx c8b: 8b 45 f4 mov -0xc(%ebp),%eax c8e: 01 d0 add %edx,%eax c90: 8a 00 mov (%eax),%al c92: 3c 63 cmp $0x63,%al c94: 75 03 jne c99 <sharedfd+0x151> nc++; c96: ff 45 f0 incl -0x10(%ebp) if(buf[i] == 'p') c99: 8d 55 d6 lea -0x2a(%ebp),%edx c9c: 8b 45 f4 mov -0xc(%ebp),%eax c9f: 01 d0 add %edx,%eax ca1: 8a 00 mov (%eax),%al ca3: 3c 70 cmp $0x70,%al ca5: 75 03 jne caa <sharedfd+0x162> np++; ca7: ff 45 ec incl -0x14(%ebp) printf(1, "fstests: cannot open sharedfd for reading\n"); return; } nc = np = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i = 0; i < sizeof(buf); i++){ caa: ff 45 f4 incl -0xc(%ebp) cad: 8b 45 f4 mov -0xc(%ebp),%eax cb0: 83 f8 09 cmp $0x9,%eax cb3: 76 d3 jbe c88 <sharedfd+0x140> if(fd < 0){ printf(1, "fstests: cannot open sharedfd for reading\n"); return; } nc = np = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ cb5: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) cbc: 00 cbd: 8d 45 d6 lea -0x2a(%ebp),%eax cc0: 89 44 24 04 mov %eax,0x4(%esp) cc4: 8b 45 e8 mov -0x18(%ebp),%eax cc7: 89 04 24 mov %eax,(%esp) cca: e8 51 2f 00 00 call 3c20 <read> ccf: 89 45 e0 mov %eax,-0x20(%ebp) cd2: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) cd6: 7f a7 jg c7f <sharedfd+0x137> nc++; if(buf[i] == 'p') np++; } } close(fd); cd8: 8b 45 e8 mov -0x18(%ebp),%eax cdb: 89 04 24 mov %eax,(%esp) cde: e8 4d 2f 00 00 call 3c30 <close> unlink("sharedfd"); ce3: c7 04 24 b2 45 00 00 movl $0x45b2,(%esp) cea: e8 69 2f 00 00 call 3c58 <unlink> if(nc == 10000 && np == 10000){ cef: 81 7d f0 10 27 00 00 cmpl $0x2710,-0x10(%ebp) cf6: 75 1f jne d17 <sharedfd+0x1cf> cf8: 81 7d ec 10 27 00 00 cmpl $0x2710,-0x14(%ebp) cff: 75 16 jne d17 <sharedfd+0x1cf> printf(1, "sharedfd ok\n"); d01: c7 44 24 04 33 46 00 movl $0x4633,0x4(%esp) d08: 00 d09: c7 04 24 01 00 00 00 movl $0x1,(%esp) d10: e8 83 30 00 00 call 3d98 <printf> d15: eb 27 jmp d3e <sharedfd+0x1f6> } else { printf(1, "sharedfd oops %d %d\n", nc, np); d17: 8b 45 ec mov -0x14(%ebp),%eax d1a: 89 44 24 0c mov %eax,0xc(%esp) d1e: 8b 45 f0 mov -0x10(%ebp),%eax d21: 89 44 24 08 mov %eax,0x8(%esp) d25: c7 44 24 04 40 46 00 movl $0x4640,0x4(%esp) d2c: 00 d2d: c7 04 24 01 00 00 00 movl $0x1,(%esp) d34: e8 5f 30 00 00 call 3d98 <printf> exit(); d39: e8 ca 2e 00 00 call 3c08 <exit> } } d3e: c9 leave d3f: c3 ret 00000d40 <twofiles>: // two processes write two different files at the same // time, to test block allocation. void twofiles(void) { d40: 55 push %ebp d41: 89 e5 mov %esp,%ebp d43: 83 ec 38 sub $0x38,%esp int fd, pid, i, j, n, total; char *fname; printf(1, "twofiles test\n"); d46: c7 44 24 04 55 46 00 movl $0x4655,0x4(%esp) d4d: 00 d4e: c7 04 24 01 00 00 00 movl $0x1,(%esp) d55: e8 3e 30 00 00 call 3d98 <printf> unlink("f1"); d5a: c7 04 24 64 46 00 00 movl $0x4664,(%esp) d61: e8 f2 2e 00 00 call 3c58 <unlink> unlink("f2"); d66: c7 04 24 67 46 00 00 movl $0x4667,(%esp) d6d: e8 e6 2e 00 00 call 3c58 <unlink> pid = fork(); d72: e8 89 2e 00 00 call 3c00 <fork> d77: 89 45 e8 mov %eax,-0x18(%ebp) if(pid < 0){ d7a: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) d7e: 79 19 jns d99 <twofiles+0x59> printf(1, "fork failed\n"); d80: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) d87: 00 d88: c7 04 24 01 00 00 00 movl $0x1,(%esp) d8f: e8 04 30 00 00 call 3d98 <printf> exit(); d94: e8 6f 2e 00 00 call 3c08 <exit> } fname = pid ? "f1" : "f2"; d99: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) d9d: 74 07 je da6 <twofiles+0x66> d9f: b8 64 46 00 00 mov $0x4664,%eax da4: eb 05 jmp dab <twofiles+0x6b> da6: b8 67 46 00 00 mov $0x4667,%eax dab: 89 45 e4 mov %eax,-0x1c(%ebp) fd = open(fname, O_CREATE | O_RDWR); dae: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) db5: 00 db6: 8b 45 e4 mov -0x1c(%ebp),%eax db9: 89 04 24 mov %eax,(%esp) dbc: e8 87 2e 00 00 call 3c48 <open> dc1: 89 45 e0 mov %eax,-0x20(%ebp) if(fd < 0){ dc4: 83 7d e0 00 cmpl $0x0,-0x20(%ebp) dc8: 79 19 jns de3 <twofiles+0xa3> printf(1, "create failed\n"); dca: c7 44 24 04 6a 46 00 movl $0x466a,0x4(%esp) dd1: 00 dd2: c7 04 24 01 00 00 00 movl $0x1,(%esp) dd9: e8 ba 2f 00 00 call 3d98 <printf> exit(); dde: e8 25 2e 00 00 call 3c08 <exit> } memset(buf, pid?'p':'c', 512); de3: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) de7: 74 07 je df0 <twofiles+0xb0> de9: b8 70 00 00 00 mov $0x70,%eax dee: eb 05 jmp df5 <twofiles+0xb5> df0: b8 63 00 00 00 mov $0x63,%eax df5: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) dfc: 00 dfd: 89 44 24 04 mov %eax,0x4(%esp) e01: c7 04 24 a0 86 00 00 movl $0x86a0,(%esp) e08: e8 63 2c 00 00 call 3a70 <memset> for(i = 0; i < 12; i++){ e0d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) e14: eb 4a jmp e60 <twofiles+0x120> if((n = write(fd, buf, 500)) != 500){ e16: c7 44 24 08 f4 01 00 movl $0x1f4,0x8(%esp) e1d: 00 e1e: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) e25: 00 e26: 8b 45 e0 mov -0x20(%ebp),%eax e29: 89 04 24 mov %eax,(%esp) e2c: e8 f7 2d 00 00 call 3c28 <write> e31: 89 45 dc mov %eax,-0x24(%ebp) e34: 81 7d dc f4 01 00 00 cmpl $0x1f4,-0x24(%ebp) e3b: 74 20 je e5d <twofiles+0x11d> printf(1, "write failed %d\n", n); e3d: 8b 45 dc mov -0x24(%ebp),%eax e40: 89 44 24 08 mov %eax,0x8(%esp) e44: c7 44 24 04 79 46 00 movl $0x4679,0x4(%esp) e4b: 00 e4c: c7 04 24 01 00 00 00 movl $0x1,(%esp) e53: e8 40 2f 00 00 call 3d98 <printf> exit(); e58: e8 ab 2d 00 00 call 3c08 <exit> printf(1, "create failed\n"); exit(); } memset(buf, pid?'p':'c', 512); for(i = 0; i < 12; i++){ e5d: ff 45 f4 incl -0xc(%ebp) e60: 83 7d f4 0b cmpl $0xb,-0xc(%ebp) e64: 7e b0 jle e16 <twofiles+0xd6> if((n = write(fd, buf, 500)) != 500){ printf(1, "write failed %d\n", n); exit(); } } close(fd); e66: 8b 45 e0 mov -0x20(%ebp),%eax e69: 89 04 24 mov %eax,(%esp) e6c: e8 bf 2d 00 00 call 3c30 <close> if(pid) e71: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) e75: 74 11 je e88 <twofiles+0x148> wait(); e77: e8 94 2d 00 00 call 3c10 <wait> else exit(); for(i = 0; i < 2; i++){ e7c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) e83: e9 e4 00 00 00 jmp f6c <twofiles+0x22c> } close(fd); if(pid) wait(); else exit(); e88: e8 7b 2d 00 00 call 3c08 <exit> for(i = 0; i < 2; i++){ fd = open(i?"f1":"f2", 0); e8d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) e91: 74 07 je e9a <twofiles+0x15a> e93: b8 64 46 00 00 mov $0x4664,%eax e98: eb 05 jmp e9f <twofiles+0x15f> e9a: b8 67 46 00 00 mov $0x4667,%eax e9f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) ea6: 00 ea7: 89 04 24 mov %eax,(%esp) eaa: e8 99 2d 00 00 call 3c48 <open> eaf: 89 45 e0 mov %eax,-0x20(%ebp) total = 0; eb2: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ eb9: eb 56 jmp f11 <twofiles+0x1d1> for(j = 0; j < n; j++){ ebb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) ec2: eb 3f jmp f03 <twofiles+0x1c3> if(buf[j] != (i?'p':'c')){ ec4: 8b 45 f0 mov -0x10(%ebp),%eax ec7: 05 a0 86 00 00 add $0x86a0,%eax ecc: 8a 00 mov (%eax),%al ece: 0f be d0 movsbl %al,%edx ed1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) ed5: 74 07 je ede <twofiles+0x19e> ed7: b8 70 00 00 00 mov $0x70,%eax edc: eb 05 jmp ee3 <twofiles+0x1a3> ede: b8 63 00 00 00 mov $0x63,%eax ee3: 39 c2 cmp %eax,%edx ee5: 74 19 je f00 <twofiles+0x1c0> printf(1, "wrong char\n"); ee7: c7 44 24 04 8a 46 00 movl $0x468a,0x4(%esp) eee: 00 eef: c7 04 24 01 00 00 00 movl $0x1,(%esp) ef6: e8 9d 2e 00 00 call 3d98 <printf> exit(); efb: e8 08 2d 00 00 call 3c08 <exit> for(i = 0; i < 2; i++){ fd = open(i?"f1":"f2", 0); total = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(j = 0; j < n; j++){ f00: ff 45 f0 incl -0x10(%ebp) f03: 8b 45 f0 mov -0x10(%ebp),%eax f06: 3b 45 dc cmp -0x24(%ebp),%eax f09: 7c b9 jl ec4 <twofiles+0x184> if(buf[j] != (i?'p':'c')){ printf(1, "wrong char\n"); exit(); } } total += n; f0b: 8b 45 dc mov -0x24(%ebp),%eax f0e: 01 45 ec add %eax,-0x14(%ebp) exit(); for(i = 0; i < 2; i++){ fd = open(i?"f1":"f2", 0); total = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ f11: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) f18: 00 f19: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) f20: 00 f21: 8b 45 e0 mov -0x20(%ebp),%eax f24: 89 04 24 mov %eax,(%esp) f27: e8 f4 2c 00 00 call 3c20 <read> f2c: 89 45 dc mov %eax,-0x24(%ebp) f2f: 83 7d dc 00 cmpl $0x0,-0x24(%ebp) f33: 7f 86 jg ebb <twofiles+0x17b> exit(); } } total += n; } close(fd); f35: 8b 45 e0 mov -0x20(%ebp),%eax f38: 89 04 24 mov %eax,(%esp) f3b: e8 f0 2c 00 00 call 3c30 <close> if(total != 12*500){ f40: 81 7d ec 70 17 00 00 cmpl $0x1770,-0x14(%ebp) f47: 74 20 je f69 <twofiles+0x229> printf(1, "wrong length %d\n", total); f49: 8b 45 ec mov -0x14(%ebp),%eax f4c: 89 44 24 08 mov %eax,0x8(%esp) f50: c7 44 24 04 96 46 00 movl $0x4696,0x4(%esp) f57: 00 f58: c7 04 24 01 00 00 00 movl $0x1,(%esp) f5f: e8 34 2e 00 00 call 3d98 <printf> exit(); f64: e8 9f 2c 00 00 call 3c08 <exit> if(pid) wait(); else exit(); for(i = 0; i < 2; i++){ f69: ff 45 f4 incl -0xc(%ebp) f6c: 83 7d f4 01 cmpl $0x1,-0xc(%ebp) f70: 0f 8e 17 ff ff ff jle e8d <twofiles+0x14d> printf(1, "wrong length %d\n", total); exit(); } } unlink("f1"); f76: c7 04 24 64 46 00 00 movl $0x4664,(%esp) f7d: e8 d6 2c 00 00 call 3c58 <unlink> unlink("f2"); f82: c7 04 24 67 46 00 00 movl $0x4667,(%esp) f89: e8 ca 2c 00 00 call 3c58 <unlink> printf(1, "twofiles ok\n"); f8e: c7 44 24 04 a7 46 00 movl $0x46a7,0x4(%esp) f95: 00 f96: c7 04 24 01 00 00 00 movl $0x1,(%esp) f9d: e8 f6 2d 00 00 call 3d98 <printf> } fa2: c9 leave fa3: c3 ret 00000fa4 <createdelete>: // two processes create and delete different files in same directory void createdelete(void) { fa4: 55 push %ebp fa5: 89 e5 mov %esp,%ebp fa7: 83 ec 48 sub $0x48,%esp enum { N = 20 }; int pid, i, fd; char name[32]; printf(1, "createdelete test\n"); faa: c7 44 24 04 b4 46 00 movl $0x46b4,0x4(%esp) fb1: 00 fb2: c7 04 24 01 00 00 00 movl $0x1,(%esp) fb9: e8 da 2d 00 00 call 3d98 <printf> pid = fork(); fbe: e8 3d 2c 00 00 call 3c00 <fork> fc3: 89 45 f0 mov %eax,-0x10(%ebp) if(pid < 0){ fc6: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) fca: 79 19 jns fe5 <createdelete+0x41> printf(1, "fork failed\n"); fcc: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) fd3: 00 fd4: c7 04 24 01 00 00 00 movl $0x1,(%esp) fdb: e8 b8 2d 00 00 call 3d98 <printf> exit(); fe0: e8 23 2c 00 00 call 3c08 <exit> } name[0] = pid ? 'p' : 'c'; fe5: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) fe9: 74 04 je fef <createdelete+0x4b> feb: b0 70 mov $0x70,%al fed: eb 02 jmp ff1 <createdelete+0x4d> fef: b0 63 mov $0x63,%al ff1: 88 45 cc mov %al,-0x34(%ebp) name[2] = '\0'; ff4: c6 45 ce 00 movb $0x0,-0x32(%ebp) for(i = 0; i < N; i++){ ff8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) fff: e9 96 00 00 00 jmp 109a <createdelete+0xf6> name[1] = '0' + i; 1004: 8b 45 f4 mov -0xc(%ebp),%eax 1007: 83 c0 30 add $0x30,%eax 100a: 88 45 cd mov %al,-0x33(%ebp) fd = open(name, O_CREATE | O_RDWR); 100d: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1014: 00 1015: 8d 45 cc lea -0x34(%ebp),%eax 1018: 89 04 24 mov %eax,(%esp) 101b: e8 28 2c 00 00 call 3c48 <open> 1020: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 1023: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1027: 79 19 jns 1042 <createdelete+0x9e> printf(1, "create failed\n"); 1029: c7 44 24 04 6a 46 00 movl $0x466a,0x4(%esp) 1030: 00 1031: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1038: e8 5b 2d 00 00 call 3d98 <printf> exit(); 103d: e8 c6 2b 00 00 call 3c08 <exit> } close(fd); 1042: 8b 45 ec mov -0x14(%ebp),%eax 1045: 89 04 24 mov %eax,(%esp) 1048: e8 e3 2b 00 00 call 3c30 <close> if(i > 0 && (i % 2 ) == 0){ 104d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1051: 7e 44 jle 1097 <createdelete+0xf3> 1053: 8b 45 f4 mov -0xc(%ebp),%eax 1056: 83 e0 01 and $0x1,%eax 1059: 85 c0 test %eax,%eax 105b: 75 3a jne 1097 <createdelete+0xf3> name[1] = '0' + (i / 2); 105d: 8b 45 f4 mov -0xc(%ebp),%eax 1060: 89 c2 mov %eax,%edx 1062: c1 ea 1f shr $0x1f,%edx 1065: 01 d0 add %edx,%eax 1067: d1 f8 sar %eax 1069: 83 c0 30 add $0x30,%eax 106c: 88 45 cd mov %al,-0x33(%ebp) if(unlink(name) < 0){ 106f: 8d 45 cc lea -0x34(%ebp),%eax 1072: 89 04 24 mov %eax,(%esp) 1075: e8 de 2b 00 00 call 3c58 <unlink> 107a: 85 c0 test %eax,%eax 107c: 79 19 jns 1097 <createdelete+0xf3> printf(1, "unlink failed\n"); 107e: c7 44 24 04 c7 46 00 movl $0x46c7,0x4(%esp) 1085: 00 1086: c7 04 24 01 00 00 00 movl $0x1,(%esp) 108d: e8 06 2d 00 00 call 3d98 <printf> exit(); 1092: e8 71 2b 00 00 call 3c08 <exit> exit(); } name[0] = pid ? 'p' : 'c'; name[2] = '\0'; for(i = 0; i < N; i++){ 1097: ff 45 f4 incl -0xc(%ebp) 109a: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 109e: 0f 8e 60 ff ff ff jle 1004 <createdelete+0x60> exit(); } } } if(pid==0) 10a4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 10a8: 75 05 jne 10af <createdelete+0x10b> exit(); 10aa: e8 59 2b 00 00 call 3c08 <exit> else wait(); 10af: e8 5c 2b 00 00 call 3c10 <wait> for(i = 0; i < N; i++){ 10b4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 10bb: e9 33 01 00 00 jmp 11f3 <createdelete+0x24f> name[0] = 'p'; 10c0: c6 45 cc 70 movb $0x70,-0x34(%ebp) name[1] = '0' + i; 10c4: 8b 45 f4 mov -0xc(%ebp),%eax 10c7: 83 c0 30 add $0x30,%eax 10ca: 88 45 cd mov %al,-0x33(%ebp) fd = open(name, 0); 10cd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 10d4: 00 10d5: 8d 45 cc lea -0x34(%ebp),%eax 10d8: 89 04 24 mov %eax,(%esp) 10db: e8 68 2b 00 00 call 3c48 <open> 10e0: 89 45 ec mov %eax,-0x14(%ebp) if((i == 0 || i >= N/2) && fd < 0){ 10e3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 10e7: 74 06 je 10ef <createdelete+0x14b> 10e9: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 10ed: 7e 26 jle 1115 <createdelete+0x171> 10ef: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 10f3: 79 20 jns 1115 <createdelete+0x171> printf(1, "oops createdelete %s didn't exist\n", name); 10f5: 8d 45 cc lea -0x34(%ebp),%eax 10f8: 89 44 24 08 mov %eax,0x8(%esp) 10fc: c7 44 24 04 d8 46 00 movl $0x46d8,0x4(%esp) 1103: 00 1104: c7 04 24 01 00 00 00 movl $0x1,(%esp) 110b: e8 88 2c 00 00 call 3d98 <printf> exit(); 1110: e8 f3 2a 00 00 call 3c08 <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 1115: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1119: 7e 2c jle 1147 <createdelete+0x1a3> 111b: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 111f: 7f 26 jg 1147 <createdelete+0x1a3> 1121: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1125: 78 20 js 1147 <createdelete+0x1a3> printf(1, "oops createdelete %s did exist\n", name); 1127: 8d 45 cc lea -0x34(%ebp),%eax 112a: 89 44 24 08 mov %eax,0x8(%esp) 112e: c7 44 24 04 fc 46 00 movl $0x46fc,0x4(%esp) 1135: 00 1136: c7 04 24 01 00 00 00 movl $0x1,(%esp) 113d: e8 56 2c 00 00 call 3d98 <printf> exit(); 1142: e8 c1 2a 00 00 call 3c08 <exit> } if(fd >= 0) 1147: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 114b: 78 0b js 1158 <createdelete+0x1b4> close(fd); 114d: 8b 45 ec mov -0x14(%ebp),%eax 1150: 89 04 24 mov %eax,(%esp) 1153: e8 d8 2a 00 00 call 3c30 <close> name[0] = 'c'; 1158: c6 45 cc 63 movb $0x63,-0x34(%ebp) name[1] = '0' + i; 115c: 8b 45 f4 mov -0xc(%ebp),%eax 115f: 83 c0 30 add $0x30,%eax 1162: 88 45 cd mov %al,-0x33(%ebp) fd = open(name, 0); 1165: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 116c: 00 116d: 8d 45 cc lea -0x34(%ebp),%eax 1170: 89 04 24 mov %eax,(%esp) 1173: e8 d0 2a 00 00 call 3c48 <open> 1178: 89 45 ec mov %eax,-0x14(%ebp) if((i == 0 || i >= N/2) && fd < 0){ 117b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 117f: 74 06 je 1187 <createdelete+0x1e3> 1181: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 1185: 7e 26 jle 11ad <createdelete+0x209> 1187: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 118b: 79 20 jns 11ad <createdelete+0x209> printf(1, "oops createdelete %s didn't exist\n", name); 118d: 8d 45 cc lea -0x34(%ebp),%eax 1190: 89 44 24 08 mov %eax,0x8(%esp) 1194: c7 44 24 04 d8 46 00 movl $0x46d8,0x4(%esp) 119b: 00 119c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 11a3: e8 f0 2b 00 00 call 3d98 <printf> exit(); 11a8: e8 5b 2a 00 00 call 3c08 <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 11ad: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 11b1: 7e 2c jle 11df <createdelete+0x23b> 11b3: 83 7d f4 09 cmpl $0x9,-0xc(%ebp) 11b7: 7f 26 jg 11df <createdelete+0x23b> 11b9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 11bd: 78 20 js 11df <createdelete+0x23b> printf(1, "oops createdelete %s did exist\n", name); 11bf: 8d 45 cc lea -0x34(%ebp),%eax 11c2: 89 44 24 08 mov %eax,0x8(%esp) 11c6: c7 44 24 04 fc 46 00 movl $0x46fc,0x4(%esp) 11cd: 00 11ce: c7 04 24 01 00 00 00 movl $0x1,(%esp) 11d5: e8 be 2b 00 00 call 3d98 <printf> exit(); 11da: e8 29 2a 00 00 call 3c08 <exit> } if(fd >= 0) 11df: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 11e3: 78 0b js 11f0 <createdelete+0x24c> close(fd); 11e5: 8b 45 ec mov -0x14(%ebp),%eax 11e8: 89 04 24 mov %eax,(%esp) 11eb: e8 40 2a 00 00 call 3c30 <close> if(pid==0) exit(); else wait(); for(i = 0; i < N; i++){ 11f0: ff 45 f4 incl -0xc(%ebp) 11f3: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 11f7: 0f 8e c3 fe ff ff jle 10c0 <createdelete+0x11c> } if(fd >= 0) close(fd); } for(i = 0; i < N; i++){ 11fd: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1204: eb 2a jmp 1230 <createdelete+0x28c> name[0] = 'p'; 1206: c6 45 cc 70 movb $0x70,-0x34(%ebp) name[1] = '0' + i; 120a: 8b 45 f4 mov -0xc(%ebp),%eax 120d: 83 c0 30 add $0x30,%eax 1210: 88 45 cd mov %al,-0x33(%ebp) unlink(name); 1213: 8d 45 cc lea -0x34(%ebp),%eax 1216: 89 04 24 mov %eax,(%esp) 1219: e8 3a 2a 00 00 call 3c58 <unlink> name[0] = 'c'; 121e: c6 45 cc 63 movb $0x63,-0x34(%ebp) unlink(name); 1222: 8d 45 cc lea -0x34(%ebp),%eax 1225: 89 04 24 mov %eax,(%esp) 1228: e8 2b 2a 00 00 call 3c58 <unlink> } if(fd >= 0) close(fd); } for(i = 0; i < N; i++){ 122d: ff 45 f4 incl -0xc(%ebp) 1230: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 1234: 7e d0 jle 1206 <createdelete+0x262> unlink(name); name[0] = 'c'; unlink(name); } printf(1, "createdelete ok\n"); 1236: c7 44 24 04 1c 47 00 movl $0x471c,0x4(%esp) 123d: 00 123e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1245: e8 4e 2b 00 00 call 3d98 <printf> } 124a: c9 leave 124b: c3 ret 0000124c <unlinkread>: // can I unlink a file and still read it? void unlinkread(void) { 124c: 55 push %ebp 124d: 89 e5 mov %esp,%ebp 124f: 83 ec 28 sub $0x28,%esp int fd, fd1; printf(1, "unlinkread test\n"); 1252: c7 44 24 04 2d 47 00 movl $0x472d,0x4(%esp) 1259: 00 125a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1261: e8 32 2b 00 00 call 3d98 <printf> fd = open("unlinkread", O_CREATE | O_RDWR); 1266: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 126d: 00 126e: c7 04 24 3e 47 00 00 movl $0x473e,(%esp) 1275: e8 ce 29 00 00 call 3c48 <open> 127a: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 127d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1281: 79 19 jns 129c <unlinkread+0x50> printf(1, "create unlinkread failed\n"); 1283: c7 44 24 04 49 47 00 movl $0x4749,0x4(%esp) 128a: 00 128b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1292: e8 01 2b 00 00 call 3d98 <printf> exit(); 1297: e8 6c 29 00 00 call 3c08 <exit> } write(fd, "hello", 5); 129c: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) 12a3: 00 12a4: c7 44 24 04 63 47 00 movl $0x4763,0x4(%esp) 12ab: 00 12ac: 8b 45 f4 mov -0xc(%ebp),%eax 12af: 89 04 24 mov %eax,(%esp) 12b2: e8 71 29 00 00 call 3c28 <write> close(fd); 12b7: 8b 45 f4 mov -0xc(%ebp),%eax 12ba: 89 04 24 mov %eax,(%esp) 12bd: e8 6e 29 00 00 call 3c30 <close> fd = open("unlinkread", O_RDWR); 12c2: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 12c9: 00 12ca: c7 04 24 3e 47 00 00 movl $0x473e,(%esp) 12d1: e8 72 29 00 00 call 3c48 <open> 12d6: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 12d9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 12dd: 79 19 jns 12f8 <unlinkread+0xac> printf(1, "open unlinkread failed\n"); 12df: c7 44 24 04 69 47 00 movl $0x4769,0x4(%esp) 12e6: 00 12e7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 12ee: e8 a5 2a 00 00 call 3d98 <printf> exit(); 12f3: e8 10 29 00 00 call 3c08 <exit> } if(unlink("unlinkread") != 0){ 12f8: c7 04 24 3e 47 00 00 movl $0x473e,(%esp) 12ff: e8 54 29 00 00 call 3c58 <unlink> 1304: 85 c0 test %eax,%eax 1306: 74 19 je 1321 <unlinkread+0xd5> printf(1, "unlink unlinkread failed\n"); 1308: c7 44 24 04 81 47 00 movl $0x4781,0x4(%esp) 130f: 00 1310: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1317: e8 7c 2a 00 00 call 3d98 <printf> exit(); 131c: e8 e7 28 00 00 call 3c08 <exit> } fd1 = open("unlinkread", O_CREATE | O_RDWR); 1321: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1328: 00 1329: c7 04 24 3e 47 00 00 movl $0x473e,(%esp) 1330: e8 13 29 00 00 call 3c48 <open> 1335: 89 45 f0 mov %eax,-0x10(%ebp) write(fd1, "yyy", 3); 1338: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) 133f: 00 1340: c7 44 24 04 9b 47 00 movl $0x479b,0x4(%esp) 1347: 00 1348: 8b 45 f0 mov -0x10(%ebp),%eax 134b: 89 04 24 mov %eax,(%esp) 134e: e8 d5 28 00 00 call 3c28 <write> close(fd1); 1353: 8b 45 f0 mov -0x10(%ebp),%eax 1356: 89 04 24 mov %eax,(%esp) 1359: e8 d2 28 00 00 call 3c30 <close> if(read(fd, buf, sizeof(buf)) != 5){ 135e: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1365: 00 1366: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 136d: 00 136e: 8b 45 f4 mov -0xc(%ebp),%eax 1371: 89 04 24 mov %eax,(%esp) 1374: e8 a7 28 00 00 call 3c20 <read> 1379: 83 f8 05 cmp $0x5,%eax 137c: 74 19 je 1397 <unlinkread+0x14b> printf(1, "unlinkread read failed"); 137e: c7 44 24 04 9f 47 00 movl $0x479f,0x4(%esp) 1385: 00 1386: c7 04 24 01 00 00 00 movl $0x1,(%esp) 138d: e8 06 2a 00 00 call 3d98 <printf> exit(); 1392: e8 71 28 00 00 call 3c08 <exit> } if(buf[0] != 'h'){ 1397: a0 a0 86 00 00 mov 0x86a0,%al 139c: 3c 68 cmp $0x68,%al 139e: 74 19 je 13b9 <unlinkread+0x16d> printf(1, "unlinkread wrong data\n"); 13a0: c7 44 24 04 b6 47 00 movl $0x47b6,0x4(%esp) 13a7: 00 13a8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 13af: e8 e4 29 00 00 call 3d98 <printf> exit(); 13b4: e8 4f 28 00 00 call 3c08 <exit> } if(write(fd, buf, 10) != 10){ 13b9: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 13c0: 00 13c1: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 13c8: 00 13c9: 8b 45 f4 mov -0xc(%ebp),%eax 13cc: 89 04 24 mov %eax,(%esp) 13cf: e8 54 28 00 00 call 3c28 <write> 13d4: 83 f8 0a cmp $0xa,%eax 13d7: 74 19 je 13f2 <unlinkread+0x1a6> printf(1, "unlinkread write failed\n"); 13d9: c7 44 24 04 cd 47 00 movl $0x47cd,0x4(%esp) 13e0: 00 13e1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 13e8: e8 ab 29 00 00 call 3d98 <printf> exit(); 13ed: e8 16 28 00 00 call 3c08 <exit> } close(fd); 13f2: 8b 45 f4 mov -0xc(%ebp),%eax 13f5: 89 04 24 mov %eax,(%esp) 13f8: e8 33 28 00 00 call 3c30 <close> unlink("unlinkread"); 13fd: c7 04 24 3e 47 00 00 movl $0x473e,(%esp) 1404: e8 4f 28 00 00 call 3c58 <unlink> printf(1, "unlinkread ok\n"); 1409: c7 44 24 04 e6 47 00 movl $0x47e6,0x4(%esp) 1410: 00 1411: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1418: e8 7b 29 00 00 call 3d98 <printf> } 141d: c9 leave 141e: c3 ret 0000141f <linktest>: void linktest(void) { 141f: 55 push %ebp 1420: 89 e5 mov %esp,%ebp 1422: 83 ec 28 sub $0x28,%esp int fd; printf(1, "linktest\n"); 1425: c7 44 24 04 f5 47 00 movl $0x47f5,0x4(%esp) 142c: 00 142d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1434: e8 5f 29 00 00 call 3d98 <printf> unlink("lf1"); 1439: c7 04 24 ff 47 00 00 movl $0x47ff,(%esp) 1440: e8 13 28 00 00 call 3c58 <unlink> unlink("lf2"); 1445: c7 04 24 03 48 00 00 movl $0x4803,(%esp) 144c: e8 07 28 00 00 call 3c58 <unlink> fd = open("lf1", O_CREATE|O_RDWR); 1451: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1458: 00 1459: c7 04 24 ff 47 00 00 movl $0x47ff,(%esp) 1460: e8 e3 27 00 00 call 3c48 <open> 1465: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1468: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 146c: 79 19 jns 1487 <linktest+0x68> printf(1, "create lf1 failed\n"); 146e: c7 44 24 04 07 48 00 movl $0x4807,0x4(%esp) 1475: 00 1476: c7 04 24 01 00 00 00 movl $0x1,(%esp) 147d: e8 16 29 00 00 call 3d98 <printf> exit(); 1482: e8 81 27 00 00 call 3c08 <exit> } if(write(fd, "hello", 5) != 5){ 1487: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp) 148e: 00 148f: c7 44 24 04 63 47 00 movl $0x4763,0x4(%esp) 1496: 00 1497: 8b 45 f4 mov -0xc(%ebp),%eax 149a: 89 04 24 mov %eax,(%esp) 149d: e8 86 27 00 00 call 3c28 <write> 14a2: 83 f8 05 cmp $0x5,%eax 14a5: 74 19 je 14c0 <linktest+0xa1> printf(1, "write lf1 failed\n"); 14a7: c7 44 24 04 1a 48 00 movl $0x481a,0x4(%esp) 14ae: 00 14af: c7 04 24 01 00 00 00 movl $0x1,(%esp) 14b6: e8 dd 28 00 00 call 3d98 <printf> exit(); 14bb: e8 48 27 00 00 call 3c08 <exit> } close(fd); 14c0: 8b 45 f4 mov -0xc(%ebp),%eax 14c3: 89 04 24 mov %eax,(%esp) 14c6: e8 65 27 00 00 call 3c30 <close> if(link("lf1", "lf2") < 0){ 14cb: c7 44 24 04 03 48 00 movl $0x4803,0x4(%esp) 14d2: 00 14d3: c7 04 24 ff 47 00 00 movl $0x47ff,(%esp) 14da: e8 89 27 00 00 call 3c68 <link> 14df: 85 c0 test %eax,%eax 14e1: 79 19 jns 14fc <linktest+0xdd> printf(1, "link lf1 lf2 failed\n"); 14e3: c7 44 24 04 2c 48 00 movl $0x482c,0x4(%esp) 14ea: 00 14eb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 14f2: e8 a1 28 00 00 call 3d98 <printf> exit(); 14f7: e8 0c 27 00 00 call 3c08 <exit> } unlink("lf1"); 14fc: c7 04 24 ff 47 00 00 movl $0x47ff,(%esp) 1503: e8 50 27 00 00 call 3c58 <unlink> if(open("lf1", 0) >= 0){ 1508: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 150f: 00 1510: c7 04 24 ff 47 00 00 movl $0x47ff,(%esp) 1517: e8 2c 27 00 00 call 3c48 <open> 151c: 85 c0 test %eax,%eax 151e: 78 19 js 1539 <linktest+0x11a> printf(1, "unlinked lf1 but it is still there!\n"); 1520: c7 44 24 04 44 48 00 movl $0x4844,0x4(%esp) 1527: 00 1528: c7 04 24 01 00 00 00 movl $0x1,(%esp) 152f: e8 64 28 00 00 call 3d98 <printf> exit(); 1534: e8 cf 26 00 00 call 3c08 <exit> } fd = open("lf2", 0); 1539: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1540: 00 1541: c7 04 24 03 48 00 00 movl $0x4803,(%esp) 1548: e8 fb 26 00 00 call 3c48 <open> 154d: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1550: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1554: 79 19 jns 156f <linktest+0x150> printf(1, "open lf2 failed\n"); 1556: c7 44 24 04 69 48 00 movl $0x4869,0x4(%esp) 155d: 00 155e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1565: e8 2e 28 00 00 call 3d98 <printf> exit(); 156a: e8 99 26 00 00 call 3c08 <exit> } if(read(fd, buf, sizeof(buf)) != 5){ 156f: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1576: 00 1577: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 157e: 00 157f: 8b 45 f4 mov -0xc(%ebp),%eax 1582: 89 04 24 mov %eax,(%esp) 1585: e8 96 26 00 00 call 3c20 <read> 158a: 83 f8 05 cmp $0x5,%eax 158d: 74 19 je 15a8 <linktest+0x189> printf(1, "read lf2 failed\n"); 158f: c7 44 24 04 7a 48 00 movl $0x487a,0x4(%esp) 1596: 00 1597: c7 04 24 01 00 00 00 movl $0x1,(%esp) 159e: e8 f5 27 00 00 call 3d98 <printf> exit(); 15a3: e8 60 26 00 00 call 3c08 <exit> } close(fd); 15a8: 8b 45 f4 mov -0xc(%ebp),%eax 15ab: 89 04 24 mov %eax,(%esp) 15ae: e8 7d 26 00 00 call 3c30 <close> if(link("lf2", "lf2") >= 0){ 15b3: c7 44 24 04 03 48 00 movl $0x4803,0x4(%esp) 15ba: 00 15bb: c7 04 24 03 48 00 00 movl $0x4803,(%esp) 15c2: e8 a1 26 00 00 call 3c68 <link> 15c7: 85 c0 test %eax,%eax 15c9: 78 19 js 15e4 <linktest+0x1c5> printf(1, "link lf2 lf2 succeeded! oops\n"); 15cb: c7 44 24 04 8b 48 00 movl $0x488b,0x4(%esp) 15d2: 00 15d3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 15da: e8 b9 27 00 00 call 3d98 <printf> exit(); 15df: e8 24 26 00 00 call 3c08 <exit> } unlink("lf2"); 15e4: c7 04 24 03 48 00 00 movl $0x4803,(%esp) 15eb: e8 68 26 00 00 call 3c58 <unlink> if(link("lf2", "lf1") >= 0){ 15f0: c7 44 24 04 ff 47 00 movl $0x47ff,0x4(%esp) 15f7: 00 15f8: c7 04 24 03 48 00 00 movl $0x4803,(%esp) 15ff: e8 64 26 00 00 call 3c68 <link> 1604: 85 c0 test %eax,%eax 1606: 78 19 js 1621 <linktest+0x202> printf(1, "link non-existant succeeded! oops\n"); 1608: c7 44 24 04 ac 48 00 movl $0x48ac,0x4(%esp) 160f: 00 1610: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1617: e8 7c 27 00 00 call 3d98 <printf> exit(); 161c: e8 e7 25 00 00 call 3c08 <exit> } if(link(".", "lf1") >= 0){ 1621: c7 44 24 04 ff 47 00 movl $0x47ff,0x4(%esp) 1628: 00 1629: c7 04 24 cf 48 00 00 movl $0x48cf,(%esp) 1630: e8 33 26 00 00 call 3c68 <link> 1635: 85 c0 test %eax,%eax 1637: 78 19 js 1652 <linktest+0x233> printf(1, "link . lf1 succeeded! oops\n"); 1639: c7 44 24 04 d1 48 00 movl $0x48d1,0x4(%esp) 1640: 00 1641: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1648: e8 4b 27 00 00 call 3d98 <printf> exit(); 164d: e8 b6 25 00 00 call 3c08 <exit> } printf(1, "linktest ok\n"); 1652: c7 44 24 04 ed 48 00 movl $0x48ed,0x4(%esp) 1659: 00 165a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1661: e8 32 27 00 00 call 3d98 <printf> } 1666: c9 leave 1667: c3 ret 00001668 <concreate>: // test concurrent create/link/unlink of the same file void concreate(void) { 1668: 55 push %ebp 1669: 89 e5 mov %esp,%ebp 166b: 83 ec 68 sub $0x68,%esp struct { ushort inum; char name[14]; } de; printf(1, "concreate test\n"); 166e: c7 44 24 04 fa 48 00 movl $0x48fa,0x4(%esp) 1675: 00 1676: c7 04 24 01 00 00 00 movl $0x1,(%esp) 167d: e8 16 27 00 00 call 3d98 <printf> file[0] = 'C'; 1682: c6 45 e5 43 movb $0x43,-0x1b(%ebp) file[2] = '\0'; 1686: c6 45 e7 00 movb $0x0,-0x19(%ebp) for(i = 0; i < 40; i++){ 168a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1691: e9 d0 00 00 00 jmp 1766 <concreate+0xfe> file[1] = '0' + i; 1696: 8b 45 f4 mov -0xc(%ebp),%eax 1699: 83 c0 30 add $0x30,%eax 169c: 88 45 e6 mov %al,-0x1a(%ebp) unlink(file); 169f: 8d 45 e5 lea -0x1b(%ebp),%eax 16a2: 89 04 24 mov %eax,(%esp) 16a5: e8 ae 25 00 00 call 3c58 <unlink> pid = fork(); 16aa: e8 51 25 00 00 call 3c00 <fork> 16af: 89 45 ec mov %eax,-0x14(%ebp) if(pid && (i % 3) == 1){ 16b2: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 16b6: 74 27 je 16df <concreate+0x77> 16b8: 8b 45 f4 mov -0xc(%ebp),%eax 16bb: b9 03 00 00 00 mov $0x3,%ecx 16c0: 99 cltd 16c1: f7 f9 idiv %ecx 16c3: 89 d0 mov %edx,%eax 16c5: 83 f8 01 cmp $0x1,%eax 16c8: 75 15 jne 16df <concreate+0x77> link("C0", file); 16ca: 8d 45 e5 lea -0x1b(%ebp),%eax 16cd: 89 44 24 04 mov %eax,0x4(%esp) 16d1: c7 04 24 0a 49 00 00 movl $0x490a,(%esp) 16d8: e8 8b 25 00 00 call 3c68 <link> 16dd: eb 74 jmp 1753 <concreate+0xeb> } else if(pid == 0 && (i % 5) == 1){ 16df: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 16e3: 75 27 jne 170c <concreate+0xa4> 16e5: 8b 45 f4 mov -0xc(%ebp),%eax 16e8: b9 05 00 00 00 mov $0x5,%ecx 16ed: 99 cltd 16ee: f7 f9 idiv %ecx 16f0: 89 d0 mov %edx,%eax 16f2: 83 f8 01 cmp $0x1,%eax 16f5: 75 15 jne 170c <concreate+0xa4> link("C0", file); 16f7: 8d 45 e5 lea -0x1b(%ebp),%eax 16fa: 89 44 24 04 mov %eax,0x4(%esp) 16fe: c7 04 24 0a 49 00 00 movl $0x490a,(%esp) 1705: e8 5e 25 00 00 call 3c68 <link> 170a: eb 47 jmp 1753 <concreate+0xeb> } else { fd = open(file, O_CREATE | O_RDWR); 170c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1713: 00 1714: 8d 45 e5 lea -0x1b(%ebp),%eax 1717: 89 04 24 mov %eax,(%esp) 171a: e8 29 25 00 00 call 3c48 <open> 171f: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ 1722: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 1726: 79 20 jns 1748 <concreate+0xe0> printf(1, "concreate create %s failed\n", file); 1728: 8d 45 e5 lea -0x1b(%ebp),%eax 172b: 89 44 24 08 mov %eax,0x8(%esp) 172f: c7 44 24 04 0d 49 00 movl $0x490d,0x4(%esp) 1736: 00 1737: c7 04 24 01 00 00 00 movl $0x1,(%esp) 173e: e8 55 26 00 00 call 3d98 <printf> exit(); 1743: e8 c0 24 00 00 call 3c08 <exit> } close(fd); 1748: 8b 45 e8 mov -0x18(%ebp),%eax 174b: 89 04 24 mov %eax,(%esp) 174e: e8 dd 24 00 00 call 3c30 <close> } if(pid == 0) 1753: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1757: 75 05 jne 175e <concreate+0xf6> exit(); 1759: e8 aa 24 00 00 call 3c08 <exit> else wait(); 175e: e8 ad 24 00 00 call 3c10 <wait> } de; printf(1, "concreate test\n"); file[0] = 'C'; file[2] = '\0'; for(i = 0; i < 40; i++){ 1763: ff 45 f4 incl -0xc(%ebp) 1766: 83 7d f4 27 cmpl $0x27,-0xc(%ebp) 176a: 0f 8e 26 ff ff ff jle 1696 <concreate+0x2e> exit(); else wait(); } memset(fa, 0, sizeof(fa)); 1770: c7 44 24 08 28 00 00 movl $0x28,0x8(%esp) 1777: 00 1778: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 177f: 00 1780: 8d 45 bd lea -0x43(%ebp),%eax 1783: 89 04 24 mov %eax,(%esp) 1786: e8 e5 22 00 00 call 3a70 <memset> fd = open(".", 0); 178b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1792: 00 1793: c7 04 24 cf 48 00 00 movl $0x48cf,(%esp) 179a: e8 a9 24 00 00 call 3c48 <open> 179f: 89 45 e8 mov %eax,-0x18(%ebp) n = 0; 17a2: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) while(read(fd, &de, sizeof(de)) > 0){ 17a9: e9 9d 00 00 00 jmp 184b <concreate+0x1e3> if(de.inum == 0) 17ae: 8b 45 ac mov -0x54(%ebp),%eax 17b1: 66 85 c0 test %ax,%ax 17b4: 0f 84 90 00 00 00 je 184a <concreate+0x1e2> continue; if(de.name[0] == 'C' && de.name[2] == '\0'){ 17ba: 8a 45 ae mov -0x52(%ebp),%al 17bd: 3c 43 cmp $0x43,%al 17bf: 0f 85 86 00 00 00 jne 184b <concreate+0x1e3> 17c5: 8a 45 b0 mov -0x50(%ebp),%al 17c8: 84 c0 test %al,%al 17ca: 75 7f jne 184b <concreate+0x1e3> i = de.name[1] - '0'; 17cc: 8a 45 af mov -0x51(%ebp),%al 17cf: 0f be c0 movsbl %al,%eax 17d2: 83 e8 30 sub $0x30,%eax 17d5: 89 45 f4 mov %eax,-0xc(%ebp) if(i < 0 || i >= sizeof(fa)){ 17d8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 17dc: 78 08 js 17e6 <concreate+0x17e> 17de: 8b 45 f4 mov -0xc(%ebp),%eax 17e1: 83 f8 27 cmp $0x27,%eax 17e4: 76 23 jbe 1809 <concreate+0x1a1> printf(1, "concreate weird file %s\n", de.name); 17e6: 8d 45 ac lea -0x54(%ebp),%eax 17e9: 83 c0 02 add $0x2,%eax 17ec: 89 44 24 08 mov %eax,0x8(%esp) 17f0: c7 44 24 04 29 49 00 movl $0x4929,0x4(%esp) 17f7: 00 17f8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 17ff: e8 94 25 00 00 call 3d98 <printf> exit(); 1804: e8 ff 23 00 00 call 3c08 <exit> } if(fa[i]){ 1809: 8d 55 bd lea -0x43(%ebp),%edx 180c: 8b 45 f4 mov -0xc(%ebp),%eax 180f: 01 d0 add %edx,%eax 1811: 8a 00 mov (%eax),%al 1813: 84 c0 test %al,%al 1815: 74 23 je 183a <concreate+0x1d2> printf(1, "concreate duplicate file %s\n", de.name); 1817: 8d 45 ac lea -0x54(%ebp),%eax 181a: 83 c0 02 add $0x2,%eax 181d: 89 44 24 08 mov %eax,0x8(%esp) 1821: c7 44 24 04 42 49 00 movl $0x4942,0x4(%esp) 1828: 00 1829: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1830: e8 63 25 00 00 call 3d98 <printf> exit(); 1835: e8 ce 23 00 00 call 3c08 <exit> } fa[i] = 1; 183a: 8d 55 bd lea -0x43(%ebp),%edx 183d: 8b 45 f4 mov -0xc(%ebp),%eax 1840: 01 d0 add %edx,%eax 1842: c6 00 01 movb $0x1,(%eax) n++; 1845: ff 45 f0 incl -0x10(%ebp) 1848: eb 01 jmp 184b <concreate+0x1e3> memset(fa, 0, sizeof(fa)); fd = open(".", 0); n = 0; while(read(fd, &de, sizeof(de)) > 0){ if(de.inum == 0) continue; 184a: 90 nop } memset(fa, 0, sizeof(fa)); fd = open(".", 0); n = 0; while(read(fd, &de, sizeof(de)) > 0){ 184b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 1852: 00 1853: 8d 45 ac lea -0x54(%ebp),%eax 1856: 89 44 24 04 mov %eax,0x4(%esp) 185a: 8b 45 e8 mov -0x18(%ebp),%eax 185d: 89 04 24 mov %eax,(%esp) 1860: e8 bb 23 00 00 call 3c20 <read> 1865: 85 c0 test %eax,%eax 1867: 0f 8f 41 ff ff ff jg 17ae <concreate+0x146> } fa[i] = 1; n++; } } close(fd); 186d: 8b 45 e8 mov -0x18(%ebp),%eax 1870: 89 04 24 mov %eax,(%esp) 1873: e8 b8 23 00 00 call 3c30 <close> if(n != 40){ 1878: 83 7d f0 28 cmpl $0x28,-0x10(%ebp) 187c: 74 19 je 1897 <concreate+0x22f> printf(1, "concreate not enough files in directory listing\n"); 187e: c7 44 24 04 60 49 00 movl $0x4960,0x4(%esp) 1885: 00 1886: c7 04 24 01 00 00 00 movl $0x1,(%esp) 188d: e8 06 25 00 00 call 3d98 <printf> exit(); 1892: e8 71 23 00 00 call 3c08 <exit> } for(i = 0; i < 40; i++){ 1897: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 189e: e9 0c 01 00 00 jmp 19af <concreate+0x347> file[1] = '0' + i; 18a3: 8b 45 f4 mov -0xc(%ebp),%eax 18a6: 83 c0 30 add $0x30,%eax 18a9: 88 45 e6 mov %al,-0x1a(%ebp) pid = fork(); 18ac: e8 4f 23 00 00 call 3c00 <fork> 18b1: 89 45 ec mov %eax,-0x14(%ebp) if(pid < 0){ 18b4: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 18b8: 79 19 jns 18d3 <concreate+0x26b> printf(1, "fork failed\n"); 18ba: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) 18c1: 00 18c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 18c9: e8 ca 24 00 00 call 3d98 <printf> exit(); 18ce: e8 35 23 00 00 call 3c08 <exit> } if(((i % 3) == 0 && pid == 0) || 18d3: 8b 45 f4 mov -0xc(%ebp),%eax 18d6: b9 03 00 00 00 mov $0x3,%ecx 18db: 99 cltd 18dc: f7 f9 idiv %ecx 18de: 89 d0 mov %edx,%eax 18e0: 85 c0 test %eax,%eax 18e2: 75 06 jne 18ea <concreate+0x282> 18e4: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 18e8: 74 18 je 1902 <concreate+0x29a> ((i % 3) == 1 && pid != 0)){ 18ea: 8b 45 f4 mov -0xc(%ebp),%eax 18ed: b9 03 00 00 00 mov $0x3,%ecx 18f2: 99 cltd 18f3: f7 f9 idiv %ecx 18f5: 89 d0 mov %edx,%eax pid = fork(); if(pid < 0){ printf(1, "fork failed\n"); exit(); } if(((i % 3) == 0 && pid == 0) || 18f7: 83 f8 01 cmp $0x1,%eax 18fa: 75 74 jne 1970 <concreate+0x308> ((i % 3) == 1 && pid != 0)){ 18fc: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1900: 74 6e je 1970 <concreate+0x308> close(open(file, 0)); 1902: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1909: 00 190a: 8d 45 e5 lea -0x1b(%ebp),%eax 190d: 89 04 24 mov %eax,(%esp) 1910: e8 33 23 00 00 call 3c48 <open> 1915: 89 04 24 mov %eax,(%esp) 1918: e8 13 23 00 00 call 3c30 <close> close(open(file, 0)); 191d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1924: 00 1925: 8d 45 e5 lea -0x1b(%ebp),%eax 1928: 89 04 24 mov %eax,(%esp) 192b: e8 18 23 00 00 call 3c48 <open> 1930: 89 04 24 mov %eax,(%esp) 1933: e8 f8 22 00 00 call 3c30 <close> close(open(file, 0)); 1938: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 193f: 00 1940: 8d 45 e5 lea -0x1b(%ebp),%eax 1943: 89 04 24 mov %eax,(%esp) 1946: e8 fd 22 00 00 call 3c48 <open> 194b: 89 04 24 mov %eax,(%esp) 194e: e8 dd 22 00 00 call 3c30 <close> close(open(file, 0)); 1953: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 195a: 00 195b: 8d 45 e5 lea -0x1b(%ebp),%eax 195e: 89 04 24 mov %eax,(%esp) 1961: e8 e2 22 00 00 call 3c48 <open> 1966: 89 04 24 mov %eax,(%esp) 1969: e8 c2 22 00 00 call 3c30 <close> 196e: eb 2c jmp 199c <concreate+0x334> } else { unlink(file); 1970: 8d 45 e5 lea -0x1b(%ebp),%eax 1973: 89 04 24 mov %eax,(%esp) 1976: e8 dd 22 00 00 call 3c58 <unlink> unlink(file); 197b: 8d 45 e5 lea -0x1b(%ebp),%eax 197e: 89 04 24 mov %eax,(%esp) 1981: e8 d2 22 00 00 call 3c58 <unlink> unlink(file); 1986: 8d 45 e5 lea -0x1b(%ebp),%eax 1989: 89 04 24 mov %eax,(%esp) 198c: e8 c7 22 00 00 call 3c58 <unlink> unlink(file); 1991: 8d 45 e5 lea -0x1b(%ebp),%eax 1994: 89 04 24 mov %eax,(%esp) 1997: e8 bc 22 00 00 call 3c58 <unlink> } if(pid == 0) 199c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 19a0: 75 05 jne 19a7 <concreate+0x33f> exit(); 19a2: e8 61 22 00 00 call 3c08 <exit> else wait(); 19a7: e8 64 22 00 00 call 3c10 <wait> if(n != 40){ printf(1, "concreate not enough files in directory listing\n"); exit(); } for(i = 0; i < 40; i++){ 19ac: ff 45 f4 incl -0xc(%ebp) 19af: 83 7d f4 27 cmpl $0x27,-0xc(%ebp) 19b3: 0f 8e ea fe ff ff jle 18a3 <concreate+0x23b> exit(); else wait(); } printf(1, "concreate ok\n"); 19b9: c7 44 24 04 91 49 00 movl $0x4991,0x4(%esp) 19c0: 00 19c1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 19c8: e8 cb 23 00 00 call 3d98 <printf> } 19cd: c9 leave 19ce: c3 ret 000019cf <linkunlink>: // another concurrent link/unlink/create test, // to look for deadlocks. void linkunlink() { 19cf: 55 push %ebp 19d0: 89 e5 mov %esp,%ebp 19d2: 83 ec 28 sub $0x28,%esp int pid, i; printf(1, "linkunlink test\n"); 19d5: c7 44 24 04 9f 49 00 movl $0x499f,0x4(%esp) 19dc: 00 19dd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 19e4: e8 af 23 00 00 call 3d98 <printf> unlink("x"); 19e9: c7 04 24 06 45 00 00 movl $0x4506,(%esp) 19f0: e8 63 22 00 00 call 3c58 <unlink> pid = fork(); 19f5: e8 06 22 00 00 call 3c00 <fork> 19fa: 89 45 ec mov %eax,-0x14(%ebp) if(pid < 0){ 19fd: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1a01: 79 19 jns 1a1c <linkunlink+0x4d> printf(1, "fork failed\n"); 1a03: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) 1a0a: 00 1a0b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1a12: e8 81 23 00 00 call 3d98 <printf> exit(); 1a17: e8 ec 21 00 00 call 3c08 <exit> } unsigned int x = (pid ? 1 : 97); 1a1c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1a20: 74 07 je 1a29 <linkunlink+0x5a> 1a22: b8 01 00 00 00 mov $0x1,%eax 1a27: eb 05 jmp 1a2e <linkunlink+0x5f> 1a29: b8 61 00 00 00 mov $0x61,%eax 1a2e: 89 45 f0 mov %eax,-0x10(%ebp) for(i = 0; i < 100; i++){ 1a31: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1a38: e9 a5 00 00 00 jmp 1ae2 <linkunlink+0x113> x = x * 1103515245 + 12345; 1a3d: 8b 4d f0 mov -0x10(%ebp),%ecx 1a40: 89 ca mov %ecx,%edx 1a42: 89 d0 mov %edx,%eax 1a44: c1 e0 09 shl $0x9,%eax 1a47: 89 c2 mov %eax,%edx 1a49: 29 ca sub %ecx,%edx 1a4b: c1 e2 02 shl $0x2,%edx 1a4e: 01 ca add %ecx,%edx 1a50: 89 d0 mov %edx,%eax 1a52: c1 e0 09 shl $0x9,%eax 1a55: 29 d0 sub %edx,%eax 1a57: d1 e0 shl %eax 1a59: 01 c8 add %ecx,%eax 1a5b: 89 c2 mov %eax,%edx 1a5d: c1 e2 05 shl $0x5,%edx 1a60: 01 d0 add %edx,%eax 1a62: c1 e0 02 shl $0x2,%eax 1a65: 29 c8 sub %ecx,%eax 1a67: c1 e0 02 shl $0x2,%eax 1a6a: 01 c8 add %ecx,%eax 1a6c: 05 39 30 00 00 add $0x3039,%eax 1a71: 89 45 f0 mov %eax,-0x10(%ebp) if((x % 3) == 0){ 1a74: 8b 45 f0 mov -0x10(%ebp),%eax 1a77: b9 03 00 00 00 mov $0x3,%ecx 1a7c: ba 00 00 00 00 mov $0x0,%edx 1a81: f7 f1 div %ecx 1a83: 89 d0 mov %edx,%eax 1a85: 85 c0 test %eax,%eax 1a87: 75 1e jne 1aa7 <linkunlink+0xd8> close(open("x", O_RDWR | O_CREATE)); 1a89: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1a90: 00 1a91: c7 04 24 06 45 00 00 movl $0x4506,(%esp) 1a98: e8 ab 21 00 00 call 3c48 <open> 1a9d: 89 04 24 mov %eax,(%esp) 1aa0: e8 8b 21 00 00 call 3c30 <close> 1aa5: eb 38 jmp 1adf <linkunlink+0x110> } else if((x % 3) == 1){ 1aa7: 8b 45 f0 mov -0x10(%ebp),%eax 1aaa: b9 03 00 00 00 mov $0x3,%ecx 1aaf: ba 00 00 00 00 mov $0x0,%edx 1ab4: f7 f1 div %ecx 1ab6: 89 d0 mov %edx,%eax 1ab8: 83 f8 01 cmp $0x1,%eax 1abb: 75 16 jne 1ad3 <linkunlink+0x104> link("cat", "x"); 1abd: c7 44 24 04 06 45 00 movl $0x4506,0x4(%esp) 1ac4: 00 1ac5: c7 04 24 b0 49 00 00 movl $0x49b0,(%esp) 1acc: e8 97 21 00 00 call 3c68 <link> 1ad1: eb 0c jmp 1adf <linkunlink+0x110> } else { unlink("x"); 1ad3: c7 04 24 06 45 00 00 movl $0x4506,(%esp) 1ada: e8 79 21 00 00 call 3c58 <unlink> printf(1, "fork failed\n"); exit(); } unsigned int x = (pid ? 1 : 97); for(i = 0; i < 100; i++){ 1adf: ff 45 f4 incl -0xc(%ebp) 1ae2: 83 7d f4 63 cmpl $0x63,-0xc(%ebp) 1ae6: 0f 8e 51 ff ff ff jle 1a3d <linkunlink+0x6e> } else { unlink("x"); } } if(pid) 1aec: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 1af0: 74 1b je 1b0d <linkunlink+0x13e> wait(); 1af2: e8 19 21 00 00 call 3c10 <wait> else exit(); printf(1, "linkunlink ok\n"); 1af7: c7 44 24 04 b4 49 00 movl $0x49b4,0x4(%esp) 1afe: 00 1aff: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1b06: e8 8d 22 00 00 call 3d98 <printf> 1b0b: eb 05 jmp 1b12 <linkunlink+0x143> } if(pid) wait(); else exit(); 1b0d: e8 f6 20 00 00 call 3c08 <exit> printf(1, "linkunlink ok\n"); } 1b12: c9 leave 1b13: c3 ret 00001b14 <bigdir>: // directory that uses indirect blocks void bigdir(void) { 1b14: 55 push %ebp 1b15: 89 e5 mov %esp,%ebp 1b17: 83 ec 38 sub $0x38,%esp int i, fd; char name[10]; printf(1, "bigdir test\n"); 1b1a: c7 44 24 04 c3 49 00 movl $0x49c3,0x4(%esp) 1b21: 00 1b22: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1b29: e8 6a 22 00 00 call 3d98 <printf> unlink("bd"); 1b2e: c7 04 24 d0 49 00 00 movl $0x49d0,(%esp) 1b35: e8 1e 21 00 00 call 3c58 <unlink> fd = open("bd", O_CREATE); 1b3a: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 1b41: 00 1b42: c7 04 24 d0 49 00 00 movl $0x49d0,(%esp) 1b49: e8 fa 20 00 00 call 3c48 <open> 1b4e: 89 45 f0 mov %eax,-0x10(%ebp) if(fd < 0){ 1b51: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1b55: 79 19 jns 1b70 <bigdir+0x5c> printf(1, "bigdir create failed\n"); 1b57: c7 44 24 04 d3 49 00 movl $0x49d3,0x4(%esp) 1b5e: 00 1b5f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1b66: e8 2d 22 00 00 call 3d98 <printf> exit(); 1b6b: e8 98 20 00 00 call 3c08 <exit> } close(fd); 1b70: 8b 45 f0 mov -0x10(%ebp),%eax 1b73: 89 04 24 mov %eax,(%esp) 1b76: e8 b5 20 00 00 call 3c30 <close> for(i = 0; i < 500; i++){ 1b7b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1b82: eb 65 jmp 1be9 <bigdir+0xd5> name[0] = 'x'; 1b84: c6 45 e6 78 movb $0x78,-0x1a(%ebp) name[1] = '0' + (i / 64); 1b88: 8b 45 f4 mov -0xc(%ebp),%eax 1b8b: 85 c0 test %eax,%eax 1b8d: 79 03 jns 1b92 <bigdir+0x7e> 1b8f: 83 c0 3f add $0x3f,%eax 1b92: c1 f8 06 sar $0x6,%eax 1b95: 83 c0 30 add $0x30,%eax 1b98: 88 45 e7 mov %al,-0x19(%ebp) name[2] = '0' + (i % 64); 1b9b: 8b 45 f4 mov -0xc(%ebp),%eax 1b9e: 25 3f 00 00 80 and $0x8000003f,%eax 1ba3: 85 c0 test %eax,%eax 1ba5: 79 05 jns 1bac <bigdir+0x98> 1ba7: 48 dec %eax 1ba8: 83 c8 c0 or $0xffffffc0,%eax 1bab: 40 inc %eax 1bac: 83 c0 30 add $0x30,%eax 1baf: 88 45 e8 mov %al,-0x18(%ebp) name[3] = '\0'; 1bb2: c6 45 e9 00 movb $0x0,-0x17(%ebp) if(link("bd", name) != 0){ 1bb6: 8d 45 e6 lea -0x1a(%ebp),%eax 1bb9: 89 44 24 04 mov %eax,0x4(%esp) 1bbd: c7 04 24 d0 49 00 00 movl $0x49d0,(%esp) 1bc4: e8 9f 20 00 00 call 3c68 <link> 1bc9: 85 c0 test %eax,%eax 1bcb: 74 19 je 1be6 <bigdir+0xd2> printf(1, "bigdir link failed\n"); 1bcd: c7 44 24 04 e9 49 00 movl $0x49e9,0x4(%esp) 1bd4: 00 1bd5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1bdc: e8 b7 21 00 00 call 3d98 <printf> exit(); 1be1: e8 22 20 00 00 call 3c08 <exit> printf(1, "bigdir create failed\n"); exit(); } close(fd); for(i = 0; i < 500; i++){ 1be6: ff 45 f4 incl -0xc(%ebp) 1be9: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp) 1bf0: 7e 92 jle 1b84 <bigdir+0x70> printf(1, "bigdir link failed\n"); exit(); } } unlink("bd"); 1bf2: c7 04 24 d0 49 00 00 movl $0x49d0,(%esp) 1bf9: e8 5a 20 00 00 call 3c58 <unlink> for(i = 0; i < 500; i++){ 1bfe: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1c05: eb 5d jmp 1c64 <bigdir+0x150> name[0] = 'x'; 1c07: c6 45 e6 78 movb $0x78,-0x1a(%ebp) name[1] = '0' + (i / 64); 1c0b: 8b 45 f4 mov -0xc(%ebp),%eax 1c0e: 85 c0 test %eax,%eax 1c10: 79 03 jns 1c15 <bigdir+0x101> 1c12: 83 c0 3f add $0x3f,%eax 1c15: c1 f8 06 sar $0x6,%eax 1c18: 83 c0 30 add $0x30,%eax 1c1b: 88 45 e7 mov %al,-0x19(%ebp) name[2] = '0' + (i % 64); 1c1e: 8b 45 f4 mov -0xc(%ebp),%eax 1c21: 25 3f 00 00 80 and $0x8000003f,%eax 1c26: 85 c0 test %eax,%eax 1c28: 79 05 jns 1c2f <bigdir+0x11b> 1c2a: 48 dec %eax 1c2b: 83 c8 c0 or $0xffffffc0,%eax 1c2e: 40 inc %eax 1c2f: 83 c0 30 add $0x30,%eax 1c32: 88 45 e8 mov %al,-0x18(%ebp) name[3] = '\0'; 1c35: c6 45 e9 00 movb $0x0,-0x17(%ebp) if(unlink(name) != 0){ 1c39: 8d 45 e6 lea -0x1a(%ebp),%eax 1c3c: 89 04 24 mov %eax,(%esp) 1c3f: e8 14 20 00 00 call 3c58 <unlink> 1c44: 85 c0 test %eax,%eax 1c46: 74 19 je 1c61 <bigdir+0x14d> printf(1, "bigdir unlink failed"); 1c48: c7 44 24 04 fd 49 00 movl $0x49fd,0x4(%esp) 1c4f: 00 1c50: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1c57: e8 3c 21 00 00 call 3d98 <printf> exit(); 1c5c: e8 a7 1f 00 00 call 3c08 <exit> exit(); } } unlink("bd"); for(i = 0; i < 500; i++){ 1c61: ff 45 f4 incl -0xc(%ebp) 1c64: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp) 1c6b: 7e 9a jle 1c07 <bigdir+0xf3> printf(1, "bigdir unlink failed"); exit(); } } printf(1, "bigdir ok\n"); 1c6d: c7 44 24 04 12 4a 00 movl $0x4a12,0x4(%esp) 1c74: 00 1c75: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1c7c: e8 17 21 00 00 call 3d98 <printf> } 1c81: c9 leave 1c82: c3 ret 00001c83 <subdir>: void subdir(void) { 1c83: 55 push %ebp 1c84: 89 e5 mov %esp,%ebp 1c86: 83 ec 28 sub $0x28,%esp int fd, cc; printf(1, "subdir test\n"); 1c89: c7 44 24 04 1d 4a 00 movl $0x4a1d,0x4(%esp) 1c90: 00 1c91: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1c98: e8 fb 20 00 00 call 3d98 <printf> unlink("ff"); 1c9d: c7 04 24 2a 4a 00 00 movl $0x4a2a,(%esp) 1ca4: e8 af 1f 00 00 call 3c58 <unlink> if(mkdir("dd") != 0){ 1ca9: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 1cb0: e8 bb 1f 00 00 call 3c70 <mkdir> 1cb5: 85 c0 test %eax,%eax 1cb7: 74 19 je 1cd2 <subdir+0x4f> printf(1, "subdir mkdir dd failed\n"); 1cb9: c7 44 24 04 30 4a 00 movl $0x4a30,0x4(%esp) 1cc0: 00 1cc1: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1cc8: e8 cb 20 00 00 call 3d98 <printf> exit(); 1ccd: e8 36 1f 00 00 call 3c08 <exit> } fd = open("dd/ff", O_CREATE | O_RDWR); 1cd2: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1cd9: 00 1cda: c7 04 24 48 4a 00 00 movl $0x4a48,(%esp) 1ce1: e8 62 1f 00 00 call 3c48 <open> 1ce6: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1ce9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1ced: 79 19 jns 1d08 <subdir+0x85> printf(1, "create dd/ff failed\n"); 1cef: c7 44 24 04 4e 4a 00 movl $0x4a4e,0x4(%esp) 1cf6: 00 1cf7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1cfe: e8 95 20 00 00 call 3d98 <printf> exit(); 1d03: e8 00 1f 00 00 call 3c08 <exit> } write(fd, "ff", 2); 1d08: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) 1d0f: 00 1d10: c7 44 24 04 2a 4a 00 movl $0x4a2a,0x4(%esp) 1d17: 00 1d18: 8b 45 f4 mov -0xc(%ebp),%eax 1d1b: 89 04 24 mov %eax,(%esp) 1d1e: e8 05 1f 00 00 call 3c28 <write> close(fd); 1d23: 8b 45 f4 mov -0xc(%ebp),%eax 1d26: 89 04 24 mov %eax,(%esp) 1d29: e8 02 1f 00 00 call 3c30 <close> if(unlink("dd") >= 0){ 1d2e: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 1d35: e8 1e 1f 00 00 call 3c58 <unlink> 1d3a: 85 c0 test %eax,%eax 1d3c: 78 19 js 1d57 <subdir+0xd4> printf(1, "unlink dd (non-empty dir) succeeded!\n"); 1d3e: c7 44 24 04 64 4a 00 movl $0x4a64,0x4(%esp) 1d45: 00 1d46: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1d4d: e8 46 20 00 00 call 3d98 <printf> exit(); 1d52: e8 b1 1e 00 00 call 3c08 <exit> } if(mkdir("/dd/dd") != 0){ 1d57: c7 04 24 8a 4a 00 00 movl $0x4a8a,(%esp) 1d5e: e8 0d 1f 00 00 call 3c70 <mkdir> 1d63: 85 c0 test %eax,%eax 1d65: 74 19 je 1d80 <subdir+0xfd> printf(1, "subdir mkdir dd/dd failed\n"); 1d67: c7 44 24 04 91 4a 00 movl $0x4a91,0x4(%esp) 1d6e: 00 1d6f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1d76: e8 1d 20 00 00 call 3d98 <printf> exit(); 1d7b: e8 88 1e 00 00 call 3c08 <exit> } fd = open("dd/dd/ff", O_CREATE | O_RDWR); 1d80: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 1d87: 00 1d88: c7 04 24 ac 4a 00 00 movl $0x4aac,(%esp) 1d8f: e8 b4 1e 00 00 call 3c48 <open> 1d94: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1d97: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1d9b: 79 19 jns 1db6 <subdir+0x133> printf(1, "create dd/dd/ff failed\n"); 1d9d: c7 44 24 04 b5 4a 00 movl $0x4ab5,0x4(%esp) 1da4: 00 1da5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1dac: e8 e7 1f 00 00 call 3d98 <printf> exit(); 1db1: e8 52 1e 00 00 call 3c08 <exit> } write(fd, "FF", 2); 1db6: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp) 1dbd: 00 1dbe: c7 44 24 04 cd 4a 00 movl $0x4acd,0x4(%esp) 1dc5: 00 1dc6: 8b 45 f4 mov -0xc(%ebp),%eax 1dc9: 89 04 24 mov %eax,(%esp) 1dcc: e8 57 1e 00 00 call 3c28 <write> close(fd); 1dd1: 8b 45 f4 mov -0xc(%ebp),%eax 1dd4: 89 04 24 mov %eax,(%esp) 1dd7: e8 54 1e 00 00 call 3c30 <close> fd = open("dd/dd/../ff", 0); 1ddc: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1de3: 00 1de4: c7 04 24 d0 4a 00 00 movl $0x4ad0,(%esp) 1deb: e8 58 1e 00 00 call 3c48 <open> 1df0: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1df3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1df7: 79 19 jns 1e12 <subdir+0x18f> printf(1, "open dd/dd/../ff failed\n"); 1df9: c7 44 24 04 dc 4a 00 movl $0x4adc,0x4(%esp) 1e00: 00 1e01: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e08: e8 8b 1f 00 00 call 3d98 <printf> exit(); 1e0d: e8 f6 1d 00 00 call 3c08 <exit> } cc = read(fd, buf, sizeof(buf)); 1e12: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1e19: 00 1e1a: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 1e21: 00 1e22: 8b 45 f4 mov -0xc(%ebp),%eax 1e25: 89 04 24 mov %eax,(%esp) 1e28: e8 f3 1d 00 00 call 3c20 <read> 1e2d: 89 45 f0 mov %eax,-0x10(%ebp) if(cc != 2 || buf[0] != 'f'){ 1e30: 83 7d f0 02 cmpl $0x2,-0x10(%ebp) 1e34: 75 09 jne 1e3f <subdir+0x1bc> 1e36: a0 a0 86 00 00 mov 0x86a0,%al 1e3b: 3c 66 cmp $0x66,%al 1e3d: 74 19 je 1e58 <subdir+0x1d5> printf(1, "dd/dd/../ff wrong content\n"); 1e3f: c7 44 24 04 f5 4a 00 movl $0x4af5,0x4(%esp) 1e46: 00 1e47: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e4e: e8 45 1f 00 00 call 3d98 <printf> exit(); 1e53: e8 b0 1d 00 00 call 3c08 <exit> } close(fd); 1e58: 8b 45 f4 mov -0xc(%ebp),%eax 1e5b: 89 04 24 mov %eax,(%esp) 1e5e: e8 cd 1d 00 00 call 3c30 <close> if(link("dd/dd/ff", "dd/dd/ffff") != 0){ 1e63: c7 44 24 04 10 4b 00 movl $0x4b10,0x4(%esp) 1e6a: 00 1e6b: c7 04 24 ac 4a 00 00 movl $0x4aac,(%esp) 1e72: e8 f1 1d 00 00 call 3c68 <link> 1e77: 85 c0 test %eax,%eax 1e79: 74 19 je 1e94 <subdir+0x211> printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); 1e7b: c7 44 24 04 1c 4b 00 movl $0x4b1c,0x4(%esp) 1e82: 00 1e83: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e8a: e8 09 1f 00 00 call 3d98 <printf> exit(); 1e8f: e8 74 1d 00 00 call 3c08 <exit> } if(unlink("dd/dd/ff") != 0){ 1e94: c7 04 24 ac 4a 00 00 movl $0x4aac,(%esp) 1e9b: e8 b8 1d 00 00 call 3c58 <unlink> 1ea0: 85 c0 test %eax,%eax 1ea2: 74 19 je 1ebd <subdir+0x23a> printf(1, "unlink dd/dd/ff failed\n"); 1ea4: c7 44 24 04 3d 4b 00 movl $0x4b3d,0x4(%esp) 1eab: 00 1eac: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1eb3: e8 e0 1e 00 00 call 3d98 <printf> exit(); 1eb8: e8 4b 1d 00 00 call 3c08 <exit> } if(open("dd/dd/ff", O_RDONLY) >= 0){ 1ebd: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1ec4: 00 1ec5: c7 04 24 ac 4a 00 00 movl $0x4aac,(%esp) 1ecc: e8 77 1d 00 00 call 3c48 <open> 1ed1: 85 c0 test %eax,%eax 1ed3: 78 19 js 1eee <subdir+0x26b> printf(1, "open (unlinked) dd/dd/ff succeeded\n"); 1ed5: c7 44 24 04 58 4b 00 movl $0x4b58,0x4(%esp) 1edc: 00 1edd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1ee4: e8 af 1e 00 00 call 3d98 <printf> exit(); 1ee9: e8 1a 1d 00 00 call 3c08 <exit> } if(chdir("dd") != 0){ 1eee: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 1ef5: e8 7e 1d 00 00 call 3c78 <chdir> 1efa: 85 c0 test %eax,%eax 1efc: 74 19 je 1f17 <subdir+0x294> printf(1, "chdir dd failed\n"); 1efe: c7 44 24 04 7c 4b 00 movl $0x4b7c,0x4(%esp) 1f05: 00 1f06: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f0d: e8 86 1e 00 00 call 3d98 <printf> exit(); 1f12: e8 f1 1c 00 00 call 3c08 <exit> } if(chdir("dd/../../dd") != 0){ 1f17: c7 04 24 8d 4b 00 00 movl $0x4b8d,(%esp) 1f1e: e8 55 1d 00 00 call 3c78 <chdir> 1f23: 85 c0 test %eax,%eax 1f25: 74 19 je 1f40 <subdir+0x2bd> printf(1, "chdir dd/../../dd failed\n"); 1f27: c7 44 24 04 99 4b 00 movl $0x4b99,0x4(%esp) 1f2e: 00 1f2f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f36: e8 5d 1e 00 00 call 3d98 <printf> exit(); 1f3b: e8 c8 1c 00 00 call 3c08 <exit> } if(chdir("dd/../../../dd") != 0){ 1f40: c7 04 24 b3 4b 00 00 movl $0x4bb3,(%esp) 1f47: e8 2c 1d 00 00 call 3c78 <chdir> 1f4c: 85 c0 test %eax,%eax 1f4e: 74 19 je 1f69 <subdir+0x2e6> printf(1, "chdir dd/../../dd failed\n"); 1f50: c7 44 24 04 99 4b 00 movl $0x4b99,0x4(%esp) 1f57: 00 1f58: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f5f: e8 34 1e 00 00 call 3d98 <printf> exit(); 1f64: e8 9f 1c 00 00 call 3c08 <exit> } if(chdir("./..") != 0){ 1f69: c7 04 24 c2 4b 00 00 movl $0x4bc2,(%esp) 1f70: e8 03 1d 00 00 call 3c78 <chdir> 1f75: 85 c0 test %eax,%eax 1f77: 74 19 je 1f92 <subdir+0x30f> printf(1, "chdir ./.. failed\n"); 1f79: c7 44 24 04 c7 4b 00 movl $0x4bc7,0x4(%esp) 1f80: 00 1f81: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1f88: e8 0b 1e 00 00 call 3d98 <printf> exit(); 1f8d: e8 76 1c 00 00 call 3c08 <exit> } fd = open("dd/dd/ffff", 0); 1f92: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1f99: 00 1f9a: c7 04 24 10 4b 00 00 movl $0x4b10,(%esp) 1fa1: e8 a2 1c 00 00 call 3c48 <open> 1fa6: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 1fa9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1fad: 79 19 jns 1fc8 <subdir+0x345> printf(1, "open dd/dd/ffff failed\n"); 1faf: c7 44 24 04 da 4b 00 movl $0x4bda,0x4(%esp) 1fb6: 00 1fb7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1fbe: e8 d5 1d 00 00 call 3d98 <printf> exit(); 1fc3: e8 40 1c 00 00 call 3c08 <exit> } if(read(fd, buf, sizeof(buf)) != 2){ 1fc8: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp) 1fcf: 00 1fd0: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 1fd7: 00 1fd8: 8b 45 f4 mov -0xc(%ebp),%eax 1fdb: 89 04 24 mov %eax,(%esp) 1fde: e8 3d 1c 00 00 call 3c20 <read> 1fe3: 83 f8 02 cmp $0x2,%eax 1fe6: 74 19 je 2001 <subdir+0x37e> printf(1, "read dd/dd/ffff wrong len\n"); 1fe8: c7 44 24 04 f2 4b 00 movl $0x4bf2,0x4(%esp) 1fef: 00 1ff0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1ff7: e8 9c 1d 00 00 call 3d98 <printf> exit(); 1ffc: e8 07 1c 00 00 call 3c08 <exit> } close(fd); 2001: 8b 45 f4 mov -0xc(%ebp),%eax 2004: 89 04 24 mov %eax,(%esp) 2007: e8 24 1c 00 00 call 3c30 <close> if(open("dd/dd/ff", O_RDONLY) >= 0){ 200c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2013: 00 2014: c7 04 24 ac 4a 00 00 movl $0x4aac,(%esp) 201b: e8 28 1c 00 00 call 3c48 <open> 2020: 85 c0 test %eax,%eax 2022: 78 19 js 203d <subdir+0x3ba> printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); 2024: c7 44 24 04 10 4c 00 movl $0x4c10,0x4(%esp) 202b: 00 202c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2033: e8 60 1d 00 00 call 3d98 <printf> exit(); 2038: e8 cb 1b 00 00 call 3c08 <exit> } if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ 203d: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 2044: 00 2045: c7 04 24 35 4c 00 00 movl $0x4c35,(%esp) 204c: e8 f7 1b 00 00 call 3c48 <open> 2051: 85 c0 test %eax,%eax 2053: 78 19 js 206e <subdir+0x3eb> printf(1, "create dd/ff/ff succeeded!\n"); 2055: c7 44 24 04 3e 4c 00 movl $0x4c3e,0x4(%esp) 205c: 00 205d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2064: e8 2f 1d 00 00 call 3d98 <printf> exit(); 2069: e8 9a 1b 00 00 call 3c08 <exit> } if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ 206e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 2075: 00 2076: c7 04 24 5a 4c 00 00 movl $0x4c5a,(%esp) 207d: e8 c6 1b 00 00 call 3c48 <open> 2082: 85 c0 test %eax,%eax 2084: 78 19 js 209f <subdir+0x41c> printf(1, "create dd/xx/ff succeeded!\n"); 2086: c7 44 24 04 63 4c 00 movl $0x4c63,0x4(%esp) 208d: 00 208e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2095: e8 fe 1c 00 00 call 3d98 <printf> exit(); 209a: e8 69 1b 00 00 call 3c08 <exit> } if(open("dd", O_CREATE) >= 0){ 209f: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 20a6: 00 20a7: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 20ae: e8 95 1b 00 00 call 3c48 <open> 20b3: 85 c0 test %eax,%eax 20b5: 78 19 js 20d0 <subdir+0x44d> printf(1, "create dd succeeded!\n"); 20b7: c7 44 24 04 7f 4c 00 movl $0x4c7f,0x4(%esp) 20be: 00 20bf: c7 04 24 01 00 00 00 movl $0x1,(%esp) 20c6: e8 cd 1c 00 00 call 3d98 <printf> exit(); 20cb: e8 38 1b 00 00 call 3c08 <exit> } if(open("dd", O_RDWR) >= 0){ 20d0: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 20d7: 00 20d8: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 20df: e8 64 1b 00 00 call 3c48 <open> 20e4: 85 c0 test %eax,%eax 20e6: 78 19 js 2101 <subdir+0x47e> printf(1, "open dd rdwr succeeded!\n"); 20e8: c7 44 24 04 95 4c 00 movl $0x4c95,0x4(%esp) 20ef: 00 20f0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 20f7: e8 9c 1c 00 00 call 3d98 <printf> exit(); 20fc: e8 07 1b 00 00 call 3c08 <exit> } if(open("dd", O_WRONLY) >= 0){ 2101: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 2108: 00 2109: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 2110: e8 33 1b 00 00 call 3c48 <open> 2115: 85 c0 test %eax,%eax 2117: 78 19 js 2132 <subdir+0x4af> printf(1, "open dd wronly succeeded!\n"); 2119: c7 44 24 04 ae 4c 00 movl $0x4cae,0x4(%esp) 2120: 00 2121: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2128: e8 6b 1c 00 00 call 3d98 <printf> exit(); 212d: e8 d6 1a 00 00 call 3c08 <exit> } if(link("dd/ff/ff", "dd/dd/xx") == 0){ 2132: c7 44 24 04 c9 4c 00 movl $0x4cc9,0x4(%esp) 2139: 00 213a: c7 04 24 35 4c 00 00 movl $0x4c35,(%esp) 2141: e8 22 1b 00 00 call 3c68 <link> 2146: 85 c0 test %eax,%eax 2148: 75 19 jne 2163 <subdir+0x4e0> printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); 214a: c7 44 24 04 d4 4c 00 movl $0x4cd4,0x4(%esp) 2151: 00 2152: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2159: e8 3a 1c 00 00 call 3d98 <printf> exit(); 215e: e8 a5 1a 00 00 call 3c08 <exit> } if(link("dd/xx/ff", "dd/dd/xx") == 0){ 2163: c7 44 24 04 c9 4c 00 movl $0x4cc9,0x4(%esp) 216a: 00 216b: c7 04 24 5a 4c 00 00 movl $0x4c5a,(%esp) 2172: e8 f1 1a 00 00 call 3c68 <link> 2177: 85 c0 test %eax,%eax 2179: 75 19 jne 2194 <subdir+0x511> printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); 217b: c7 44 24 04 f8 4c 00 movl $0x4cf8,0x4(%esp) 2182: 00 2183: c7 04 24 01 00 00 00 movl $0x1,(%esp) 218a: e8 09 1c 00 00 call 3d98 <printf> exit(); 218f: e8 74 1a 00 00 call 3c08 <exit> } if(link("dd/ff", "dd/dd/ffff") == 0){ 2194: c7 44 24 04 10 4b 00 movl $0x4b10,0x4(%esp) 219b: 00 219c: c7 04 24 48 4a 00 00 movl $0x4a48,(%esp) 21a3: e8 c0 1a 00 00 call 3c68 <link> 21a8: 85 c0 test %eax,%eax 21aa: 75 19 jne 21c5 <subdir+0x542> printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); 21ac: c7 44 24 04 1c 4d 00 movl $0x4d1c,0x4(%esp) 21b3: 00 21b4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 21bb: e8 d8 1b 00 00 call 3d98 <printf> exit(); 21c0: e8 43 1a 00 00 call 3c08 <exit> } if(mkdir("dd/ff/ff") == 0){ 21c5: c7 04 24 35 4c 00 00 movl $0x4c35,(%esp) 21cc: e8 9f 1a 00 00 call 3c70 <mkdir> 21d1: 85 c0 test %eax,%eax 21d3: 75 19 jne 21ee <subdir+0x56b> printf(1, "mkdir dd/ff/ff succeeded!\n"); 21d5: c7 44 24 04 3e 4d 00 movl $0x4d3e,0x4(%esp) 21dc: 00 21dd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 21e4: e8 af 1b 00 00 call 3d98 <printf> exit(); 21e9: e8 1a 1a 00 00 call 3c08 <exit> } if(mkdir("dd/xx/ff") == 0){ 21ee: c7 04 24 5a 4c 00 00 movl $0x4c5a,(%esp) 21f5: e8 76 1a 00 00 call 3c70 <mkdir> 21fa: 85 c0 test %eax,%eax 21fc: 75 19 jne 2217 <subdir+0x594> printf(1, "mkdir dd/xx/ff succeeded!\n"); 21fe: c7 44 24 04 59 4d 00 movl $0x4d59,0x4(%esp) 2205: 00 2206: c7 04 24 01 00 00 00 movl $0x1,(%esp) 220d: e8 86 1b 00 00 call 3d98 <printf> exit(); 2212: e8 f1 19 00 00 call 3c08 <exit> } if(mkdir("dd/dd/ffff") == 0){ 2217: c7 04 24 10 4b 00 00 movl $0x4b10,(%esp) 221e: e8 4d 1a 00 00 call 3c70 <mkdir> 2223: 85 c0 test %eax,%eax 2225: 75 19 jne 2240 <subdir+0x5bd> printf(1, "mkdir dd/dd/ffff succeeded!\n"); 2227: c7 44 24 04 74 4d 00 movl $0x4d74,0x4(%esp) 222e: 00 222f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2236: e8 5d 1b 00 00 call 3d98 <printf> exit(); 223b: e8 c8 19 00 00 call 3c08 <exit> } if(unlink("dd/xx/ff") == 0){ 2240: c7 04 24 5a 4c 00 00 movl $0x4c5a,(%esp) 2247: e8 0c 1a 00 00 call 3c58 <unlink> 224c: 85 c0 test %eax,%eax 224e: 75 19 jne 2269 <subdir+0x5e6> printf(1, "unlink dd/xx/ff succeeded!\n"); 2250: c7 44 24 04 91 4d 00 movl $0x4d91,0x4(%esp) 2257: 00 2258: c7 04 24 01 00 00 00 movl $0x1,(%esp) 225f: e8 34 1b 00 00 call 3d98 <printf> exit(); 2264: e8 9f 19 00 00 call 3c08 <exit> } if(unlink("dd/ff/ff") == 0){ 2269: c7 04 24 35 4c 00 00 movl $0x4c35,(%esp) 2270: e8 e3 19 00 00 call 3c58 <unlink> 2275: 85 c0 test %eax,%eax 2277: 75 19 jne 2292 <subdir+0x60f> printf(1, "unlink dd/ff/ff succeeded!\n"); 2279: c7 44 24 04 ad 4d 00 movl $0x4dad,0x4(%esp) 2280: 00 2281: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2288: e8 0b 1b 00 00 call 3d98 <printf> exit(); 228d: e8 76 19 00 00 call 3c08 <exit> } if(chdir("dd/ff") == 0){ 2292: c7 04 24 48 4a 00 00 movl $0x4a48,(%esp) 2299: e8 da 19 00 00 call 3c78 <chdir> 229e: 85 c0 test %eax,%eax 22a0: 75 19 jne 22bb <subdir+0x638> printf(1, "chdir dd/ff succeeded!\n"); 22a2: c7 44 24 04 c9 4d 00 movl $0x4dc9,0x4(%esp) 22a9: 00 22aa: c7 04 24 01 00 00 00 movl $0x1,(%esp) 22b1: e8 e2 1a 00 00 call 3d98 <printf> exit(); 22b6: e8 4d 19 00 00 call 3c08 <exit> } if(chdir("dd/xx") == 0){ 22bb: c7 04 24 e1 4d 00 00 movl $0x4de1,(%esp) 22c2: e8 b1 19 00 00 call 3c78 <chdir> 22c7: 85 c0 test %eax,%eax 22c9: 75 19 jne 22e4 <subdir+0x661> printf(1, "chdir dd/xx succeeded!\n"); 22cb: c7 44 24 04 e7 4d 00 movl $0x4de7,0x4(%esp) 22d2: 00 22d3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 22da: e8 b9 1a 00 00 call 3d98 <printf> exit(); 22df: e8 24 19 00 00 call 3c08 <exit> } if(unlink("dd/dd/ffff") != 0){ 22e4: c7 04 24 10 4b 00 00 movl $0x4b10,(%esp) 22eb: e8 68 19 00 00 call 3c58 <unlink> 22f0: 85 c0 test %eax,%eax 22f2: 74 19 je 230d <subdir+0x68a> printf(1, "unlink dd/dd/ff failed\n"); 22f4: c7 44 24 04 3d 4b 00 movl $0x4b3d,0x4(%esp) 22fb: 00 22fc: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2303: e8 90 1a 00 00 call 3d98 <printf> exit(); 2308: e8 fb 18 00 00 call 3c08 <exit> } if(unlink("dd/ff") != 0){ 230d: c7 04 24 48 4a 00 00 movl $0x4a48,(%esp) 2314: e8 3f 19 00 00 call 3c58 <unlink> 2319: 85 c0 test %eax,%eax 231b: 74 19 je 2336 <subdir+0x6b3> printf(1, "unlink dd/ff failed\n"); 231d: c7 44 24 04 ff 4d 00 movl $0x4dff,0x4(%esp) 2324: 00 2325: c7 04 24 01 00 00 00 movl $0x1,(%esp) 232c: e8 67 1a 00 00 call 3d98 <printf> exit(); 2331: e8 d2 18 00 00 call 3c08 <exit> } if(unlink("dd") == 0){ 2336: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 233d: e8 16 19 00 00 call 3c58 <unlink> 2342: 85 c0 test %eax,%eax 2344: 75 19 jne 235f <subdir+0x6dc> printf(1, "unlink non-empty dd succeeded!\n"); 2346: c7 44 24 04 14 4e 00 movl $0x4e14,0x4(%esp) 234d: 00 234e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2355: e8 3e 1a 00 00 call 3d98 <printf> exit(); 235a: e8 a9 18 00 00 call 3c08 <exit> } if(unlink("dd/dd") < 0){ 235f: c7 04 24 34 4e 00 00 movl $0x4e34,(%esp) 2366: e8 ed 18 00 00 call 3c58 <unlink> 236b: 85 c0 test %eax,%eax 236d: 79 19 jns 2388 <subdir+0x705> printf(1, "unlink dd/dd failed\n"); 236f: c7 44 24 04 3a 4e 00 movl $0x4e3a,0x4(%esp) 2376: 00 2377: c7 04 24 01 00 00 00 movl $0x1,(%esp) 237e: e8 15 1a 00 00 call 3d98 <printf> exit(); 2383: e8 80 18 00 00 call 3c08 <exit> } if(unlink("dd") < 0){ 2388: c7 04 24 2d 4a 00 00 movl $0x4a2d,(%esp) 238f: e8 c4 18 00 00 call 3c58 <unlink> 2394: 85 c0 test %eax,%eax 2396: 79 19 jns 23b1 <subdir+0x72e> printf(1, "unlink dd failed\n"); 2398: c7 44 24 04 4f 4e 00 movl $0x4e4f,0x4(%esp) 239f: 00 23a0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 23a7: e8 ec 19 00 00 call 3d98 <printf> exit(); 23ac: e8 57 18 00 00 call 3c08 <exit> } printf(1, "subdir ok\n"); 23b1: c7 44 24 04 61 4e 00 movl $0x4e61,0x4(%esp) 23b8: 00 23b9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 23c0: e8 d3 19 00 00 call 3d98 <printf> } 23c5: c9 leave 23c6: c3 ret 000023c7 <bigwrite>: // test writes that are larger than the log. void bigwrite(void) { 23c7: 55 push %ebp 23c8: 89 e5 mov %esp,%ebp 23ca: 83 ec 28 sub $0x28,%esp int fd, sz; printf(1, "bigwrite test\n"); 23cd: c7 44 24 04 6c 4e 00 movl $0x4e6c,0x4(%esp) 23d4: 00 23d5: c7 04 24 01 00 00 00 movl $0x1,(%esp) 23dc: e8 b7 19 00 00 call 3d98 <printf> unlink("bigwrite"); 23e1: c7 04 24 7b 4e 00 00 movl $0x4e7b,(%esp) 23e8: e8 6b 18 00 00 call 3c58 <unlink> for(sz = 499; sz < 12*512; sz += 471){ 23ed: c7 45 f4 f3 01 00 00 movl $0x1f3,-0xc(%ebp) 23f4: e9 b2 00 00 00 jmp 24ab <bigwrite+0xe4> fd = open("bigwrite", O_CREATE | O_RDWR); 23f9: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 2400: 00 2401: c7 04 24 7b 4e 00 00 movl $0x4e7b,(%esp) 2408: e8 3b 18 00 00 call 3c48 <open> 240d: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 2410: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 2414: 79 19 jns 242f <bigwrite+0x68> printf(1, "cannot create bigwrite\n"); 2416: c7 44 24 04 84 4e 00 movl $0x4e84,0x4(%esp) 241d: 00 241e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2425: e8 6e 19 00 00 call 3d98 <printf> exit(); 242a: e8 d9 17 00 00 call 3c08 <exit> } int i; for(i = 0; i < 2; i++){ 242f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 2436: eb 4f jmp 2487 <bigwrite+0xc0> int cc = write(fd, buf, sz); 2438: 8b 45 f4 mov -0xc(%ebp),%eax 243b: 89 44 24 08 mov %eax,0x8(%esp) 243f: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 2446: 00 2447: 8b 45 ec mov -0x14(%ebp),%eax 244a: 89 04 24 mov %eax,(%esp) 244d: e8 d6 17 00 00 call 3c28 <write> 2452: 89 45 e8 mov %eax,-0x18(%ebp) if(cc != sz){ 2455: 8b 45 e8 mov -0x18(%ebp),%eax 2458: 3b 45 f4 cmp -0xc(%ebp),%eax 245b: 74 27 je 2484 <bigwrite+0xbd> printf(1, "write(%d) ret %d\n", sz, cc); 245d: 8b 45 e8 mov -0x18(%ebp),%eax 2460: 89 44 24 0c mov %eax,0xc(%esp) 2464: 8b 45 f4 mov -0xc(%ebp),%eax 2467: 89 44 24 08 mov %eax,0x8(%esp) 246b: c7 44 24 04 9c 4e 00 movl $0x4e9c,0x4(%esp) 2472: 00 2473: c7 04 24 01 00 00 00 movl $0x1,(%esp) 247a: e8 19 19 00 00 call 3d98 <printf> exit(); 247f: e8 84 17 00 00 call 3c08 <exit> if(fd < 0){ printf(1, "cannot create bigwrite\n"); exit(); } int i; for(i = 0; i < 2; i++){ 2484: ff 45 f0 incl -0x10(%ebp) 2487: 83 7d f0 01 cmpl $0x1,-0x10(%ebp) 248b: 7e ab jle 2438 <bigwrite+0x71> if(cc != sz){ printf(1, "write(%d) ret %d\n", sz, cc); exit(); } } close(fd); 248d: 8b 45 ec mov -0x14(%ebp),%eax 2490: 89 04 24 mov %eax,(%esp) 2493: e8 98 17 00 00 call 3c30 <close> unlink("bigwrite"); 2498: c7 04 24 7b 4e 00 00 movl $0x4e7b,(%esp) 249f: e8 b4 17 00 00 call 3c58 <unlink> int fd, sz; printf(1, "bigwrite test\n"); unlink("bigwrite"); for(sz = 499; sz < 12*512; sz += 471){ 24a4: 81 45 f4 d7 01 00 00 addl $0x1d7,-0xc(%ebp) 24ab: 81 7d f4 ff 17 00 00 cmpl $0x17ff,-0xc(%ebp) 24b2: 0f 8e 41 ff ff ff jle 23f9 <bigwrite+0x32> } close(fd); unlink("bigwrite"); } printf(1, "bigwrite ok\n"); 24b8: c7 44 24 04 ae 4e 00 movl $0x4eae,0x4(%esp) 24bf: 00 24c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 24c7: e8 cc 18 00 00 call 3d98 <printf> } 24cc: c9 leave 24cd: c3 ret 000024ce <bigfile>: void bigfile(void) { 24ce: 55 push %ebp 24cf: 89 e5 mov %esp,%ebp 24d1: 83 ec 28 sub $0x28,%esp int fd, i, total, cc; printf(1, "bigfile test\n"); 24d4: c7 44 24 04 bb 4e 00 movl $0x4ebb,0x4(%esp) 24db: 00 24dc: c7 04 24 01 00 00 00 movl $0x1,(%esp) 24e3: e8 b0 18 00 00 call 3d98 <printf> unlink("bigfile"); 24e8: c7 04 24 c9 4e 00 00 movl $0x4ec9,(%esp) 24ef: e8 64 17 00 00 call 3c58 <unlink> fd = open("bigfile", O_CREATE | O_RDWR); 24f4: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 24fb: 00 24fc: c7 04 24 c9 4e 00 00 movl $0x4ec9,(%esp) 2503: e8 40 17 00 00 call 3c48 <open> 2508: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 250b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 250f: 79 19 jns 252a <bigfile+0x5c> printf(1, "cannot create bigfile"); 2511: c7 44 24 04 d1 4e 00 movl $0x4ed1,0x4(%esp) 2518: 00 2519: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2520: e8 73 18 00 00 call 3d98 <printf> exit(); 2525: e8 de 16 00 00 call 3c08 <exit> } for(i = 0; i < 20; i++){ 252a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2531: eb 59 jmp 258c <bigfile+0xbe> memset(buf, i, 600); 2533: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) 253a: 00 253b: 8b 45 f4 mov -0xc(%ebp),%eax 253e: 89 44 24 04 mov %eax,0x4(%esp) 2542: c7 04 24 a0 86 00 00 movl $0x86a0,(%esp) 2549: e8 22 15 00 00 call 3a70 <memset> if(write(fd, buf, 600) != 600){ 254e: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp) 2555: 00 2556: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 255d: 00 255e: 8b 45 ec mov -0x14(%ebp),%eax 2561: 89 04 24 mov %eax,(%esp) 2564: e8 bf 16 00 00 call 3c28 <write> 2569: 3d 58 02 00 00 cmp $0x258,%eax 256e: 74 19 je 2589 <bigfile+0xbb> printf(1, "write bigfile failed\n"); 2570: c7 44 24 04 e7 4e 00 movl $0x4ee7,0x4(%esp) 2577: 00 2578: c7 04 24 01 00 00 00 movl $0x1,(%esp) 257f: e8 14 18 00 00 call 3d98 <printf> exit(); 2584: e8 7f 16 00 00 call 3c08 <exit> fd = open("bigfile", O_CREATE | O_RDWR); if(fd < 0){ printf(1, "cannot create bigfile"); exit(); } for(i = 0; i < 20; i++){ 2589: ff 45 f4 incl -0xc(%ebp) 258c: 83 7d f4 13 cmpl $0x13,-0xc(%ebp) 2590: 7e a1 jle 2533 <bigfile+0x65> if(write(fd, buf, 600) != 600){ printf(1, "write bigfile failed\n"); exit(); } } close(fd); 2592: 8b 45 ec mov -0x14(%ebp),%eax 2595: 89 04 24 mov %eax,(%esp) 2598: e8 93 16 00 00 call 3c30 <close> fd = open("bigfile", 0); 259d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 25a4: 00 25a5: c7 04 24 c9 4e 00 00 movl $0x4ec9,(%esp) 25ac: e8 97 16 00 00 call 3c48 <open> 25b1: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 25b4: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 25b8: 79 19 jns 25d3 <bigfile+0x105> printf(1, "cannot open bigfile\n"); 25ba: c7 44 24 04 fd 4e 00 movl $0x4efd,0x4(%esp) 25c1: 00 25c2: c7 04 24 01 00 00 00 movl $0x1,(%esp) 25c9: e8 ca 17 00 00 call 3d98 <printf> exit(); 25ce: e8 35 16 00 00 call 3c08 <exit> } total = 0; 25d3: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) for(i = 0; ; i++){ 25da: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) cc = read(fd, buf, 300); 25e1: c7 44 24 08 2c 01 00 movl $0x12c,0x8(%esp) 25e8: 00 25e9: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 25f0: 00 25f1: 8b 45 ec mov -0x14(%ebp),%eax 25f4: 89 04 24 mov %eax,(%esp) 25f7: e8 24 16 00 00 call 3c20 <read> 25fc: 89 45 e8 mov %eax,-0x18(%ebp) if(cc < 0){ 25ff: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 2603: 79 19 jns 261e <bigfile+0x150> printf(1, "read bigfile failed\n"); 2605: c7 44 24 04 12 4f 00 movl $0x4f12,0x4(%esp) 260c: 00 260d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2614: e8 7f 17 00 00 call 3d98 <printf> exit(); 2619: e8 ea 15 00 00 call 3c08 <exit> } if(cc == 0) 261e: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 2622: 74 79 je 269d <bigfile+0x1cf> break; if(cc != 300){ 2624: 81 7d e8 2c 01 00 00 cmpl $0x12c,-0x18(%ebp) 262b: 74 19 je 2646 <bigfile+0x178> printf(1, "short read bigfile\n"); 262d: c7 44 24 04 27 4f 00 movl $0x4f27,0x4(%esp) 2634: 00 2635: c7 04 24 01 00 00 00 movl $0x1,(%esp) 263c: e8 57 17 00 00 call 3d98 <printf> exit(); 2641: e8 c2 15 00 00 call 3c08 <exit> } if(buf[0] != i/2 || buf[299] != i/2){ 2646: a0 a0 86 00 00 mov 0x86a0,%al 264b: 0f be d0 movsbl %al,%edx 264e: 8b 45 f4 mov -0xc(%ebp),%eax 2651: 89 c1 mov %eax,%ecx 2653: c1 e9 1f shr $0x1f,%ecx 2656: 01 c8 add %ecx,%eax 2658: d1 f8 sar %eax 265a: 39 c2 cmp %eax,%edx 265c: 75 18 jne 2676 <bigfile+0x1a8> 265e: a0 cb 87 00 00 mov 0x87cb,%al 2663: 0f be d0 movsbl %al,%edx 2666: 8b 45 f4 mov -0xc(%ebp),%eax 2669: 89 c1 mov %eax,%ecx 266b: c1 e9 1f shr $0x1f,%ecx 266e: 01 c8 add %ecx,%eax 2670: d1 f8 sar %eax 2672: 39 c2 cmp %eax,%edx 2674: 74 19 je 268f <bigfile+0x1c1> printf(1, "read bigfile wrong data\n"); 2676: c7 44 24 04 3b 4f 00 movl $0x4f3b,0x4(%esp) 267d: 00 267e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2685: e8 0e 17 00 00 call 3d98 <printf> exit(); 268a: e8 79 15 00 00 call 3c08 <exit> } total += cc; 268f: 8b 45 e8 mov -0x18(%ebp),%eax 2692: 01 45 f0 add %eax,-0x10(%ebp) if(fd < 0){ printf(1, "cannot open bigfile\n"); exit(); } total = 0; for(i = 0; ; i++){ 2695: ff 45 f4 incl -0xc(%ebp) if(buf[0] != i/2 || buf[299] != i/2){ printf(1, "read bigfile wrong data\n"); exit(); } total += cc; } 2698: e9 44 ff ff ff jmp 25e1 <bigfile+0x113> if(cc < 0){ printf(1, "read bigfile failed\n"); exit(); } if(cc == 0) break; 269d: 90 nop printf(1, "read bigfile wrong data\n"); exit(); } total += cc; } close(fd); 269e: 8b 45 ec mov -0x14(%ebp),%eax 26a1: 89 04 24 mov %eax,(%esp) 26a4: e8 87 15 00 00 call 3c30 <close> if(total != 20*600){ 26a9: 81 7d f0 e0 2e 00 00 cmpl $0x2ee0,-0x10(%ebp) 26b0: 74 19 je 26cb <bigfile+0x1fd> printf(1, "read bigfile wrong total\n"); 26b2: c7 44 24 04 54 4f 00 movl $0x4f54,0x4(%esp) 26b9: 00 26ba: c7 04 24 01 00 00 00 movl $0x1,(%esp) 26c1: e8 d2 16 00 00 call 3d98 <printf> exit(); 26c6: e8 3d 15 00 00 call 3c08 <exit> } unlink("bigfile"); 26cb: c7 04 24 c9 4e 00 00 movl $0x4ec9,(%esp) 26d2: e8 81 15 00 00 call 3c58 <unlink> printf(1, "bigfile test ok\n"); 26d7: c7 44 24 04 6e 4f 00 movl $0x4f6e,0x4(%esp) 26de: 00 26df: c7 04 24 01 00 00 00 movl $0x1,(%esp) 26e6: e8 ad 16 00 00 call 3d98 <printf> } 26eb: c9 leave 26ec: c3 ret 000026ed <fourteen>: void fourteen(void) { 26ed: 55 push %ebp 26ee: 89 e5 mov %esp,%ebp 26f0: 83 ec 28 sub $0x28,%esp int fd; // DIRSIZ is 14. printf(1, "fourteen test\n"); 26f3: c7 44 24 04 7f 4f 00 movl $0x4f7f,0x4(%esp) 26fa: 00 26fb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2702: e8 91 16 00 00 call 3d98 <printf> if(mkdir("12345678901234") != 0){ 2707: c7 04 24 8e 4f 00 00 movl $0x4f8e,(%esp) 270e: e8 5d 15 00 00 call 3c70 <mkdir> 2713: 85 c0 test %eax,%eax 2715: 74 19 je 2730 <fourteen+0x43> printf(1, "mkdir 12345678901234 failed\n"); 2717: c7 44 24 04 9d 4f 00 movl $0x4f9d,0x4(%esp) 271e: 00 271f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2726: e8 6d 16 00 00 call 3d98 <printf> exit(); 272b: e8 d8 14 00 00 call 3c08 <exit> } if(mkdir("12345678901234/123456789012345") != 0){ 2730: c7 04 24 bc 4f 00 00 movl $0x4fbc,(%esp) 2737: e8 34 15 00 00 call 3c70 <mkdir> 273c: 85 c0 test %eax,%eax 273e: 74 19 je 2759 <fourteen+0x6c> printf(1, "mkdir 12345678901234/123456789012345 failed\n"); 2740: c7 44 24 04 dc 4f 00 movl $0x4fdc,0x4(%esp) 2747: 00 2748: c7 04 24 01 00 00 00 movl $0x1,(%esp) 274f: e8 44 16 00 00 call 3d98 <printf> exit(); 2754: e8 af 14 00 00 call 3c08 <exit> } fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); 2759: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2760: 00 2761: c7 04 24 0c 50 00 00 movl $0x500c,(%esp) 2768: e8 db 14 00 00 call 3c48 <open> 276d: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 2770: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2774: 79 19 jns 278f <fourteen+0xa2> printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); 2776: c7 44 24 04 3c 50 00 movl $0x503c,0x4(%esp) 277d: 00 277e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2785: e8 0e 16 00 00 call 3d98 <printf> exit(); 278a: e8 79 14 00 00 call 3c08 <exit> } close(fd); 278f: 8b 45 f4 mov -0xc(%ebp),%eax 2792: 89 04 24 mov %eax,(%esp) 2795: e8 96 14 00 00 call 3c30 <close> fd = open("12345678901234/12345678901234/12345678901234", 0); 279a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 27a1: 00 27a2: c7 04 24 7c 50 00 00 movl $0x507c,(%esp) 27a9: e8 9a 14 00 00 call 3c48 <open> 27ae: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 27b1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 27b5: 79 19 jns 27d0 <fourteen+0xe3> printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); 27b7: c7 44 24 04 ac 50 00 movl $0x50ac,0x4(%esp) 27be: 00 27bf: c7 04 24 01 00 00 00 movl $0x1,(%esp) 27c6: e8 cd 15 00 00 call 3d98 <printf> exit(); 27cb: e8 38 14 00 00 call 3c08 <exit> } close(fd); 27d0: 8b 45 f4 mov -0xc(%ebp),%eax 27d3: 89 04 24 mov %eax,(%esp) 27d6: e8 55 14 00 00 call 3c30 <close> if(mkdir("12345678901234/12345678901234") == 0){ 27db: c7 04 24 e6 50 00 00 movl $0x50e6,(%esp) 27e2: e8 89 14 00 00 call 3c70 <mkdir> 27e7: 85 c0 test %eax,%eax 27e9: 75 19 jne 2804 <fourteen+0x117> printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); 27eb: c7 44 24 04 04 51 00 movl $0x5104,0x4(%esp) 27f2: 00 27f3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 27fa: e8 99 15 00 00 call 3d98 <printf> exit(); 27ff: e8 04 14 00 00 call 3c08 <exit> } if(mkdir("123456789012345/12345678901234") == 0){ 2804: c7 04 24 34 51 00 00 movl $0x5134,(%esp) 280b: e8 60 14 00 00 call 3c70 <mkdir> 2810: 85 c0 test %eax,%eax 2812: 75 19 jne 282d <fourteen+0x140> printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); 2814: c7 44 24 04 54 51 00 movl $0x5154,0x4(%esp) 281b: 00 281c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2823: e8 70 15 00 00 call 3d98 <printf> exit(); 2828: e8 db 13 00 00 call 3c08 <exit> } printf(1, "fourteen ok\n"); 282d: c7 44 24 04 85 51 00 movl $0x5185,0x4(%esp) 2834: 00 2835: c7 04 24 01 00 00 00 movl $0x1,(%esp) 283c: e8 57 15 00 00 call 3d98 <printf> } 2841: c9 leave 2842: c3 ret 00002843 <rmdot>: void rmdot(void) { 2843: 55 push %ebp 2844: 89 e5 mov %esp,%ebp 2846: 83 ec 18 sub $0x18,%esp printf(1, "rmdot test\n"); 2849: c7 44 24 04 92 51 00 movl $0x5192,0x4(%esp) 2850: 00 2851: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2858: e8 3b 15 00 00 call 3d98 <printf> if(mkdir("dots") != 0){ 285d: c7 04 24 9e 51 00 00 movl $0x519e,(%esp) 2864: e8 07 14 00 00 call 3c70 <mkdir> 2869: 85 c0 test %eax,%eax 286b: 74 19 je 2886 <rmdot+0x43> printf(1, "mkdir dots failed\n"); 286d: c7 44 24 04 a3 51 00 movl $0x51a3,0x4(%esp) 2874: 00 2875: c7 04 24 01 00 00 00 movl $0x1,(%esp) 287c: e8 17 15 00 00 call 3d98 <printf> exit(); 2881: e8 82 13 00 00 call 3c08 <exit> } if(chdir("dots") != 0){ 2886: c7 04 24 9e 51 00 00 movl $0x519e,(%esp) 288d: e8 e6 13 00 00 call 3c78 <chdir> 2892: 85 c0 test %eax,%eax 2894: 74 19 je 28af <rmdot+0x6c> printf(1, "chdir dots failed\n"); 2896: c7 44 24 04 b6 51 00 movl $0x51b6,0x4(%esp) 289d: 00 289e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 28a5: e8 ee 14 00 00 call 3d98 <printf> exit(); 28aa: e8 59 13 00 00 call 3c08 <exit> } if(unlink(".") == 0){ 28af: c7 04 24 cf 48 00 00 movl $0x48cf,(%esp) 28b6: e8 9d 13 00 00 call 3c58 <unlink> 28bb: 85 c0 test %eax,%eax 28bd: 75 19 jne 28d8 <rmdot+0x95> printf(1, "rm . worked!\n"); 28bf: c7 44 24 04 c9 51 00 movl $0x51c9,0x4(%esp) 28c6: 00 28c7: c7 04 24 01 00 00 00 movl $0x1,(%esp) 28ce: e8 c5 14 00 00 call 3d98 <printf> exit(); 28d3: e8 30 13 00 00 call 3c08 <exit> } if(unlink("..") == 0){ 28d8: c7 04 24 5c 44 00 00 movl $0x445c,(%esp) 28df: e8 74 13 00 00 call 3c58 <unlink> 28e4: 85 c0 test %eax,%eax 28e6: 75 19 jne 2901 <rmdot+0xbe> printf(1, "rm .. worked!\n"); 28e8: c7 44 24 04 d7 51 00 movl $0x51d7,0x4(%esp) 28ef: 00 28f0: c7 04 24 01 00 00 00 movl $0x1,(%esp) 28f7: e8 9c 14 00 00 call 3d98 <printf> exit(); 28fc: e8 07 13 00 00 call 3c08 <exit> } if(chdir("/") != 0){ 2901: c7 04 24 e6 51 00 00 movl $0x51e6,(%esp) 2908: e8 6b 13 00 00 call 3c78 <chdir> 290d: 85 c0 test %eax,%eax 290f: 74 19 je 292a <rmdot+0xe7> printf(1, "chdir / failed\n"); 2911: c7 44 24 04 e8 51 00 movl $0x51e8,0x4(%esp) 2918: 00 2919: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2920: e8 73 14 00 00 call 3d98 <printf> exit(); 2925: e8 de 12 00 00 call 3c08 <exit> } if(unlink("dots/.") == 0){ 292a: c7 04 24 f8 51 00 00 movl $0x51f8,(%esp) 2931: e8 22 13 00 00 call 3c58 <unlink> 2936: 85 c0 test %eax,%eax 2938: 75 19 jne 2953 <rmdot+0x110> printf(1, "unlink dots/. worked!\n"); 293a: c7 44 24 04 ff 51 00 movl $0x51ff,0x4(%esp) 2941: 00 2942: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2949: e8 4a 14 00 00 call 3d98 <printf> exit(); 294e: e8 b5 12 00 00 call 3c08 <exit> } if(unlink("dots/..") == 0){ 2953: c7 04 24 16 52 00 00 movl $0x5216,(%esp) 295a: e8 f9 12 00 00 call 3c58 <unlink> 295f: 85 c0 test %eax,%eax 2961: 75 19 jne 297c <rmdot+0x139> printf(1, "unlink dots/.. worked!\n"); 2963: c7 44 24 04 1e 52 00 movl $0x521e,0x4(%esp) 296a: 00 296b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2972: e8 21 14 00 00 call 3d98 <printf> exit(); 2977: e8 8c 12 00 00 call 3c08 <exit> } if(unlink("dots") != 0){ 297c: c7 04 24 9e 51 00 00 movl $0x519e,(%esp) 2983: e8 d0 12 00 00 call 3c58 <unlink> 2988: 85 c0 test %eax,%eax 298a: 74 19 je 29a5 <rmdot+0x162> printf(1, "unlink dots failed!\n"); 298c: c7 44 24 04 36 52 00 movl $0x5236,0x4(%esp) 2993: 00 2994: c7 04 24 01 00 00 00 movl $0x1,(%esp) 299b: e8 f8 13 00 00 call 3d98 <printf> exit(); 29a0: e8 63 12 00 00 call 3c08 <exit> } printf(1, "rmdot ok\n"); 29a5: c7 44 24 04 4b 52 00 movl $0x524b,0x4(%esp) 29ac: 00 29ad: c7 04 24 01 00 00 00 movl $0x1,(%esp) 29b4: e8 df 13 00 00 call 3d98 <printf> } 29b9: c9 leave 29ba: c3 ret 000029bb <dirfile>: void dirfile(void) { 29bb: 55 push %ebp 29bc: 89 e5 mov %esp,%ebp 29be: 83 ec 28 sub $0x28,%esp int fd; printf(1, "dir vs file\n"); 29c1: c7 44 24 04 55 52 00 movl $0x5255,0x4(%esp) 29c8: 00 29c9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 29d0: e8 c3 13 00 00 call 3d98 <printf> fd = open("dirfile", O_CREATE); 29d5: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 29dc: 00 29dd: c7 04 24 62 52 00 00 movl $0x5262,(%esp) 29e4: e8 5f 12 00 00 call 3c48 <open> 29e9: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0){ 29ec: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 29f0: 79 19 jns 2a0b <dirfile+0x50> printf(1, "create dirfile failed\n"); 29f2: c7 44 24 04 6a 52 00 movl $0x526a,0x4(%esp) 29f9: 00 29fa: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a01: e8 92 13 00 00 call 3d98 <printf> exit(); 2a06: e8 fd 11 00 00 call 3c08 <exit> } close(fd); 2a0b: 8b 45 f4 mov -0xc(%ebp),%eax 2a0e: 89 04 24 mov %eax,(%esp) 2a11: e8 1a 12 00 00 call 3c30 <close> if(chdir("dirfile") == 0){ 2a16: c7 04 24 62 52 00 00 movl $0x5262,(%esp) 2a1d: e8 56 12 00 00 call 3c78 <chdir> 2a22: 85 c0 test %eax,%eax 2a24: 75 19 jne 2a3f <dirfile+0x84> printf(1, "chdir dirfile succeeded!\n"); 2a26: c7 44 24 04 81 52 00 movl $0x5281,0x4(%esp) 2a2d: 00 2a2e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a35: e8 5e 13 00 00 call 3d98 <printf> exit(); 2a3a: e8 c9 11 00 00 call 3c08 <exit> } fd = open("dirfile/xx", 0); 2a3f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2a46: 00 2a47: c7 04 24 9b 52 00 00 movl $0x529b,(%esp) 2a4e: e8 f5 11 00 00 call 3c48 <open> 2a53: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2a56: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2a5a: 78 19 js 2a75 <dirfile+0xba> printf(1, "create dirfile/xx succeeded!\n"); 2a5c: c7 44 24 04 a6 52 00 movl $0x52a6,0x4(%esp) 2a63: 00 2a64: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2a6b: e8 28 13 00 00 call 3d98 <printf> exit(); 2a70: e8 93 11 00 00 call 3c08 <exit> } fd = open("dirfile/xx", O_CREATE); 2a75: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2a7c: 00 2a7d: c7 04 24 9b 52 00 00 movl $0x529b,(%esp) 2a84: e8 bf 11 00 00 call 3c48 <open> 2a89: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2a8c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2a90: 78 19 js 2aab <dirfile+0xf0> printf(1, "create dirfile/xx succeeded!\n"); 2a92: c7 44 24 04 a6 52 00 movl $0x52a6,0x4(%esp) 2a99: 00 2a9a: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2aa1: e8 f2 12 00 00 call 3d98 <printf> exit(); 2aa6: e8 5d 11 00 00 call 3c08 <exit> } if(mkdir("dirfile/xx") == 0){ 2aab: c7 04 24 9b 52 00 00 movl $0x529b,(%esp) 2ab2: e8 b9 11 00 00 call 3c70 <mkdir> 2ab7: 85 c0 test %eax,%eax 2ab9: 75 19 jne 2ad4 <dirfile+0x119> printf(1, "mkdir dirfile/xx succeeded!\n"); 2abb: c7 44 24 04 c4 52 00 movl $0x52c4,0x4(%esp) 2ac2: 00 2ac3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2aca: e8 c9 12 00 00 call 3d98 <printf> exit(); 2acf: e8 34 11 00 00 call 3c08 <exit> } if(unlink("dirfile/xx") == 0){ 2ad4: c7 04 24 9b 52 00 00 movl $0x529b,(%esp) 2adb: e8 78 11 00 00 call 3c58 <unlink> 2ae0: 85 c0 test %eax,%eax 2ae2: 75 19 jne 2afd <dirfile+0x142> printf(1, "unlink dirfile/xx succeeded!\n"); 2ae4: c7 44 24 04 e1 52 00 movl $0x52e1,0x4(%esp) 2aeb: 00 2aec: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2af3: e8 a0 12 00 00 call 3d98 <printf> exit(); 2af8: e8 0b 11 00 00 call 3c08 <exit> } if(link("README", "dirfile/xx") == 0){ 2afd: c7 44 24 04 9b 52 00 movl $0x529b,0x4(%esp) 2b04: 00 2b05: c7 04 24 ff 52 00 00 movl $0x52ff,(%esp) 2b0c: e8 57 11 00 00 call 3c68 <link> 2b11: 85 c0 test %eax,%eax 2b13: 75 19 jne 2b2e <dirfile+0x173> printf(1, "link to dirfile/xx succeeded!\n"); 2b15: c7 44 24 04 08 53 00 movl $0x5308,0x4(%esp) 2b1c: 00 2b1d: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b24: e8 6f 12 00 00 call 3d98 <printf> exit(); 2b29: e8 da 10 00 00 call 3c08 <exit> } if(unlink("dirfile") != 0){ 2b2e: c7 04 24 62 52 00 00 movl $0x5262,(%esp) 2b35: e8 1e 11 00 00 call 3c58 <unlink> 2b3a: 85 c0 test %eax,%eax 2b3c: 74 19 je 2b57 <dirfile+0x19c> printf(1, "unlink dirfile failed!\n"); 2b3e: c7 44 24 04 27 53 00 movl $0x5327,0x4(%esp) 2b45: 00 2b46: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b4d: e8 46 12 00 00 call 3d98 <printf> exit(); 2b52: e8 b1 10 00 00 call 3c08 <exit> } fd = open(".", O_RDWR); 2b57: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp) 2b5e: 00 2b5f: c7 04 24 cf 48 00 00 movl $0x48cf,(%esp) 2b66: e8 dd 10 00 00 call 3c48 <open> 2b6b: 89 45 f4 mov %eax,-0xc(%ebp) if(fd >= 0){ 2b6e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2b72: 78 19 js 2b8d <dirfile+0x1d2> printf(1, "open . for writing succeeded!\n"); 2b74: c7 44 24 04 40 53 00 movl $0x5340,0x4(%esp) 2b7b: 00 2b7c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2b83: e8 10 12 00 00 call 3d98 <printf> exit(); 2b88: e8 7b 10 00 00 call 3c08 <exit> } fd = open(".", 0); 2b8d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2b94: 00 2b95: c7 04 24 cf 48 00 00 movl $0x48cf,(%esp) 2b9c: e8 a7 10 00 00 call 3c48 <open> 2ba1: 89 45 f4 mov %eax,-0xc(%ebp) if(write(fd, "x", 1) > 0){ 2ba4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2bab: 00 2bac: c7 44 24 04 06 45 00 movl $0x4506,0x4(%esp) 2bb3: 00 2bb4: 8b 45 f4 mov -0xc(%ebp),%eax 2bb7: 89 04 24 mov %eax,(%esp) 2bba: e8 69 10 00 00 call 3c28 <write> 2bbf: 85 c0 test %eax,%eax 2bc1: 7e 19 jle 2bdc <dirfile+0x221> printf(1, "write . succeeded!\n"); 2bc3: c7 44 24 04 5f 53 00 movl $0x535f,0x4(%esp) 2bca: 00 2bcb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2bd2: e8 c1 11 00 00 call 3d98 <printf> exit(); 2bd7: e8 2c 10 00 00 call 3c08 <exit> } close(fd); 2bdc: 8b 45 f4 mov -0xc(%ebp),%eax 2bdf: 89 04 24 mov %eax,(%esp) 2be2: e8 49 10 00 00 call 3c30 <close> printf(1, "dir vs file OK\n"); 2be7: c7 44 24 04 73 53 00 movl $0x5373,0x4(%esp) 2bee: 00 2bef: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2bf6: e8 9d 11 00 00 call 3d98 <printf> } 2bfb: c9 leave 2bfc: c3 ret 00002bfd <iref>: // test that iput() is called at the end of _namei() void iref(void) { 2bfd: 55 push %ebp 2bfe: 89 e5 mov %esp,%ebp 2c00: 83 ec 28 sub $0x28,%esp int i, fd; printf(1, "empty file name\n"); 2c03: c7 44 24 04 83 53 00 movl $0x5383,0x4(%esp) 2c0a: 00 2c0b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c12: e8 81 11 00 00 call 3d98 <printf> // the 50 is NINODE for(i = 0; i < 50 + 1; i++){ 2c17: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2c1e: e9 d1 00 00 00 jmp 2cf4 <iref+0xf7> if(mkdir("irefd") != 0){ 2c23: c7 04 24 94 53 00 00 movl $0x5394,(%esp) 2c2a: e8 41 10 00 00 call 3c70 <mkdir> 2c2f: 85 c0 test %eax,%eax 2c31: 74 19 je 2c4c <iref+0x4f> printf(1, "mkdir irefd failed\n"); 2c33: c7 44 24 04 9a 53 00 movl $0x539a,0x4(%esp) 2c3a: 00 2c3b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c42: e8 51 11 00 00 call 3d98 <printf> exit(); 2c47: e8 bc 0f 00 00 call 3c08 <exit> } if(chdir("irefd") != 0){ 2c4c: c7 04 24 94 53 00 00 movl $0x5394,(%esp) 2c53: e8 20 10 00 00 call 3c78 <chdir> 2c58: 85 c0 test %eax,%eax 2c5a: 74 19 je 2c75 <iref+0x78> printf(1, "chdir irefd failed\n"); 2c5c: c7 44 24 04 ae 53 00 movl $0x53ae,0x4(%esp) 2c63: 00 2c64: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2c6b: e8 28 11 00 00 call 3d98 <printf> exit(); 2c70: e8 93 0f 00 00 call 3c08 <exit> } mkdir(""); 2c75: c7 04 24 c2 53 00 00 movl $0x53c2,(%esp) 2c7c: e8 ef 0f 00 00 call 3c70 <mkdir> link("README", ""); 2c81: c7 44 24 04 c2 53 00 movl $0x53c2,0x4(%esp) 2c88: 00 2c89: c7 04 24 ff 52 00 00 movl $0x52ff,(%esp) 2c90: e8 d3 0f 00 00 call 3c68 <link> fd = open("", O_CREATE); 2c95: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2c9c: 00 2c9d: c7 04 24 c2 53 00 00 movl $0x53c2,(%esp) 2ca4: e8 9f 0f 00 00 call 3c48 <open> 2ca9: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0) 2cac: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2cb0: 78 0b js 2cbd <iref+0xc0> close(fd); 2cb2: 8b 45 f0 mov -0x10(%ebp),%eax 2cb5: 89 04 24 mov %eax,(%esp) 2cb8: e8 73 0f 00 00 call 3c30 <close> fd = open("xx", O_CREATE); 2cbd: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 2cc4: 00 2cc5: c7 04 24 c3 53 00 00 movl $0x53c3,(%esp) 2ccc: e8 77 0f 00 00 call 3c48 <open> 2cd1: 89 45 f0 mov %eax,-0x10(%ebp) if(fd >= 0) 2cd4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2cd8: 78 0b js 2ce5 <iref+0xe8> close(fd); 2cda: 8b 45 f0 mov -0x10(%ebp),%eax 2cdd: 89 04 24 mov %eax,(%esp) 2ce0: e8 4b 0f 00 00 call 3c30 <close> unlink("xx"); 2ce5: c7 04 24 c3 53 00 00 movl $0x53c3,(%esp) 2cec: e8 67 0f 00 00 call 3c58 <unlink> int i, fd; printf(1, "empty file name\n"); // the 50 is NINODE for(i = 0; i < 50 + 1; i++){ 2cf1: ff 45 f4 incl -0xc(%ebp) 2cf4: 83 7d f4 32 cmpl $0x32,-0xc(%ebp) 2cf8: 0f 8e 25 ff ff ff jle 2c23 <iref+0x26> if(fd >= 0) close(fd); unlink("xx"); } chdir("/"); 2cfe: c7 04 24 e6 51 00 00 movl $0x51e6,(%esp) 2d05: e8 6e 0f 00 00 call 3c78 <chdir> printf(1, "empty file name OK\n"); 2d0a: c7 44 24 04 c6 53 00 movl $0x53c6,0x4(%esp) 2d11: 00 2d12: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d19: e8 7a 10 00 00 call 3d98 <printf> } 2d1e: c9 leave 2d1f: c3 ret 00002d20 <forktest>: // test that fork fails gracefully // the forktest binary also does this, but it runs out of proc entries first. // inside the bigger usertests binary, we run out of memory first. void forktest(void) { 2d20: 55 push %ebp 2d21: 89 e5 mov %esp,%ebp 2d23: 83 ec 28 sub $0x28,%esp int n, pid; printf(1, "fork test\n"); 2d26: c7 44 24 04 da 53 00 movl $0x53da,0x4(%esp) 2d2d: 00 2d2e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d35: e8 5e 10 00 00 call 3d98 <printf> for(n=0; n<1000; n++){ 2d3a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 2d41: eb 1c jmp 2d5f <forktest+0x3f> pid = fork(); 2d43: e8 b8 0e 00 00 call 3c00 <fork> 2d48: 89 45 f0 mov %eax,-0x10(%ebp) if(pid < 0) 2d4b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2d4f: 78 19 js 2d6a <forktest+0x4a> break; if(pid == 0) 2d51: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 2d55: 75 05 jne 2d5c <forktest+0x3c> exit(); 2d57: e8 ac 0e 00 00 call 3c08 <exit> { int n, pid; printf(1, "fork test\n"); for(n=0; n<1000; n++){ 2d5c: ff 45 f4 incl -0xc(%ebp) 2d5f: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp) 2d66: 7e db jle 2d43 <forktest+0x23> 2d68: eb 01 jmp 2d6b <forktest+0x4b> pid = fork(); if(pid < 0) break; 2d6a: 90 nop if(pid == 0) exit(); } if(n == 1000){ 2d6b: 81 7d f4 e8 03 00 00 cmpl $0x3e8,-0xc(%ebp) 2d72: 75 3e jne 2db2 <forktest+0x92> printf(1, "fork claimed to work 1000 times!\n"); 2d74: c7 44 24 04 e8 53 00 movl $0x53e8,0x4(%esp) 2d7b: 00 2d7c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2d83: e8 10 10 00 00 call 3d98 <printf> exit(); 2d88: e8 7b 0e 00 00 call 3c08 <exit> } for(; n > 0; n--){ if(wait() < 0){ 2d8d: e8 7e 0e 00 00 call 3c10 <wait> 2d92: 85 c0 test %eax,%eax 2d94: 79 19 jns 2daf <forktest+0x8f> printf(1, "wait stopped early\n"); 2d96: c7 44 24 04 0a 54 00 movl $0x540a,0x4(%esp) 2d9d: 00 2d9e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2da5: e8 ee 0f 00 00 call 3d98 <printf> exit(); 2daa: e8 59 0e 00 00 call 3c08 <exit> if(n == 1000){ printf(1, "fork claimed to work 1000 times!\n"); exit(); } for(; n > 0; n--){ 2daf: ff 4d f4 decl -0xc(%ebp) 2db2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2db6: 7f d5 jg 2d8d <forktest+0x6d> printf(1, "wait stopped early\n"); exit(); } } if(wait() != -1){ 2db8: e8 53 0e 00 00 call 3c10 <wait> 2dbd: 83 f8 ff cmp $0xffffffff,%eax 2dc0: 74 19 je 2ddb <forktest+0xbb> printf(1, "wait got too many\n"); 2dc2: c7 44 24 04 1e 54 00 movl $0x541e,0x4(%esp) 2dc9: 00 2dca: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2dd1: e8 c2 0f 00 00 call 3d98 <printf> exit(); 2dd6: e8 2d 0e 00 00 call 3c08 <exit> } printf(1, "fork test OK\n"); 2ddb: c7 44 24 04 31 54 00 movl $0x5431,0x4(%esp) 2de2: 00 2de3: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2dea: e8 a9 0f 00 00 call 3d98 <printf> } 2def: c9 leave 2df0: c3 ret 00002df1 <sbrktest>: void sbrktest(void) { 2df1: 55 push %ebp 2df2: 89 e5 mov %esp,%ebp 2df4: 53 push %ebx 2df5: 81 ec 84 00 00 00 sub $0x84,%esp int fds[2], pid, pids[10], ppid; char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch; uint amt; printf(stdout, "sbrk test\n"); 2dfb: a1 b4 5e 00 00 mov 0x5eb4,%eax 2e00: c7 44 24 04 3f 54 00 movl $0x543f,0x4(%esp) 2e07: 00 2e08: 89 04 24 mov %eax,(%esp) 2e0b: e8 88 0f 00 00 call 3d98 <printf> oldbrk = sbrk(0); 2e10: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2e17: e8 74 0e 00 00 call 3c90 <sbrk> 2e1c: 89 45 ec mov %eax,-0x14(%ebp) // can one sbrk() less than a page? a = sbrk(0); 2e1f: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2e26: e8 65 0e 00 00 call 3c90 <sbrk> 2e2b: 89 45 f4 mov %eax,-0xc(%ebp) int i; for(i = 0; i < 5000; i++){ 2e2e: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 2e35: eb 56 jmp 2e8d <sbrktest+0x9c> b = sbrk(1); 2e37: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2e3e: e8 4d 0e 00 00 call 3c90 <sbrk> 2e43: 89 45 e8 mov %eax,-0x18(%ebp) if(b != a){ 2e46: 8b 45 e8 mov -0x18(%ebp),%eax 2e49: 3b 45 f4 cmp -0xc(%ebp),%eax 2e4c: 74 2f je 2e7d <sbrktest+0x8c> printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); 2e4e: a1 b4 5e 00 00 mov 0x5eb4,%eax 2e53: 8b 55 e8 mov -0x18(%ebp),%edx 2e56: 89 54 24 10 mov %edx,0x10(%esp) 2e5a: 8b 55 f4 mov -0xc(%ebp),%edx 2e5d: 89 54 24 0c mov %edx,0xc(%esp) 2e61: 8b 55 f0 mov -0x10(%ebp),%edx 2e64: 89 54 24 08 mov %edx,0x8(%esp) 2e68: c7 44 24 04 4a 54 00 movl $0x544a,0x4(%esp) 2e6f: 00 2e70: 89 04 24 mov %eax,(%esp) 2e73: e8 20 0f 00 00 call 3d98 <printf> exit(); 2e78: e8 8b 0d 00 00 call 3c08 <exit> } *b = 1; 2e7d: 8b 45 e8 mov -0x18(%ebp),%eax 2e80: c6 00 01 movb $0x1,(%eax) a = b + 1; 2e83: 8b 45 e8 mov -0x18(%ebp),%eax 2e86: 40 inc %eax 2e87: 89 45 f4 mov %eax,-0xc(%ebp) oldbrk = sbrk(0); // can one sbrk() less than a page? a = sbrk(0); int i; for(i = 0; i < 5000; i++){ 2e8a: ff 45 f0 incl -0x10(%ebp) 2e8d: 81 7d f0 87 13 00 00 cmpl $0x1387,-0x10(%ebp) 2e94: 7e a1 jle 2e37 <sbrktest+0x46> exit(); } *b = 1; a = b + 1; } pid = fork(); 2e96: e8 65 0d 00 00 call 3c00 <fork> 2e9b: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 2e9e: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 2ea2: 79 1a jns 2ebe <sbrktest+0xcd> printf(stdout, "sbrk test fork failed\n"); 2ea4: a1 b4 5e 00 00 mov 0x5eb4,%eax 2ea9: c7 44 24 04 65 54 00 movl $0x5465,0x4(%esp) 2eb0: 00 2eb1: 89 04 24 mov %eax,(%esp) 2eb4: e8 df 0e 00 00 call 3d98 <printf> exit(); 2eb9: e8 4a 0d 00 00 call 3c08 <exit> } c = sbrk(1); 2ebe: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ec5: e8 c6 0d 00 00 call 3c90 <sbrk> 2eca: 89 45 e0 mov %eax,-0x20(%ebp) c = sbrk(1); 2ecd: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2ed4: e8 b7 0d 00 00 call 3c90 <sbrk> 2ed9: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a + 1){ 2edc: 8b 45 f4 mov -0xc(%ebp),%eax 2edf: 40 inc %eax 2ee0: 3b 45 e0 cmp -0x20(%ebp),%eax 2ee3: 74 1a je 2eff <sbrktest+0x10e> printf(stdout, "sbrk test failed post-fork\n"); 2ee5: a1 b4 5e 00 00 mov 0x5eb4,%eax 2eea: c7 44 24 04 7c 54 00 movl $0x547c,0x4(%esp) 2ef1: 00 2ef2: 89 04 24 mov %eax,(%esp) 2ef5: e8 9e 0e 00 00 call 3d98 <printf> exit(); 2efa: e8 09 0d 00 00 call 3c08 <exit> } if(pid == 0) 2eff: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 2f03: 75 05 jne 2f0a <sbrktest+0x119> exit(); 2f05: e8 fe 0c 00 00 call 3c08 <exit> wait(); 2f0a: e8 01 0d 00 00 call 3c10 <wait> // can one grow address space to something big? #define BIG (100*1024*1024) a = sbrk(0); 2f0f: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2f16: e8 75 0d 00 00 call 3c90 <sbrk> 2f1b: 89 45 f4 mov %eax,-0xc(%ebp) amt = (BIG) - (uint)a; 2f1e: 8b 45 f4 mov -0xc(%ebp),%eax 2f21: ba 00 00 40 06 mov $0x6400000,%edx 2f26: 89 d1 mov %edx,%ecx 2f28: 29 c1 sub %eax,%ecx 2f2a: 89 c8 mov %ecx,%eax 2f2c: 89 45 dc mov %eax,-0x24(%ebp) p = sbrk(amt); 2f2f: 8b 45 dc mov -0x24(%ebp),%eax 2f32: 89 04 24 mov %eax,(%esp) 2f35: e8 56 0d 00 00 call 3c90 <sbrk> 2f3a: 89 45 d8 mov %eax,-0x28(%ebp) if (p != a) { 2f3d: 8b 45 d8 mov -0x28(%ebp),%eax 2f40: 3b 45 f4 cmp -0xc(%ebp),%eax 2f43: 74 1a je 2f5f <sbrktest+0x16e> printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); 2f45: a1 b4 5e 00 00 mov 0x5eb4,%eax 2f4a: c7 44 24 04 98 54 00 movl $0x5498,0x4(%esp) 2f51: 00 2f52: 89 04 24 mov %eax,(%esp) 2f55: e8 3e 0e 00 00 call 3d98 <printf> exit(); 2f5a: e8 a9 0c 00 00 call 3c08 <exit> } lastaddr = (char*) (BIG-1); 2f5f: c7 45 d4 ff ff 3f 06 movl $0x63fffff,-0x2c(%ebp) *lastaddr = 99; 2f66: 8b 45 d4 mov -0x2c(%ebp),%eax 2f69: c6 00 63 movb $0x63,(%eax) // can one de-allocate? a = sbrk(0); 2f6c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2f73: e8 18 0d 00 00 call 3c90 <sbrk> 2f78: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(-4096); 2f7b: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) 2f82: e8 09 0d 00 00 call 3c90 <sbrk> 2f87: 89 45 e0 mov %eax,-0x20(%ebp) if(c == (char*)0xffffffff){ 2f8a: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp) 2f8e: 75 1a jne 2faa <sbrktest+0x1b9> printf(stdout, "sbrk could not deallocate\n"); 2f90: a1 b4 5e 00 00 mov 0x5eb4,%eax 2f95: c7 44 24 04 d6 54 00 movl $0x54d6,0x4(%esp) 2f9c: 00 2f9d: 89 04 24 mov %eax,(%esp) 2fa0: e8 f3 0d 00 00 call 3d98 <printf> exit(); 2fa5: e8 5e 0c 00 00 call 3c08 <exit> } c = sbrk(0); 2faa: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2fb1: e8 da 0c 00 00 call 3c90 <sbrk> 2fb6: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a - 4096){ 2fb9: 8b 45 f4 mov -0xc(%ebp),%eax 2fbc: 2d 00 10 00 00 sub $0x1000,%eax 2fc1: 3b 45 e0 cmp -0x20(%ebp),%eax 2fc4: 74 28 je 2fee <sbrktest+0x1fd> printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); 2fc6: a1 b4 5e 00 00 mov 0x5eb4,%eax 2fcb: 8b 55 e0 mov -0x20(%ebp),%edx 2fce: 89 54 24 0c mov %edx,0xc(%esp) 2fd2: 8b 55 f4 mov -0xc(%ebp),%edx 2fd5: 89 54 24 08 mov %edx,0x8(%esp) 2fd9: c7 44 24 04 f4 54 00 movl $0x54f4,0x4(%esp) 2fe0: 00 2fe1: 89 04 24 mov %eax,(%esp) 2fe4: e8 af 0d 00 00 call 3d98 <printf> exit(); 2fe9: e8 1a 0c 00 00 call 3c08 <exit> } // can one re-allocate that page? a = sbrk(0); 2fee: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2ff5: e8 96 0c 00 00 call 3c90 <sbrk> 2ffa: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(4096); 2ffd: c7 04 24 00 10 00 00 movl $0x1000,(%esp) 3004: e8 87 0c 00 00 call 3c90 <sbrk> 3009: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a || sbrk(0) != a + 4096){ 300c: 8b 45 e0 mov -0x20(%ebp),%eax 300f: 3b 45 f4 cmp -0xc(%ebp),%eax 3012: 75 19 jne 302d <sbrktest+0x23c> 3014: c7 04 24 00 00 00 00 movl $0x0,(%esp) 301b: e8 70 0c 00 00 call 3c90 <sbrk> 3020: 8b 55 f4 mov -0xc(%ebp),%edx 3023: 81 c2 00 10 00 00 add $0x1000,%edx 3029: 39 d0 cmp %edx,%eax 302b: 74 28 je 3055 <sbrktest+0x264> printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); 302d: a1 b4 5e 00 00 mov 0x5eb4,%eax 3032: 8b 55 e0 mov -0x20(%ebp),%edx 3035: 89 54 24 0c mov %edx,0xc(%esp) 3039: 8b 55 f4 mov -0xc(%ebp),%edx 303c: 89 54 24 08 mov %edx,0x8(%esp) 3040: c7 44 24 04 2c 55 00 movl $0x552c,0x4(%esp) 3047: 00 3048: 89 04 24 mov %eax,(%esp) 304b: e8 48 0d 00 00 call 3d98 <printf> exit(); 3050: e8 b3 0b 00 00 call 3c08 <exit> } if(*lastaddr == 99){ 3055: 8b 45 d4 mov -0x2c(%ebp),%eax 3058: 8a 00 mov (%eax),%al 305a: 3c 63 cmp $0x63,%al 305c: 75 1a jne 3078 <sbrktest+0x287> // should be zero printf(stdout, "sbrk de-allocation didn't really deallocate\n"); 305e: a1 b4 5e 00 00 mov 0x5eb4,%eax 3063: c7 44 24 04 54 55 00 movl $0x5554,0x4(%esp) 306a: 00 306b: 89 04 24 mov %eax,(%esp) 306e: e8 25 0d 00 00 call 3d98 <printf> exit(); 3073: e8 90 0b 00 00 call 3c08 <exit> } a = sbrk(0); 3078: c7 04 24 00 00 00 00 movl $0x0,(%esp) 307f: e8 0c 0c 00 00 call 3c90 <sbrk> 3084: 89 45 f4 mov %eax,-0xc(%ebp) c = sbrk(-(sbrk(0) - oldbrk)); 3087: 8b 5d ec mov -0x14(%ebp),%ebx 308a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3091: e8 fa 0b 00 00 call 3c90 <sbrk> 3096: 89 da mov %ebx,%edx 3098: 29 c2 sub %eax,%edx 309a: 89 d0 mov %edx,%eax 309c: 89 04 24 mov %eax,(%esp) 309f: e8 ec 0b 00 00 call 3c90 <sbrk> 30a4: 89 45 e0 mov %eax,-0x20(%ebp) if(c != a){ 30a7: 8b 45 e0 mov -0x20(%ebp),%eax 30aa: 3b 45 f4 cmp -0xc(%ebp),%eax 30ad: 74 28 je 30d7 <sbrktest+0x2e6> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); 30af: a1 b4 5e 00 00 mov 0x5eb4,%eax 30b4: 8b 55 e0 mov -0x20(%ebp),%edx 30b7: 89 54 24 0c mov %edx,0xc(%esp) 30bb: 8b 55 f4 mov -0xc(%ebp),%edx 30be: 89 54 24 08 mov %edx,0x8(%esp) 30c2: c7 44 24 04 84 55 00 movl $0x5584,0x4(%esp) 30c9: 00 30ca: 89 04 24 mov %eax,(%esp) 30cd: e8 c6 0c 00 00 call 3d98 <printf> exit(); 30d2: e8 31 0b 00 00 call 3c08 <exit> } // can we read the kernel's memory? for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 30d7: c7 45 f4 00 00 00 80 movl $0x80000000,-0xc(%ebp) 30de: eb 7a jmp 315a <sbrktest+0x369> ppid = getpid(); 30e0: e8 a3 0b 00 00 call 3c88 <getpid> 30e5: 89 45 d0 mov %eax,-0x30(%ebp) pid = fork(); 30e8: e8 13 0b 00 00 call 3c00 <fork> 30ed: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 30f0: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 30f4: 79 1a jns 3110 <sbrktest+0x31f> printf(stdout, "fork failed\n"); 30f6: a1 b4 5e 00 00 mov 0x5eb4,%eax 30fb: c7 44 24 04 4d 45 00 movl $0x454d,0x4(%esp) 3102: 00 3103: 89 04 24 mov %eax,(%esp) 3106: e8 8d 0c 00 00 call 3d98 <printf> exit(); 310b: e8 f8 0a 00 00 call 3c08 <exit> } if(pid == 0){ 3110: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 3114: 75 38 jne 314e <sbrktest+0x35d> printf(stdout, "oops could read %x = %x\n", a, *a); 3116: 8b 45 f4 mov -0xc(%ebp),%eax 3119: 8a 00 mov (%eax),%al 311b: 0f be d0 movsbl %al,%edx 311e: a1 b4 5e 00 00 mov 0x5eb4,%eax 3123: 89 54 24 0c mov %edx,0xc(%esp) 3127: 8b 55 f4 mov -0xc(%ebp),%edx 312a: 89 54 24 08 mov %edx,0x8(%esp) 312e: c7 44 24 04 a5 55 00 movl $0x55a5,0x4(%esp) 3135: 00 3136: 89 04 24 mov %eax,(%esp) 3139: e8 5a 0c 00 00 call 3d98 <printf> kill(ppid); 313e: 8b 45 d0 mov -0x30(%ebp),%eax 3141: 89 04 24 mov %eax,(%esp) 3144: e8 ef 0a 00 00 call 3c38 <kill> exit(); 3149: e8 ba 0a 00 00 call 3c08 <exit> } wait(); 314e: e8 bd 0a 00 00 call 3c10 <wait> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); exit(); } // can we read the kernel's memory? for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 3153: 81 45 f4 50 c3 00 00 addl $0xc350,-0xc(%ebp) 315a: 81 7d f4 7f 84 1e 80 cmpl $0x801e847f,-0xc(%ebp) 3161: 0f 86 79 ff ff ff jbe 30e0 <sbrktest+0x2ef> wait(); } // if we run the system out of memory, does it clean up the last // failed allocation? if(pipe(fds) != 0){ 3167: 8d 45 c8 lea -0x38(%ebp),%eax 316a: 89 04 24 mov %eax,(%esp) 316d: e8 a6 0a 00 00 call 3c18 <pipe> 3172: 85 c0 test %eax,%eax 3174: 74 19 je 318f <sbrktest+0x39e> printf(1, "pipe() failed\n"); 3176: c7 44 24 04 a1 44 00 movl $0x44a1,0x4(%esp) 317d: 00 317e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3185: e8 0e 0c 00 00 call 3d98 <printf> exit(); 318a: e8 79 0a 00 00 call 3c08 <exit> } for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 318f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 3196: e9 88 00 00 00 jmp 3223 <sbrktest+0x432> if((pids[i] = fork()) == 0){ 319b: e8 60 0a 00 00 call 3c00 <fork> 31a0: 8b 55 f0 mov -0x10(%ebp),%edx 31a3: 89 44 95 a0 mov %eax,-0x60(%ebp,%edx,4) 31a7: 8b 45 f0 mov -0x10(%ebp),%eax 31aa: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 31ae: 85 c0 test %eax,%eax 31b0: 75 48 jne 31fa <sbrktest+0x409> // allocate a lot of memory sbrk(BIG - (uint)sbrk(0)); 31b2: c7 04 24 00 00 00 00 movl $0x0,(%esp) 31b9: e8 d2 0a 00 00 call 3c90 <sbrk> 31be: ba 00 00 40 06 mov $0x6400000,%edx 31c3: 89 d1 mov %edx,%ecx 31c5: 29 c1 sub %eax,%ecx 31c7: 89 c8 mov %ecx,%eax 31c9: 89 04 24 mov %eax,(%esp) 31cc: e8 bf 0a 00 00 call 3c90 <sbrk> write(fds[1], "x", 1); 31d1: 8b 45 cc mov -0x34(%ebp),%eax 31d4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 31db: 00 31dc: c7 44 24 04 06 45 00 movl $0x4506,0x4(%esp) 31e3: 00 31e4: 89 04 24 mov %eax,(%esp) 31e7: e8 3c 0a 00 00 call 3c28 <write> // sit around until killed for(;;) sleep(1000); 31ec: c7 04 24 e8 03 00 00 movl $0x3e8,(%esp) 31f3: e8 a0 0a 00 00 call 3c98 <sleep> 31f8: eb f2 jmp 31ec <sbrktest+0x3fb> } if(pids[i] != -1) 31fa: 8b 45 f0 mov -0x10(%ebp),%eax 31fd: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 3201: 83 f8 ff cmp $0xffffffff,%eax 3204: 74 1a je 3220 <sbrktest+0x42f> read(fds[0], &scratch, 1); 3206: 8b 45 c8 mov -0x38(%ebp),%eax 3209: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3210: 00 3211: 8d 55 9f lea -0x61(%ebp),%edx 3214: 89 54 24 04 mov %edx,0x4(%esp) 3218: 89 04 24 mov %eax,(%esp) 321b: e8 00 0a 00 00 call 3c20 <read> // failed allocation? if(pipe(fds) != 0){ printf(1, "pipe() failed\n"); exit(); } for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 3220: ff 45 f0 incl -0x10(%ebp) 3223: 8b 45 f0 mov -0x10(%ebp),%eax 3226: 83 f8 09 cmp $0x9,%eax 3229: 0f 86 6c ff ff ff jbe 319b <sbrktest+0x3aa> if(pids[i] != -1) read(fds[0], &scratch, 1); } // if those failed allocations freed up the pages they did allocate, // we'll be able to allocate here c = sbrk(4096); 322f: c7 04 24 00 10 00 00 movl $0x1000,(%esp) 3236: e8 55 0a 00 00 call 3c90 <sbrk> 323b: 89 45 e0 mov %eax,-0x20(%ebp) for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 323e: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 3245: eb 26 jmp 326d <sbrktest+0x47c> if(pids[i] == -1) 3247: 8b 45 f0 mov -0x10(%ebp),%eax 324a: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 324e: 83 f8 ff cmp $0xffffffff,%eax 3251: 74 16 je 3269 <sbrktest+0x478> continue; kill(pids[i]); 3253: 8b 45 f0 mov -0x10(%ebp),%eax 3256: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax 325a: 89 04 24 mov %eax,(%esp) 325d: e8 d6 09 00 00 call 3c38 <kill> wait(); 3262: e8 a9 09 00 00 call 3c10 <wait> 3267: eb 01 jmp 326a <sbrktest+0x479> // if those failed allocations freed up the pages they did allocate, // we'll be able to allocate here c = sbrk(4096); for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ if(pids[i] == -1) continue; 3269: 90 nop read(fds[0], &scratch, 1); } // if those failed allocations freed up the pages they did allocate, // we'll be able to allocate here c = sbrk(4096); for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 326a: ff 45 f0 incl -0x10(%ebp) 326d: 8b 45 f0 mov -0x10(%ebp),%eax 3270: 83 f8 09 cmp $0x9,%eax 3273: 76 d2 jbe 3247 <sbrktest+0x456> if(pids[i] == -1) continue; kill(pids[i]); wait(); } if(c == (char*)0xffffffff){ 3275: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp) 3279: 75 1a jne 3295 <sbrktest+0x4a4> printf(stdout, "failed sbrk leaked memory\n"); 327b: a1 b4 5e 00 00 mov 0x5eb4,%eax 3280: c7 44 24 04 be 55 00 movl $0x55be,0x4(%esp) 3287: 00 3288: 89 04 24 mov %eax,(%esp) 328b: e8 08 0b 00 00 call 3d98 <printf> exit(); 3290: e8 73 09 00 00 call 3c08 <exit> } if(sbrk(0) > oldbrk) 3295: c7 04 24 00 00 00 00 movl $0x0,(%esp) 329c: e8 ef 09 00 00 call 3c90 <sbrk> 32a1: 3b 45 ec cmp -0x14(%ebp),%eax 32a4: 76 1d jbe 32c3 <sbrktest+0x4d2> sbrk(-(sbrk(0) - oldbrk)); 32a6: 8b 5d ec mov -0x14(%ebp),%ebx 32a9: c7 04 24 00 00 00 00 movl $0x0,(%esp) 32b0: e8 db 09 00 00 call 3c90 <sbrk> 32b5: 89 da mov %ebx,%edx 32b7: 29 c2 sub %eax,%edx 32b9: 89 d0 mov %edx,%eax 32bb: 89 04 24 mov %eax,(%esp) 32be: e8 cd 09 00 00 call 3c90 <sbrk> printf(stdout, "sbrk test OK\n"); 32c3: a1 b4 5e 00 00 mov 0x5eb4,%eax 32c8: c7 44 24 04 d9 55 00 movl $0x55d9,0x4(%esp) 32cf: 00 32d0: 89 04 24 mov %eax,(%esp) 32d3: e8 c0 0a 00 00 call 3d98 <printf> } 32d8: 81 c4 84 00 00 00 add $0x84,%esp 32de: 5b pop %ebx 32df: 5d pop %ebp 32e0: c3 ret 000032e1 <validateint>: void validateint(int *p) { 32e1: 55 push %ebp 32e2: 89 e5 mov %esp,%ebp 32e4: 56 push %esi 32e5: 53 push %ebx 32e6: 83 ec 14 sub $0x14,%esp int res; asm("mov %%esp, %%ebx\n\t" 32e9: c7 45 e4 0d 00 00 00 movl $0xd,-0x1c(%ebp) 32f0: 8b 55 08 mov 0x8(%ebp),%edx 32f3: 8b 45 e4 mov -0x1c(%ebp),%eax 32f6: 89 d1 mov %edx,%ecx 32f8: 89 e3 mov %esp,%ebx 32fa: 89 cc mov %ecx,%esp 32fc: cd 40 int $0x40 32fe: 89 dc mov %ebx,%esp 3300: 89 c6 mov %eax,%esi 3302: 89 75 f4 mov %esi,-0xc(%ebp) "int %2\n\t" "mov %%ebx, %%esp" : "=a" (res) : "a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) : "ebx"); } 3305: 83 c4 14 add $0x14,%esp 3308: 5b pop %ebx 3309: 5e pop %esi 330a: 5d pop %ebp 330b: c3 ret 0000330c <validatetest>: void validatetest(void) { 330c: 55 push %ebp 330d: 89 e5 mov %esp,%ebp 330f: 83 ec 28 sub $0x28,%esp int hi, pid; uint p; printf(stdout, "validate test\n"); 3312: a1 b4 5e 00 00 mov 0x5eb4,%eax 3317: c7 44 24 04 e7 55 00 movl $0x55e7,0x4(%esp) 331e: 00 331f: 89 04 24 mov %eax,(%esp) 3322: e8 71 0a 00 00 call 3d98 <printf> hi = 1100*1024; 3327: c7 45 f0 00 30 11 00 movl $0x113000,-0x10(%ebp) for(p = 0; p <= (uint)hi; p += 4096){ 332e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3335: eb 7f jmp 33b6 <validatetest+0xaa> if((pid = fork()) == 0){ 3337: e8 c4 08 00 00 call 3c00 <fork> 333c: 89 45 ec mov %eax,-0x14(%ebp) 333f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3343: 75 10 jne 3355 <validatetest+0x49> // try to crash the kernel by passing in a badly placed integer validateint((int*)p); 3345: 8b 45 f4 mov -0xc(%ebp),%eax 3348: 89 04 24 mov %eax,(%esp) 334b: e8 91 ff ff ff call 32e1 <validateint> exit(); 3350: e8 b3 08 00 00 call 3c08 <exit> } sleep(0); 3355: c7 04 24 00 00 00 00 movl $0x0,(%esp) 335c: e8 37 09 00 00 call 3c98 <sleep> sleep(0); 3361: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3368: e8 2b 09 00 00 call 3c98 <sleep> kill(pid); 336d: 8b 45 ec mov -0x14(%ebp),%eax 3370: 89 04 24 mov %eax,(%esp) 3373: e8 c0 08 00 00 call 3c38 <kill> wait(); 3378: e8 93 08 00 00 call 3c10 <wait> // try to crash the kernel by passing in a bad string pointer if(link("nosuchfile", (char*)p) != -1){ 337d: 8b 45 f4 mov -0xc(%ebp),%eax 3380: 89 44 24 04 mov %eax,0x4(%esp) 3384: c7 04 24 f6 55 00 00 movl $0x55f6,(%esp) 338b: e8 d8 08 00 00 call 3c68 <link> 3390: 83 f8 ff cmp $0xffffffff,%eax 3393: 74 1a je 33af <validatetest+0xa3> printf(stdout, "link should not succeed\n"); 3395: a1 b4 5e 00 00 mov 0x5eb4,%eax 339a: c7 44 24 04 01 56 00 movl $0x5601,0x4(%esp) 33a1: 00 33a2: 89 04 24 mov %eax,(%esp) 33a5: e8 ee 09 00 00 call 3d98 <printf> exit(); 33aa: e8 59 08 00 00 call 3c08 <exit> uint p; printf(stdout, "validate test\n"); hi = 1100*1024; for(p = 0; p <= (uint)hi; p += 4096){ 33af: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp) 33b6: 8b 45 f0 mov -0x10(%ebp),%eax 33b9: 3b 45 f4 cmp -0xc(%ebp),%eax 33bc: 0f 83 75 ff ff ff jae 3337 <validatetest+0x2b> printf(stdout, "link should not succeed\n"); exit(); } } printf(stdout, "validate ok\n"); 33c2: a1 b4 5e 00 00 mov 0x5eb4,%eax 33c7: c7 44 24 04 1a 56 00 movl $0x561a,0x4(%esp) 33ce: 00 33cf: 89 04 24 mov %eax,(%esp) 33d2: e8 c1 09 00 00 call 3d98 <printf> } 33d7: c9 leave 33d8: c3 ret 000033d9 <bsstest>: // does unintialized data start out zero? char uninit[10000]; void bsstest(void) { 33d9: 55 push %ebp 33da: 89 e5 mov %esp,%ebp 33dc: 83 ec 28 sub $0x28,%esp int i; printf(stdout, "bss test\n"); 33df: a1 b4 5e 00 00 mov 0x5eb4,%eax 33e4: c7 44 24 04 27 56 00 movl $0x5627,0x4(%esp) 33eb: 00 33ec: 89 04 24 mov %eax,(%esp) 33ef: e8 a4 09 00 00 call 3d98 <printf> for(i = 0; i < sizeof(uninit); i++){ 33f4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 33fb: eb 2b jmp 3428 <bsstest+0x4f> if(uninit[i] != '\0'){ 33fd: 8b 45 f4 mov -0xc(%ebp),%eax 3400: 05 80 5f 00 00 add $0x5f80,%eax 3405: 8a 00 mov (%eax),%al 3407: 84 c0 test %al,%al 3409: 74 1a je 3425 <bsstest+0x4c> printf(stdout, "bss test failed\n"); 340b: a1 b4 5e 00 00 mov 0x5eb4,%eax 3410: c7 44 24 04 31 56 00 movl $0x5631,0x4(%esp) 3417: 00 3418: 89 04 24 mov %eax,(%esp) 341b: e8 78 09 00 00 call 3d98 <printf> exit(); 3420: e8 e3 07 00 00 call 3c08 <exit> bsstest(void) { int i; printf(stdout, "bss test\n"); for(i = 0; i < sizeof(uninit); i++){ 3425: ff 45 f4 incl -0xc(%ebp) 3428: 8b 45 f4 mov -0xc(%ebp),%eax 342b: 3d 0f 27 00 00 cmp $0x270f,%eax 3430: 76 cb jbe 33fd <bsstest+0x24> if(uninit[i] != '\0'){ printf(stdout, "bss test failed\n"); exit(); } } printf(stdout, "bss test ok\n"); 3432: a1 b4 5e 00 00 mov 0x5eb4,%eax 3437: c7 44 24 04 42 56 00 movl $0x5642,0x4(%esp) 343e: 00 343f: 89 04 24 mov %eax,(%esp) 3442: e8 51 09 00 00 call 3d98 <printf> } 3447: c9 leave 3448: c3 ret 00003449 <bigargtest>: // does exec return an error if the arguments // are larger than a page? or does it write // below the stack and wreck the instructions/data? void bigargtest(void) { 3449: 55 push %ebp 344a: 89 e5 mov %esp,%ebp 344c: 83 ec 28 sub $0x28,%esp int pid, fd; unlink("bigarg-ok"); 344f: c7 04 24 4f 56 00 00 movl $0x564f,(%esp) 3456: e8 fd 07 00 00 call 3c58 <unlink> pid = fork(); 345b: e8 a0 07 00 00 call 3c00 <fork> 3460: 89 45 f0 mov %eax,-0x10(%ebp) if(pid == 0){ 3463: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3467: 0f 85 8f 00 00 00 jne 34fc <bigargtest+0xb3> static char *args[MAXARG]; int i; for(i = 0; i < MAXARG-1; i++) 346d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3474: eb 11 jmp 3487 <bigargtest+0x3e> args[i] = "bigargs test: failed\n "; 3476: 8b 45 f4 mov -0xc(%ebp),%eax 3479: c7 04 85 e0 5e 00 00 movl $0x565c,0x5ee0(,%eax,4) 3480: 5c 56 00 00 unlink("bigarg-ok"); pid = fork(); if(pid == 0){ static char *args[MAXARG]; int i; for(i = 0; i < MAXARG-1; i++) 3484: ff 45 f4 incl -0xc(%ebp) 3487: 83 7d f4 1e cmpl $0x1e,-0xc(%ebp) 348b: 7e e9 jle 3476 <bigargtest+0x2d> args[i] = "bigargs test: failed\n "; args[MAXARG-1] = 0; 348d: c7 05 5c 5f 00 00 00 movl $0x0,0x5f5c 3494: 00 00 00 printf(stdout, "bigarg test\n"); 3497: a1 b4 5e 00 00 mov 0x5eb4,%eax 349c: c7 44 24 04 39 57 00 movl $0x5739,0x4(%esp) 34a3: 00 34a4: 89 04 24 mov %eax,(%esp) 34a7: e8 ec 08 00 00 call 3d98 <printf> exec("echo", args); 34ac: c7 44 24 04 e0 5e 00 movl $0x5ee0,0x4(%esp) 34b3: 00 34b4: c7 04 24 60 41 00 00 movl $0x4160,(%esp) 34bb: e8 80 07 00 00 call 3c40 <exec> printf(stdout, "bigarg test ok\n"); 34c0: a1 b4 5e 00 00 mov 0x5eb4,%eax 34c5: c7 44 24 04 46 57 00 movl $0x5746,0x4(%esp) 34cc: 00 34cd: 89 04 24 mov %eax,(%esp) 34d0: e8 c3 08 00 00 call 3d98 <printf> fd = open("bigarg-ok", O_CREATE); 34d5: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 34dc: 00 34dd: c7 04 24 4f 56 00 00 movl $0x564f,(%esp) 34e4: e8 5f 07 00 00 call 3c48 <open> 34e9: 89 45 ec mov %eax,-0x14(%ebp) close(fd); 34ec: 8b 45 ec mov -0x14(%ebp),%eax 34ef: 89 04 24 mov %eax,(%esp) 34f2: e8 39 07 00 00 call 3c30 <close> exit(); 34f7: e8 0c 07 00 00 call 3c08 <exit> } else if(pid < 0){ 34fc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3500: 79 1a jns 351c <bigargtest+0xd3> printf(stdout, "bigargtest: fork failed\n"); 3502: a1 b4 5e 00 00 mov 0x5eb4,%eax 3507: c7 44 24 04 56 57 00 movl $0x5756,0x4(%esp) 350e: 00 350f: 89 04 24 mov %eax,(%esp) 3512: e8 81 08 00 00 call 3d98 <printf> exit(); 3517: e8 ec 06 00 00 call 3c08 <exit> } wait(); 351c: e8 ef 06 00 00 call 3c10 <wait> fd = open("bigarg-ok", 0); 3521: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 3528: 00 3529: c7 04 24 4f 56 00 00 movl $0x564f,(%esp) 3530: e8 13 07 00 00 call 3c48 <open> 3535: 89 45 ec mov %eax,-0x14(%ebp) if(fd < 0){ 3538: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 353c: 79 1a jns 3558 <bigargtest+0x10f> printf(stdout, "bigarg test failed!\n"); 353e: a1 b4 5e 00 00 mov 0x5eb4,%eax 3543: c7 44 24 04 6f 57 00 movl $0x576f,0x4(%esp) 354a: 00 354b: 89 04 24 mov %eax,(%esp) 354e: e8 45 08 00 00 call 3d98 <printf> exit(); 3553: e8 b0 06 00 00 call 3c08 <exit> } close(fd); 3558: 8b 45 ec mov -0x14(%ebp),%eax 355b: 89 04 24 mov %eax,(%esp) 355e: e8 cd 06 00 00 call 3c30 <close> unlink("bigarg-ok"); 3563: c7 04 24 4f 56 00 00 movl $0x564f,(%esp) 356a: e8 e9 06 00 00 call 3c58 <unlink> } 356f: c9 leave 3570: c3 ret 00003571 <fsfull>: // what happens when the file system runs out of blocks? // answer: balloc panics, so this test is not useful. void fsfull() { 3571: 55 push %ebp 3572: 89 e5 mov %esp,%ebp 3574: 53 push %ebx 3575: 83 ec 74 sub $0x74,%esp int nfiles; int fsblocks = 0; 3578: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) printf(1, "fsfull test\n"); 357f: c7 44 24 04 84 57 00 movl $0x5784,0x4(%esp) 3586: 00 3587: c7 04 24 01 00 00 00 movl $0x1,(%esp) 358e: e8 05 08 00 00 call 3d98 <printf> for(nfiles = 0; ; nfiles++){ 3593: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) char name[64]; name[0] = 'f'; 359a: c6 45 a4 66 movb $0x66,-0x5c(%ebp) name[1] = '0' + nfiles / 1000; 359e: 8b 4d f4 mov -0xc(%ebp),%ecx 35a1: b8 d3 4d 62 10 mov $0x10624dd3,%eax 35a6: f7 e9 imul %ecx 35a8: c1 fa 06 sar $0x6,%edx 35ab: 89 c8 mov %ecx,%eax 35ad: c1 f8 1f sar $0x1f,%eax 35b0: 89 d1 mov %edx,%ecx 35b2: 29 c1 sub %eax,%ecx 35b4: 89 c8 mov %ecx,%eax 35b6: 83 c0 30 add $0x30,%eax 35b9: 88 45 a5 mov %al,-0x5b(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 35bc: 8b 5d f4 mov -0xc(%ebp),%ebx 35bf: b8 d3 4d 62 10 mov $0x10624dd3,%eax 35c4: f7 eb imul %ebx 35c6: c1 fa 06 sar $0x6,%edx 35c9: 89 d8 mov %ebx,%eax 35cb: c1 f8 1f sar $0x1f,%eax 35ce: 89 d1 mov %edx,%ecx 35d0: 29 c1 sub %eax,%ecx 35d2: 89 c8 mov %ecx,%eax 35d4: c1 e0 02 shl $0x2,%eax 35d7: 01 c8 add %ecx,%eax 35d9: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 35e0: 01 d0 add %edx,%eax 35e2: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 35e9: 01 d0 add %edx,%eax 35eb: c1 e0 03 shl $0x3,%eax 35ee: 89 d9 mov %ebx,%ecx 35f0: 29 c1 sub %eax,%ecx 35f2: b8 1f 85 eb 51 mov $0x51eb851f,%eax 35f7: f7 e9 imul %ecx 35f9: c1 fa 05 sar $0x5,%edx 35fc: 89 c8 mov %ecx,%eax 35fe: c1 f8 1f sar $0x1f,%eax 3601: 89 d1 mov %edx,%ecx 3603: 29 c1 sub %eax,%ecx 3605: 89 c8 mov %ecx,%eax 3607: 83 c0 30 add $0x30,%eax 360a: 88 45 a6 mov %al,-0x5a(%ebp) name[3] = '0' + (nfiles % 100) / 10; 360d: 8b 5d f4 mov -0xc(%ebp),%ebx 3610: b8 1f 85 eb 51 mov $0x51eb851f,%eax 3615: f7 eb imul %ebx 3617: c1 fa 05 sar $0x5,%edx 361a: 89 d8 mov %ebx,%eax 361c: c1 f8 1f sar $0x1f,%eax 361f: 89 d1 mov %edx,%ecx 3621: 29 c1 sub %eax,%ecx 3623: 89 c8 mov %ecx,%eax 3625: c1 e0 02 shl $0x2,%eax 3628: 01 c8 add %ecx,%eax 362a: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 3631: 01 d0 add %edx,%eax 3633: c1 e0 02 shl $0x2,%eax 3636: 89 d9 mov %ebx,%ecx 3638: 29 c1 sub %eax,%ecx 363a: ba 67 66 66 66 mov $0x66666667,%edx 363f: 89 c8 mov %ecx,%eax 3641: f7 ea imul %edx 3643: c1 fa 02 sar $0x2,%edx 3646: 89 c8 mov %ecx,%eax 3648: c1 f8 1f sar $0x1f,%eax 364b: 89 d1 mov %edx,%ecx 364d: 29 c1 sub %eax,%ecx 364f: 89 c8 mov %ecx,%eax 3651: 83 c0 30 add $0x30,%eax 3654: 88 45 a7 mov %al,-0x59(%ebp) name[4] = '0' + (nfiles % 10); 3657: 8b 4d f4 mov -0xc(%ebp),%ecx 365a: ba 67 66 66 66 mov $0x66666667,%edx 365f: 89 c8 mov %ecx,%eax 3661: f7 ea imul %edx 3663: c1 fa 02 sar $0x2,%edx 3666: 89 c8 mov %ecx,%eax 3668: c1 f8 1f sar $0x1f,%eax 366b: 29 c2 sub %eax,%edx 366d: 89 d0 mov %edx,%eax 366f: c1 e0 02 shl $0x2,%eax 3672: 01 d0 add %edx,%eax 3674: d1 e0 shl %eax 3676: 89 ca mov %ecx,%edx 3678: 29 c2 sub %eax,%edx 367a: 88 d0 mov %dl,%al 367c: 83 c0 30 add $0x30,%eax 367f: 88 45 a8 mov %al,-0x58(%ebp) name[5] = '\0'; 3682: c6 45 a9 00 movb $0x0,-0x57(%ebp) printf(1, "writing %s\n", name); 3686: 8d 45 a4 lea -0x5c(%ebp),%eax 3689: 89 44 24 08 mov %eax,0x8(%esp) 368d: c7 44 24 04 91 57 00 movl $0x5791,0x4(%esp) 3694: 00 3695: c7 04 24 01 00 00 00 movl $0x1,(%esp) 369c: e8 f7 06 00 00 call 3d98 <printf> int fd = open(name, O_CREATE|O_RDWR); 36a1: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) 36a8: 00 36a9: 8d 45 a4 lea -0x5c(%ebp),%eax 36ac: 89 04 24 mov %eax,(%esp) 36af: e8 94 05 00 00 call 3c48 <open> 36b4: 89 45 e8 mov %eax,-0x18(%ebp) if(fd < 0){ 36b7: 83 7d e8 00 cmpl $0x0,-0x18(%ebp) 36bb: 79 20 jns 36dd <fsfull+0x16c> printf(1, "open %s failed\n", name); 36bd: 8d 45 a4 lea -0x5c(%ebp),%eax 36c0: 89 44 24 08 mov %eax,0x8(%esp) 36c4: c7 44 24 04 9d 57 00 movl $0x579d,0x4(%esp) 36cb: 00 36cc: c7 04 24 01 00 00 00 movl $0x1,(%esp) 36d3: e8 c0 06 00 00 call 3d98 <printf> close(fd); if(total == 0) break; } while(nfiles >= 0){ 36d8: e9 6c 01 00 00 jmp 3849 <fsfull+0x2d8> int fd = open(name, O_CREATE|O_RDWR); if(fd < 0){ printf(1, "open %s failed\n", name); break; } int total = 0; 36dd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) while(1){ int cc = write(fd, buf, 512); 36e4: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 36eb: 00 36ec: c7 44 24 04 a0 86 00 movl $0x86a0,0x4(%esp) 36f3: 00 36f4: 8b 45 e8 mov -0x18(%ebp),%eax 36f7: 89 04 24 mov %eax,(%esp) 36fa: e8 29 05 00 00 call 3c28 <write> 36ff: 89 45 e4 mov %eax,-0x1c(%ebp) if(cc < 512) 3702: 81 7d e4 ff 01 00 00 cmpl $0x1ff,-0x1c(%ebp) 3709: 7e 0b jle 3716 <fsfull+0x1a5> break; total += cc; 370b: 8b 45 e4 mov -0x1c(%ebp),%eax 370e: 01 45 ec add %eax,-0x14(%ebp) fsblocks++; 3711: ff 45 f0 incl -0x10(%ebp) } 3714: eb ce jmp 36e4 <fsfull+0x173> } int total = 0; while(1){ int cc = write(fd, buf, 512); if(cc < 512) break; 3716: 90 nop total += cc; fsblocks++; } printf(1, "wrote %d bytes\n", total); 3717: 8b 45 ec mov -0x14(%ebp),%eax 371a: 89 44 24 08 mov %eax,0x8(%esp) 371e: c7 44 24 04 ad 57 00 movl $0x57ad,0x4(%esp) 3725: 00 3726: c7 04 24 01 00 00 00 movl $0x1,(%esp) 372d: e8 66 06 00 00 call 3d98 <printf> close(fd); 3732: 8b 45 e8 mov -0x18(%ebp),%eax 3735: 89 04 24 mov %eax,(%esp) 3738: e8 f3 04 00 00 call 3c30 <close> if(total == 0) 373d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3741: 0f 84 02 01 00 00 je 3849 <fsfull+0x2d8> int nfiles; int fsblocks = 0; printf(1, "fsfull test\n"); for(nfiles = 0; ; nfiles++){ 3747: ff 45 f4 incl -0xc(%ebp) } printf(1, "wrote %d bytes\n", total); close(fd); if(total == 0) break; } 374a: e9 4b fe ff ff jmp 359a <fsfull+0x29> while(nfiles >= 0){ char name[64]; name[0] = 'f'; 374f: c6 45 a4 66 movb $0x66,-0x5c(%ebp) name[1] = '0' + nfiles / 1000; 3753: 8b 4d f4 mov -0xc(%ebp),%ecx 3756: b8 d3 4d 62 10 mov $0x10624dd3,%eax 375b: f7 e9 imul %ecx 375d: c1 fa 06 sar $0x6,%edx 3760: 89 c8 mov %ecx,%eax 3762: c1 f8 1f sar $0x1f,%eax 3765: 89 d1 mov %edx,%ecx 3767: 29 c1 sub %eax,%ecx 3769: 89 c8 mov %ecx,%eax 376b: 83 c0 30 add $0x30,%eax 376e: 88 45 a5 mov %al,-0x5b(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 3771: 8b 5d f4 mov -0xc(%ebp),%ebx 3774: b8 d3 4d 62 10 mov $0x10624dd3,%eax 3779: f7 eb imul %ebx 377b: c1 fa 06 sar $0x6,%edx 377e: 89 d8 mov %ebx,%eax 3780: c1 f8 1f sar $0x1f,%eax 3783: 89 d1 mov %edx,%ecx 3785: 29 c1 sub %eax,%ecx 3787: 89 c8 mov %ecx,%eax 3789: c1 e0 02 shl $0x2,%eax 378c: 01 c8 add %ecx,%eax 378e: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 3795: 01 d0 add %edx,%eax 3797: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 379e: 01 d0 add %edx,%eax 37a0: c1 e0 03 shl $0x3,%eax 37a3: 89 d9 mov %ebx,%ecx 37a5: 29 c1 sub %eax,%ecx 37a7: b8 1f 85 eb 51 mov $0x51eb851f,%eax 37ac: f7 e9 imul %ecx 37ae: c1 fa 05 sar $0x5,%edx 37b1: 89 c8 mov %ecx,%eax 37b3: c1 f8 1f sar $0x1f,%eax 37b6: 89 d1 mov %edx,%ecx 37b8: 29 c1 sub %eax,%ecx 37ba: 89 c8 mov %ecx,%eax 37bc: 83 c0 30 add $0x30,%eax 37bf: 88 45 a6 mov %al,-0x5a(%ebp) name[3] = '0' + (nfiles % 100) / 10; 37c2: 8b 5d f4 mov -0xc(%ebp),%ebx 37c5: b8 1f 85 eb 51 mov $0x51eb851f,%eax 37ca: f7 eb imul %ebx 37cc: c1 fa 05 sar $0x5,%edx 37cf: 89 d8 mov %ebx,%eax 37d1: c1 f8 1f sar $0x1f,%eax 37d4: 89 d1 mov %edx,%ecx 37d6: 29 c1 sub %eax,%ecx 37d8: 89 c8 mov %ecx,%eax 37da: c1 e0 02 shl $0x2,%eax 37dd: 01 c8 add %ecx,%eax 37df: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 37e6: 01 d0 add %edx,%eax 37e8: c1 e0 02 shl $0x2,%eax 37eb: 89 d9 mov %ebx,%ecx 37ed: 29 c1 sub %eax,%ecx 37ef: ba 67 66 66 66 mov $0x66666667,%edx 37f4: 89 c8 mov %ecx,%eax 37f6: f7 ea imul %edx 37f8: c1 fa 02 sar $0x2,%edx 37fb: 89 c8 mov %ecx,%eax 37fd: c1 f8 1f sar $0x1f,%eax 3800: 89 d1 mov %edx,%ecx 3802: 29 c1 sub %eax,%ecx 3804: 89 c8 mov %ecx,%eax 3806: 83 c0 30 add $0x30,%eax 3809: 88 45 a7 mov %al,-0x59(%ebp) name[4] = '0' + (nfiles % 10); 380c: 8b 4d f4 mov -0xc(%ebp),%ecx 380f: ba 67 66 66 66 mov $0x66666667,%edx 3814: 89 c8 mov %ecx,%eax 3816: f7 ea imul %edx 3818: c1 fa 02 sar $0x2,%edx 381b: 89 c8 mov %ecx,%eax 381d: c1 f8 1f sar $0x1f,%eax 3820: 29 c2 sub %eax,%edx 3822: 89 d0 mov %edx,%eax 3824: c1 e0 02 shl $0x2,%eax 3827: 01 d0 add %edx,%eax 3829: d1 e0 shl %eax 382b: 89 ca mov %ecx,%edx 382d: 29 c2 sub %eax,%edx 382f: 88 d0 mov %dl,%al 3831: 83 c0 30 add $0x30,%eax 3834: 88 45 a8 mov %al,-0x58(%ebp) name[5] = '\0'; 3837: c6 45 a9 00 movb $0x0,-0x57(%ebp) unlink(name); 383b: 8d 45 a4 lea -0x5c(%ebp),%eax 383e: 89 04 24 mov %eax,(%esp) 3841: e8 12 04 00 00 call 3c58 <unlink> nfiles--; 3846: ff 4d f4 decl -0xc(%ebp) close(fd); if(total == 0) break; } while(nfiles >= 0){ 3849: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 384d: 0f 89 fc fe ff ff jns 374f <fsfull+0x1de> name[5] = '\0'; unlink(name); nfiles--; } printf(1, "fsfull test finished\n"); 3853: c7 44 24 04 bd 57 00 movl $0x57bd,0x4(%esp) 385a: 00 385b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 3862: e8 31 05 00 00 call 3d98 <printf> } 3867: 83 c4 74 add $0x74,%esp 386a: 5b pop %ebx 386b: 5d pop %ebp 386c: c3 ret 0000386d <rand>: unsigned long randstate = 1; unsigned int rand() { 386d: 55 push %ebp 386e: 89 e5 mov %esp,%ebp randstate = randstate * 1664525 + 1013904223; 3870: 8b 15 b8 5e 00 00 mov 0x5eb8,%edx 3876: 89 d0 mov %edx,%eax 3878: d1 e0 shl %eax 387a: 01 d0 add %edx,%eax 387c: c1 e0 02 shl $0x2,%eax 387f: 01 d0 add %edx,%eax 3881: c1 e0 08 shl $0x8,%eax 3884: 01 d0 add %edx,%eax 3886: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx 388d: 01 c8 add %ecx,%eax 388f: c1 e0 02 shl $0x2,%eax 3892: 01 d0 add %edx,%eax 3894: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 389b: 01 d0 add %edx,%eax 389d: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 38a4: 01 d0 add %edx,%eax 38a6: 05 5f f3 6e 3c add $0x3c6ef35f,%eax 38ab: a3 b8 5e 00 00 mov %eax,0x5eb8 return randstate; 38b0: a1 b8 5e 00 00 mov 0x5eb8,%eax } 38b5: 5d pop %ebp 38b6: c3 ret 000038b7 <main>: int main(int argc, char *argv[]) { 38b7: 55 push %ebp 38b8: 89 e5 mov %esp,%ebp 38ba: 83 e4 f0 and $0xfffffff0,%esp 38bd: 83 ec 10 sub $0x10,%esp printf(1, "usertests starting\n"); 38c0: c7 44 24 04 d3 57 00 movl $0x57d3,0x4(%esp) 38c7: 00 38c8: c7 04 24 01 00 00 00 movl $0x1,(%esp) 38cf: e8 c4 04 00 00 call 3d98 <printf> if(open("usertests.ran", 0) >= 0){ 38d4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 38db: 00 38dc: c7 04 24 e7 57 00 00 movl $0x57e7,(%esp) 38e3: e8 60 03 00 00 call 3c48 <open> 38e8: 85 c0 test %eax,%eax 38ea: 78 19 js 3905 <main+0x4e> printf(1, "already ran user tests -- rebuild fs.img\n"); 38ec: c7 44 24 04 f8 57 00 movl $0x57f8,0x4(%esp) 38f3: 00 38f4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 38fb: e8 98 04 00 00 call 3d98 <printf> exit(); 3900: e8 03 03 00 00 call 3c08 <exit> } close(open("usertests.ran", O_CREATE)); 3905: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp) 390c: 00 390d: c7 04 24 e7 57 00 00 movl $0x57e7,(%esp) 3914: e8 2f 03 00 00 call 3c48 <open> 3919: 89 04 24 mov %eax,(%esp) 391c: e8 0f 03 00 00 call 3c30 <close> bigargtest(); 3921: e8 23 fb ff ff call 3449 <bigargtest> bigwrite(); 3926: e8 9c ea ff ff call 23c7 <bigwrite> bigargtest(); 392b: e8 19 fb ff ff call 3449 <bigargtest> bsstest(); 3930: e8 a4 fa ff ff call 33d9 <bsstest> sbrktest(); 3935: e8 b7 f4 ff ff call 2df1 <sbrktest> validatetest(); 393a: e8 cd f9 ff ff call 330c <validatetest> opentest(); 393f: e8 bc c6 ff ff call 0 <opentest> writetest(); 3944: e8 62 c7 ff ff call ab <writetest> writetest1(); 3949: e8 71 c9 ff ff call 2bf <writetest1> createtest(); 394e: e8 73 cb ff ff call 4c6 <createtest> mem(); 3953: e8 0b d1 ff ff call a63 <mem> pipe1(); 3958: e8 48 cd ff ff call 6a5 <pipe1> preempt(); 395d: e8 2b cf ff ff call 88d <preempt> exitwait(); 3962: e8 7f d0 ff ff call 9e6 <exitwait> rmdot(); 3967: e8 d7 ee ff ff call 2843 <rmdot> fourteen(); 396c: e8 7c ed ff ff call 26ed <fourteen> bigfile(); 3971: e8 58 eb ff ff call 24ce <bigfile> subdir(); 3976: e8 08 e3 ff ff call 1c83 <subdir> concreate(); 397b: e8 e8 dc ff ff call 1668 <concreate> linkunlink(); 3980: e8 4a e0 ff ff call 19cf <linkunlink> linktest(); 3985: e8 95 da ff ff call 141f <linktest> unlinkread(); 398a: e8 bd d8 ff ff call 124c <unlinkread> createdelete(); 398f: e8 10 d6 ff ff call fa4 <createdelete> twofiles(); 3994: e8 a7 d3 ff ff call d40 <twofiles> sharedfd(); 3999: e8 aa d1 ff ff call b48 <sharedfd> dirfile(); 399e: e8 18 f0 ff ff call 29bb <dirfile> iref(); 39a3: e8 55 f2 ff ff call 2bfd <iref> forktest(); 39a8: e8 73 f3 ff ff call 2d20 <forktest> bigdir(); // slow 39ad: e8 62 e1 ff ff call 1b14 <bigdir> exectest(); 39b2: e8 9f cc ff ff call 656 <exectest> exit(); 39b7: e8 4c 02 00 00 call 3c08 <exit> 000039bc <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 39bc: 55 push %ebp 39bd: 89 e5 mov %esp,%ebp 39bf: 57 push %edi 39c0: 53 push %ebx asm volatile("cld; rep stosb" : 39c1: 8b 4d 08 mov 0x8(%ebp),%ecx 39c4: 8b 55 10 mov 0x10(%ebp),%edx 39c7: 8b 45 0c mov 0xc(%ebp),%eax 39ca: 89 cb mov %ecx,%ebx 39cc: 89 df mov %ebx,%edi 39ce: 89 d1 mov %edx,%ecx 39d0: fc cld 39d1: f3 aa rep stos %al,%es:(%edi) 39d3: 89 ca mov %ecx,%edx 39d5: 89 fb mov %edi,%ebx 39d7: 89 5d 08 mov %ebx,0x8(%ebp) 39da: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 39dd: 5b pop %ebx 39de: 5f pop %edi 39df: 5d pop %ebp 39e0: c3 ret 000039e1 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 39e1: 55 push %ebp 39e2: 89 e5 mov %esp,%ebp 39e4: 83 ec 10 sub $0x10,%esp char *os; os = s; 39e7: 8b 45 08 mov 0x8(%ebp),%eax 39ea: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 39ed: 90 nop 39ee: 8b 45 0c mov 0xc(%ebp),%eax 39f1: 8a 10 mov (%eax),%dl 39f3: 8b 45 08 mov 0x8(%ebp),%eax 39f6: 88 10 mov %dl,(%eax) 39f8: 8b 45 08 mov 0x8(%ebp),%eax 39fb: 8a 00 mov (%eax),%al 39fd: 84 c0 test %al,%al 39ff: 0f 95 c0 setne %al 3a02: ff 45 08 incl 0x8(%ebp) 3a05: ff 45 0c incl 0xc(%ebp) 3a08: 84 c0 test %al,%al 3a0a: 75 e2 jne 39ee <strcpy+0xd> ; return os; 3a0c: 8b 45 fc mov -0x4(%ebp),%eax } 3a0f: c9 leave 3a10: c3 ret 00003a11 <strcmp>: int strcmp(const char *p, const char *q) { 3a11: 55 push %ebp 3a12: 89 e5 mov %esp,%ebp while(*p && *p == *q) 3a14: eb 06 jmp 3a1c <strcmp+0xb> p++, q++; 3a16: ff 45 08 incl 0x8(%ebp) 3a19: ff 45 0c incl 0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 3a1c: 8b 45 08 mov 0x8(%ebp),%eax 3a1f: 8a 00 mov (%eax),%al 3a21: 84 c0 test %al,%al 3a23: 74 0e je 3a33 <strcmp+0x22> 3a25: 8b 45 08 mov 0x8(%ebp),%eax 3a28: 8a 10 mov (%eax),%dl 3a2a: 8b 45 0c mov 0xc(%ebp),%eax 3a2d: 8a 00 mov (%eax),%al 3a2f: 38 c2 cmp %al,%dl 3a31: 74 e3 je 3a16 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 3a33: 8b 45 08 mov 0x8(%ebp),%eax 3a36: 8a 00 mov (%eax),%al 3a38: 0f b6 d0 movzbl %al,%edx 3a3b: 8b 45 0c mov 0xc(%ebp),%eax 3a3e: 8a 00 mov (%eax),%al 3a40: 0f b6 c0 movzbl %al,%eax 3a43: 89 d1 mov %edx,%ecx 3a45: 29 c1 sub %eax,%ecx 3a47: 89 c8 mov %ecx,%eax } 3a49: 5d pop %ebp 3a4a: c3 ret 00003a4b <strlen>: uint strlen(char *s) { 3a4b: 55 push %ebp 3a4c: 89 e5 mov %esp,%ebp 3a4e: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 3a51: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 3a58: eb 03 jmp 3a5d <strlen+0x12> 3a5a: ff 45 fc incl -0x4(%ebp) 3a5d: 8b 55 fc mov -0x4(%ebp),%edx 3a60: 8b 45 08 mov 0x8(%ebp),%eax 3a63: 01 d0 add %edx,%eax 3a65: 8a 00 mov (%eax),%al 3a67: 84 c0 test %al,%al 3a69: 75 ef jne 3a5a <strlen+0xf> ; return n; 3a6b: 8b 45 fc mov -0x4(%ebp),%eax } 3a6e: c9 leave 3a6f: c3 ret 00003a70 <memset>: void* memset(void *dst, int c, uint n) { 3a70: 55 push %ebp 3a71: 89 e5 mov %esp,%ebp 3a73: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 3a76: 8b 45 10 mov 0x10(%ebp),%eax 3a79: 89 44 24 08 mov %eax,0x8(%esp) 3a7d: 8b 45 0c mov 0xc(%ebp),%eax 3a80: 89 44 24 04 mov %eax,0x4(%esp) 3a84: 8b 45 08 mov 0x8(%ebp),%eax 3a87: 89 04 24 mov %eax,(%esp) 3a8a: e8 2d ff ff ff call 39bc <stosb> return dst; 3a8f: 8b 45 08 mov 0x8(%ebp),%eax } 3a92: c9 leave 3a93: c3 ret 00003a94 <strchr>: char* strchr(const char *s, char c) { 3a94: 55 push %ebp 3a95: 89 e5 mov %esp,%ebp 3a97: 83 ec 04 sub $0x4,%esp 3a9a: 8b 45 0c mov 0xc(%ebp),%eax 3a9d: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 3aa0: eb 12 jmp 3ab4 <strchr+0x20> if(*s == c) 3aa2: 8b 45 08 mov 0x8(%ebp),%eax 3aa5: 8a 00 mov (%eax),%al 3aa7: 3a 45 fc cmp -0x4(%ebp),%al 3aaa: 75 05 jne 3ab1 <strchr+0x1d> return (char*)s; 3aac: 8b 45 08 mov 0x8(%ebp),%eax 3aaf: eb 11 jmp 3ac2 <strchr+0x2e> } char* strchr(const char *s, char c) { for(; *s; s++) 3ab1: ff 45 08 incl 0x8(%ebp) 3ab4: 8b 45 08 mov 0x8(%ebp),%eax 3ab7: 8a 00 mov (%eax),%al 3ab9: 84 c0 test %al,%al 3abb: 75 e5 jne 3aa2 <strchr+0xe> if(*s == c) return (char*)s; return 0; 3abd: b8 00 00 00 00 mov $0x0,%eax } 3ac2: c9 leave 3ac3: c3 ret 00003ac4 <gets>: char* gets(char *buf, int max) { 3ac4: 55 push %ebp 3ac5: 89 e5 mov %esp,%ebp 3ac7: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 3aca: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 3ad1: eb 42 jmp 3b15 <gets+0x51> cc = read(0, &c, 1); 3ad3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3ada: 00 3adb: 8d 45 ef lea -0x11(%ebp),%eax 3ade: 89 44 24 04 mov %eax,0x4(%esp) 3ae2: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3ae9: e8 32 01 00 00 call 3c20 <read> 3aee: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 3af1: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3af5: 7e 29 jle 3b20 <gets+0x5c> break; buf[i++] = c; 3af7: 8b 55 f4 mov -0xc(%ebp),%edx 3afa: 8b 45 08 mov 0x8(%ebp),%eax 3afd: 01 c2 add %eax,%edx 3aff: 8a 45 ef mov -0x11(%ebp),%al 3b02: 88 02 mov %al,(%edx) 3b04: ff 45 f4 incl -0xc(%ebp) if(c == '\n' || c == '\r') 3b07: 8a 45 ef mov -0x11(%ebp),%al 3b0a: 3c 0a cmp $0xa,%al 3b0c: 74 13 je 3b21 <gets+0x5d> 3b0e: 8a 45 ef mov -0x11(%ebp),%al 3b11: 3c 0d cmp $0xd,%al 3b13: 74 0c je 3b21 <gets+0x5d> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 3b15: 8b 45 f4 mov -0xc(%ebp),%eax 3b18: 40 inc %eax 3b19: 3b 45 0c cmp 0xc(%ebp),%eax 3b1c: 7c b5 jl 3ad3 <gets+0xf> 3b1e: eb 01 jmp 3b21 <gets+0x5d> cc = read(0, &c, 1); if(cc < 1) break; 3b20: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 3b21: 8b 55 f4 mov -0xc(%ebp),%edx 3b24: 8b 45 08 mov 0x8(%ebp),%eax 3b27: 01 d0 add %edx,%eax 3b29: c6 00 00 movb $0x0,(%eax) return buf; 3b2c: 8b 45 08 mov 0x8(%ebp),%eax } 3b2f: c9 leave 3b30: c3 ret 00003b31 <stat>: int stat(char *n, struct stat *st) { 3b31: 55 push %ebp 3b32: 89 e5 mov %esp,%ebp 3b34: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 3b37: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 3b3e: 00 3b3f: 8b 45 08 mov 0x8(%ebp),%eax 3b42: 89 04 24 mov %eax,(%esp) 3b45: e8 fe 00 00 00 call 3c48 <open> 3b4a: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 3b4d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3b51: 79 07 jns 3b5a <stat+0x29> return -1; 3b53: b8 ff ff ff ff mov $0xffffffff,%eax 3b58: eb 23 jmp 3b7d <stat+0x4c> r = fstat(fd, st); 3b5a: 8b 45 0c mov 0xc(%ebp),%eax 3b5d: 89 44 24 04 mov %eax,0x4(%esp) 3b61: 8b 45 f4 mov -0xc(%ebp),%eax 3b64: 89 04 24 mov %eax,(%esp) 3b67: e8 f4 00 00 00 call 3c60 <fstat> 3b6c: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 3b6f: 8b 45 f4 mov -0xc(%ebp),%eax 3b72: 89 04 24 mov %eax,(%esp) 3b75: e8 b6 00 00 00 call 3c30 <close> return r; 3b7a: 8b 45 f0 mov -0x10(%ebp),%eax } 3b7d: c9 leave 3b7e: c3 ret 00003b7f <atoi>: int atoi(const char *s) { 3b7f: 55 push %ebp 3b80: 89 e5 mov %esp,%ebp 3b82: 83 ec 10 sub $0x10,%esp int n; n = 0; 3b85: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 3b8c: eb 21 jmp 3baf <atoi+0x30> n = n*10 + *s++ - '0'; 3b8e: 8b 55 fc mov -0x4(%ebp),%edx 3b91: 89 d0 mov %edx,%eax 3b93: c1 e0 02 shl $0x2,%eax 3b96: 01 d0 add %edx,%eax 3b98: d1 e0 shl %eax 3b9a: 89 c2 mov %eax,%edx 3b9c: 8b 45 08 mov 0x8(%ebp),%eax 3b9f: 8a 00 mov (%eax),%al 3ba1: 0f be c0 movsbl %al,%eax 3ba4: 01 d0 add %edx,%eax 3ba6: 83 e8 30 sub $0x30,%eax 3ba9: 89 45 fc mov %eax,-0x4(%ebp) 3bac: ff 45 08 incl 0x8(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3baf: 8b 45 08 mov 0x8(%ebp),%eax 3bb2: 8a 00 mov (%eax),%al 3bb4: 3c 2f cmp $0x2f,%al 3bb6: 7e 09 jle 3bc1 <atoi+0x42> 3bb8: 8b 45 08 mov 0x8(%ebp),%eax 3bbb: 8a 00 mov (%eax),%al 3bbd: 3c 39 cmp $0x39,%al 3bbf: 7e cd jle 3b8e <atoi+0xf> n = n*10 + *s++ - '0'; return n; 3bc1: 8b 45 fc mov -0x4(%ebp),%eax } 3bc4: c9 leave 3bc5: c3 ret 00003bc6 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 3bc6: 55 push %ebp 3bc7: 89 e5 mov %esp,%ebp 3bc9: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 3bcc: 8b 45 08 mov 0x8(%ebp),%eax 3bcf: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 3bd2: 8b 45 0c mov 0xc(%ebp),%eax 3bd5: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 3bd8: eb 10 jmp 3bea <memmove+0x24> *dst++ = *src++; 3bda: 8b 45 f8 mov -0x8(%ebp),%eax 3bdd: 8a 10 mov (%eax),%dl 3bdf: 8b 45 fc mov -0x4(%ebp),%eax 3be2: 88 10 mov %dl,(%eax) 3be4: ff 45 fc incl -0x4(%ebp) 3be7: ff 45 f8 incl -0x8(%ebp) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 3bea: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 3bee: 0f 9f c0 setg %al 3bf1: ff 4d 10 decl 0x10(%ebp) 3bf4: 84 c0 test %al,%al 3bf6: 75 e2 jne 3bda <memmove+0x14> *dst++ = *src++; return vdst; 3bf8: 8b 45 08 mov 0x8(%ebp),%eax } 3bfb: c9 leave 3bfc: c3 ret 3bfd: 66 90 xchg %ax,%ax 3bff: 90 nop 00003c00 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3c00: b8 01 00 00 00 mov $0x1,%eax 3c05: cd 40 int $0x40 3c07: c3 ret 00003c08 <exit>: SYSCALL(exit) 3c08: b8 02 00 00 00 mov $0x2,%eax 3c0d: cd 40 int $0x40 3c0f: c3 ret 00003c10 <wait>: SYSCALL(wait) 3c10: b8 03 00 00 00 mov $0x3,%eax 3c15: cd 40 int $0x40 3c17: c3 ret 00003c18 <pipe>: SYSCALL(pipe) 3c18: b8 04 00 00 00 mov $0x4,%eax 3c1d: cd 40 int $0x40 3c1f: c3 ret 00003c20 <read>: SYSCALL(read) 3c20: b8 05 00 00 00 mov $0x5,%eax 3c25: cd 40 int $0x40 3c27: c3 ret 00003c28 <write>: SYSCALL(write) 3c28: b8 10 00 00 00 mov $0x10,%eax 3c2d: cd 40 int $0x40 3c2f: c3 ret 00003c30 <close>: SYSCALL(close) 3c30: b8 15 00 00 00 mov $0x15,%eax 3c35: cd 40 int $0x40 3c37: c3 ret 00003c38 <kill>: SYSCALL(kill) 3c38: b8 06 00 00 00 mov $0x6,%eax 3c3d: cd 40 int $0x40 3c3f: c3 ret 00003c40 <exec>: SYSCALL(exec) 3c40: b8 07 00 00 00 mov $0x7,%eax 3c45: cd 40 int $0x40 3c47: c3 ret 00003c48 <open>: SYSCALL(open) 3c48: b8 0f 00 00 00 mov $0xf,%eax 3c4d: cd 40 int $0x40 3c4f: c3 ret 00003c50 <mknod>: SYSCALL(mknod) 3c50: b8 11 00 00 00 mov $0x11,%eax 3c55: cd 40 int $0x40 3c57: c3 ret 00003c58 <unlink>: SYSCALL(unlink) 3c58: b8 12 00 00 00 mov $0x12,%eax 3c5d: cd 40 int $0x40 3c5f: c3 ret 00003c60 <fstat>: SYSCALL(fstat) 3c60: b8 08 00 00 00 mov $0x8,%eax 3c65: cd 40 int $0x40 3c67: c3 ret 00003c68 <link>: SYSCALL(link) 3c68: b8 13 00 00 00 mov $0x13,%eax 3c6d: cd 40 int $0x40 3c6f: c3 ret 00003c70 <mkdir>: SYSCALL(mkdir) 3c70: b8 14 00 00 00 mov $0x14,%eax 3c75: cd 40 int $0x40 3c77: c3 ret 00003c78 <chdir>: SYSCALL(chdir) 3c78: b8 09 00 00 00 mov $0x9,%eax 3c7d: cd 40 int $0x40 3c7f: c3 ret 00003c80 <dup>: SYSCALL(dup) 3c80: b8 0a 00 00 00 mov $0xa,%eax 3c85: cd 40 int $0x40 3c87: c3 ret 00003c88 <getpid>: SYSCALL(getpid) 3c88: b8 0b 00 00 00 mov $0xb,%eax 3c8d: cd 40 int $0x40 3c8f: c3 ret 00003c90 <sbrk>: SYSCALL(sbrk) 3c90: b8 0c 00 00 00 mov $0xc,%eax 3c95: cd 40 int $0x40 3c97: c3 ret 00003c98 <sleep>: SYSCALL(sleep) 3c98: b8 0d 00 00 00 mov $0xd,%eax 3c9d: cd 40 int $0x40 3c9f: c3 ret 00003ca0 <uptime>: SYSCALL(uptime) 3ca0: b8 0e 00 00 00 mov $0xe,%eax 3ca5: cd 40 int $0x40 3ca7: c3 ret 00003ca8 <getppid>: SYSCALL(getppid) // USER DEFINED SYS CALL 3ca8: b8 16 00 00 00 mov $0x16,%eax 3cad: cd 40 int $0x40 3caf: c3 ret 00003cb0 <icount>: SYSCALL(icount) // USER DEFINED SYS CALL 3cb0: b8 17 00 00 00 mov $0x17,%eax 3cb5: cd 40 int $0x40 3cb7: c3 ret 00003cb8 <signal>: SYSCALL(signal) // USER DEFINED SYS CALL 3cb8: b8 18 00 00 00 mov $0x18,%eax 3cbd: cd 40 int $0x40 3cbf: c3 ret 00003cc0 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 3cc0: 55 push %ebp 3cc1: 89 e5 mov %esp,%ebp 3cc3: 83 ec 28 sub $0x28,%esp 3cc6: 8b 45 0c mov 0xc(%ebp),%eax 3cc9: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 3ccc: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3cd3: 00 3cd4: 8d 45 f4 lea -0xc(%ebp),%eax 3cd7: 89 44 24 04 mov %eax,0x4(%esp) 3cdb: 8b 45 08 mov 0x8(%ebp),%eax 3cde: 89 04 24 mov %eax,(%esp) 3ce1: e8 42 ff ff ff call 3c28 <write> } 3ce6: c9 leave 3ce7: c3 ret 00003ce8 <printint>: static void printint(int fd, int xx, int base, int sgn) { 3ce8: 55 push %ebp 3ce9: 89 e5 mov %esp,%ebp 3ceb: 83 ec 48 sub $0x48,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3cee: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 3cf5: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 3cf9: 74 17 je 3d12 <printint+0x2a> 3cfb: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 3cff: 79 11 jns 3d12 <printint+0x2a> neg = 1; 3d01: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 3d08: 8b 45 0c mov 0xc(%ebp),%eax 3d0b: f7 d8 neg %eax 3d0d: 89 45 ec mov %eax,-0x14(%ebp) 3d10: eb 06 jmp 3d18 <printint+0x30> } else { x = xx; 3d12: 8b 45 0c mov 0xc(%ebp),%eax 3d15: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 3d18: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 3d1f: 8b 4d 10 mov 0x10(%ebp),%ecx 3d22: 8b 45 ec mov -0x14(%ebp),%eax 3d25: ba 00 00 00 00 mov $0x0,%edx 3d2a: f7 f1 div %ecx 3d2c: 89 d0 mov %edx,%eax 3d2e: 8a 80 bc 5e 00 00 mov 0x5ebc(%eax),%al 3d34: 8d 4d dc lea -0x24(%ebp),%ecx 3d37: 8b 55 f4 mov -0xc(%ebp),%edx 3d3a: 01 ca add %ecx,%edx 3d3c: 88 02 mov %al,(%edx) 3d3e: ff 45 f4 incl -0xc(%ebp) }while((x /= base) != 0); 3d41: 8b 55 10 mov 0x10(%ebp),%edx 3d44: 89 55 d4 mov %edx,-0x2c(%ebp) 3d47: 8b 45 ec mov -0x14(%ebp),%eax 3d4a: ba 00 00 00 00 mov $0x0,%edx 3d4f: f7 75 d4 divl -0x2c(%ebp) 3d52: 89 45 ec mov %eax,-0x14(%ebp) 3d55: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3d59: 75 c4 jne 3d1f <printint+0x37> if(neg) 3d5b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 3d5f: 74 2c je 3d8d <printint+0xa5> buf[i++] = '-'; 3d61: 8d 55 dc lea -0x24(%ebp),%edx 3d64: 8b 45 f4 mov -0xc(%ebp),%eax 3d67: 01 d0 add %edx,%eax 3d69: c6 00 2d movb $0x2d,(%eax) 3d6c: ff 45 f4 incl -0xc(%ebp) while(--i >= 0) 3d6f: eb 1c jmp 3d8d <printint+0xa5> putc(fd, buf[i]); 3d71: 8d 55 dc lea -0x24(%ebp),%edx 3d74: 8b 45 f4 mov -0xc(%ebp),%eax 3d77: 01 d0 add %edx,%eax 3d79: 8a 00 mov (%eax),%al 3d7b: 0f be c0 movsbl %al,%eax 3d7e: 89 44 24 04 mov %eax,0x4(%esp) 3d82: 8b 45 08 mov 0x8(%ebp),%eax 3d85: 89 04 24 mov %eax,(%esp) 3d88: e8 33 ff ff ff call 3cc0 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3d8d: ff 4d f4 decl -0xc(%ebp) 3d90: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3d94: 79 db jns 3d71 <printint+0x89> putc(fd, buf[i]); } 3d96: c9 leave 3d97: c3 ret 00003d98 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 3d98: 55 push %ebp 3d99: 89 e5 mov %esp,%ebp 3d9b: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 3d9e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 3da5: 8d 45 0c lea 0xc(%ebp),%eax 3da8: 83 c0 04 add $0x4,%eax 3dab: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 3dae: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 3db5: e9 78 01 00 00 jmp 3f32 <printf+0x19a> c = fmt[i] & 0xff; 3dba: 8b 55 0c mov 0xc(%ebp),%edx 3dbd: 8b 45 f0 mov -0x10(%ebp),%eax 3dc0: 01 d0 add %edx,%eax 3dc2: 8a 00 mov (%eax),%al 3dc4: 0f be c0 movsbl %al,%eax 3dc7: 25 ff 00 00 00 and $0xff,%eax 3dcc: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 3dcf: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 3dd3: 75 2c jne 3e01 <printf+0x69> if(c == '%'){ 3dd5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 3dd9: 75 0c jne 3de7 <printf+0x4f> state = '%'; 3ddb: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 3de2: e9 48 01 00 00 jmp 3f2f <printf+0x197> } else { putc(fd, c); 3de7: 8b 45 e4 mov -0x1c(%ebp),%eax 3dea: 0f be c0 movsbl %al,%eax 3ded: 89 44 24 04 mov %eax,0x4(%esp) 3df1: 8b 45 08 mov 0x8(%ebp),%eax 3df4: 89 04 24 mov %eax,(%esp) 3df7: e8 c4 fe ff ff call 3cc0 <putc> 3dfc: e9 2e 01 00 00 jmp 3f2f <printf+0x197> } } else if(state == '%'){ 3e01: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 3e05: 0f 85 24 01 00 00 jne 3f2f <printf+0x197> if(c == 'd'){ 3e0b: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 3e0f: 75 2d jne 3e3e <printf+0xa6> printint(fd, *ap, 10, 1); 3e11: 8b 45 e8 mov -0x18(%ebp),%eax 3e14: 8b 00 mov (%eax),%eax 3e16: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 3e1d: 00 3e1e: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 3e25: 00 3e26: 89 44 24 04 mov %eax,0x4(%esp) 3e2a: 8b 45 08 mov 0x8(%ebp),%eax 3e2d: 89 04 24 mov %eax,(%esp) 3e30: e8 b3 fe ff ff call 3ce8 <printint> ap++; 3e35: 83 45 e8 04 addl $0x4,-0x18(%ebp) 3e39: e9 ea 00 00 00 jmp 3f28 <printf+0x190> } else if(c == 'x' || c == 'p'){ 3e3e: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 3e42: 74 06 je 3e4a <printf+0xb2> 3e44: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 3e48: 75 2d jne 3e77 <printf+0xdf> printint(fd, *ap, 16, 0); 3e4a: 8b 45 e8 mov -0x18(%ebp),%eax 3e4d: 8b 00 mov (%eax),%eax 3e4f: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 3e56: 00 3e57: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 3e5e: 00 3e5f: 89 44 24 04 mov %eax,0x4(%esp) 3e63: 8b 45 08 mov 0x8(%ebp),%eax 3e66: 89 04 24 mov %eax,(%esp) 3e69: e8 7a fe ff ff call 3ce8 <printint> ap++; 3e6e: 83 45 e8 04 addl $0x4,-0x18(%ebp) 3e72: e9 b1 00 00 00 jmp 3f28 <printf+0x190> } else if(c == 's'){ 3e77: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 3e7b: 75 43 jne 3ec0 <printf+0x128> s = (char*)*ap; 3e7d: 8b 45 e8 mov -0x18(%ebp),%eax 3e80: 8b 00 mov (%eax),%eax 3e82: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 3e85: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 3e89: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3e8d: 75 25 jne 3eb4 <printf+0x11c> s = "(null)"; 3e8f: c7 45 f4 22 58 00 00 movl $0x5822,-0xc(%ebp) while(*s != 0){ 3e96: eb 1c jmp 3eb4 <printf+0x11c> putc(fd, *s); 3e98: 8b 45 f4 mov -0xc(%ebp),%eax 3e9b: 8a 00 mov (%eax),%al 3e9d: 0f be c0 movsbl %al,%eax 3ea0: 89 44 24 04 mov %eax,0x4(%esp) 3ea4: 8b 45 08 mov 0x8(%ebp),%eax 3ea7: 89 04 24 mov %eax,(%esp) 3eaa: e8 11 fe ff ff call 3cc0 <putc> s++; 3eaf: ff 45 f4 incl -0xc(%ebp) 3eb2: eb 01 jmp 3eb5 <printf+0x11d> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 3eb4: 90 nop 3eb5: 8b 45 f4 mov -0xc(%ebp),%eax 3eb8: 8a 00 mov (%eax),%al 3eba: 84 c0 test %al,%al 3ebc: 75 da jne 3e98 <printf+0x100> 3ebe: eb 68 jmp 3f28 <printf+0x190> putc(fd, *s); s++; } } else if(c == 'c'){ 3ec0: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 3ec4: 75 1d jne 3ee3 <printf+0x14b> putc(fd, *ap); 3ec6: 8b 45 e8 mov -0x18(%ebp),%eax 3ec9: 8b 00 mov (%eax),%eax 3ecb: 0f be c0 movsbl %al,%eax 3ece: 89 44 24 04 mov %eax,0x4(%esp) 3ed2: 8b 45 08 mov 0x8(%ebp),%eax 3ed5: 89 04 24 mov %eax,(%esp) 3ed8: e8 e3 fd ff ff call 3cc0 <putc> ap++; 3edd: 83 45 e8 04 addl $0x4,-0x18(%ebp) 3ee1: eb 45 jmp 3f28 <printf+0x190> } else if(c == '%'){ 3ee3: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 3ee7: 75 17 jne 3f00 <printf+0x168> putc(fd, c); 3ee9: 8b 45 e4 mov -0x1c(%ebp),%eax 3eec: 0f be c0 movsbl %al,%eax 3eef: 89 44 24 04 mov %eax,0x4(%esp) 3ef3: 8b 45 08 mov 0x8(%ebp),%eax 3ef6: 89 04 24 mov %eax,(%esp) 3ef9: e8 c2 fd ff ff call 3cc0 <putc> 3efe: eb 28 jmp 3f28 <printf+0x190> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 3f00: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 3f07: 00 3f08: 8b 45 08 mov 0x8(%ebp),%eax 3f0b: 89 04 24 mov %eax,(%esp) 3f0e: e8 ad fd ff ff call 3cc0 <putc> putc(fd, c); 3f13: 8b 45 e4 mov -0x1c(%ebp),%eax 3f16: 0f be c0 movsbl %al,%eax 3f19: 89 44 24 04 mov %eax,0x4(%esp) 3f1d: 8b 45 08 mov 0x8(%ebp),%eax 3f20: 89 04 24 mov %eax,(%esp) 3f23: e8 98 fd ff ff call 3cc0 <putc> } state = 0; 3f28: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3f2f: ff 45 f0 incl -0x10(%ebp) 3f32: 8b 55 0c mov 0xc(%ebp),%edx 3f35: 8b 45 f0 mov -0x10(%ebp),%eax 3f38: 01 d0 add %edx,%eax 3f3a: 8a 00 mov (%eax),%al 3f3c: 84 c0 test %al,%al 3f3e: 0f 85 76 fe ff ff jne 3dba <printf+0x22> putc(fd, c); } state = 0; } } } 3f44: c9 leave 3f45: c3 ret 3f46: 66 90 xchg %ax,%ax 00003f48 <free>: static Header base; static Header *freep; void free(void *ap) { 3f48: 55 push %ebp 3f49: 89 e5 mov %esp,%ebp 3f4b: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 3f4e: 8b 45 08 mov 0x8(%ebp),%eax 3f51: 83 e8 08 sub $0x8,%eax 3f54: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3f57: a1 68 5f 00 00 mov 0x5f68,%eax 3f5c: 89 45 fc mov %eax,-0x4(%ebp) 3f5f: eb 24 jmp 3f85 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 3f61: 8b 45 fc mov -0x4(%ebp),%eax 3f64: 8b 00 mov (%eax),%eax 3f66: 3b 45 fc cmp -0x4(%ebp),%eax 3f69: 77 12 ja 3f7d <free+0x35> 3f6b: 8b 45 f8 mov -0x8(%ebp),%eax 3f6e: 3b 45 fc cmp -0x4(%ebp),%eax 3f71: 77 24 ja 3f97 <free+0x4f> 3f73: 8b 45 fc mov -0x4(%ebp),%eax 3f76: 8b 00 mov (%eax),%eax 3f78: 3b 45 f8 cmp -0x8(%ebp),%eax 3f7b: 77 1a ja 3f97 <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) 3f7d: 8b 45 fc mov -0x4(%ebp),%eax 3f80: 8b 00 mov (%eax),%eax 3f82: 89 45 fc mov %eax,-0x4(%ebp) 3f85: 8b 45 f8 mov -0x8(%ebp),%eax 3f88: 3b 45 fc cmp -0x4(%ebp),%eax 3f8b: 76 d4 jbe 3f61 <free+0x19> 3f8d: 8b 45 fc mov -0x4(%ebp),%eax 3f90: 8b 00 mov (%eax),%eax 3f92: 3b 45 f8 cmp -0x8(%ebp),%eax 3f95: 76 ca jbe 3f61 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 3f97: 8b 45 f8 mov -0x8(%ebp),%eax 3f9a: 8b 40 04 mov 0x4(%eax),%eax 3f9d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 3fa4: 8b 45 f8 mov -0x8(%ebp),%eax 3fa7: 01 c2 add %eax,%edx 3fa9: 8b 45 fc mov -0x4(%ebp),%eax 3fac: 8b 00 mov (%eax),%eax 3fae: 39 c2 cmp %eax,%edx 3fb0: 75 24 jne 3fd6 <free+0x8e> bp->s.size += p->s.ptr->s.size; 3fb2: 8b 45 f8 mov -0x8(%ebp),%eax 3fb5: 8b 50 04 mov 0x4(%eax),%edx 3fb8: 8b 45 fc mov -0x4(%ebp),%eax 3fbb: 8b 00 mov (%eax),%eax 3fbd: 8b 40 04 mov 0x4(%eax),%eax 3fc0: 01 c2 add %eax,%edx 3fc2: 8b 45 f8 mov -0x8(%ebp),%eax 3fc5: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 3fc8: 8b 45 fc mov -0x4(%ebp),%eax 3fcb: 8b 00 mov (%eax),%eax 3fcd: 8b 10 mov (%eax),%edx 3fcf: 8b 45 f8 mov -0x8(%ebp),%eax 3fd2: 89 10 mov %edx,(%eax) 3fd4: eb 0a jmp 3fe0 <free+0x98> } else bp->s.ptr = p->s.ptr; 3fd6: 8b 45 fc mov -0x4(%ebp),%eax 3fd9: 8b 10 mov (%eax),%edx 3fdb: 8b 45 f8 mov -0x8(%ebp),%eax 3fde: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 3fe0: 8b 45 fc mov -0x4(%ebp),%eax 3fe3: 8b 40 04 mov 0x4(%eax),%eax 3fe6: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 3fed: 8b 45 fc mov -0x4(%ebp),%eax 3ff0: 01 d0 add %edx,%eax 3ff2: 3b 45 f8 cmp -0x8(%ebp),%eax 3ff5: 75 20 jne 4017 <free+0xcf> p->s.size += bp->s.size; 3ff7: 8b 45 fc mov -0x4(%ebp),%eax 3ffa: 8b 50 04 mov 0x4(%eax),%edx 3ffd: 8b 45 f8 mov -0x8(%ebp),%eax 4000: 8b 40 04 mov 0x4(%eax),%eax 4003: 01 c2 add %eax,%edx 4005: 8b 45 fc mov -0x4(%ebp),%eax 4008: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 400b: 8b 45 f8 mov -0x8(%ebp),%eax 400e: 8b 10 mov (%eax),%edx 4010: 8b 45 fc mov -0x4(%ebp),%eax 4013: 89 10 mov %edx,(%eax) 4015: eb 08 jmp 401f <free+0xd7> } else p->s.ptr = bp; 4017: 8b 45 fc mov -0x4(%ebp),%eax 401a: 8b 55 f8 mov -0x8(%ebp),%edx 401d: 89 10 mov %edx,(%eax) freep = p; 401f: 8b 45 fc mov -0x4(%ebp),%eax 4022: a3 68 5f 00 00 mov %eax,0x5f68 } 4027: c9 leave 4028: c3 ret 00004029 <morecore>: static Header* morecore(uint nu) { 4029: 55 push %ebp 402a: 89 e5 mov %esp,%ebp 402c: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 402f: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 4036: 77 07 ja 403f <morecore+0x16> nu = 4096; 4038: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 403f: 8b 45 08 mov 0x8(%ebp),%eax 4042: c1 e0 03 shl $0x3,%eax 4045: 89 04 24 mov %eax,(%esp) 4048: e8 43 fc ff ff call 3c90 <sbrk> 404d: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 4050: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 4054: 75 07 jne 405d <morecore+0x34> return 0; 4056: b8 00 00 00 00 mov $0x0,%eax 405b: eb 22 jmp 407f <morecore+0x56> hp = (Header*)p; 405d: 8b 45 f4 mov -0xc(%ebp),%eax 4060: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 4063: 8b 45 f0 mov -0x10(%ebp),%eax 4066: 8b 55 08 mov 0x8(%ebp),%edx 4069: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 406c: 8b 45 f0 mov -0x10(%ebp),%eax 406f: 83 c0 08 add $0x8,%eax 4072: 89 04 24 mov %eax,(%esp) 4075: e8 ce fe ff ff call 3f48 <free> return freep; 407a: a1 68 5f 00 00 mov 0x5f68,%eax } 407f: c9 leave 4080: c3 ret 00004081 <malloc>: void* malloc(uint nbytes) { 4081: 55 push %ebp 4082: 89 e5 mov %esp,%ebp 4084: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 4087: 8b 45 08 mov 0x8(%ebp),%eax 408a: 83 c0 07 add $0x7,%eax 408d: c1 e8 03 shr $0x3,%eax 4090: 40 inc %eax 4091: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 4094: a1 68 5f 00 00 mov 0x5f68,%eax 4099: 89 45 f0 mov %eax,-0x10(%ebp) 409c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 40a0: 75 23 jne 40c5 <malloc+0x44> base.s.ptr = freep = prevp = &base; 40a2: c7 45 f0 60 5f 00 00 movl $0x5f60,-0x10(%ebp) 40a9: 8b 45 f0 mov -0x10(%ebp),%eax 40ac: a3 68 5f 00 00 mov %eax,0x5f68 40b1: a1 68 5f 00 00 mov 0x5f68,%eax 40b6: a3 60 5f 00 00 mov %eax,0x5f60 base.s.size = 0; 40bb: c7 05 64 5f 00 00 00 movl $0x0,0x5f64 40c2: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 40c5: 8b 45 f0 mov -0x10(%ebp),%eax 40c8: 8b 00 mov (%eax),%eax 40ca: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 40cd: 8b 45 f4 mov -0xc(%ebp),%eax 40d0: 8b 40 04 mov 0x4(%eax),%eax 40d3: 3b 45 ec cmp -0x14(%ebp),%eax 40d6: 72 4d jb 4125 <malloc+0xa4> if(p->s.size == nunits) 40d8: 8b 45 f4 mov -0xc(%ebp),%eax 40db: 8b 40 04 mov 0x4(%eax),%eax 40de: 3b 45 ec cmp -0x14(%ebp),%eax 40e1: 75 0c jne 40ef <malloc+0x6e> prevp->s.ptr = p->s.ptr; 40e3: 8b 45 f4 mov -0xc(%ebp),%eax 40e6: 8b 10 mov (%eax),%edx 40e8: 8b 45 f0 mov -0x10(%ebp),%eax 40eb: 89 10 mov %edx,(%eax) 40ed: eb 26 jmp 4115 <malloc+0x94> else { p->s.size -= nunits; 40ef: 8b 45 f4 mov -0xc(%ebp),%eax 40f2: 8b 40 04 mov 0x4(%eax),%eax 40f5: 89 c2 mov %eax,%edx 40f7: 2b 55 ec sub -0x14(%ebp),%edx 40fa: 8b 45 f4 mov -0xc(%ebp),%eax 40fd: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 4100: 8b 45 f4 mov -0xc(%ebp),%eax 4103: 8b 40 04 mov 0x4(%eax),%eax 4106: c1 e0 03 shl $0x3,%eax 4109: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 410c: 8b 45 f4 mov -0xc(%ebp),%eax 410f: 8b 55 ec mov -0x14(%ebp),%edx 4112: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 4115: 8b 45 f0 mov -0x10(%ebp),%eax 4118: a3 68 5f 00 00 mov %eax,0x5f68 return (void*)(p + 1); 411d: 8b 45 f4 mov -0xc(%ebp),%eax 4120: 83 c0 08 add $0x8,%eax 4123: eb 38 jmp 415d <malloc+0xdc> } if(p == freep) 4125: a1 68 5f 00 00 mov 0x5f68,%eax 412a: 39 45 f4 cmp %eax,-0xc(%ebp) 412d: 75 1b jne 414a <malloc+0xc9> if((p = morecore(nunits)) == 0) 412f: 8b 45 ec mov -0x14(%ebp),%eax 4132: 89 04 24 mov %eax,(%esp) 4135: e8 ef fe ff ff call 4029 <morecore> 413a: 89 45 f4 mov %eax,-0xc(%ebp) 413d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 4141: 75 07 jne 414a <malloc+0xc9> return 0; 4143: b8 00 00 00 00 mov $0x0,%eax 4148: eb 13 jmp 415d <malloc+0xdc> 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){ 414a: 8b 45 f4 mov -0xc(%ebp),%eax 414d: 89 45 f0 mov %eax,-0x10(%ebp) 4150: 8b 45 f4 mov -0xc(%ebp),%eax 4153: 8b 00 mov (%eax),%eax 4155: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 4158: e9 70 ff ff ff jmp 40cd <malloc+0x4c> } 415d: c9 leave 415e: c3 ret
#include <iostream> #include <unistd.h> #include "conf.hpp" #include "client_sim.hpp" #include "realtime_pool.hpp" #include "read_buffer.hpp" const std::string CONF_DIR(std::getenv("UNCALLED_CONF")), DEF_MODEL = CONF_DIR + "/r94_5mers.txt", DEF_CONF = CONF_DIR + "/defaults.toml"; bool load_conf(int argc, char** argv, Conf &conf); int main(int argc, char** argv) { std::cerr << "Loading conf\n"; Conf conf; if (!load_conf(argc, argv, conf)) { return 1; } ClientSim sim(conf); std::cerr << "Loading mappers\n"; RealtimePool pool(conf); const u64 MAX_SLEEP = 100; std::cerr << "Starting simulation\n"; sim.run(); Timer t; std::vector<float> chunk_times(conf.get_num_channels(), t.get()); std::vector<u32> unblocked(conf.get_num_channels(), 0); bool deplete = conf.get_realtime_mode() == RealtimeParams::Mode::DEPLETE; std::cerr << "Starting " << deplete << "\n"; while (sim.is_running()) { u64 t0 = t.get(); u16 channel; u32 number; Paf paf; for (MapResult m : pool.update()) { std::tie(channel, number, paf) = m; float map_time = (t.get() - chunk_times[channel-1])/1000; if (paf.is_ended()) { paf.set_float(Paf::Tag::ENDED, map_time); sim.stop_receiving_read(channel, number); } else if ((paf.is_mapped() && deplete) || (!paf.is_mapped() && !deplete)) { u32 delay = sim.unblock_read(channel, number); paf.set_float(Paf::Tag::EJECT, map_time); paf.set_int(Paf::Tag::DELAY, delay); unblocked[channel-1] = number; } else { sim.stop_receiving_read(channel, number); paf.set_float(Paf::Tag::KEEP, map_time); } paf.print_paf(); std::cout.flush(); } for (auto &r : sim.get_read_chunks()) { Chunk &ch = r.second; if (unblocked[ch.get_channel_idx()] == ch.get_number()) { std::cout << "# recieved chunk from " << ch.get_id() << " after unblocking\n"; continue; } else if (pool.add_chunk(ch)) { chunk_times[ch.get_channel_idx()] = t.get(); } else { std::cerr << "Error: failed to add chunk from " << ch.get_id() << std::endl; } } u64 dt = t.get() - t0; if (dt < MAX_SLEEP) usleep(1000*(MAX_SLEEP - dt)); } std::cerr << "Reads aligned (" << (t.get() / 1000) << " sec)\n"; pool.stop_all(); std::cerr << "Done " << (t.get() / 1000) << "\n"; } #define FLAG_TO_CONF(C, T, F) { \ case C: \ conf.set_##F(T(optarg)); \ break; \ } #define POSITIONAL_TO_CONF(T, F) {\ if (i < argc) { \ conf.set_##F(T(argv[i])); \ i++; \ } else { \ std::cerr << "Error: must specify " << #F << "\n"; \ return false; \ } \ } bool load_conf(int argc, char** argv, Conf &conf) { int opt; std::string flagstr = ":t:c:p:de"; #ifdef DEBUG_OUT flagstr += "D:"; #endif //parse flags while((opt = getopt(argc, argv, flagstr.c_str())) != -1) { switch(opt) { FLAG_TO_CONF('p', std::string, idx_preset) FLAG_TO_CONF('t', atoi, threads) FLAG_TO_CONF('c', atoi, max_chunks) #ifdef DEBUG_OUT FLAG_TO_CONF('D', std::string, dbg_prefix); #endif case 'd': conf.set_realtime_mode(RealtimeParams::Mode::DEPLETE); break; case 'e': conf.set_realtime_mode(RealtimeParams::Mode::ENRICH); break; case ':': std::cerr << "Error: failed to load flag value\n"; return false; case '?': std::cerr << "Error: unknown flag\n"; return false; } } //parse positionals int i = optind; POSITIONAL_TO_CONF(std::string, bwa_prefix) POSITIONAL_TO_CONF(std::string, fast5_list) return true; }
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: Epson 9-pin driver FILE: eplx9fx100Info.asm AUTHOR: Dave Durran, 28 Mar 1990 REVISION HISTORY: Name Date Description ---- ---- ----------- Dave 3/28/90 Initial revision Dave 5/92 Initial 2.0 version DESCRIPTION: This file contains the device information for the Epson fx100 printer Other Printers Supported by this resource: $Id: eplx9fx100Info.asm,v 1.1 97/04/18 11:54:40 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ;---------------------------------------------------------------------------- ; Epson fx100 ;---------------------------------------------------------------------------- fx100Info segment resource ; info blocks PrinterInfo < ; ---- PrinterType ------------- < PT_RASTER, BMF_MONO >, ; ---- PrinterConnections ------ < IC_NO_IEEE488, CC_NO_CUSTOM, SC_NO_SCSI, RC_RS232C, CC_CENTRONICS, FC_FILE, AC_NO_APPLETALK >, ; ---- PrinterSmarts ----------- PS_DUMB_RASTER, ;-------Custom Entry Routine------- NULL, ;-------Custom Exit Routine------- NULL, ; ---- Mode Info Offsets ------- offset fx100lowRes, offset fx100medRes, offset fx100hiRes, offset printerFontInfo:fx80draft, offset printerFontInfo:fx80nlq, ; ---- Font Geometry ----------- offset fx100fontGeometries, ; ---- Symbol Set list ----------- NULL, ; ---- PaperMargins ------------ < PR_MARGIN_LEFT, ; Tractor Margins PR_MARGIN_TRACTOR, PR_MARGIN_RIGHT, PR_MARGIN_TRACTOR >, < PR_MARGIN_LEFT, ; ASF Margins PR_MARGIN_TOP, PR_MARGIN_RIGHT, PR_MARGIN_BOTTOM >, ; ---- PaperInputOptions ------- < MF_MANUAL1, TF_TRACTOR1, ASF_TRAY1 >, ; ---- PaperOutputOptions ------ < OC_NO_COPIES, PS_REVERSE, OD_SIMPLEX, SO_NO_STAPLER, OS_NO_SORTER, OB_NO_OUTPUTBIN >, ; 1008, ; paper width (points). NULL, ; Main UI ASF1BinOptionsDialogBox, ; Options UI PrintEvalASF1Bin ; UI eval Routine > ;---------------------------------------------------------------------------- ; Graphics modes info ;---------------------------------------------------------------------------- fx100lowRes GraphicsProperties < LO_RES_X_RES, ; xres LO_RES_Y_RES, ; yres LO_RES_BAND_HEIGHT, ; band height LO_RES_BUFF_HEIGHT, ; buffer height LO_RES_INTERLEAVE_FACTOR, ;#interleaves BMF_MONO, ;color format NULL > ; color correction fx100medRes GraphicsProperties < MED_RES_X_RES, ; xres MED_RES_Y_RES, ; yres MED_RES_BAND_HEIGHT, ; band height MED_RES_BUFF_HEIGHT, ; buffer height MED_RES_INTERLEAVE_FACTOR, ;#interleaves BMF_MONO, ;color format NULL > ; color correction fx100hiRes GraphicsProperties < HI_RES_X_RES, ; xres HI_RES_Y_RES, ; yres HI_RES_BAND_HEIGHT, ; band height HI_RES_BUFF_HEIGHT, ; buffer height HI_RES_INTERLEAVE_FACTOR, ;#interleaves BMF_MONO, ;color format NULL > ; color correction ;---------------------------------------------------------------------------- ; Text modes info ;---------------------------------------------------------------------------- ;need to add geometries in ascending pointsize, grouped by font fx100fontGeometries FontGeometry \ < FID_DTC_URW_ROMAN, 12, offset fx100_12ptpitchTab >, < FID_DTC_URW_ROMAN, 24, offset fx100_24ptpitchTab > word FID_INVALID ;table terminator fx100_12ptpitchTab label byte byte TP_20_PITCH byte TP_17_PITCH byte TP_12_PITCH byte TP_10_PITCH byte TP_6_PITCH byte TP_5_PITCH byte TP_PROPORTIONAL ;"table Terminator" fx100_24ptpitchTab label byte byte TP_12_PITCH byte TP_10_PITCH byte TP_6_PITCH byte TP_5_PITCH byte TP_PROPORTIONAL ;"table Terminator" fx100Info ends
; A087165: a(n)=1 when n == 1 (mod 4), otherwise a(n) = a(n - ceiling(n/4)) + 1. Removing all the 1's results in the original sequence with every term incremented by 1. ; 1,2,3,4,1,5,2,6,1,3,7,2,1,4,8,3,1,2,5,9,1,4,2,3,1,6,10,2,1,5,3,4,1,2,7,11,1,3,2,6,1,4,5,2,1,3,8,12,1,2,4,3,1,7,2,5,1,6,3,2,1,4,9,13,1,2,3,5,1,4,2,8,1,3,6,2,1,7,4,3,1,2,5,10,1,14,2,3,1,4,6,2,1,5,3,9,1,2,4,7 mov $4,2 mov $6,$0 lpb $4 mov $0,$6 mov $2,0 sub $4,1 add $0,$4 lpb $0 mul $0,3 div $0,4 add $2,$0 lpe mov $3,$4 mov $5,$2 lpb $3 mov $1,$5 sub $3,1 lpe lpe lpb $6 sub $1,$5 mov $6,0 lpe add $1,1 mov $0,$1
; A211522: Number of ordered triples (w,x,y) with all terms in {1,...,n} and w + 5y = 2x. ; 0,0,0,1,2,3,4,6,8,11,13,16,19,23,27,31,35,40,45,51,56,62,68,75,82,89,96,104,112,121,129,138,147,157,167,177,187,198,209,221,232,244,256,269,282,295,308,322,336,351,365,380,395,411,427,443,459,476,493,511,528,546,564,583,602,621,640,660,680,701,721,742,763,785,807,829,851,874,897,921,944,968,992,1017,1042,1067,1092,1118,1144,1171,1197,1224,1251,1279,1307,1335,1363,1392,1421,1451,1480,1510,1540,1571,1602,1633,1664,1696,1728,1761,1793,1826,1859,1893,1927,1961,1995,2030,2065,2101,2136,2172,2208,2245,2282,2319,2356,2394,2432,2471,2509,2548,2587,2627,2667,2707,2747,2788,2829,2871,2912,2954,2996,3039,3082,3125,3168,3212,3256,3301,3345,3390,3435,3481,3527,3573,3619,3666,3713,3761,3808,3856,3904,3953,4002,4051,4100,4150,4200,4251,4301,4352,4403,4455,4507,4559,4611,4664,4717,4771,4824,4878,4932,4987,5042,5097,5152,5208,5264,5321,5377,5434,5491,5549,5607,5665,5723,5782,5841,5901,5960,6020,6080,6141,6202,6263,6324,6386,6448,6511,6573,6636,6699,6763,6827,6891,6955,7020,7085,7151,7216,7282,7348,7415,7482,7549,7616,7684,7752,7821,7889,7958,8027,8097,8167,8237,8307,8378,8449,8521,8592,8664,8736,8809,8882,8955,9028,9102,9176,9251 mov $2,1 mov $3,$0 add $3,2 lpb $0 add $1,$0 sub $0,1 trn $0,1 trn $3,$2 trn $1,$3 mov $2,5 lpe
;/************************************************************************************************************************************/ ;/** ; * @file TxFM0.asm ; * @brief RFID Transmit in FM0 ; * @details ; * ; * @author Justin Reina, UW Sensor Systems Lab ; * @created ; * @last rev ; * ; * @notes ; * @todo ; * @calling extern void TxFM0(volatile uint8_t *data,uint8_t numBytes,uint8_t numBits,uint8_t TRext) ; */ ;/************************************************************************************************************************************/ ;/INCLUDES---------------------------------------------------------------------------------------------------------------------------- .cdecls C,LIST, "../globals.h", "rfid.h" .include "../internals/NOPdefs.asm"; Definitions of NOPx MACROs... .global TxClock, RxClock ;/PRESERVED REGISTERS----------------------------------------------------------------------------------------------------------------- R_currByte .set R6 R_prevState .set R7 R_scratch0 .set R8 R_scratch1 .set R9 R_scratch2 .set R10 ;/SCRATCH REGISTERS------------------------------------------------------------------------------------------------------------------- R_dataPtr .set R12 ; Entry: address of dataBuf start is in R_dataPtr R_byteCt .set R13 ; Entry: length of Tx'd Bytes is in R_byteCt R_bitCt .set R14 ; Entry: length of Tx'd Bits is in R_bitCt R_TRext .set R15 ; Entry: TRext? is in R_TRext ;/Timing Notes------------------------------------------------------------------------------------------------------------------------ ;* Cycles Between Bits: 9 (for LF=640kHz @ 11.52MHz CPU) */ ;/** @todo Make sure the proper link frequency is listed here, or give a table of LF vs clock frequency */ ;* Cycles Before First Bit Toggle: 29 worst case */ ;/Begin ASM Code---------------------------------------------------------------------------------------------------------------------- .def TxFM0 TxFM0: CLR &TA0CTL ;[] Disable TimerA when doing the TX related stuffs to allow the system to go to lpm4 for sleep. BIS.W #BIT7, &PTXDIR; BIS.W #BIT7, &PTXOUT; BIC.W #BIT7, &PTXOUT; ;/Push the Preserved Registers---------------------------------------------------------------------------------------------------- PUSHM.A #5, R10 ;[?] Push all preserved registers onto stack R6-R10/** @todo Find out how long this takes */ ;PUSH R_currByte ;[3] Note: Could optimize these two lines down into the preamble if necessary ;PUSH R_prevState ;[3] "" ;PUSH R_scratch0 ;[3] ;PUSH R_scratch1 ;[3] Note: Could optimize this line down into the pilot if necessary ;PUSH R_scratch2 ;[3] "" <- this one would need a jump conditional and would be messy. CALLA #TxClock ;Switch to TxClock ;MOV &(INFO_ADDR_TXUCS0), &UCSCTL0;[] switch to corr Tx Frequency ;MOV &(INFO_ADDR_TXUCS1), &UCSCTL1;[] "" ;/************************************************************************************************************************************ ;/ CHECK WHICH VERSION TO SEND * ;/ operation: in order to meet the timing constraint of 10 cycles, we need to eliminate some overhead in transmitting the data (see * ;/ 'why:' below). Thus we split the transmission into three possible modes V0/V1/V2. We establish which mode to use for * ;/ transmit here and then use it. * ;/ * ;/ versions: V0: (bytes>0) && (bits>0) * ;/ V1: (bytes>0) && (bits==0) * ;/ V2: (bytes==0) && (bits>0) * ;/ V3: (bytes==0) && (bits==0) <- D.C. cause no one should ever call this. it is coded to go to V1 in this case. * ; * ;/ why: notice that the jump to 'load_byte:' after sending b7 takes JNZ[2],MOV[2],INV[1],MOV[4] == 9 cycles. Note here for b0* ;/ we also optimized out a MOV but left it commented for clarity. Anyways this is 9 cycles, 1 less than our 10 cycle * ;/ criteria. It would be nice to hit 9 cycles though; then we could drop our CPU speed. * ;/ * ;/ entry timing: worst case this code burns 37 cycles before transmitting the first pilot tone bit of V1. At 12.57MHz this is 2.9us..* ;/ I hope this won't be an issue later! * ;/ * ;/ future optim: one note here is that the pilot tones never really get called in FM0_640, so if that's the case then the cycles are * ;/ 32. also not that two PUSH cycles could be optimized, and perhaps the test logic could too. let's hope we never have* ;/ to go there! * ;/ opt note: (temp until fixed) I load up scratch0/1 for transmitting tones to save cycles. but i don't need to save those cycles* ;/ and in fact it costs me entry and exit cycles because it requires a pop/push of R_scratch2. FIXME!!! * ;/************************************************************************************************************************************ Test_For_Version0: TST.B R_byteCt ;[1] Check for bytes JZ Test_For_Version2 ;[2] JMP if no bytes TST.B R_bitCt ;[1] Check for bytes JZ Test_For_Version2 ;[2] JMP if no bits JMP V0_Send_Pilot_Tones ;[2] if we got here then (bytes>0) && (bits>0). JMP to V0. Test_For_Version2: TST.B R_byteCt ;[1] Check for bytes JNZ Go_To_Version1 ;[2] JMP if bytes TST.B R_bitCt ;[1] Check For bits JZ Go_To_Version1 ;[2] JMP if no bits JMP tramp_V2_Send_Pilot_Tones ;[2] if we got here then (bytes==0) && (bits>0). JMP to V2 Go_To_Version1: ; Else just go to Version1 ;************************************************************************************************************************************* ; * ; Version 1: bytes>0 && bits==0 todo make NOPdefs.h NOPx4 something more optimized. * ; * ; Optimizations: For Each Byte sent, we need to do the following tasks: * ; - decrement byte count (R_byteCt) * ; - test for more bytes * ;************************************************************************************************************************************/ V1_Send_Pilot_Tones: ;/Prep Some Registers to Send (optimized scratch0/2 down below though)------------------------------------------------------------ MOV.B #0xFF, R_scratch1 ;[1] preloading our HIGH and LOW Tx bits to save us some cycles for pilot tones and preamble MOV.B #12, R_scratch2 ;[2] load up numTones=12 ;/Test to see if we should send pilot tones--------------------------------------------------------------------------------------- TST.B R_TRext ;[1] TRext means that we should send the pilot tones JZ V1_Send_Preamble ;[2] skip 'em if (!TRext) ;/Send Pilot Tones if TRext------------------------------------------------------------------------------------------------------- V1_Send_A_Pilot_Tone: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;*Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] setup R_scratch0 as LOW (note: if this is skipped, make sure to do it in preamble below too) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] LOW on PTXOUT.PIN_TX NOP ;[1] 1 timing cycles DEC R_scratch2 ;[1] decrement the tone count TST.B R_scratch2 ;[1] keep sending until the count is zero JNZ V1_Send_A_Pilot_Tone ;[2] "" ;/************************************************************************************************************************************ ;/ SEND PREAMBLE (UNROLLED) * ;/ operation: The preamble signals a tag transmission. It is unique as one data bit (the 5th, LL) doesn't follow FM0 modulation, so * ;/ the reader can pick up the transmission for sure. other than that, not too much here. * ;/ * ;/ tx sequence: 000...[1/0/1/0/v/1] or encoded as -> [HH/LH/LL/HL/LL/HH] * ;/************************************************************************************************************************************ V1_Send_Preamble: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;* Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] just in case the pilot tones were skipped (where scratch0 was loaded) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX MOV.B #0xFF, R_prevState ;[1] load up prevStateLogic to HIGH (cause preamble left it that way) ;* Timing Optimization Shoved Here (1 Free Cycle)*/ MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc (optimized line for b0 of transmit below). ;* End of 1 free cycle */ ;/************************************************************************************************************************************ ;/ SEND A DATA BYTE (UNROLLED) * ;/ operation: first a data byte is loaded into currByte, then 8 bits are shifted out onto PIN_TX. one nice cycle saving thing here is* ;/ that the secondFM0bit is also prevStateLogic for the next bit. also, keep in mind that prevStateLogic is only in the * ;/ b0 spot, so careful with byte or word operations if you change the code. * ;/************************************************************************************************************************************ V1_Load_Data: MOV.B @R_dataPtr+, R_currByte ;[2] load current byte of data V1_Send_a_Byte: ;/(b0)First Bit [FM0 Calculations are only commented for bit0]-------------------------------------------------------------------- ;*optimizedOut:MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc*/;<-Now meets 9 cycles on JMP! INV R_scratch0 ;[1] firstFM0Bit = !prevLogicState (i.e. STATE0|STATE2 from EPC Spec Table) MOV.B R_scratch0, &PTXOUT ;[4] push bit out on PTXOUT.PIN_TX XOR R_currByte, R_prevState ;[1] secondFM0Bit = currDataBit^prevLogicState (STATE1|STATE2) from EPC Spec Table). This also NOPx4 ;[4] 4 timing cycles MOV.B R_prevState, &PTXOUT ;[4] push bit out on PTXOUT.PIN_TX //happens to be the new value of prevLogicState RLA R_currByte ;[1] load next bit into hot seat //, which this line does too. NOPx2 ;[2] 2 timing cycles ;/(b1)Second Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] any lines beyond here that I don't comment are just standard FM0 calc&shoveOut lines INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b2)Third Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b3)Fourth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b4)Fifth Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b5)Sixth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b6)Seventh Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b7)Eighth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] ;*Timing Optimization Shoved Here (4 free cycles)*/ DEC R_byteCt ;[1] decrement the number of bytes sent TST.B R_byteCt ;[1] test if there are bytes left to send MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc (optimized line for b0 of next byte) NOP ;[1] 1 timing cycle ;*End of 4 free cycles*/ MOV.B R_prevState, &PTXOUT ;[4] *don't worry, MOV doesn't affect Z JNZ V1_Load_Data ;[2] if (byteCt!=0) Continue Sending Bytes ;/Send the Last Bit (EoS Bit)----------------------------------------------------------------------------------------------------- V1_Send_EoS_Byte: NOP ;[1] 1 timing cycles MOV R_prevState, R_scratch0 ;[1] calc last bit INV R_scratch0 ;[1] invert it MOV.B R_scratch0, &PTXOUT ;[4] push it out on 2.0 ;*Timing Optimization Shoved Here(14 free cycles). Note that the 14 cycles are used to enforce EoS bit timing (18cycles total)*/ ;BIS.B #PIN_RX_EN, &PRXEOUT ;[4] Leave with Port Low except for RX_EN. POPM.A #5, R10 ;[?] Restore preserved registers R6-R10 /** @todo Find out how long this takes */ ;POP R_scratch2 ;[2] return the preserved registers ;POP R_scratch1 ;[2] "" ;POP R_scratch0 ;[2] "" ;POP R_prevState ;[2] "" ;POP R_currByte ;[2] "" BIC.B #0x81, &PTXOUT ;[] Clear 2.0 & 2.7 (1.0 is for old 4.1 HW, 2.7 is for current hack...) eventually just 1.0 ;* End of 16 free cycles. Also note we only put these here to save 3 friggin cycles which prolly won't make a darn difference...*/ RETA ; trampoline to avoid a very long jump to V2_Send_Pilot_Tones ; XXX does this extra redirection take too long? tramp_V2_Send_Pilot_Tones: JMP V2_Send_Pilot_Tones ;************************************************************************************************************************************* ; * ; Version 0: bytes>0 && bits>0 * ; * ; Notes: This is the same as version 1 above, but it does a bits transmit loop too. * ; * ;************************************************************************************************************************************/ V0_Send_Pilot_Tones: ;/Prep Some Registers to Send (optimized scratch0/2 down below though)------------------------------------------------------------ MOV.B #0xFF, R_scratch1 ;[1] preloading our HIGH and LOW Tx bits to save us some cycles for pilot tones and preamble MOV.B #12, R_scratch2 ;[1] load up numTones=12 ;/Test to see if we should send pilot tones--------------------------------------------------------------------------------------- TST.B R_TRext ;[1] TRext means that we should send the pilot tones JZ V0_Send_Preamble ;[2] skip 'em if (!TRext) ;/Send Pilot Tonies if TRext------------------------------------------------------------------------------------------------------ V0_Send_A_Pilot_Tone: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;*Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] setup R_scratch0 as LOW (note: if this is skipped, make sure to do it in preamble below too) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] LOW on PTXOUT.PIN_TX NOP ;[1] 1 timing cycles DEC R_scratch2 ;[1] decrement the tone count TST.B R_scratch2 ;[1] keep sending until the count is zero JNZ V0_Send_A_Pilot_Tone ;[2] "" ;/************************************************************************************************************************************ ;/ SEND PREAMBLE (UNROLLED) * ;/ operation: The preamble signals a tag transmission. It is unique as one data bit (the 5th, LL) doesn't follow FM0 modulation, so * ;/ the reader can pick up the transmission for sure. other than that, not too much here. * ;/ * ;/ tx sequence: 000...[1/0/1/0/v/1] or encoded as -> [HH/LH/LL/HL/LL/HH] * ;/************************************************************************************************************************************ V0_Send_Preamble: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;* Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] just in case the pilot tones were skipped (where scratch0 was loaded) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX MOV.B #0xFF, R_prevState ;[1] load up prevStateLogic to HIGH (cause preamble left it that way) ;* Timing Optimization Shoved Here (1 Free Cycle)*/ MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc (optimized line for b0 of transmit below). ;* End of 1 free cycle */ ;/************************************************************************************************************************************ ;/ SEND A DATA BYTE (UNROLLED) * ;/ operation: first a data byte is loaded into currByte, then 8 bits are shifted out onto PIN_TX. one nice cycle saving thing here is* ;/ that the secondFM0bit is also prevStateLogic for the next bit. also, keep in mind that prevStateLogic is only in the * ;/ b0 spot, so careful with byte or word operations if you change the code. * ;/************************************************************************************************************************************ V0_Load_Data: MOV.B @R_dataPtr+, R_currByte ;[2] load current byte of data V0_Send_a_Byte: ;/(b0)First Bit [FM0 Calculations are only commented for bit0]-------------------------------------------------------------------- ;*optimizedOut:MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc*/;<-Now meets 9 cycles on JMP! INV R_scratch0 ;[1] firstFM0Bit = !prevLogicState (i.e. STATE0|STATE2 from EPC Spec Table) MOV.B R_scratch0, &PTXOUT ;[4] push bit out on PTXOUT.PIN_TX XOR R_currByte, R_prevState ;[1] secondFM0Bit = currDataBit^prevLogicState (STATE1|STATE2) from EPC Spec Table). This also NOPx4 ;[4] 4 timing cycles MOV.B R_prevState, &PTXOUT ;[4] push bit out on PTXOUT.PIN_TX //happens to be the new value of prevLogicState RLA R_currByte ;[1] load next bit into hot seat //, which this line does too. NOPx2 ;[2] 2 timing cycles ;/(b1)Second Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] any lines beyond here that I don't comment are just standard FM0 calc&shoveOut lines INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b2)Third Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b3)Fourth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b4)Fifth Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b5)Sixth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b6)Seventh Bit------------------------------------------------------------------------------------------------------------------- MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] NOPx4 ;[4] MOV.B R_prevState, &PTXOUT ;[4] RLA R_currByte ;[1] NOPx2 ;[2] ;/(b7)Eighth Bit------------------------------------------------------------------------------------------------------------------ MOV R_prevState, R_scratch0 ;[1] INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] ;*Timing Optimization Shoved Here (4 free cycles)*/ DEC R_byteCt ;[1] decrement the number of bytes sent TST.B R_byteCt ;[1] test if there are bytes left to send MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc (optimized line for b0 of next byte) NOP ;[1] 1 timing cycle ;*End of 4 free cycles*/ MOV.B R_prevState, &PTXOUT ;[4] *don't worry, MOV doesn't affect Z JNZ V0_Load_Data ;[2] if (byteCt!=0) Continue Sending Bytes ;/************************************************************************************************************************************ ;/ SEND LAST BITS * ;/ operation: same procedure as looping on bytes. number of bits to Tx is in R_bitCt. * ;/************************************************************************************************************************************ V0_Send_Last_Bits: MOV.B @R_dataPtr+, R_currByte;[2] load current byte of data V0_Send_A_Bit: ;*optimizedOut:MOV R_prevState, R_scratch0 ;[1] <- Already there for us from above. optimized out*/ INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] ;*Timing Optimization Shoved Here (4 free cycles)*/ RLA R_currByte ;[1] load in next bit DEC R_bitCt ;[1] decrement the number of bits to send TST.B R_bitCt ;[1] test if there are bytes left to send MOV R_prevState, R_scratch0 ;[1] ;*End of 4 free cycles*/ MOV.B R_prevState, &PTXOUT ;[4] NOPx2 ;[2] 2 timing cycles JNZ V0_Send_A_Bit ;[2] if(bitCt!=0) Continue Sending Bytes ;/Send the Last Bit (EoS Bit)----------------------------------------------------------------------------------------------------- V0_Send_EoS_Byte: NOP ;[1] 1 timing cycles MOV R_prevState, R_scratch0 ;[1] calc last bit INV R_scratch0 ;[1] invert it MOV.B R_scratch0, &PTXOUT ;[4] push it out on 2.0 ;*Timing Optimization Shoved Here(14 free cycles). Note that the 14 cycles are used to enforce EoS bit timing (18cycles total)*/ ;BIS.B #PIN_RX_EN, &PRXEOUT ;[4] Leave with Port Low except for RX_EN. POPM.A #5, R10 ;[?] Restore preserved registers R6-R10 /** @todo Find out how long this takes */ ;POP R_scratch2 ;[2] return the preserved registers ;POP R_scratch1 ;[2] "" ;POP R_scratch0 ;[2] "" ;POP R_prevState ;[2] "" ;POP R_currByte ;[2] "" BIC.B #0x81, &PTXOUT ;[] Clear 1.0 & 1.7 (1.0 is for old 4.1 HW, 1.7 is for current hack...) eventually just 1.0 ;* End of 16 free cycles. Also note we only put these here to save 3 friggin cycles which prolly won't make a darn difference...*/ RETA ;************************************************************************************************************************************* ; * ; Version 2: bytes==0 && bits>0 * ; * ; Notes: This is the same as version 0 above, but it omits the byte loop * ; * ;************************************************************************************************************************************/ V2_Send_Pilot_Tones: ;/Prep Some Registers to Send (optimized scratch0/2 down below though)------------------------------------------------------------ MOV.B #0xFF, R_scratch1 ;[1] preloading our HIGH and LOW Tx bits to save us some cycles for pilot tones and preamble MOV.B #12, R_scratch2 ;[1] load up numTones=12 ;/Test to see if we should send pilot tones--------------------------------------------------------------------------------------- TST.B R_TRext ;[1] TRext means that we should send the pilot tones JZ V2_Send_Preamble ;[2] skip 'em if (!TRext) ;/Send Pilot Tonies if TRext------------------------------------------------------------------------------------------------------ V2_Send_A_Pilot_Tone: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;*Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] setup R_scratch0 as LOW (note: if this is skipped, make sure to do it in preamble below too) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] LOW on PTXOUT.PIN_TX NOP ;[1] 1 timing cycles DEC R_scratch2 ;[1] decrement the tone count TST.B R_scratch2 ;[1] keep sending until the count is zero JNZ V2_Send_A_Pilot_Tone ;[2] "" ;/************************************************************************************************************************************ ;/ SEND PREAMBLE (UNROLLED) * ;/ operation: The preamble signals a tag transmission. It is unique as one data bit (the 5th, LL) doesn't follow FM0 modulation, so * ;/ the reader can pick up the transmission for sure. other than that, not too much here. * ;/ * ;/ tx sequence: 000...[1/0/1/0/v/1] or encoded as -> [HH/LH/LL/HL/LL/HH] * ;/************************************************************************************************************************************ V2_Send_Preamble: MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX ;* Timing Optimization Shoved Here(5 free cycles)*/ MOV.B #0x00, R_scratch0 ;[1] just in case the pilot tones were skipped (where scratch0 was loaded) NOPx4 ;[4] 4 timing cycles ;*End of 5 free cycles*/ MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*LL*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch0, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX /*HH*/ NOPx5 ;[5] 5 timing cycles MOV.B R_scratch1, &PTXOUT ;[4] HIGH on PTXOUT.PIN_TX MOV.B #0xFF, R_prevState ;[1] load up prevStateLogic to HIGH (cause preamble left it that way) ;* Timing Optimization Shoved Here (1 Free Cycle)*/ MOV R_prevState, R_scratch0 ;[1] load prevStateLogic into scratch0 for calc (optimized line for b0 of transmit below). ;* End of 1 free cycle */ ;/************************************************************************************************************************************ ;/ SEND LAST BITS * ;/ operation: same procedure as looping on bytes. number of bits to Tx is in R_bitCt. * ;/************************************************************************************************************************************ V2_Send_Last_Bits: MOV.B @R_dataPtr+, R_currByte;[2] load current byte of data V2_Send_A_Bit: ;*optimizedOut:MOV R_prevState, R_scratch0 ;[1] <- Already there for us from above. optimized out*/ INV R_scratch0 ;[1] MOV.B R_scratch0, &PTXOUT ;[4] XOR R_currByte, R_prevState ;[1] ;*Timing Optimization Shoved Here (4 free cycles)*/ RLA R_currByte ;[1] load in next bit DEC R_bitCt ;[1] decrement the number of bits to send TST.B R_bitCt ;[1] test if there are bytes left to send MOV R_prevState, R_scratch0 ;[1] ;*End of 4 free cycles*/ MOV.B R_prevState, &PTXOUT ;[4] NOPx2 ;[2] 2 timing cycles JNZ V2_Send_A_Bit ;[2] if(bitCt!=0) Continue Sending Bytes ;/Send the Last Bit (EoS Bit)----------------------------------------------------------------------------------------------------- V2_Send_EoS_Byte: NOP ;[1] 1 timing cycles (note: instead of PIN_RX_EN line below(4cyc) we could just use this cycle to OR in Bit3 @ a reg (maybe 2 cyc though:( ) MOV R_prevState, R_scratch0 ;[1] calc last bit INV R_scratch0 ;[1] invert it MOV.B R_scratch0, &PTXOUT ;[4] push it out on 2.0 ;*Timing Optimization Shoved Here(14 free cycles). Note that the 14 cycles are used to enforce EoS bit timing (18cycles total)*/ ;BIS.B #PIN_RX_EN, &PRXEOUT ;[4] Leave with Port Low except for RX_EN. POPM.A #5, R10 ;[?] Restore preserved registers R6-R10 /** @todo Find out how long this takes */ ;POP R_scratch2 ;[2] return the preserved registers ;POP R_scratch1 ;[2] "" ;POP R_scratch0 ;[2] "" ;POP R_prevState ;[2] "" ;POP R_currByte ;[2] "" BIC.B #0x81, &PTXOUT ;[] Clear 1.0 & 1.7 (1.0 is for old 4.1 HW, 1.7 is for current hack...) eventually just 1.0 ;* End of 16 free cycles. Also note we only put these here to save 3 friggin cycles which prolly won't make a darn difference...*/ RETA .end ;* End of ASM */
;****************************************************************************** ;* FFT transform with SSE/3DNow optimizations ;* Copyright (c) 2008 Loren Merritt ;* Copyright (c) 2011 Vitor Sessak ;* ;* This algorithm (though not any of the implementation details) is ;* based on libdjbfft by D. J. Bernstein. ;* ;* This file is part of FFmpeg. ;* ;* FFmpeg is free software; you can redistribute it and/or ;* modify it under the terms of the GNU Lesser General Public ;* License as published by the Free Software Foundation; either ;* version 2.1 of the License, or (at your option) any later version. ;* ;* FFmpeg is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;* Lesser General Public License for more details. ;* ;* You should have received a copy of the GNU Lesser General Public ;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** ; These functions are not individually interchangeable with the C versions. ; While C takes arrays of FFTComplex, SSE/3DNow leave intermediate results ; in blocks as conventient to the vector size. ; i.e. {4x real, 4x imaginary, 4x real, ...} (or 2x respectively) %include "x86inc.asm" %ifdef ARCH_X86_64 %define pointer resq %else %define pointer resd %endif struc FFTContext .nbits: resd 1 .reverse: resd 1 .revtab: pointer 1 .tmpbuf: pointer 1 .mdctsize: resd 1 .mdctbits: resd 1 .tcos: pointer 1 .tsin: pointer 1 endstruc SECTION_RODATA %define M_SQRT1_2 0.70710678118654752440 %define M_COS_PI_1_8 0.923879532511287 %define M_COS_PI_3_8 0.38268343236509 align 32 ps_cos16_1: dd 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8, 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8 ps_cos16_2: dd 0, M_COS_PI_3_8, M_SQRT1_2, M_COS_PI_1_8, 0, -M_COS_PI_3_8, -M_SQRT1_2, -M_COS_PI_1_8 ps_root2: times 8 dd M_SQRT1_2 ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2 ps_p1p1m1p1: dd 0, 0, 1<<31, 0, 0, 0, 1<<31, 0 perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01 perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03 ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2 ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31 ps_m1p1: dd 1<<31, 0 %assign i 16 %rep 13 cextern cos_ %+ i %assign i i<<1 %endrep %ifdef ARCH_X86_64 %define pointer dq %else %define pointer dd %endif %macro IF0 1+ %endmacro %macro IF1 1+ %1 %endmacro SECTION_TEXT %macro T2_3DN 4 ; z0, z1, mem0, mem1 mova %1, %3 mova %2, %1 pfadd %1, %4 pfsub %2, %4 %endmacro %macro T4_3DN 6 ; z0, z1, z2, z3, tmp0, tmp1 mova %5, %3 pfsub %3, %4 pfadd %5, %4 ; {t6,t5} pxor %3, [ps_m1p1] ; {t8,t7} mova %6, %1 pswapd %3, %3 pfadd %1, %5 ; {r0,i0} pfsub %6, %5 ; {r2,i2} mova %4, %2 pfadd %2, %3 ; {r1,i1} pfsub %4, %3 ; {r3,i3} SWAP %3, %6 %endmacro ; in: %1 = {r0,i0,r2,i2,r4,i4,r6,i6} ; %2 = {r1,i1,r3,i3,r5,i5,r7,i7} ; %3, %4, %5 tmp ; out: %1 = {r0,r1,r2,r3,i0,i1,i2,i3} ; %2 = {r4,r5,r6,r7,i4,i5,i6,i7} %macro T8_AVX 5 vsubps %5, %1, %2 ; v = %1 - %2 vaddps %3, %1, %2 ; w = %1 + %2 vmulps %2, %5, [ps_p1p1m1p1root2] ; v *= vals1 vpermilps %2, %2, [perm1] vblendps %1, %2, %3, 0x33 ; q = {w1,w2,v4,v2,w5,w6,v7,v6} vshufps %5, %3, %2, 0x4e ; r = {w3,w4,v1,v3,w7,w8,v8,v5} vsubps %4, %5, %1 ; s = r - q vaddps %1, %5, %1 ; u = r + q vpermilps %1, %1, [perm2] ; k = {u1,u2,u3,u4,u6,u5,u7,u8} vshufps %5, %4, %1, 0xbb vshufps %3, %4, %1, 0xee vperm2f128 %3, %3, %5, 0x13 vxorps %4, %4, [ps_m1m1p1m1p1m1m1m1] ; s *= {1,1,-1,-1,1,-1,-1,-1} vshufps %2, %1, %4, 0xdd vshufps %1, %1, %4, 0x88 vperm2f128 %4, %2, %1, 0x02 ; v = {k1,k3,s1,s3,k2,k4,s2,s4} vperm2f128 %1, %1, %2, 0x13 ; w = {k6,k8,s6,s8,k5,k7,s5,s7} vsubps %5, %1, %3 vblendps %1, %5, %1, 0x55 ; w -= {0,s7,0,k7,0,s8,0,k8} vsubps %2, %4, %1 ; %2 = v - w vaddps %1, %4, %1 ; %1 = v + w %endmacro ; In SSE mode do one fft4 transforms ; in: %1={r0,i0,r2,i2} %2={r1,i1,r3,i3} ; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} ; ; In AVX mode do two fft4 transforms ; in: %1={r0,i0,r2,i2,r4,i4,r6,i6} %2={r1,i1,r3,i3,r5,i5,r7,i7} ; out: %1={r0,r1,r2,r3,r4,r5,r6,r7} %2={i0,i1,i2,i3,i4,i5,i6,i7} %macro T4_SSE 3 subps %3, %1, %2 ; {t3,t4,-t8,t7} addps %1, %1, %2 ; {t1,t2,t6,t5} xorps %3, %3, [ps_p1p1m1p1] shufps %2, %1, %3, 0xbe ; {t6,t5,t7,t8} shufps %1, %1, %3, 0x44 ; {t1,t2,t3,t4} subps %3, %1, %2 ; {r2,i2,r3,i3} addps %1, %1, %2 ; {r0,i0,r1,i1} shufps %2, %1, %3, 0xdd ; {i0,i1,i2,i3} shufps %1, %1, %3, 0x88 ; {r0,r1,r2,r3} %endmacro ; In SSE mode do one FFT8 ; in: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %3={r4,i4,r6,i6} %4={r5,i5,r7,i7} ; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %1={r4,r5,r6,r7} %2={i4,i5,i6,i7} ; ; In AVX mode do two FFT8 ; in: %1={r0,i0,r2,i2,r8, i8, r10,i10} %2={r1,i1,r3,i3,r9, i9, r11,i11} ; %3={r4,i4,r6,i6,r12,i12,r14,i14} %4={r5,i5,r7,i7,r13,i13,r15,i15} ; out: %1={r0,r1,r2,r3,r8, r9, r10,r11} %2={i0,i1,i2,i3,i8, i9, i10,i11} ; %3={r4,r5,r6,r7,r12,r13,r14,r15} %4={i4,i5,i6,i7,i12,i13,i14,i15} %macro T8_SSE 6 addps %6, %3, %4 ; {t1,t2,t3,t4} subps %3, %3, %4 ; {r5,i5,r7,i7} shufps %4, %3, %3, 0xb1 ; {i5,r5,i7,r7} mulps %3, %3, [ps_root2mppm] ; {-r5,i5,r7,-i7} mulps %4, %4, [ps_root2] addps %3, %3, %4 ; {t8,t7,ta,t9} shufps %4, %6, %3, 0x9c ; {t1,t4,t7,ta} shufps %6, %6, %3, 0x36 ; {t3,t2,t9,t8} subps %3, %6, %4 ; {t6,t5,tc,tb} addps %6, %6, %4 ; {t1,t2,t9,ta} shufps %5, %6, %3, 0x8d ; {t2,ta,t6,tc} shufps %6, %6, %3, 0xd8 ; {t1,t9,t5,tb} subps %3, %1, %6 ; {r4,r5,r6,r7} addps %1, %1, %6 ; {r0,r1,r2,r3} subps %4, %2, %5 ; {i4,i5,i6,i7} addps %2, %2, %5 ; {i0,i1,i2,i3} %endmacro ; scheduled for cpu-bound sizes %macro PASS_SMALL 3 ; (to load m4-m7), wre, wim IF%1 mova m4, Z(4) IF%1 mova m5, Z(5) mova m0, %2 ; wre mova m1, %3 ; wim mulps m2, m4, m0 ; r2*wre IF%1 mova m6, Z2(6) mulps m3, m5, m1 ; i2*wim IF%1 mova m7, Z2(7) mulps m4, m4, m1 ; r2*wim mulps m5, m5, m0 ; i2*wre addps m2, m2, m3 ; r2*wre + i2*wim mulps m3, m1, m7 ; i3*wim subps m5, m5, m4 ; i2*wre - r2*wim mulps m1, m1, m6 ; r3*wim mulps m4, m0, m6 ; r3*wre mulps m0, m0, m7 ; i3*wre subps m4, m4, m3 ; r3*wre - i3*wim mova m3, Z(0) addps m0, m0, m1 ; i3*wre + r3*wim subps m1, m4, m2 ; t3 addps m4, m4, m2 ; t5 subps m3, m3, m4 ; r2 addps m4, m4, Z(0) ; r0 mova m6, Z(2) mova Z(4), m3 mova Z(0), m4 subps m3, m5, m0 ; t4 subps m4, m6, m3 ; r3 addps m3, m3, m6 ; r1 mova Z2(6), m4 mova Z(2), m3 mova m2, Z(3) addps m3, m5, m0 ; t6 subps m2, m2, m1 ; i3 mova m7, Z(1) addps m1, m1, Z(3) ; i1 mova Z2(7), m2 mova Z(3), m1 subps m4, m7, m3 ; i2 addps m3, m3, m7 ; i0 mova Z(5), m4 mova Z(1), m3 %endmacro ; scheduled to avoid store->load aliasing %macro PASS_BIG 1 ; (!interleave) mova m4, Z(4) ; r2 mova m5, Z(5) ; i2 mova m0, [wq] ; wre mova m1, [wq+o1q] ; wim mulps m2, m4, m0 ; r2*wre mova m6, Z2(6) ; r3 mulps m3, m5, m1 ; i2*wim mova m7, Z2(7) ; i3 mulps m4, m4, m1 ; r2*wim mulps m5, m5, m0 ; i2*wre addps m2, m2, m3 ; r2*wre + i2*wim mulps m3, m1, m7 ; i3*wim mulps m1, m1, m6 ; r3*wim subps m5, m5, m4 ; i2*wre - r2*wim mulps m4, m0, m6 ; r3*wre mulps m0, m0, m7 ; i3*wre subps m4, m4, m3 ; r3*wre - i3*wim mova m3, Z(0) addps m0, m0, m1 ; i3*wre + r3*wim subps m1, m4, m2 ; t3 addps m4, m4, m2 ; t5 subps m3, m3, m4 ; r2 addps m4, m4, Z(0) ; r0 mova m6, Z(2) mova Z(4), m3 mova Z(0), m4 subps m3, m5, m0 ; t4 subps m4, m6, m3 ; r3 addps m3, m3, m6 ; r1 IF%1 mova Z2(6), m4 IF%1 mova Z(2), m3 mova m2, Z(3) addps m5, m5, m0 ; t6 subps m2, m2, m1 ; i3 mova m7, Z(1) addps m1, m1, Z(3) ; i1 IF%1 mova Z2(7), m2 IF%1 mova Z(3), m1 subps m6, m7, m5 ; i2 addps m5, m5, m7 ; i0 IF%1 mova Z(5), m6 IF%1 mova Z(1), m5 %if %1==0 INTERL m1, m3, m7, Z, 2 INTERL m2, m4, m0, Z2, 6 mova m1, Z(0) mova m2, Z(4) INTERL m5, m1, m3, Z, 0 INTERL m6, m2, m7, Z, 4 %endif %endmacro %macro PUNPCK 3 mova %3, %1 punpckldq %1, %2 punpckhdq %3, %2 %endmacro %define Z(x) [r0+mmsize*x] %define Z2(x) [r0+mmsize*x] %define ZH(x) [r0+mmsize*x+mmsize/2] INIT_YMM %ifdef HAVE_AVX align 16 fft8_avx: mova m0, Z(0) mova m1, Z(1) T8_AVX m0, m1, m2, m3, m4 mova Z(0), m0 mova Z(1), m1 ret align 16 fft16_avx: mova m2, Z(2) mova m3, Z(3) T4_SSE m2, m3, m7 mova m0, Z(0) mova m1, Z(1) T8_AVX m0, m1, m4, m5, m7 mova m4, [ps_cos16_1] mova m5, [ps_cos16_2] vmulps m6, m2, m4 vmulps m7, m3, m5 vaddps m7, m7, m6 vmulps m2, m2, m5 vmulps m3, m3, m4 vsubps m3, m3, m2 vblendps m2, m7, m3, 0xf0 vperm2f128 m3, m7, m3, 0x21 vaddps m4, m2, m3 vsubps m2, m3, m2 vperm2f128 m2, m2, m2, 0x01 vsubps m3, m1, m2 vaddps m1, m1, m2 vsubps m5, m0, m4 vaddps m0, m0, m4 vextractf128 Z(0), m0, 0 vextractf128 ZH(0), m1, 0 vextractf128 Z(1), m0, 1 vextractf128 ZH(1), m1, 1 vextractf128 Z(2), m5, 0 vextractf128 ZH(2), m3, 0 vextractf128 Z(3), m5, 1 vextractf128 ZH(3), m3, 1 ret align 16 fft32_avx: call fft16_avx mova m0, Z(4) mova m1, Z(5) T4_SSE m0, m1, m4 mova m2, Z(6) mova m3, Z(7) T8_SSE m0, m1, m2, m3, m4, m6 ; m0={r0,r1,r2,r3,r8, r9, r10,r11} m1={i0,i1,i2,i3,i8, i9, i10,i11} ; m2={r4,r5,r6,r7,r12,r13,r14,r15} m3={i4,i5,i6,i7,i12,i13,i14,i15} vperm2f128 m4, m0, m2, 0x20 vperm2f128 m5, m1, m3, 0x20 vperm2f128 m6, m0, m2, 0x31 vperm2f128 m7, m1, m3, 0x31 PASS_SMALL 0, [cos_32], [cos_32+32] ret fft32_interleave_avx: call fft32_avx mov r2d, 32 .deint_loop: mova m2, Z(0) mova m3, Z(1) vunpcklps m0, m2, m3 vunpckhps m1, m2, m3 vextractf128 Z(0), m0, 0 vextractf128 ZH(0), m1, 0 vextractf128 Z(1), m0, 1 vextractf128 ZH(1), m1, 1 add r0, mmsize*2 sub r2d, mmsize/4 jg .deint_loop ret %endif INIT_XMM %define movdqa movaps align 16 fft4_avx: fft4_sse: mova m0, Z(0) mova m1, Z(1) T4_SSE m0, m1, m2 mova Z(0), m0 mova Z(1), m1 ret align 16 fft8_sse: mova m0, Z(0) mova m1, Z(1) T4_SSE m0, m1, m2 mova m2, Z(2) mova m3, Z(3) T8_SSE m0, m1, m2, m3, m4, m5 mova Z(0), m0 mova Z(1), m1 mova Z(2), m2 mova Z(3), m3 ret align 16 fft16_sse: mova m0, Z(0) mova m1, Z(1) T4_SSE m0, m1, m2 mova m2, Z(2) mova m3, Z(3) T8_SSE m0, m1, m2, m3, m4, m5 mova m4, Z(4) mova m5, Z(5) mova Z(0), m0 mova Z(1), m1 mova Z(2), m2 mova Z(3), m3 T4_SSE m4, m5, m6 mova m6, Z2(6) mova m7, Z2(7) T4_SSE m6, m7, m0 PASS_SMALL 0, [cos_16], [cos_16+16] ret INIT_MMX %macro FFT48_3DN 1 align 16 fft4%1: T2_3DN m0, m1, Z(0), Z(1) mova m2, Z(2) mova m3, Z(3) T4_3DN m0, m1, m2, m3, m4, m5 PUNPCK m0, m1, m4 PUNPCK m2, m3, m5 mova Z(0), m0 mova Z(1), m4 mova Z(2), m2 mova Z(3), m5 ret align 16 fft8%1: T2_3DN m0, m1, Z(0), Z(1) mova m2, Z(2) mova m3, Z(3) T4_3DN m0, m1, m2, m3, m4, m5 mova Z(0), m0 mova Z(2), m2 T2_3DN m4, m5, Z(4), Z(5) T2_3DN m6, m7, Z2(6), Z2(7) pswapd m0, m5 pswapd m2, m7 pxor m0, [ps_m1p1] pxor m2, [ps_m1p1] pfsub m5, m0 pfadd m7, m2 pfmul m5, [ps_root2] pfmul m7, [ps_root2] T4_3DN m1, m3, m5, m7, m0, m2 mova Z(5), m5 mova Z2(7), m7 mova m0, Z(0) mova m2, Z(2) T4_3DN m0, m2, m4, m6, m5, m7 PUNPCK m0, m1, m5 PUNPCK m2, m3, m7 mova Z(0), m0 mova Z(1), m5 mova Z(2), m2 mova Z(3), m7 PUNPCK m4, Z(5), m5 PUNPCK m6, Z2(7), m7 mova Z(4), m4 mova Z(5), m5 mova Z2(6), m6 mova Z2(7), m7 ret %endmacro FFT48_3DN _3dn2 %macro pswapd 2 %ifidn %1, %2 movd [r0+12], %1 punpckhdq %1, [r0+8] %else movq %1, %2 psrlq %1, 32 punpckldq %1, %2 %endif %endmacro FFT48_3DN _3dn %define Z(x) [zq + o1q*(x&6) + mmsize*(x&1)] %define Z2(x) [zq + o3q + mmsize*(x&1)] %define ZH(x) [zq + o1q*(x&6) + mmsize*(x&1) + mmsize/2] %define Z2H(x) [zq + o3q + mmsize*(x&1) + mmsize/2] %macro DECL_PASS 2+ ; name, payload align 16 %1: DEFINE_ARGS z, w, n, o1, o3 lea o3q, [nq*3] lea o1q, [nq*8] shl o3q, 4 .loop: %2 add zq, mmsize*2 add wq, mmsize sub nd, mmsize/8 jg .loop rep ret %endmacro INIT_YMM %ifdef HAVE_AVX %macro INTERL_AVX 5 vunpckhps %3, %2, %1 vunpcklps %2, %2, %1 vextractf128 %4(%5), %2, 0 vextractf128 %4 %+ H(%5), %3, 0 vextractf128 %4(%5 + 1), %2, 1 vextractf128 %4 %+ H(%5 + 1), %3, 1 %endmacro %define INTERL INTERL_AVX DECL_PASS pass_avx, PASS_BIG 1 DECL_PASS pass_interleave_avx, PASS_BIG 0 %endif INIT_XMM %macro INTERL_SSE 5 mova %3, %2 unpcklps %2, %1 unpckhps %3, %1 mova %4(%5), %2 mova %4(%5+1), %3 %endmacro %define INTERL INTERL_SSE DECL_PASS pass_sse, PASS_BIG 1 DECL_PASS pass_interleave_sse, PASS_BIG 0 INIT_MMX %define mulps pfmul %define addps pfadd %define subps pfsub %define unpcklps punpckldq %define unpckhps punpckhdq DECL_PASS pass_3dn, PASS_SMALL 1, [wq], [wq+o1q] DECL_PASS pass_interleave_3dn, PASS_BIG 0 %define pass_3dn2 pass_3dn %define pass_interleave_3dn2 pass_interleave_3dn %ifdef PIC %define SECTION_REL - $$ %else %define SECTION_REL %endif %macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs lea r2, [dispatch_tab%1] mov r2, [r2 + (%2q-2)*gprsize] %ifdef PIC lea r3, [$$] add r2, r3 %endif call r2 %endmacro ; FFT_DISPATCH %macro DECL_FFT 2-3 ; nbits, cpu, suffix %xdefine list_of_fft fft4%2 SECTION_REL, fft8%2 SECTION_REL %if %1>=5 %xdefine list_of_fft list_of_fft, fft16%2 SECTION_REL %endif %if %1>=6 %xdefine list_of_fft list_of_fft, fft32%3%2 SECTION_REL %endif %assign n 1<<%1 %rep 17-%1 %assign n2 n/2 %assign n4 n/4 %xdefine list_of_fft list_of_fft, fft %+ n %+ %3%2 SECTION_REL align 16 fft %+ n %+ %3%2: call fft %+ n2 %+ %2 add r0, n*4 - (n&(-2<<%1)) call fft %+ n4 %+ %2 add r0, n*2 - (n2&(-2<<%1)) call fft %+ n4 %+ %2 sub r0, n*6 + (n2&(-2<<%1)) lea r1, [cos_ %+ n] mov r2d, n4/2 jmp pass%3%2 %assign n n*2 %endrep %undef n align 8 dispatch_tab%3%2: pointer list_of_fft section .text ; On x86_32, this function does the register saving and restoring for all of fft. ; The others pass args in registers and don't spill anything. cglobal fft_dispatch%3%2, 2,5,8, z, nbits FFT_DISPATCH %3%2, nbits %ifidn %2, _avx vzeroupper %endif RET %endmacro ; DECL_FFT %ifdef HAVE_AVX DECL_FFT 6, _avx DECL_FFT 6, _avx, _interleave %endif DECL_FFT 5, _sse DECL_FFT 5, _sse, _interleave DECL_FFT 4, _3dn DECL_FFT 4, _3dn, _interleave DECL_FFT 4, _3dn2 DECL_FFT 4, _3dn2, _interleave INIT_XMM %undef mulps %undef addps %undef subps %undef unpcklps %undef unpckhps %macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8 movaps xmm0, [%3+%2*4] movaps xmm1, [%3+%1*4-0x10] movaps xmm2, xmm0 shufps xmm0, xmm1, 0x88 shufps xmm1, xmm2, 0x77 movlps xmm4, [%4+%2*2] movlps xmm5, [%5+%2*2+0x0] movhps xmm4, [%4+%1*2-0x8] movhps xmm5, [%5+%1*2-0x8] movaps xmm2, xmm0 movaps xmm3, xmm1 mulps xmm0, xmm5 mulps xmm1, xmm4 mulps xmm2, xmm4 mulps xmm3, xmm5 subps xmm1, xmm0 addps xmm2, xmm3 movaps xmm0, xmm1 unpcklps xmm1, xmm2 unpckhps xmm0, xmm2 %endmacro %macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5 mulps m6, %3, [%5+%1] mulps m7, %2, [%5+%1] mulps %2, %2, [%6+%1] mulps %3, %3, [%6+%1] subps %2, %2, m6 addps %3, %3, m7 %endmacro %macro POSROTATESHUF_AVX 5 ;j, k, z+n8, tcos+n8, tsin+n8 .post: vmovaps ymm1, [%3+%1*2] vmovaps ymm0, [%3+%1*2+0x20] vmovaps ymm3, [%3+%2*2] vmovaps ymm2, [%3+%2*2+0x20] CMUL %1, ymm0, ymm1, %3, %4, %5 CMUL %2, ymm2, ymm3, %3, %4, %5 vshufps ymm1, ymm1, ymm1, 0x1b vshufps ymm3, ymm3, ymm3, 0x1b vperm2f128 ymm1, ymm1, ymm1, 0x01 vperm2f128 ymm3, ymm3, ymm3, 0x01 vunpcklps ymm6, ymm2, ymm1 vunpckhps ymm4, ymm2, ymm1 vunpcklps ymm7, ymm0, ymm3 vunpckhps ymm5, ymm0, ymm3 vextractf128 [%3+%1*2], ymm7, 0 vextractf128 [%3+%1*2+0x10], ymm5, 0 vextractf128 [%3+%1*2+0x20], ymm7, 1 vextractf128 [%3+%1*2+0x30], ymm5, 1 vextractf128 [%3+%2*2], ymm6, 0 vextractf128 [%3+%2*2+0x10], ymm4, 0 vextractf128 [%3+%2*2+0x20], ymm6, 1 vextractf128 [%3+%2*2+0x30], ymm4, 1 sub %2, 0x20 add %1, 0x20 jl .post %endmacro %macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8 .post: movaps xmm1, [%3+%1*2] movaps xmm0, [%3+%1*2+0x10] CMUL %1, xmm0, xmm1, %3, %4, %5 movaps xmm5, [%3+%2*2] movaps xmm4, [%3+%2*2+0x10] CMUL %2, xmm4, xmm5, %3, %4, %5 shufps xmm1, xmm1, 0x1b shufps xmm5, xmm5, 0x1b movaps xmm6, xmm4 unpckhps xmm4, xmm1 unpcklps xmm6, xmm1 movaps xmm2, xmm0 unpcklps xmm0, xmm5 unpckhps xmm2, xmm5 movaps [%3+%2*2], xmm6 movaps [%3+%2*2+0x10], xmm4 movaps [%3+%1*2], xmm0 movaps [%3+%1*2+0x10], xmm2 sub %2, 0x10 add %1, 0x10 jl .post %endmacro %macro DECL_IMDCT 2 cglobal imdct_half%1, 3,7,8; FFTContext *s, FFTSample *output, const FFTSample *input %ifdef ARCH_X86_64 %define rrevtab r10 %define rtcos r11 %define rtsin r12 push r12 push r13 push r14 %else %define rrevtab r6 %define rtsin r6 %define rtcos r5 %endif mov r3d, [r0+FFTContext.mdctsize] add r2, r3 shr r3, 1 mov rtcos, [r0+FFTContext.tcos] mov rtsin, [r0+FFTContext.tsin] add rtcos, r3 add rtsin, r3 %ifndef ARCH_X86_64 push rtcos push rtsin %endif shr r3, 1 mov rrevtab, [r0+FFTContext.revtab] add rrevtab, r3 %ifndef ARCH_X86_64 push rrevtab %endif sub r3, 4 %ifdef ARCH_X86_64 xor r4, r4 sub r4, r3 %endif .pre: %ifndef ARCH_X86_64 ;unspill xor r4, r4 sub r4, r3 mov rtsin, [esp+4] mov rtcos, [esp+8] %endif PREROTATER r4, r3, r2, rtcos, rtsin %ifdef ARCH_X86_64 movzx r5, word [rrevtab+r4-4] movzx r6, word [rrevtab+r4-2] movzx r13, word [rrevtab+r3] movzx r14, word [rrevtab+r3+2] movlps [r1+r5 *8], xmm0 movhps [r1+r6 *8], xmm0 movlps [r1+r13*8], xmm1 movhps [r1+r14*8], xmm1 add r4, 4 %else mov r6, [esp] movzx r5, word [r6+r4-4] movzx r4, word [r6+r4-2] movlps [r1+r5*8], xmm0 movhps [r1+r4*8], xmm0 movzx r5, word [r6+r3] movzx r4, word [r6+r3+2] movlps [r1+r5*8], xmm1 movhps [r1+r4*8], xmm1 %endif sub r3, 4 jns .pre mov r5, r0 mov r6, r1 mov r0, r1 mov r1d, [r5+FFTContext.nbits] FFT_DISPATCH %1, r1 mov r0d, [r5+FFTContext.mdctsize] add r6, r0 shr r0, 1 %ifndef ARCH_X86_64 %define rtcos r2 %define rtsin r3 mov rtcos, [esp+8] mov rtsin, [esp+4] %endif neg r0 mov r1, -mmsize sub r1, r0 %2 r0, r1, r6, rtcos, rtsin %ifdef ARCH_X86_64 pop r14 pop r13 pop r12 %else add esp, 12 %endif %ifidn avx_enabled, 1 vzeroupper %endif RET %endmacro DECL_IMDCT _sse, POSROTATESHUF INIT_YMM %ifdef HAVE_AVX DECL_IMDCT _avx, POSROTATESHUF_AVX %endif
include ksamd64.inc EXTERNDEF __imp_RtlCaptureContext:QWORD extern harness_main:proc extern report_end:QWORD extern savedContext:QWORD .code FuzzingHarness PROC add rsp, 8 ; discard return address push qword ptr [report_end] ; new retaddr push rcx ; preserve rcx lea rcx, qword ptr [savedContext] call __imp_RtlCaptureContext pop [rcx+CxRcx] ; 0x80 = offset of rcx lea rax, [rsp] ; calculate original rsp mov [rcx+CxRsp], rax ; 0x98 = offset of rsp sub rsp, 1020h ; allocate a ton of space on the stack incl. shadow space jmp harness_main FuzzingHarness ENDP end
; ---------------------------------------------------------------------------------------- ; Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only. ; To assemble and run: ; ; nasm -felf64 hello.asm && ld hello.o && ./a.out ; ---------------------------------------------------------------------------------------- bits 64 global _start section .text _start: ; write(1, message, 13) mov rax, 1 ; system call 1 is write mov rdi, 1 ; file handle 1 is stdout mov rsi, message ; address of string to output mov rdx, 13 ; number of bytes ;syscall ; invoke operating system to do the write ; exit(0) ;mov eax, 60 ; system call 60 is exit ;xor rdi, rdi ; exit code 0 ;syscall ; invoke operating system to exit message: db "Hello, World", 10 ; note the newline at the end
; A025790: Expansion of 1/((1-x)(1-x^8)(1-x^11)). ; 1,1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,4,4,4,5,5,5,6,6,7,7,7,8,8,8,9,9,10,11,11,12,12,12,13,13,14,15,15,16,17,17,18,18,19,20,20,21,22,22,23,24,25,26,26,27,28,28,29,30,31 lpb $0 mov $2,$0 sub $0,8 div $2,11 seq $2,14181 ; Numbers > 9 with all digits the same. add $1,$2 lpe div $1,11 add $1,1 mov $0,$1
; Windows externdef ExitProcess:PROTO ; SDL include SDL.inc .CONST SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 WINDOW_TITLE BYTE "SDL Tutorial",0 .DATA .DATA? pWindow QWORD ? pScreenSurface QWORD ? .CODE main PROC sub rsp, 8 ; Align stack sub rsp, 20h ; Create shadow space mov rcx, SDL_INIT_VIDEO call SDL_Init cmp rax, 0 jb EXIT ; We create the Window mov DWORD PTR [rsp+40], SDL_WINDOW_SHOWN ; 6xt argument - (4) mov DWORD PTR [rsp+32], SCREEN_HEIGHT ; 5th argument - (480) 000001e0H mov r9, SCREEN_WIDTH ; 4th argument - (640) 00000280H mov r8, SDL_WINDOWPOS_UNDEFINED ; 3rd argument - 1fff0000H mov rdx, r8 ; 2nd argument - 1fff0000H lea rcx, OFFSET WINDOW_TITLE ; 1st argument - Window title call SDL_CreateWindow cmp rax, 0 je SDLERROR mov pWindow, rax ; Save the handle ; Get Window surface mov rcx, rax call SDL_GetWindowSurface mov pScreenSurface, rax ; Call to SDL_MapRGB mov r9, 0ffh mov r8, 0ffh mov rdx, 0ffh mov rcx, (SDL_Surface PTR[rax]).format ; Cast to SDL structure call SDL_MapRGB ; Fill the surface with white color mov r8, rax ; Result of SDL_MapRGB mov rdx, 0 mov rcx, pScreenSurface call SDL_FillRect ; Update the surface mov rcx, pWindow call SDL_UpdateWindowSurface ; Wait to seconds mov rcx, 2000 ; 2 seconds call SDL_Delay ; Destroy the window mov rcx, pWindow call SDL_DestroyWindow SDLERROR: ; Quit the subsystem call SDL_Quit EXIT: mov rax, 0 call ExitProcess main endp END
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %r8 push %r9 push %rdx push %rsi lea addresses_WC_ht+0x55c8, %r8 nop cmp $55016, %rsi movw $0x6162, (%r8) nop nop nop nop add %r11, %r11 lea addresses_normal_ht+0x78c8, %r9 clflush (%r9) nop nop cmp %rsi, %rsi vmovups (%r9), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $1, %xmm0, %r15 nop nop nop nop inc %r15 lea addresses_A_ht+0x126f8, %r8 nop nop inc %r13 mov $0x6162636465666768, %rdx movq %rdx, %xmm3 and $0xffffffffffffffc0, %r8 movntdq %xmm3, (%r8) nop nop nop cmp $58679, %r13 lea addresses_WT_ht+0xf62a, %r8 nop nop nop nop nop sub %r15, %r15 movb $0x61, (%r8) nop nop xor %r15, %r15 lea addresses_WT_ht+0x16d12, %rsi nop nop nop dec %r9 mov (%rsi), %r8d add $33981, %r8 pop %rsi pop %rdx pop %r9 pop %r8 pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %rbp push %rdi push %rsi // Store lea addresses_D+0xe2c8, %r13 nop nop inc %r11 movl $0x51525354, (%r13) xor %r12, %r12 // Store lea addresses_UC+0x1d6bc, %rsi nop nop nop nop add $39334, %r10 movw $0x5152, (%rsi) nop xor %r10, %r10 // Faulty Load lea addresses_WC+0x3fc8, %r10 nop nop nop sub %rdi, %rdi mov (%r10), %ebp lea oracles, %rsi and $0xff, %rbp shlq $12, %rbp mov (%rsi,%rbp,1), %rbp pop %rsi pop %rdi pop %rbp pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} {'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 2, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 8, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
; ; Z88dk Generic Floating Point Math Library ; ; fraction add c ix de += (hl) ; ; $Id: fradd.asm,v 1.2 2012/04/17 16:37:46 stefano Exp $: XLIB fradd .FRADD LD A,(HL) ADD A,E LD E,A INC HL LD A,(HL) ADC A,D LD D,A INC HL LD A,(HL) ADC A,IXL LD IXL,A INC HL LD A,(HL) ADC A,IXH LD IXH,A INC HL LD A,(HL) ADC A,C LD C,A RET
#include <iostream> #include "drink_shop_protocol.hpp" int main(int argc, char const *argv[]) { /* code */ class drink_shop_protocol p1; char *b1 = "hello"; std::cout << p1; p1.set_command(DRINK_SHOP_PROTO_CMD_ORDER); p1.set_result(-ENAVAIL); p1.set_body(b1); p1.set_body_length(strlen(b1)); std::cout << p1; class drink_shop_protocol p2(DRINK_SHOP_PROTO_CMD_ORDER,0,16); std::cout << p2; char *b3 = "world"; class drink_shop_protocol p3(DRINK_SHOP_PROTO_CMD_ORDER,0,strlen(b3),b3); std::cout << p3; return 0; }
; A193361: a(0)=0, a(1)=0; for n>1, a(n) = a(n-1) + (n-3)*a(n-2) + 1. ; Submitted by Jon Maiga ; 0,0,1,2,4,9,22,59,170,525,1716,5917,21362,80533,315516,1281913,5383622,23330405,104084736,477371217,2246811730,10839493637,53528916508,270318789249,1394426035918,7341439399397,39413238225512,215607783811041,1200938739448842,6806741118535909,39232087083654644,229820838402660097,1367551363828644774,8262176515908447685,50656268794596435680,315045917303666761601,1986702787525349139042,12698263975850019033477,82232861539237238899948,539370364669837924105121,3581986241621615763403198 add $0,1 lpb $0 sub $0,2 lpb $0 sub $0,1 add $3,$4 sub $4,$3 add $3,1 mul $4,$2 sub $2,1 lpe lpe mov $0,$3
; A097806: Riordan array (1+x, 1) read by rows. ; 1,1,1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 lpb $0 add $1,$2 add $2,1 sub $0,$2 trn $1,$0 lpe cmp $1,0 mov $0,$1
;/**************************************************************************** ; * ; * XVID MPEG-4 VIDEO CODEC ; * - MMX and XMM forward discrete cosine transform - ; * ; * Copyright(C) 2002 Pascal Massimino <[email protected]> ; * ; * This program is free software; you can redistribute it and/or modify it ; * under the terms of the GNU General Public License as published by ; * the Free Software Foundation; either version 2 of the License, or ; * (at your option) any later version. ; * ; * This program is distributed in the hope that it will be useful, ; * but WITHOUT ANY WARRANTY; without even the implied warranty of ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; * GNU General Public License for more details. ; * ; * You should have received a copy of the GNU General Public License ; * along with this program; if not, write to the Free Software ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; * ; * $Id: fdct_mmx_skal.asm,v 1.12 2009-09-16 17:07:58 Isibaar Exp $ ; * ; ***************************************************************************/ %include "nasm.inc" ;;; Define this if you want an unrolled version of the code %define UNROLLED_LOOP ;============================================================================= ; ; Vertical pass is an implementation of the scheme: ; Loeffler C., Ligtenberg A., and Moschytz C.S.: ; Practical Fast 1D DCT Algorithm with Eleven Multiplications, ; Proc. ICASSP 1989, 988-991. ; ; Horizontal pass is a double 4x4 vector/matrix multiplication, ; (see also Intel's Application Note 922: ; http://developer.intel.com/vtune/cbts/strmsimd/922down.htm ; Copyright (C) 1999 Intel Corporation) ; ; Notes: ; * tan(3pi/16) is greater than 0.5, and would use the ; sign bit when turned into 16b fixed-point precision. So, ; we use the trick: x*tan3 = x*(tan3-1)+x ; ; * There's only one SSE-specific instruction (pshufw). ; Porting to SSE2 also seems straightforward. ; ; * There's still 1 or 2 ticks to save in fLLM_PASS, but ; I prefer having a readable code, instead of a tightly ; scheduled one... ; ; * Quantization stage (as well as pre-transposition for the ; idct way back) can be included in the fTab* constants ; (with induced loss of precision, somehow) ; ; * Some more details at: http://skal.planet-d.net/coding/dct.html ; ;============================================================================= ; ; idct-like IEEE errors: ; ; ========================= ; Peak error: 1.0000 ; Peak MSE: 0.0365 ; Overall MSE: 0.0201 ; Peak ME: 0.0265 ; Overall ME: 0.0006 ; ; == Mean square errors == ; 0.000 0.001 0.001 0.002 0.000 0.002 0.001 0.000 [0.001] ; 0.035 0.029 0.032 0.032 0.031 0.032 0.034 0.035 [0.032] ; 0.026 0.028 0.027 0.027 0.025 0.028 0.028 0.025 [0.027] ; 0.037 0.032 0.031 0.030 0.028 0.029 0.026 0.031 [0.030] ; 0.000 0.001 0.001 0.002 0.000 0.002 0.001 0.001 [0.001] ; 0.025 0.024 0.022 0.022 0.022 0.022 0.023 0.023 [0.023] ; 0.026 0.028 0.025 0.028 0.030 0.025 0.026 0.027 [0.027] ; 0.021 0.020 0.020 0.022 0.020 0.022 0.017 0.019 [0.020] ; ; == Abs Mean errors == ; 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [0.000] ; 0.020 0.001 0.003 0.003 0.000 0.004 0.002 0.003 [0.002] ; 0.000 0.001 0.001 0.001 0.001 0.004 0.000 0.000 [0.000] ; 0.027 0.001 0.000 0.002 0.002 0.002 0.001 0.000 [0.003] ; 0.000 0.000 0.000 0.000 0.000 0.001 0.000 0.001 [-0.000] ; 0.001 0.003 0.001 0.001 0.002 0.001 0.000 0.000 [-0.000] ; 0.000 0.002 0.002 0.001 0.001 0.002 0.001 0.000 [-0.000] ; 0.000 0.002 0.001 0.002 0.001 0.002 0.001 0.001 [-0.000] ; ;============================================================================= ;============================================================================= ; Read only data ;============================================================================= DATA ALIGN SECTION_ALIGN tan1: dw 0x32ec,0x32ec,0x32ec,0x32ec ; tan( pi/16) tan2: dw 0x6a0a,0x6a0a,0x6a0a,0x6a0a ; tan(2pi/16) (=sqrt(2)-1) tan3: dw 0xab0e,0xab0e,0xab0e,0xab0e ; tan(3pi/16)-1 sqrt2: dw 0x5a82,0x5a82,0x5a82,0x5a82 ; 0.5/sqrt(2) ALIGN SECTION_ALIGN fdct_table: ;fTab1: dw 0x4000, 0x4000, 0x58c5, 0x4b42 dw 0x4000, 0x4000, 0x3249, 0x11a8 dw 0x539f, 0x22a3, 0x4b42, 0xee58 dw 0xdd5d, 0xac61, 0xa73b, 0xcdb7 dw 0x4000, 0xc000, 0x3249, 0xa73b dw 0xc000, 0x4000, 0x11a8, 0x4b42 dw 0x22a3, 0xac61, 0x11a8, 0xcdb7 dw 0x539f, 0xdd5d, 0x4b42, 0xa73b ;fTab2: dw 0x58c5, 0x58c5, 0x7b21, 0x6862 dw 0x58c5, 0x58c5, 0x45bf, 0x187e dw 0x73fc, 0x300b, 0x6862, 0xe782 dw 0xcff5, 0x8c04, 0x84df, 0xba41 dw 0x58c5, 0xa73b, 0x45bf, 0x84df dw 0xa73b, 0x58c5, 0x187e, 0x6862 dw 0x300b, 0x8c04, 0x187e, 0xba41 dw 0x73fc, 0xcff5, 0x6862, 0x84df ;fTab3: dw 0x539f, 0x539f, 0x73fc, 0x6254 dw 0x539f, 0x539f, 0x41b3, 0x1712 dw 0x6d41, 0x2d41, 0x6254, 0xe8ee dw 0xd2bf, 0x92bf, 0x8c04, 0xbe4d dw 0x539f, 0xac61, 0x41b3, 0x8c04 dw 0xac61, 0x539f, 0x1712, 0x6254 dw 0x2d41, 0x92bf, 0x1712, 0xbe4d dw 0x6d41, 0xd2bf, 0x6254, 0x8c04 ;fTab4: dw 0x4b42, 0x4b42, 0x6862, 0x587e dw 0x4b42, 0x4b42, 0x3b21, 0x14c3 dw 0x6254, 0x28ba, 0x587e, 0xeb3d dw 0xd746, 0x9dac, 0x979e, 0xc4df dw 0x4b42, 0xb4be, 0x3b21, 0x979e dw 0xb4be, 0x4b42, 0x14c3, 0x587e dw 0x28ba, 0x9dac, 0x14c3, 0xc4df dw 0x6254, 0xd746, 0x587e, 0x979e ;fTab1: dw 0x4000, 0x4000, 0x58c5, 0x4b42 dw 0x4000, 0x4000, 0x3249, 0x11a8 dw 0x539f, 0x22a3, 0x4b42, 0xee58 dw 0xdd5d, 0xac61, 0xa73b, 0xcdb7 dw 0x4000, 0xc000, 0x3249, 0xa73b dw 0xc000, 0x4000, 0x11a8, 0x4b42 dw 0x22a3, 0xac61, 0x11a8, 0xcdb7 dw 0x539f, 0xdd5d, 0x4b42, 0xa73b ;fTab4: dw 0x4b42, 0x4b42, 0x6862, 0x587e dw 0x4b42, 0x4b42, 0x3b21, 0x14c3 dw 0x6254, 0x28ba, 0x587e, 0xeb3d dw 0xd746, 0x9dac, 0x979e, 0xc4df dw 0x4b42, 0xb4be, 0x3b21, 0x979e dw 0xb4be, 0x4b42, 0x14c3, 0x587e dw 0x28ba, 0x9dac, 0x14c3, 0xc4df dw 0x6254, 0xd746, 0x587e, 0x979e ;fTab3: dw 0x539f, 0x539f, 0x73fc, 0x6254 dw 0x539f, 0x539f, 0x41b3, 0x1712 dw 0x6d41, 0x2d41, 0x6254, 0xe8ee dw 0xd2bf, 0x92bf, 0x8c04, 0xbe4d dw 0x539f, 0xac61, 0x41b3, 0x8c04 dw 0xac61, 0x539f, 0x1712, 0x6254 dw 0x2d41, 0x92bf, 0x1712, 0xbe4d dw 0x6d41, 0xd2bf, 0x6254, 0x8c04 ;fTab2: dw 0x58c5, 0x58c5, 0x7b21, 0x6862 dw 0x58c5, 0x58c5, 0x45bf, 0x187e dw 0x73fc, 0x300b, 0x6862, 0xe782 dw 0xcff5, 0x8c04, 0x84df, 0xba41 dw 0x58c5, 0xa73b, 0x45bf, 0x84df dw 0xa73b, 0x58c5, 0x187e, 0x6862 dw 0x300b, 0x8c04, 0x187e, 0xba41 dw 0x73fc, 0xcff5, 0x6862, 0x84df ALIGN SECTION_ALIGN fdct_rounding_1: dw 6, 8, 8, 8 dw 10, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 dw 6, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 ALIGN SECTION_ALIGN fdct_rounding_2: dw 6, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 dw 6, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 dw 8, 8, 8, 8 ALIGN SECTION_ALIGN MMX_One: dw 1, 1, 1, 1 ;============================================================================= ; Helper Macros for real code ;============================================================================= ;----------------------------------------------------------------------------- ; FDCT LLM vertical pass (~39c) ; %1=dst, %2=src, %3:Shift ;----------------------------------------------------------------------------- %macro fLLM_PASS 3 movq mm0, [%2+0*16] ; In0 movq mm2, [%2+2*16] ; In2 movq mm3, mm0 movq mm4, mm2 movq mm7, [%2+7*16] ; In7 movq mm5, [%2+5*16] ; In5 psubsw mm0, mm7 ; t7 = In0-In7 paddsw mm7, mm3 ; t0 = In0+In7 psubsw mm2, mm5 ; t5 = In2-In5 paddsw mm5, mm4 ; t2 = In2+In5 movq mm3, [%2+3*16] ; In3 movq mm4, [%2+4*16] ; In4 movq mm1, mm3 psubsw mm3, mm4 ; t4 = In3-In4 paddsw mm4, mm1 ; t3 = In3+In4 movq mm6, [%2+6*16] ; In6 movq mm1, [%2+1*16] ; In1 psubsw mm1, mm6 ; t6 = In1-In6 paddsw mm6, [%2+1*16] ; t1 = In1+In6 psubsw mm7, mm4 ; tm03 = t0-t3 psubsw mm6, mm5 ; tm12 = t1-t2 paddsw mm4, mm4 ; 2.t3 paddsw mm5, mm5 ; 2.t2 paddsw mm4, mm7 ; tp03 = t0+t3 paddsw mm5, mm6 ; tp12 = t1+t2 psllw mm2, %3+1 ; shift t5 (shift +1 to.. psllw mm1, %3+1 ; shift t6 ..compensate cos4/2) psllw mm4, %3 ; shift t3 psllw mm5, %3 ; shift t2 psllw mm7, %3 ; shift t0 psllw mm6, %3 ; shift t1 psllw mm3, %3 ; shift t4 psllw mm0, %3 ; shift t7 psubsw mm4, mm5 ; out4 = tp03-tp12 psubsw mm1, mm2 ; mm1: t6-t5 paddsw mm5, mm5 paddsw mm2, mm2 paddsw mm5, mm4 ; out0 = tp03+tp12 movq [%1+4*16], mm4 ; => out4 paddsw mm2, mm1 ; mm2: t6+t5 movq [%1+0*16], mm5 ; => out0 movq mm4, [tan2] ; mm4 <= tan2 pmulhw mm4, mm7 ; tm03*tan2 movq mm5, [tan2] ; mm5 <= tan2 psubsw mm4, mm6 ; out6 = tm03*tan2 - tm12 pmulhw mm5, mm6 ; tm12*tan2 paddsw mm5, mm7 ; out2 = tm12*tan2 + tm03 movq mm6, [sqrt2] movq mm7, [MMX_One] pmulhw mm2, mm6 ; mm2: tp65 = (t6 + t5)*cos4 por mm5, mm7 ; correct out2 por mm4, mm7 ; correct out6 pmulhw mm1, mm6 ; mm1: tm65 = (t6 - t5)*cos4 por mm2, mm7 ; correct tp65 movq [%1+2*16], mm5 ; => out2 movq mm5, mm3 ; save t4 movq [%1+6*16], mm4 ; => out6 movq mm4, mm0 ; save t7 psubsw mm3, mm1 ; mm3: tm465 = t4 - tm65 psubsw mm0, mm2 ; mm0: tm765 = t7 - tp65 paddsw mm2, mm4 ; mm2: tp765 = t7 + tp65 paddsw mm1, mm5 ; mm1: tp465 = t4 + tm65 movq mm4, [tan3] ; tan3 - 1 movq mm5, [tan1] ; tan1 movq mm7, mm3 ; save tm465 pmulhw mm3, mm4 ; tm465*(tan3-1) movq mm6, mm1 ; save tp465 pmulhw mm1, mm5 ; tp465*tan1 paddsw mm3, mm7 ; tm465*tan3 pmulhw mm4, mm0 ; tm765*(tan3-1) paddsw mm4, mm0 ; tm765*tan3 pmulhw mm5, mm2 ; tp765*tan1 paddsw mm1, mm2 ; out1 = tp765 + tp465*tan1 psubsw mm0, mm3 ; out3 = tm765 - tm465*tan3 paddsw mm7, mm4 ; out5 = tm465 + tm765*tan3 psubsw mm5, mm6 ; out7 =-tp465 + tp765*tan1 movq [%1+1*16], mm1 ; => out1 movq [%1+3*16], mm0 ; => out3 movq [%1+5*16], mm7 ; => out5 movq [%1+7*16], mm5 ; => out7 %endmacro ;----------------------------------------------------------------------------- ; fMTX_MULT_XMM (~20c) ; %1=dst, %2=src, %3 = Coeffs, %4/%5=rounders ;----------------------------------------------------------------------------- %macro fMTX_MULT_XMM 5 movq mm0, [%2 + 0] ; mm0 = [0123] ; the 'pshufw' below is the only SSE instruction. ; For MMX-only version, it should be emulated with ; some 'punpck' soup... pshufw mm1, [%2 + 8], 00011011b ; mm1 = [7654] movq mm7, mm0 paddsw mm0, mm1 ; mm0 = [a0 a1 a2 a3] psubsw mm7, mm1 ; mm7 = [b0 b1 b2 b3] movq mm1, mm0 punpckldq mm0, mm7 ; mm0 = [a0 a1 b0 b1] punpckhdq mm1, mm7 ; mm1 = [b2 b3 a2 a3] movq mm2, qword [%3 + 0] ; [ M00 M01 M16 M17] movq mm3, qword [%3 + 8] ; [ M02 M03 M18 M19] pmaddwd mm2, mm0 ; [a0.M00+a1.M01 | b0.M16+b1.M17] movq mm4, qword [%3 + 16] ; [ M04 M05 M20 M21] pmaddwd mm3, mm1 ; [a2.M02+a3.M03 | b2.M18+b3.M19] movq mm5, qword [%3 + 24] ; [ M06 M07 M22 M23] pmaddwd mm4, mm0 ; [a0.M04+a1.M05 | b0.M20+b1.M21] movq mm6, qword [%3 + 32] ; [ M08 M09 M24 M25] pmaddwd mm5, mm1 ; [a2.M06+a3.M07 | b2.M22+b3.M23] movq mm7, qword [%3 + 40] ; [ M10 M11 M26 M27] pmaddwd mm6, mm0 ; [a0.M08+a1.M09 | b0.M24+b1.M25] paddd mm2, mm3 ; [ out0 | out1 ] pmaddwd mm7, mm1 ; [a0.M10+a1.M11 | b0.M26+b1.M27] psrad mm2, 16 pmaddwd mm0, [%3 + 48] ; [a0.M12+a1.M13 | b0.M28+b1.M29] paddd mm4, mm5 ; [ out2 | out3 ] pmaddwd mm1, [%3 + 56] ; [a0.M14+a1.M15 | b0.M30+b1.M31] psrad mm4, 16 paddd mm6, mm7 ; [ out4 | out5 ] psrad mm6, 16 paddd mm0, mm1 ; [ out6 | out7 ] psrad mm0, 16 packssdw mm2, mm4 ; [ out0|out1|out2|out3 ] paddsw mm2, [%4] ; Round packssdw mm6, mm0 ; [ out4|out5|out6|out7 ] paddsw mm6, [%5] ; Round psraw mm2, 4 ; => [-2048, 2047] psraw mm6, 4 movq [%1 + 0], mm2 movq [%1 + 8], mm6 %endmacro ;----------------------------------------------------------------------------- ; fMTX_MULT_MMX (~22c) ; %1=dst, %2=src, %3 = Coeffs, %4/%5=rounders ;----------------------------------------------------------------------------- %macro fMTX_MULT_MMX 5 ; MMX-only version (no 'pshufw'. ~10% overall slower than SSE) movd mm1, [%2 + 8 + 4] ; [67..] movq mm0, [%2 + 0] ; mm0 = [0123] movq mm7, mm0 punpcklwd mm1, [%2 + 8] ; [6475] movq mm2, mm1 psrlq mm1, 32 ; [75..] punpcklwd mm1,mm2 ; [7654] paddsw mm0, mm1 ; mm0 = [a0 a1 a2 a3] psubsw mm7, mm1 ; mm7 = [b0 b1 b2 b3] movq mm1, mm0 punpckldq mm0, mm7 ; mm0 = [a0 a1 b0 b1] punpckhdq mm1, mm7 ; mm1 = [b2 b3 a2 a3] movq mm2, qword [%3 + 0] ; [ M00 M01 M16 M17] movq mm3, qword [%3 + 8] ; [ M02 M03 M18 M19] pmaddwd mm2, mm0 ; [a0.M00+a1.M01 | b0.M16+b1.M17] movq mm4, qword [%3 + 16] ; [ M04 M05 M20 M21] pmaddwd mm3, mm1 ; [a2.M02+a3.M03 | b2.M18+b3.M19] movq mm5, qword [%3 + 24] ; [ M06 M07 M22 M23] pmaddwd mm4, mm0 ; [a0.M04+a1.M05 | b0.M20+b1.M21] movq mm6, qword [%3 + 32] ; [ M08 M09 M24 M25] pmaddwd mm5, mm1 ; [a2.M06+a3.M07 | b2.M22+b3.M23] movq mm7, qword [%3 + 40] ; [ M10 M11 M26 M27] pmaddwd mm6, mm0 ; [a0.M08+a1.M09 | b0.M24+b1.M25] paddd mm2, mm3 ; [ out0 | out1 ] pmaddwd mm7, mm1 ; [a0.M10+a1.M11 | b0.M26+b1.M27] psrad mm2, 16 pmaddwd mm0, [%3 + 48] ; [a0.M12+a1.M13 | b0.M28+b1.M29] paddd mm4, mm5 ; [ out2 | out3 ] pmaddwd mm1, [%3 + 56] ; [a0.M14+a1.M15 | b0.M30+b1.M31] psrad mm4, 16 paddd mm6, mm7 ; [ out4 | out5 ] psrad mm6, 16 paddd mm0, mm1 ; [ out6 | out7 ] psrad mm0, 16 packssdw mm2, mm4 ; [ out0|out1|out2|out3 ] paddsw mm2, [%4] ; Round packssdw mm6, mm0 ; [ out4|out5|out6|out7 ] paddsw mm6, [%5] ; Round psraw mm2, 4 ; => [-2048, 2047] psraw mm6, 4 movq [%1 + 0], mm2 movq [%1 + 8], mm6 %endmacro ;----------------------------------------------------------------------------- ; MAKE_FDCT_FUNC ; %1 funcname, %2 macro for row dct ;----------------------------------------------------------------------------- %macro MAKE_FDCT_FUNC 2 ALIGN SECTION_ALIGN cglobal %1 %1: mov TMP0, prm1 %ifndef UNROLLED_LOOP push _EBX push _EDI %endif fLLM_PASS TMP0+0, TMP0+0, 3 fLLM_PASS TMP0+8, TMP0+8, 3 %ifdef UNROLLED_LOOP %assign i 0 %rep 8 %2 TMP0+i*16, TMP0+i*16, fdct_table+i*64, fdct_rounding_1+i*8, fdct_rounding_2+i*8 %assign i i+1 %endrep %else mov _EAX, 8 mov TMP1, fdct_table mov _EBX, fdct_rounding_1 mov _EDI, fdct_rounding_2 .loop %2 TMP0, TMP0, TMP1, _EBX, _EDI add TMP0, 2*8 add TMP1, 2*32 add _EBX, 2*4 add _EDI, 2*4 dec _EAX jne .loop pop _EDI pop _EBX %endif ret ENDFUNC %endmacro ;============================================================================= ; Code ;============================================================================= TEXT ;----------------------------------------------------------------------------- ; void fdct_mmx_skal(int16_t block[64]]; ;----------------------------------------------------------------------------- MAKE_FDCT_FUNC fdct_mmx_skal, fMTX_MULT_MMX ;----------------------------------------------------------------------------- ; void fdct_xmm_skal(int16_t block[64]]; ;----------------------------------------------------------------------------- MAKE_FDCT_FUNC fdct_xmm_skal, fMTX_MULT_XMM NON_EXEC_STACK
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x179a9, %r10 nop nop and %r12, %r12 movl $0x61626364, (%r10) nop nop nop nop nop and $19898, %r13 lea addresses_D_ht+0x1e601, %rdx nop nop nop nop dec %rax movb (%rdx), %r13b cmp %r12, %r12 lea addresses_A_ht+0x13c01, %r9 nop nop and %rsi, %rsi movb (%r9), %dl nop cmp %r9, %r9 lea addresses_A_ht+0xbb75, %r12 nop nop xor $62764, %r13 and $0xffffffffffffffc0, %r12 vmovntdqa (%r12), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rax nop nop sub %r13, %r13 lea addresses_WT_ht+0x15001, %r13 nop nop nop nop nop and %r10, %r10 movw $0x6162, (%r13) nop nop nop nop nop dec %rsi lea addresses_A_ht+0x16e11, %rsi clflush (%rsi) nop nop nop nop nop add $59970, %r12 mov (%rsi), %r9 nop nop nop sub $7227, %r13 lea addresses_A_ht+0x5401, %rdx nop nop nop cmp $48646, %r9 and $0xffffffffffffffc0, %rdx movaps (%rdx), %xmm7 vpextrq $1, %xmm7, %r13 nop nop nop xor $26662, %r13 lea addresses_UC_ht+0x9101, %rsi lea addresses_D_ht+0x15f01, %rdi nop nop nop nop nop cmp %rax, %rax mov $19, %rcx rep movsw nop nop lfence lea addresses_A_ht+0x13201, %rsi lea addresses_UC_ht+0x1d3d1, %rdi clflush (%rsi) nop nop sub %r10, %r10 mov $106, %rcx rep movsl nop nop nop xor %rdx, %rdx lea addresses_A_ht+0xf8b1, %rdx clflush (%rdx) nop nop nop nop nop xor %r13, %r13 movw $0x6162, (%rdx) nop nop add $5996, %r12 lea addresses_normal_ht+0xc201, %rax nop nop xor $18197, %rdx movl $0x61626364, (%rax) nop and $51237, %rdx lea addresses_UC_ht+0x1b881, %rsi lea addresses_WT_ht+0x8271, %rdi nop nop nop nop nop inc %r12 mov $16, %rcx rep movsw nop nop nop xor $54660, %rdx lea addresses_WC_ht+0x1159b, %rsi lea addresses_WC_ht+0x1ca1, %rdi nop nop nop nop and $6612, %rax mov $46, %rcx rep movsq nop nop nop nop dec %rsi lea addresses_WT_ht+0x2581, %rsi lea addresses_A_ht+0xd6b5, %rdi nop nop nop nop nop add $36440, %r9 mov $127, %rcx rep movsq dec %rdi lea addresses_A_ht+0x647f, %rsi lea addresses_D_ht+0x36c1, %rdi nop nop inc %r10 mov $43, %rcx rep movsw nop nop nop nop dec %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r8 push %r9 push %rbp push %rdi push %rsi // Store lea addresses_WT+0x3a41, %r14 clflush (%r14) nop cmp %rbp, %rbp mov $0x5152535455565758, %rdi movq %rdi, (%r14) nop nop nop dec %rdi // Load lea addresses_WC+0x4201, %r9 nop nop cmp %r14, %r14 mov (%r9), %ebp nop nop dec %rdi // Faulty Load lea addresses_normal+0x9201, %rdi clflush (%rdi) nop nop nop inc %rsi mov (%rdi), %r8 lea oracles, %rsi and $0xff, %r8 shlq $12, %r8 mov (%rsi,%r8,1), %r8 pop %rsi pop %rdi pop %rbp pop %r9 pop %r8 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 11}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': True, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 4}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
#include <bits/stdc++.h> #define each(i, c) for (auto& i : c) #define unless(cond) if (!(cond)) using namespace std; typedef long long int lli; typedef unsigned long long ull; typedef complex<double> point; template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; while (cin >> h >> w) { char g[h][w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> g[i][j]; } } int mn_h = 1 << 29; int mn_w = 1 << 29; int mx_h = -1; int mx_w = -1; int cnt = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (g[i][j] == 'B') { ++cnt; mn_h = min(mn_h, i); mn_w = min(mn_w, j); mx_h = max(mx_h, i); mx_w = max(mx_w, j); } } } const int inf = 1 << 29; int mn = inf; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { for (int k = 0; i + k < h && j + k < w; ++k) { pair<int, int> a = make_pair(i, j); pair<int, int> b = make_pair(i + k, j + k); if (a.first <= mn_h && a.second <= mn_w && mx_h <= b.first && mx_w <= b.second) { mn = min(mn, (k + 1) * (k + 1) - cnt); } } } } if (cnt == 0) mn = 1; cout << (mn == inf ? -1 : mn) << endl; } return 0; }
/* Siconos is a program dedicated to modeling, simulation and control * of non smooth dynamical systems. * * Copyright 2016 INRIA. * * 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 "Disk.hpp" void Disk::MassSetup() { _mass.reset(new SimpleMatrix(_ndof, _ndof)); // mass->resize(ndof,ndof); _mass->zero(); (*_mass)(0, 0) = (*_mass)(1, 1) = massValue; (*_mass)(2, 2) = massValue * radius * radius / 2.; } Disk::Disk(double r, double m, SP::SiconosVector qinit, SP::SiconosVector vinit) : CircularDS(r, m, qinit, vinit) { MassSetup(); } Disk::~Disk() {}
/* Copyright 2013-2018 MultiMC Contributors * * 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 "StatusChecker.h" #include <net/URLConstants.h> #include <QByteArray> #include <QDebug> StatusChecker::StatusChecker() { } void StatusChecker::timerEvent(QTimerEvent *e) { QObject::timerEvent(e); reloadStatus(); } void StatusChecker::reloadStatus() { if (isLoadingStatus()) { // qDebug() << "Ignored request to reload status. Currently reloading already."; return; } // qDebug() << "Reloading status."; NetJob* job = new NetJob("Status JSON"); job->addNetAction(Net::Download::makeByteArray(URLConstants::MOJANG_STATUS_URL, &dataSink)); QObject::connect(job, &NetJob::succeeded, this, &StatusChecker::statusDownloadFinished); QObject::connect(job, &NetJob::failed, this, &StatusChecker::statusDownloadFailed); m_statusNetJob.reset(job); emit statusLoading(true); job->start(); } void StatusChecker::statusDownloadFinished() { qDebug() << "Finished loading status JSON."; m_statusEntries.clear(); m_statusNetJob.reset(); QJsonParseError jsonError; QJsonDocument jsonDoc = QJsonDocument::fromJson(dataSink, &jsonError); if (jsonError.error != QJsonParseError::NoError) { fail("Error parsing status JSON:" + jsonError.errorString()); return; } if (!jsonDoc.isArray()) { fail("Error parsing status JSON: JSON root is not an array"); return; } QJsonArray root = jsonDoc.array(); for(auto status = root.begin(); status != root.end(); ++status) { QVariantMap map = (*status).toObject().toVariantMap(); for (QVariantMap::const_iterator iter = map.begin(); iter != map.end(); ++iter) { QString key = iter.key(); QVariant value = iter.value(); if(value.type() == QVariant::Type::String) { m_statusEntries.insert(key, value.toString()); //qDebug() << "Status JSON object: " << key << m_statusEntries[key]; } else { fail("Malformed status JSON: expected status type to be a string."); return; } } } succeed(); } void StatusChecker::statusDownloadFailed(QString reason) { fail(tr("Failed to load status JSON:\n%1").arg(reason)); } QMap<QString, QString> StatusChecker::getStatusEntries() const { return m_statusEntries; } bool StatusChecker::isLoadingStatus() const { return m_statusNetJob.get() != nullptr; } QString StatusChecker::getLastLoadErrorMsg() const { return m_lastLoadError; } void StatusChecker::succeed() { if(m_prevEntries != m_statusEntries) { emit statusChanged(m_statusEntries); m_prevEntries = m_statusEntries; } m_lastLoadError = ""; qDebug() << "Status loading succeeded."; m_statusNetJob.reset(); emit statusLoading(false); } void StatusChecker::fail(const QString& errorMsg) { if(m_prevEntries != m_statusEntries) { emit statusChanged(m_statusEntries); m_prevEntries = m_statusEntries; } m_lastLoadError = errorMsg; qDebug() << "Failed to load status:" << errorMsg; m_statusNetJob.reset(); emit statusLoading(false); }
/* * Copyright (c) 2016, The OpenThread Authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file * This file implements the CLI interpreter. */ #include "cli.hpp" #ifdef OTDLL #include <assert.h> #endif #include <stdio.h> #include <stdlib.h> #include "mac/channel_mask.hpp" #include "utils/parse_cmdline.hpp" #include "utils/wrap_string.h" #include <openthread/commissioner.h> #include <openthread/icmp6.h> #include <openthread/joiner.h> #include <openthread/link.h> #include <openthread/ncp.h> #include <openthread/thread.h> #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC #include <openthread/network_time.h> #endif #if OPENTHREAD_FTD #include <openthread/dataset_ftd.h> #include <openthread/thread_ftd.h> #endif #if OPENTHREAD_ENABLE_BORDER_ROUTER #include <openthread/border_router.h> #endif #if OPENTHREAD_ENABLE_SERVICE #include <openthread/server.h> #endif #ifndef OTDLL #include <openthread/diag.h> #include <openthread/icmp6.h> #include <openthread/platform/uart.h> #include "common/new.hpp" #include "net/ip6.hpp" #endif #include "cli_dataset.hpp" #if OPENTHREAD_ENABLE_APPLICATION_COAP #include "cli_coap.hpp" #endif #if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE #include "cli_coap_secure.hpp" #endif #if OPENTHREAD_ENABLE_CHANNEL_MANAGER && OPENTHREAD_FTD #include <openthread/channel_manager.h> #endif #if OPENTHREAD_ENABLE_CHANNEL_MONITOR #include <openthread/channel_monitor.h> #endif #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && OPENTHREAD_POSIX #include <openthread/platform/debug_uart.h> #endif #include "cli_server.hpp" #include "common/encoding.hpp" using ot::Encoding::BigEndian::HostSwap16; using ot::Encoding::BigEndian::HostSwap32; namespace ot { namespace Cli { const struct Command Interpreter::sCommands[] = { {"help", &Interpreter::ProcessHelp}, {"autostart", &Interpreter::ProcessAutoStart}, {"bufferinfo", &Interpreter::ProcessBufferInfo}, {"channel", &Interpreter::ProcessChannel}, #if OPENTHREAD_FTD {"child", &Interpreter::ProcessChild}, {"childip", &Interpreter::ProcessChildIp}, {"childmax", &Interpreter::ProcessChildMax}, #endif {"childtimeout", &Interpreter::ProcessChildTimeout}, #if OPENTHREAD_ENABLE_APPLICATION_COAP {"coap", &Interpreter::ProcessCoap}, #endif #if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE {"coaps", &Interpreter::ProcessCoapSecure}, #endif #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD {"commissioner", &Interpreter::ProcessCommissioner}, #endif #if OPENTHREAD_FTD {"contextreusedelay", &Interpreter::ProcessContextIdReuseDelay}, #endif {"counters", &Interpreter::ProcessCounters}, {"dataset", &Interpreter::ProcessDataset}, #if OPENTHREAD_FTD {"delaytimermin", &Interpreter::ProcessDelayTimerMin}, #endif #if OPENTHREAD_ENABLE_DIAG {"diag", &Interpreter::ProcessDiag}, #endif {"discover", &Interpreter::ProcessDiscover}, #if OPENTHREAD_ENABLE_DNS_CLIENT {"dns", &Interpreter::ProcessDns}, #endif #if OPENTHREAD_FTD {"eidcache", &Interpreter::ProcessEidCache}, #endif {"eui64", &Interpreter::ProcessEui64}, #if OPENTHREAD_POSIX {"exit", &Interpreter::ProcessExit}, #endif #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && OPENTHREAD_POSIX {"logfilename", &Interpreter::ProcessLogFilename}, #endif {"extaddr", &Interpreter::ProcessExtAddress}, {"extpanid", &Interpreter::ProcessExtPanId}, {"factoryreset", &Interpreter::ProcessFactoryReset}, {"ifconfig", &Interpreter::ProcessIfconfig}, #ifdef OTDLL {"instance", &Interpreter::ProcessInstance}, {"instancelist", &Interpreter::ProcessInstanceList}, #endif {"ipaddr", &Interpreter::ProcessIpAddr}, #ifndef OTDLL {"ipmaddr", &Interpreter::ProcessIpMulticastAddr}, #endif #if OPENTHREAD_ENABLE_JOINER {"joiner", &Interpreter::ProcessJoiner}, {"joinerid", &Interpreter::ProcessJoinerId}, #endif #if OPENTHREAD_FTD {"joinerport", &Interpreter::ProcessJoinerPort}, #endif {"keysequence", &Interpreter::ProcessKeySequence}, {"leaderdata", &Interpreter::ProcessLeaderData}, #if OPENTHREAD_FTD {"leaderpartitionid", &Interpreter::ProcessLeaderPartitionId}, {"leaderweight", &Interpreter::ProcessLeaderWeight}, #endif #if OPENTHREAD_ENABLE_MAC_FILTER {"macfilter", &Interpreter::ProcessMacFilter}, #endif {"masterkey", &Interpreter::ProcessMasterKey}, {"mode", &Interpreter::ProcessMode}, #if OPENTHREAD_FTD {"neighbor", &Interpreter::ProcessNeighbor}, #endif #if OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE {"netdataregister", &Interpreter::ProcessNetworkDataRegister}, #endif #if OPENTHREAD_ENABLE_SERVICE {"netdatashow", &Interpreter::ProcessNetworkDataShow}, #endif #if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC {"networkdiagnostic", &Interpreter::ProcessNetworkDiagnostic}, #endif // OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC #if OPENTHREAD_FTD {"networkidtimeout", &Interpreter::ProcessNetworkIdTimeout}, #endif {"networkname", &Interpreter::ProcessNetworkName}, #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC {"networktime", &Interpreter::ProcessNetworkTime}, #endif {"panid", &Interpreter::ProcessPanId}, {"parent", &Interpreter::ProcessParent}, #if OPENTHREAD_FTD {"parentpriority", &Interpreter::ProcessParentPriority}, #endif #ifndef OTDLL {"ping", &Interpreter::ProcessPing}, #endif {"pollperiod", &Interpreter::ProcessPollPeriod}, #ifndef OTDLL {"promiscuous", &Interpreter::ProcessPromiscuous}, #endif #if OPENTHREAD_ENABLE_BORDER_ROUTER {"prefix", &Interpreter::ProcessPrefix}, #endif #if OPENTHREAD_FTD {"pskc", &Interpreter::ProcessPSKc}, {"releaserouterid", &Interpreter::ProcessReleaseRouterId}, #endif {"reset", &Interpreter::ProcessReset}, {"rloc16", &Interpreter::ProcessRloc16}, #if OPENTHREAD_ENABLE_BORDER_ROUTER {"route", &Interpreter::ProcessRoute}, #endif #if OPENTHREAD_FTD {"router", &Interpreter::ProcessRouter}, {"routerdowngradethreshold", &Interpreter::ProcessRouterDowngradeThreshold}, {"routerrole", &Interpreter::ProcessRouterRole}, {"routerselectionjitter", &Interpreter::ProcessRouterSelectionJitter}, {"routerupgradethreshold", &Interpreter::ProcessRouterUpgradeThreshold}, #endif {"scan", &Interpreter::ProcessScan}, #if OPENTHREAD_ENABLE_SERVICE {"service", &Interpreter::ProcessService}, #endif {"singleton", &Interpreter::ProcessSingleton}, #if OPENTHREAD_ENABLE_SNTP_CLIENT {"sntp", &Interpreter::ProcessSntp}, #endif {"state", &Interpreter::ProcessState}, {"thread", &Interpreter::ProcessThread}, #ifndef OTDLL {"txpower", &Interpreter::ProcessTxPower}, {"udp", &Interpreter::ProcessUdp}, #endif {"version", &Interpreter::ProcessVersion}, }; #ifdef OTDLL uint32_t otPlatRandomGet(void) { return (uint32_t)rand(); } #else void otFreeMemory(const void *) { // No-op on systems running OpenThread in-proc } #endif template <class T> class otPtr { T *ptr; public: explicit otPtr(T *_ptr) : ptr(_ptr) { } ~otPtr() { if (ptr) { otFreeMemory(ptr); } } T *get() const { return ptr; } operator T *() const { return ptr; } T *operator->() const { return ptr; } }; typedef otPtr<const otMacCounters> otMacCountersPtr; typedef otPtr<const otMleCounters> otMleCountersPtr; typedef otPtr<const otNetifAddress> otNetifAddressPtr; typedef otPtr<const uint8_t> otBufferPtr; typedef otPtr<const char> otStringPtr; Interpreter::Interpreter(Instance *aInstance) : mUserCommands(NULL) , mUserCommandsLength(0) , mServer(NULL) #ifdef OTDLL , mApiInstance(otApiInit()) , mInstanceIndex(0) #else , mLength(8) , mCount(1) , mInterval(1000) , mPingTimer(*aInstance, &Interpreter::s_HandlePingTimer, this) #if OPENTHREAD_ENABLE_DNS_CLIENT , mResolvingInProgress(0) #endif , mUdp(*this) #endif , mDataset(*this) #if OPENTHREAD_ENABLE_APPLICATION_COAP , mCoap(*this) #endif #if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE , mCoapSecure(*this) #endif , mInstance(aInstance) { #ifdef OTDLL // On Windows, mInstance represents the current selected otInstance // which should be NULL now. assert(aInstance = NULL); assert(mApiInstance); CacheInstances(); #else #if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC otThreadSetReceiveDiagnosticGetCallback(mInstance, &Interpreter::s_HandleDiagnosticGetResponse, this); #endif mIcmpHandler.mReceiveCallback = Interpreter::s_HandleIcmpReceive; mIcmpHandler.mContext = this; otIcmp6RegisterHandler(mInstance, &mIcmpHandler); #if OPENTHREAD_ENABLE_DNS_CLIENT memset(mResolvingHostname, 0, sizeof(mResolvingHostname)); #endif // OPENTHREAD_ENABLE_DNS_CLIENT #endif } int Interpreter::Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength) { size_t hexLength = strlen(aHex); const char *hexEnd = aHex + hexLength; uint8_t * cur = aBin; uint8_t numChars = hexLength & 1; uint8_t byte = 0; int rval; VerifyOrExit((hexLength + 1) / 2 <= aBinLength, rval = -1); while (aHex < hexEnd) { if ('A' <= *aHex && *aHex <= 'F') { byte |= 10 + (*aHex - 'A'); } else if ('a' <= *aHex && *aHex <= 'f') { byte |= 10 + (*aHex - 'a'); } else if ('0' <= *aHex && *aHex <= '9') { byte |= *aHex - '0'; } else { ExitNow(rval = -1); } aHex++; numChars++; if (numChars >= 2) { numChars = 0; *cur++ = byte; byte = 0; } else { byte <<= 4; } } rval = static_cast<int>(cur - aBin); exit: return rval; } void Interpreter::AppendResult(otError aError) const { if (aError == OT_ERROR_NONE) { mServer->OutputFormat("Done\r\n"); } else { mServer->OutputFormat("Error %d: %s\r\n", aError, otThreadErrorToString(aError)); } } void Interpreter::OutputBytes(const uint8_t *aBytes, uint8_t aLength) const { for (int i = 0; i < aLength; i++) { mServer->OutputFormat("%02x", aBytes[i]); } } otError Interpreter::ParseLong(char *aString, long &aLong) { char *endptr; aLong = strtol(aString, &endptr, 0); return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE; } otError Interpreter::ParseUnsignedLong(char *aString, unsigned long &aUnsignedLong) { char *endptr; aUnsignedLong = strtoul(aString, &endptr, 0); return (*endptr == '\0') ? OT_ERROR_NONE : OT_ERROR_PARSE; } otError Interpreter::ParsePingInterval(const char *aString, uint32_t &aInterval) { otError error = OT_ERROR_NONE; const uint32_t msFactor = 1000; uint32_t factor = msFactor; aInterval = 0; while (*aString) { if ('0' <= *aString && *aString <= '9') { // In the case of seconds, change the base of already calculated value. if (factor == msFactor) { aInterval *= 10; } aInterval += static_cast<uint32_t>(*aString - '0') * factor; // In the case of milliseconds, change the multiplier factor. if (factor != msFactor) { factor /= 10; } } else if (*aString == '.') { // Accept only one dot character. VerifyOrExit(factor == msFactor, error = OT_ERROR_PARSE); // Start analyzing hundreds of milliseconds. factor /= 10; } else { ExitNow(error = OT_ERROR_PARSE); } aString++; } exit: return error; } void Interpreter::ProcessHelp(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); for (unsigned int i = 0; i < OT_ARRAY_LENGTH(sCommands); i++) { mServer->OutputFormat("%s\r\n", sCommands[i].mName); } for (unsigned int i = 0; i < mUserCommandsLength; i++) { mServer->OutputFormat("%s\r\n", mUserCommands[i].mName); } } void Interpreter::ProcessAutoStart(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { if (otThreadGetAutoStart(mInstance)) { mServer->OutputFormat("Enabled\r\n"); } else { mServer->OutputFormat("Disabled\r\n"); } } else if (strcmp(argv[0], "enable") == 0) { error = otThreadSetAutoStart(mInstance, true); } else if (strcmp(argv[0], "disable") == 0) { error = otThreadSetAutoStart(mInstance, false); } else { error = OT_ERROR_INVALID_ARGS; } AppendResult(error); } void Interpreter::ProcessBufferInfo(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otBufferInfo bufferInfo; otMessageGetBufferInfo(mInstance, &bufferInfo); mServer->OutputFormat("total: %d\r\n", bufferInfo.mTotalBuffers); mServer->OutputFormat("free: %d\r\n", bufferInfo.mFreeBuffers); mServer->OutputFormat("6lo send: %d %d\r\n", bufferInfo.m6loSendMessages, bufferInfo.m6loSendBuffers); mServer->OutputFormat("6lo reas: %d %d\r\n", bufferInfo.m6loReassemblyMessages, bufferInfo.m6loReassemblyBuffers); mServer->OutputFormat("ip6: %d %d\r\n", bufferInfo.mIp6Messages, bufferInfo.mIp6Buffers); mServer->OutputFormat("mpl: %d %d\r\n", bufferInfo.mMplMessages, bufferInfo.mMplBuffers); mServer->OutputFormat("mle: %d %d\r\n", bufferInfo.mMleMessages, bufferInfo.mMleBuffers); mServer->OutputFormat("arp: %d %d\r\n", bufferInfo.mArpMessages, bufferInfo.mArpBuffers); mServer->OutputFormat("coap: %d %d\r\n", bufferInfo.mCoapMessages, bufferInfo.mCoapBuffers); mServer->OutputFormat("coap secure: %d %d\r\n", bufferInfo.mCoapSecureMessages, bufferInfo.mCoapSecureBuffers); mServer->OutputFormat("application coap: %d %d\r\n", bufferInfo.mApplicationCoapMessages, bufferInfo.mApplicationCoapBuffers); AppendResult(OT_ERROR_NONE); } void Interpreter::ProcessChannel(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otLinkGetChannel(mInstance)); } #if OPENTHREAD_ENABLE_CHANNEL_MONITOR else if (strcmp(argv[0], "monitor") == 0) { if (argc == 1) { mServer->OutputFormat("enabled: %d\r\n", otChannelMonitorIsEnabled(mInstance)); if (otChannelMonitorIsEnabled(mInstance)) { uint32_t channelMask = otLinkGetSupportedChannelMask(mInstance); uint8_t channelNum = sizeof(channelMask) * CHAR_BIT; mServer->OutputFormat("interval: %lu\r\n", otChannelMonitorGetSampleInterval(mInstance)); mServer->OutputFormat("threshold: %d\r\n", otChannelMonitorGetRssiThreshold(mInstance)); mServer->OutputFormat("window: %lu\r\n", otChannelMonitorGetSampleWindow(mInstance)); mServer->OutputFormat("count: %lu\r\n", otChannelMonitorGetSampleCount(mInstance)); mServer->OutputFormat("occupancies:\r\n"); for (uint8_t channel = 0; channel < channelNum; channel++) { uint32_t occupancy = 0; if (!((1UL << channel) & channelMask)) { continue; } occupancy = otChannelMonitorGetChannelOccupancy(mInstance, channel); mServer->OutputFormat("ch %d (0x%04x) ", channel, occupancy); occupancy = (occupancy * 10000) / 0xffff; mServer->OutputFormat("%2d.%02d%% busy\r\n", occupancy / 100, occupancy % 100); } mServer->OutputFormat("\r\n"); } } else if (strcmp(argv[1], "start") == 0) { error = otChannelMonitorSetEnabled(mInstance, true); } else if (strcmp(argv[1], "stop") == 0) { error = otChannelMonitorSetEnabled(mInstance, false); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } #endif #if OPENTHREAD_ENABLE_CHANNEL_MANAGER && OPENTHREAD_FTD else if (strcmp(argv[0], "manager") == 0) { if (argc == 1) { mServer->OutputFormat("channel: %d\r\n", otChannelManagerGetRequestedChannel(mInstance)); mServer->OutputFormat("auto: %d\r\n", otChannelManagerGetAutoChannelSelectionEnabled(mInstance)); if (otChannelManagerGetAutoChannelSelectionEnabled(mInstance)) { Mac::ChannelMask supportedMask(otChannelManagerGetSupportedChannels(mInstance)); Mac::ChannelMask favoredMask(otChannelManagerGetFavoredChannels(mInstance)); mServer->OutputFormat("delay: %d\r\n", otChannelManagerGetDelay(mInstance)); mServer->OutputFormat("interval: %lu\r\n", otChannelManagerGetAutoChannelSelectionInterval(mInstance)); mServer->OutputFormat("supported: %s\r\n", supportedMask.ToString().AsCString()); mServer->OutputFormat("favored: %s\r\n", supportedMask.ToString().AsCString()); } } else if (strcmp(argv[1], "change") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); otChannelManagerRequestChannelChange(mInstance, static_cast<uint8_t>(value)); } else if (strcmp(argv[1], "select") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); error = otChannelManagerRequestChannelSelect(mInstance, (value != 0) ? true : false); } else if (strcmp(argv[1], "auto") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); otChannelManagerSetAutoChannelSelectionEnabled(mInstance, (value != 0) ? true : false); } else if (strcmp(argv[1], "delay") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); error = otChannelManagerSetDelay(mInstance, static_cast<uint8_t>(value)); } else if (strcmp(argv[1], "interval") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); error = otChannelManagerSetAutoChannelSelectionInterval(mInstance, static_cast<uint32_t>(value)); } else if (strcmp(argv[1], "supported") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); otChannelManagerSetSupportedChannels(mInstance, static_cast<uint32_t>(value)); } else if (strcmp(argv[1], "favored") == 0) { VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); otChannelManagerSetFavoredChannels(mInstance, static_cast<uint32_t>(value)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } #endif else { SuccessOrExit(error = ParseLong(argv[0], value)); error = otLinkSetChannel(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } #if OPENTHREAD_FTD void Interpreter::ProcessChild(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otChildInfo childInfo; long value; bool isTable; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); isTable = (strcmp(argv[0], "table") == 0); if (isTable || strcmp(argv[0], "list") == 0) { uint8_t maxChildren; if (isTable) { mServer->OutputFormat( "| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|S|D|N| Extended MAC |\r\n"); mServer->OutputFormat( "+-----+--------+------------+------------+-------+------+-+-+-+-+------------------+\r\n"); } maxChildren = otThreadGetMaxAllowedChildren(mInstance); for (uint8_t i = 0; i < maxChildren; i++) { if ((otThreadGetChildInfoByIndex(mInstance, i, &childInfo) != OT_ERROR_NONE) || childInfo.mIsStateRestoring) { continue; } if (isTable) { mServer->OutputFormat("| %3d ", childInfo.mChildId); mServer->OutputFormat("| 0x%04x ", childInfo.mRloc16); mServer->OutputFormat("| %10d ", childInfo.mTimeout); mServer->OutputFormat("| %10d ", childInfo.mAge); mServer->OutputFormat("| %5d ", childInfo.mLinkQualityIn); mServer->OutputFormat("| %4d ", childInfo.mNetworkDataVersion); mServer->OutputFormat("|%1d", childInfo.mRxOnWhenIdle); mServer->OutputFormat("|%1d", childInfo.mSecureDataRequest); mServer->OutputFormat("|%1d", childInfo.mFullThreadDevice); mServer->OutputFormat("|%1d", childInfo.mFullNetworkData); mServer->OutputFormat("| "); for (size_t j = 0; j < sizeof(childInfo.mExtAddress); j++) { mServer->OutputFormat("%02x", childInfo.mExtAddress.m8[j]); } mServer->OutputFormat(" |\r\n"); } else { mServer->OutputFormat("%d ", childInfo.mChildId); } } mServer->OutputFormat("\r\n"); ExitNow(); } SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otThreadGetChildInfoById(mInstance, static_cast<uint16_t>(value), &childInfo)); mServer->OutputFormat("Child ID: %d\r\n", childInfo.mChildId); mServer->OutputFormat("Rloc: %04x\r\n", childInfo.mRloc16); mServer->OutputFormat("Ext Addr: "); for (size_t j = 0; j < sizeof(childInfo.mExtAddress); j++) { mServer->OutputFormat("%02x", childInfo.mExtAddress.m8[j]); } mServer->OutputFormat("\r\n"); mServer->OutputFormat("Mode: "); if (childInfo.mRxOnWhenIdle) { mServer->OutputFormat("r"); } if (childInfo.mSecureDataRequest) { mServer->OutputFormat("s"); } if (childInfo.mFullThreadDevice) { mServer->OutputFormat("d"); } if (childInfo.mFullNetworkData) { mServer->OutputFormat("n"); } mServer->OutputFormat("\r\n"); mServer->OutputFormat("Net Data: %d\r\n", childInfo.mNetworkDataVersion); mServer->OutputFormat("Timeout: %d\r\n", childInfo.mTimeout); mServer->OutputFormat("Age: %d\r\n", childInfo.mAge); mServer->OutputFormat("Link Quality In: %d\r\n", childInfo.mLinkQualityIn); mServer->OutputFormat("RSSI: %d\r\n", childInfo.mAverageRssi); exit: AppendResult(error); } void Interpreter::ProcessChildIp(int argc, char *argv[]) { otError error = OT_ERROR_NONE; uint8_t maxChildren; VerifyOrExit(argc == 0, error = OT_ERROR_INVALID_ARGS); maxChildren = otThreadGetMaxAllowedChildren(mInstance); for (uint8_t childIndex = 0; childIndex < maxChildren; childIndex++) { otChildIp6AddressIterator iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT; otIp6Address ip6Address; otChildInfo childInfo; if ((otThreadGetChildInfoByIndex(mInstance, childIndex, &childInfo) != OT_ERROR_NONE) || childInfo.mIsStateRestoring) { continue; } iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT; while (otThreadGetChildNextIp6Address(mInstance, childIndex, &iterator, &ip6Address) == OT_ERROR_NONE) { mServer->OutputFormat("%04x: %x:%x:%x:%x:%x:%x:%x:%x\r\n", childInfo.mRloc16, HostSwap16(ip6Address.mFields.m16[0]), HostSwap16(ip6Address.mFields.m16[1]), HostSwap16(ip6Address.mFields.m16[2]), HostSwap16(ip6Address.mFields.m16[3]), HostSwap16(ip6Address.mFields.m16[4]), HostSwap16(ip6Address.mFields.m16[5]), HostSwap16(ip6Address.mFields.m16[6]), HostSwap16(ip6Address.mFields.m16[7])); } } exit: OT_UNUSED_VARIABLE(argv); AppendResult(error); } void Interpreter::ProcessChildMax(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetMaxAllowedChildren(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otThreadSetMaxAllowedChildren(mInstance, static_cast<uint8_t>(value))); } exit: AppendResult(error); } #endif // OPENTHREAD_FTD void Interpreter::ProcessChildTimeout(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetChildTimeout(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); otThreadSetChildTimeout(mInstance, static_cast<uint32_t>(value)); } exit: AppendResult(error); } #if OPENTHREAD_ENABLE_APPLICATION_COAP void Interpreter::ProcessCoap(int argc, char *argv[]) { otError error; error = mCoap.Process(argc, argv); AppendResult(error); } #endif // OPENTHREAD_ENABLE_APPLICATION_COAP #if OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE void Interpreter::ProcessCoapSecure(int argc, char *argv[]) { otError error; error = mCoapSecure.Process(argc, argv); AppendResult(error); } #endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE #if OPENTHREAD_FTD void Interpreter::ProcessContextIdReuseDelay(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetContextIdReuseDelay(mInstance)); } else { SuccessOrExit(ParseLong(argv[0], value)); otThreadSetContextIdReuseDelay(mInstance, static_cast<uint32_t>(value)); } exit: AppendResult(error); } #endif // OPENTHREAD_FTD void Interpreter::ProcessCounters(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { mServer->OutputFormat("mac\r\n"); mServer->OutputFormat("mle\r\n"); } else if (argc == 1) { if (strcmp(argv[0], "mac") == 0) { otMacCountersPtr macCounters(otLinkGetCounters(mInstance)); mServer->OutputFormat("TxTotal: %d\r\n", macCounters->mTxTotal); mServer->OutputFormat(" TxUnicast: %d\r\n", macCounters->mTxUnicast); mServer->OutputFormat(" TxBroadcast: %d\r\n", macCounters->mTxBroadcast); mServer->OutputFormat(" TxAckRequested: %d\r\n", macCounters->mTxAckRequested); mServer->OutputFormat(" TxAcked: %d\r\n", macCounters->mTxAcked); mServer->OutputFormat(" TxNoAckRequested: %d\r\n", macCounters->mTxNoAckRequested); mServer->OutputFormat(" TxData: %d\r\n", macCounters->mTxData); mServer->OutputFormat(" TxDataPoll: %d\r\n", macCounters->mTxDataPoll); mServer->OutputFormat(" TxBeacon: %d\r\n", macCounters->mTxBeacon); mServer->OutputFormat(" TxBeaconRequest: %d\r\n", macCounters->mTxBeaconRequest); mServer->OutputFormat(" TxOther: %d\r\n", macCounters->mTxOther); mServer->OutputFormat(" TxRetry: %d\r\n", macCounters->mTxRetry); mServer->OutputFormat(" TxErrCca: %d\r\n", macCounters->mTxErrCca); mServer->OutputFormat(" TxErrBusyChannel: %d\r\n", macCounters->mTxErrBusyChannel); mServer->OutputFormat("RxTotal: %d\r\n", macCounters->mRxTotal); mServer->OutputFormat(" RxUnicast: %d\r\n", macCounters->mRxUnicast); mServer->OutputFormat(" RxBroadcast: %d\r\n", macCounters->mRxBroadcast); mServer->OutputFormat(" RxData: %d\r\n", macCounters->mRxData); mServer->OutputFormat(" RxDataPoll: %d\r\n", macCounters->mRxDataPoll); mServer->OutputFormat(" RxBeacon: %d\r\n", macCounters->mRxBeacon); mServer->OutputFormat(" RxBeaconRequest: %d\r\n", macCounters->mRxBeaconRequest); mServer->OutputFormat(" RxOther: %d\r\n", macCounters->mRxOther); mServer->OutputFormat(" RxAddressFiltered: %d\r\n", macCounters->mRxAddressFiltered); mServer->OutputFormat(" RxDestAddrFiltered: %d\r\n", macCounters->mRxDestAddrFiltered); mServer->OutputFormat(" RxDuplicated: %d\r\n", macCounters->mRxDuplicated); mServer->OutputFormat(" RxErrNoFrame: %d\r\n", macCounters->mRxErrNoFrame); mServer->OutputFormat(" RxErrNoUnknownNeighbor: %d\r\n", macCounters->mRxErrUnknownNeighbor); mServer->OutputFormat(" RxErrInvalidSrcAddr: %d\r\n", macCounters->mRxErrInvalidSrcAddr); mServer->OutputFormat(" RxErrSec: %d\r\n", macCounters->mRxErrSec); mServer->OutputFormat(" RxErrFcs: %d\r\n", macCounters->mRxErrFcs); mServer->OutputFormat(" RxErrOther: %d\r\n", macCounters->mRxErrOther); } else if (strcmp(argv[0], "mle") == 0) { otMleCountersPtr mleCounters(otThreadGetMleCounters(mInstance)); mServer->OutputFormat("Role Disabled: %d\r\n", mleCounters->mDisabledRole); mServer->OutputFormat("Role Detached: %d\r\n", mleCounters->mDetachedRole); mServer->OutputFormat("Role Child: %d\r\n", mleCounters->mChildRole); mServer->OutputFormat("Role Router: %d\r\n", mleCounters->mRouterRole); mServer->OutputFormat("Role Leader: %d\r\n", mleCounters->mLeaderRole); mServer->OutputFormat("Attach Attempts: %d\r\n", mleCounters->mAttachAttempts); mServer->OutputFormat("Partition Id Changes: %d\r\n", mleCounters->mPartitionIdChanges); mServer->OutputFormat("Better Partition Attach Attempts: %d\r\n", mleCounters->mBetterPartitionAttachAttempts); mServer->OutputFormat("Parent Changes: %d\r\n", mleCounters->mParentChanges); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #if OPENTHREAD_FTD void Interpreter::ProcessDelayTimerMin(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { mServer->OutputFormat("%d\r\n", (otDatasetGetDelayTimerMinimal(mInstance) / 1000)); } else if (argc == 1) { unsigned long value; SuccessOrExit(error = ParseUnsignedLong(argv[0], value)); SuccessOrExit(error = otDatasetSetDelayTimerMinimal(mInstance, static_cast<uint32_t>(value * 1000))); } else { error = OT_ERROR_INVALID_ARGS; } exit: AppendResult(error); } #endif void Interpreter::ProcessDiscover(int argc, char *argv[]) { otError error = OT_ERROR_NONE; uint32_t scanChannels = 0; long value; if (argc > 0) { SuccessOrExit(error = ParseLong(argv[0], value)); VerifyOrExit((0 <= value) && (value < static_cast<long>(sizeof(scanChannels) * CHAR_BIT)), error = OT_ERROR_INVALID_ARGS); scanChannels = 1 << value; } SuccessOrExit(error = otThreadDiscover(mInstance, scanChannels, OT_PANID_BROADCAST, false, false, &Interpreter::s_HandleActiveScanResult, this)); mServer->OutputFormat("| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |\r\n"); mServer->OutputFormat("+---+------------------+------------------+------+------------------+----+-----+-----+\r\n"); return; exit: AppendResult(error); } #if OPENTHREAD_ENABLE_DNS_CLIENT void Interpreter::ProcessDns(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long port = OT_DNS_DEFAULT_SERVER_PORT; Ip6::MessageInfo messageInfo; otDnsQuery query; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "resolve") == 0) { VerifyOrExit(!mResolvingInProgress, error = OT_ERROR_BUSY); VerifyOrExit(argc > 1, error = OT_ERROR_INVALID_ARGS); VerifyOrExit(strlen(argv[1]) < OT_DNS_MAX_HOSTNAME_LENGTH, error = OT_ERROR_INVALID_ARGS); strcpy(mResolvingHostname, argv[1]); messageInfo.mInterfaceId = OT_NETIF_INTERFACE_ID_THREAD; if (argc > 2) { SuccessOrExit(error = messageInfo.GetPeerAddr().FromString(argv[2])); } else { // Use IPv6 address of default DNS server. SuccessOrExit(error = messageInfo.GetPeerAddr().FromString(OT_DNS_DEFAULT_SERVER_IP)); } if (argc > 3) { SuccessOrExit(error = ParseLong(argv[3], port)); } messageInfo.SetPeerPort(static_cast<uint16_t>(port)); query.mHostname = mResolvingHostname; query.mMessageInfo = static_cast<const otMessageInfo *>(&messageInfo); query.mNoRecursion = false; SuccessOrExit(error = otDnsClientQuery(mInstance, &query, &Interpreter::s_HandleDnsResponse, this)); mResolvingInProgress = true; } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: if (error != OT_ERROR_NONE) { AppendResult(error); } } void Interpreter::s_HandleDnsResponse(void * aContext, const char * aHostname, otIp6Address *aAddress, uint32_t aTtl, otError aResult) { static_cast<Interpreter *>(aContext)->HandleDnsResponse(aHostname, *static_cast<Ip6::Address *>(aAddress), aTtl, aResult); } void Interpreter::HandleDnsResponse(const char *aHostname, Ip6::Address &aAddress, uint32_t aTtl, otError aResult) { mServer->OutputFormat("DNS response for %s - ", aHostname); if (aResult == OT_ERROR_NONE) { mServer->OutputFormat("[%x:%x:%x:%x:%x:%x:%x:%x] TTL: %d\r\n", HostSwap16(aAddress.mFields.m16[0]), HostSwap16(aAddress.mFields.m16[1]), HostSwap16(aAddress.mFields.m16[2]), HostSwap16(aAddress.mFields.m16[3]), HostSwap16(aAddress.mFields.m16[4]), HostSwap16(aAddress.mFields.m16[5]), HostSwap16(aAddress.mFields.m16[6]), HostSwap16(aAddress.mFields.m16[7]), aTtl); } else { AppendResult(aResult); } mResolvingInProgress = false; } #endif #if OPENTHREAD_FTD void Interpreter::ProcessEidCache(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otEidCacheEntry entry; for (uint8_t i = 0;; i++) { SuccessOrExit(otThreadGetEidCacheEntry(mInstance, i, &entry)); if (entry.mValid == false) { continue; } mServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x %04x\r\n", HostSwap16(entry.mTarget.mFields.m16[0]), HostSwap16(entry.mTarget.mFields.m16[1]), HostSwap16(entry.mTarget.mFields.m16[2]), HostSwap16(entry.mTarget.mFields.m16[3]), HostSwap16(entry.mTarget.mFields.m16[4]), HostSwap16(entry.mTarget.mFields.m16[5]), HostSwap16(entry.mTarget.mFields.m16[6]), HostSwap16(entry.mTarget.mFields.m16[7]), entry.mRloc16); } exit: AppendResult(OT_ERROR_NONE); } #endif // OPENTHREAD_FTD void Interpreter::ProcessEui64(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; otExtAddress extAddress; VerifyOrExit(argc == 0, error = OT_ERROR_INVALID_ARGS); otLinkGetFactoryAssignedIeeeEui64(mInstance, &extAddress); OutputBytes(extAddress.m8, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat("\r\n"); exit: AppendResult(error); } void Interpreter::ProcessExtAddress(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { otBufferPtr extAddress(reinterpret_cast<const uint8_t *>(otLinkGetExtendedAddress(mInstance))); OutputBytes(extAddress, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat("\r\n"); } else { otExtAddress extAddress; VerifyOrExit(Hex2Bin(argv[0], extAddress.m8, sizeof(otExtAddress)) >= 0, error = OT_ERROR_PARSE); error = otLinkSetExtendedAddress(mInstance, &extAddress); } exit: AppendResult(error); } #if OPENTHREAD_POSIX void Interpreter::ProcessExit(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); exit(EXIT_SUCCESS); } #endif #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && OPENTHREAD_POSIX void Interpreter::ProcessLogFilename(int argc, char *argv[]) { otError error = OT_ERROR_NONE; VerifyOrExit(argc == 1, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otPlatDebugUart_logfile(argv[0])); exit: AppendResult(error); } #endif void Interpreter::ProcessExtPanId(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { otBufferPtr extPanId(reinterpret_cast<const uint8_t *>(otThreadGetExtendedPanId(mInstance))); OutputBytes(extPanId, OT_EXT_PAN_ID_SIZE); mServer->OutputFormat("\r\n"); } else { otExtendedPanId extPanId; VerifyOrExit(Hex2Bin(argv[0], extPanId.m8, sizeof(extPanId)) >= 0, error = OT_ERROR_PARSE); error = otThreadSetExtendedPanId(mInstance, &extPanId); } exit: AppendResult(error); } void Interpreter::ProcessFactoryReset(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otInstanceFactoryReset(mInstance); } void Interpreter::ProcessIfconfig(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { if (otIp6IsEnabled(mInstance)) { mServer->OutputFormat("up\r\n"); } else { mServer->OutputFormat("down\r\n"); } } else if (strcmp(argv[0], "up") == 0) { SuccessOrExit(error = otIp6SetEnabled(mInstance, true)); } else if (strcmp(argv[0], "down") == 0) { SuccessOrExit(error = otIp6SetEnabled(mInstance, false)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } otError Interpreter::ProcessIpAddrAdd(int argc, char *argv[]) { otError error; otNetifAddress aAddress; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otIp6AddressFromString(argv[0], &aAddress.mAddress)); aAddress.mPrefixLength = 64; aAddress.mPreferred = true; aAddress.mValid = true; error = otIp6AddUnicastAddress(mInstance, &aAddress); exit: return error; } otError Interpreter::ProcessIpAddrDel(int argc, char *argv[]) { otError error; struct otIp6Address address; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otIp6AddressFromString(argv[0], &address)); error = otIp6RemoveUnicastAddress(mInstance, &address); exit: return error; } void Interpreter::ProcessIpAddr(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { otNetifAddressPtr unicastAddrs(otIp6GetUnicastAddresses(mInstance)); for (const otNetifAddress *addr = unicastAddrs; addr; addr = addr->mNext) { mServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x\r\n", HostSwap16(addr->mAddress.mFields.m16[0]), HostSwap16(addr->mAddress.mFields.m16[1]), HostSwap16(addr->mAddress.mFields.m16[2]), HostSwap16(addr->mAddress.mFields.m16[3]), HostSwap16(addr->mAddress.mFields.m16[4]), HostSwap16(addr->mAddress.mFields.m16[5]), HostSwap16(addr->mAddress.mFields.m16[6]), HostSwap16(addr->mAddress.mFields.m16[7])); } } else { if (strcmp(argv[0], "add") == 0) { SuccessOrExit(error = ProcessIpAddrAdd(argc - 1, argv + 1)); } else if (strcmp(argv[0], "del") == 0) { SuccessOrExit(error = ProcessIpAddrDel(argc - 1, argv + 1)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } exit: AppendResult(error); } #ifndef OTDLL otError Interpreter::ProcessIpMulticastAddrAdd(int argc, char *argv[]) { otError error; struct otIp6Address address; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otIp6AddressFromString(argv[0], &address)); error = otIp6SubscribeMulticastAddress(mInstance, &address); exit: return error; } otError Interpreter::ProcessIpMulticastAddrDel(int argc, char *argv[]) { otError error; struct otIp6Address address; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otIp6AddressFromString(argv[0], &address)); error = otIp6UnsubscribeMulticastAddress(mInstance, &address); exit: return error; } otError Interpreter::ProcessMulticastPromiscuous(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { if (otIp6IsMulticastPromiscuousEnabled(mInstance)) { mServer->OutputFormat("Enabled\r\n"); } else { mServer->OutputFormat("Disabled\r\n"); } } else { if (strcmp(argv[0], "enable") == 0) { otIp6SetMulticastPromiscuousEnabled(mInstance, true); } else if (strcmp(argv[0], "disable") == 0) { otIp6SetMulticastPromiscuousEnabled(mInstance, false); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } exit: return error; } void Interpreter::ProcessIpMulticastAddr(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { for (const otNetifMulticastAddress *addr = otIp6GetMulticastAddresses(mInstance); addr; addr = addr->mNext) { mServer->OutputFormat("%x:%x:%x:%x:%x:%x:%x:%x\r\n", HostSwap16(addr->mAddress.mFields.m16[0]), HostSwap16(addr->mAddress.mFields.m16[1]), HostSwap16(addr->mAddress.mFields.m16[2]), HostSwap16(addr->mAddress.mFields.m16[3]), HostSwap16(addr->mAddress.mFields.m16[4]), HostSwap16(addr->mAddress.mFields.m16[5]), HostSwap16(addr->mAddress.mFields.m16[6]), HostSwap16(addr->mAddress.mFields.m16[7])); } } else { if (strcmp(argv[0], "add") == 0) { SuccessOrExit(error = ProcessIpMulticastAddrAdd(argc - 1, argv + 1)); } else if (strcmp(argv[0], "del") == 0) { SuccessOrExit(error = ProcessIpMulticastAddrDel(argc - 1, argv + 1)); } else if (strcmp(argv[0], "promiscuous") == 0) { SuccessOrExit(error = ProcessMulticastPromiscuous(argc - 1, argv + 1)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } exit: AppendResult(error); } #endif void Interpreter::ProcessKeySequence(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; VerifyOrExit(argc == 1 || argc == 2, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "counter") == 0) { if (argc == 1) { mServer->OutputFormat("%d\r\n", otThreadGetKeySequenceCounter(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[1], value)); otThreadSetKeySequenceCounter(mInstance, static_cast<uint32_t>(value)); } } else if (strcmp(argv[0], "guardtime") == 0) { if (argc == 1) { mServer->OutputFormat("%d\r\n", otThreadGetKeySwitchGuardTime(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[1], value)); otThreadSetKeySwitchGuardTime(mInstance, static_cast<uint32_t>(value)); } } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } void Interpreter::ProcessLeaderData(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error; otLeaderData leaderData; SuccessOrExit(error = otThreadGetLeaderData(mInstance, &leaderData)); mServer->OutputFormat("Partition ID: %u\r\n", leaderData.mPartitionId); mServer->OutputFormat("Weighting: %d\r\n", leaderData.mWeighting); mServer->OutputFormat("Data Version: %d\r\n", leaderData.mDataVersion); mServer->OutputFormat("Stable Data Version: %d\r\n", leaderData.mStableDataVersion); mServer->OutputFormat("Leader Router ID: %d\r\n", leaderData.mLeaderRouterId); exit: AppendResult(error); } #if OPENTHREAD_FTD void Interpreter::ProcessLeaderPartitionId(int argc, char *argv[]) { otError error = OT_ERROR_NONE; unsigned long value; if (argc == 0) { mServer->OutputFormat("%u\r\n", otThreadGetLocalLeaderPartitionId(mInstance)); } else { SuccessOrExit(error = ParseUnsignedLong(argv[0], value)); otThreadSetLocalLeaderPartitionId(mInstance, static_cast<uint32_t>(value)); } exit: AppendResult(error); } void Interpreter::ProcessLeaderWeight(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetLocalLeaderWeight(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); otThreadSetLocalLeaderWeight(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } #endif // OPENTHREAD_FTD #if OPENTHREAD_FTD void Interpreter::ProcessPSKc(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { const otPSKc *pskc = otThreadGetPSKc(mInstance); for (int i = 0; i < OT_PSKC_MAX_SIZE; i++) { mServer->OutputFormat("%02x", pskc->m8[i]); } mServer->OutputFormat("\r\n"); } else { otPSKc pskc; VerifyOrExit(Hex2Bin(argv[0], pskc.m8, sizeof(pskc)) == OT_PSKC_MAX_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otThreadSetPSKc(mInstance, &pskc)); } exit: AppendResult(error); } #endif void Interpreter::ProcessMasterKey(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { otBufferPtr key(reinterpret_cast<const uint8_t *>(otThreadGetMasterKey(mInstance))); for (int i = 0; i < OT_MASTER_KEY_SIZE; i++) { mServer->OutputFormat("%02x", key[i]); } mServer->OutputFormat("\r\n"); } else { otMasterKey key; VerifyOrExit(Hex2Bin(argv[0], key.m8, sizeof(key.m8)) == OT_MASTER_KEY_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otThreadSetMasterKey(mInstance, &key)); } exit: AppendResult(error); } void Interpreter::ProcessMode(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otLinkModeConfig linkMode; memset(&linkMode, 0, sizeof(otLinkModeConfig)); if (argc == 0) { linkMode = otThreadGetLinkMode(mInstance); if (linkMode.mRxOnWhenIdle) { mServer->OutputFormat("r"); } if (linkMode.mSecureDataRequests) { mServer->OutputFormat("s"); } if (linkMode.mDeviceType) { mServer->OutputFormat("d"); } if (linkMode.mNetworkData) { mServer->OutputFormat("n"); } mServer->OutputFormat("\r\n"); } else { for (char *arg = argv[0]; *arg != '\0'; arg++) { switch (*arg) { case 'r': linkMode.mRxOnWhenIdle = 1; break; case 's': linkMode.mSecureDataRequests = 1; break; case 'd': linkMode.mDeviceType = 1; break; case 'n': linkMode.mNetworkData = 1; break; default: ExitNow(error = OT_ERROR_PARSE); } } SuccessOrExit(error = otThreadSetLinkMode(mInstance, linkMode)); } exit: AppendResult(error); } #if OPENTHREAD_FTD void Interpreter::ProcessNeighbor(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otNeighborInfo neighborInfo; bool isTable; otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); isTable = (strcmp(argv[0], "table") == 0); if (isTable || strcmp(argv[0], "list") == 0) { if (isTable) { mServer->OutputFormat("| Role | RLOC16 | Age | Avg RSSI | Last RSSI |R|S|D|N| Extended MAC |\r\n"); mServer->OutputFormat("+------+--------+-----+----------+-----------+-+-+-+-+------------------+\r\n"); } while (otThreadGetNextNeighborInfo(mInstance, &iterator, &neighborInfo) == OT_ERROR_NONE) { if (isTable) { mServer->OutputFormat("| %3c ", neighborInfo.mIsChild ? 'C' : 'R'); mServer->OutputFormat("| 0x%04x ", neighborInfo.mRloc16); mServer->OutputFormat("| %3d ", neighborInfo.mAge); mServer->OutputFormat("| %8d ", neighborInfo.mAverageRssi); mServer->OutputFormat("| %9d ", neighborInfo.mLastRssi); mServer->OutputFormat("|%1d", neighborInfo.mRxOnWhenIdle); mServer->OutputFormat("|%1d", neighborInfo.mSecureDataRequest); mServer->OutputFormat("|%1d", neighborInfo.mFullThreadDevice); mServer->OutputFormat("|%1d", neighborInfo.mFullNetworkData); mServer->OutputFormat("| "); for (size_t j = 0; j < sizeof(neighborInfo.mExtAddress); j++) { mServer->OutputFormat("%02x", neighborInfo.mExtAddress.m8[j]); } mServer->OutputFormat(" |\r\n"); } else { mServer->OutputFormat("0x%04x ", neighborInfo.mRloc16); } } mServer->OutputFormat("\r\n"); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #endif #if OPENTHREAD_ENABLE_SERVICE void Interpreter::ProcessNetworkDataShow(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; uint8_t data[255]; uint8_t len = sizeof(data); SuccessOrExit(error = otNetDataGet(mInstance, false, data, &len)); this->OutputBytes(data, static_cast<uint8_t>(len)); mServer->OutputFormat("\r\n"); exit: AppendResult(error); } void Interpreter::ProcessService(int argc, char *argv[]) { otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "add") == 0) { otServiceConfig cfg; long enterpriseNumber; size_t length; VerifyOrExit(argc > 3, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[1], enterpriseNumber)); cfg.mEnterpriseNumber = static_cast<uint32_t>(enterpriseNumber); length = strlen(argv[2]); VerifyOrExit(length <= sizeof(cfg.mServiceData), error = OT_ERROR_NO_BUFS); cfg.mServiceDataLength = static_cast<uint8_t>(length); memcpy(cfg.mServiceData, argv[2], cfg.mServiceDataLength); length = strlen(argv[3]); VerifyOrExit(length <= sizeof(cfg.mServerConfig.mServerData), error = OT_ERROR_NO_BUFS); cfg.mServerConfig.mServerDataLength = static_cast<uint8_t>(length); memcpy(cfg.mServerConfig.mServerData, argv[3], cfg.mServerConfig.mServerDataLength); cfg.mServerConfig.mStable = true; SuccessOrExit(error = otServerAddService(mInstance, &cfg)); } else if (strcmp(argv[0], "remove") == 0) { long enterpriseNumber = 0; VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[1], enterpriseNumber)); SuccessOrExit(error = otServerRemoveService(mInstance, static_cast<uint32_t>(enterpriseNumber), reinterpret_cast<uint8_t *>(argv[2]), static_cast<uint8_t>(strlen(argv[2])))); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #endif #if OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE void Interpreter::ProcessNetworkDataRegister(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; #if OPENTHREAD_ENABLE_BORDER_ROUTER SuccessOrExit(error = otBorderRouterRegister(mInstance)); #else SuccessOrExit(error = otServerRegister(mInstance)); #endif exit: AppendResult(error); } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE #if OPENTHREAD_FTD void Interpreter::ProcessNetworkIdTimeout(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetNetworkIdTimeout(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); otThreadSetNetworkIdTimeout(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } #endif // OPENTHREAD_FTD void Interpreter::ProcessNetworkName(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { otStringPtr networkName(otThreadGetNetworkName(mInstance)); mServer->OutputFormat("%.*s\r\n", OT_NETWORK_NAME_MAX_SIZE, static_cast<const char *>(networkName)); } else { SuccessOrExit(error = otThreadSetNetworkName(mInstance, argv[0])); } exit: AppendResult(error); } #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC void Interpreter::ProcessNetworkTime(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { uint64_t time; otNetworkTimeStatus networkTimeStatus; networkTimeStatus = otNetworkTimeGet(mInstance, time); mServer->OutputFormat("Network Time: %luus", time); switch (networkTimeStatus) { case OT_NETWORK_TIME_UNSYNCHRONIZED: mServer->OutputFormat(" (unsynchronized)\r\n"); break; case OT_NETWORK_TIME_RESYNC_NEEDED: mServer->OutputFormat(" (resync needed)\r\n"); break; case OT_NETWORK_TIME_SYNCHRONIZED: mServer->OutputFormat(" (synchronized)\r\n"); break; default: break; } mServer->OutputFormat("Time Sync Period: %ds\r\n", otNetworkTimeGetSyncPeriod(mInstance)); mServer->OutputFormat("XTAL Threshold: %dppm\r\n", otNetworkTimeGetXtalThreshold(mInstance)); } else if (argc == 2) { SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otNetworkTimeSetSyncPeriod(mInstance, static_cast<uint16_t>(value))); SuccessOrExit(error = ParseLong(argv[1], value)); SuccessOrExit(error = otNetworkTimeSetXtalThreshold(mInstance, static_cast<uint16_t>(value))); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #endif // OPENTHREAD_CONFIG_ENABLE_TIME_SYNC void Interpreter::ProcessPanId(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%04x\r\n", otLinkGetPanId(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); error = otLinkSetPanId(mInstance, static_cast<otPanId>(value)); } exit: AppendResult(error); } void Interpreter::ProcessParent(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; otRouterInfo parentInfo; SuccessOrExit(error = otThreadGetParentInfo(mInstance, &parentInfo)); mServer->OutputFormat("Ext Addr: "); for (size_t i = 0; i < sizeof(parentInfo.mExtAddress); i++) { mServer->OutputFormat("%02x", parentInfo.mExtAddress.m8[i]); } mServer->OutputFormat("\r\n"); mServer->OutputFormat("Rloc: %x\r\n", parentInfo.mRloc16); mServer->OutputFormat("Link Quality In: %d\r\n", parentInfo.mLinkQualityIn); mServer->OutputFormat("Link Quality Out: %d\r\n", parentInfo.mLinkQualityOut); mServer->OutputFormat("Age: %d\r\n", parentInfo.mAge); exit: AppendResult(error); } #if OPENTHREAD_FTD void Interpreter::ProcessParentPriority(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetParentPriority(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); error = otThreadSetParentPriority(mInstance, static_cast<int8_t>(value)); } exit: AppendResult(error); } #endif #ifndef OTDLL void Interpreter::s_HandleIcmpReceive(void * aContext, otMessage * aMessage, const otMessageInfo *aMessageInfo, const otIcmp6Header *aIcmpHeader) { static_cast<Interpreter *>(aContext)->HandleIcmpReceive(*static_cast<Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo), *static_cast<const Ip6::IcmpHeader *>(aIcmpHeader)); } void Interpreter::HandleIcmpReceive(Message & aMessage, const Ip6::MessageInfo &aMessageInfo, const otIcmp6Header & aIcmpHeader) { uint32_t timestamp = 0; VerifyOrExit(aIcmpHeader.mType == OT_ICMP6_TYPE_ECHO_REPLY); mServer->OutputFormat("%d bytes from ", aMessage.GetLength() - aMessage.GetOffset() + sizeof(otIcmp6Header)); mServer->OutputFormat( "%x:%x:%x:%x:%x:%x:%x:%x", HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[0]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[1]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[2]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[3]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[4]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[5]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[6]), HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7])); mServer->OutputFormat(": icmp_seq=%d hlim=%d", HostSwap16(aIcmpHeader.mData.m16[1]), aMessageInfo.mHopLimit); if (aMessage.Read(aMessage.GetOffset(), sizeof(uint32_t), &timestamp) >= static_cast<int>(sizeof(uint32_t))) { mServer->OutputFormat(" time=%dms", TimerMilli::Elapsed(HostSwap32(timestamp))); } mServer->OutputFormat("\r\n"); exit: return; } void Interpreter::ProcessPing(int argc, char *argv[]) { otError error = OT_ERROR_NONE; uint8_t index = 1; long value; uint32_t interval; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "stop") == 0) { if (!mPingTimer.IsRunning()) { error = OT_ERROR_INVALID_STATE; } else { mPingTimer.Stop(); } ExitNow(); } VerifyOrExit(!mPingTimer.IsRunning(), error = OT_ERROR_BUSY); SuccessOrExit(error = mMessageInfo.GetPeerAddr().FromString(argv[0])); mMessageInfo.mInterfaceId = OT_NETIF_INTERFACE_ID_THREAD; mLength = 8; mCount = 1; mInterval = 1000; while (index < argc) { switch (index) { case 1: SuccessOrExit(error = ParseLong(argv[index], value)); mLength = static_cast<uint16_t>(value); break; case 2: SuccessOrExit(error = ParseLong(argv[index], value)); mCount = static_cast<uint16_t>(value); break; case 3: SuccessOrExit(error = ParsePingInterval(argv[index], interval)); VerifyOrExit(0 < interval && interval <= Timer::kMaxDt, error = OT_ERROR_INVALID_ARGS); mInterval = interval; break; default: ExitNow(error = OT_ERROR_INVALID_ARGS); } index++; } HandlePingTimer(); return; exit: AppendResult(error); } void Interpreter::s_HandlePingTimer(Timer &aTimer) { GetOwner(aTimer).HandlePingTimer(); } void Interpreter::HandlePingTimer() { otError error = OT_ERROR_NONE; uint32_t timestamp = HostSwap32(TimerMilli::GetNow()); otMessage * message; const otMessageInfo *messageInfo = static_cast<const otMessageInfo *>(&mMessageInfo); VerifyOrExit((message = otIp6NewMessage(mInstance, NULL)) != NULL, error = OT_ERROR_NO_BUFS); SuccessOrExit(error = otMessageAppend(message, &timestamp, sizeof(timestamp))); SuccessOrExit(error = otMessageSetLength(message, mLength)); SuccessOrExit(error = otIcmp6SendEchoRequest(mInstance, message, messageInfo, 1)); mCount--; exit: if (error != OT_ERROR_NONE && message != NULL) { otMessageFree(message); } if (mCount) { mPingTimer.Start(mInterval); } } #endif void Interpreter::ProcessPollPeriod(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otLinkGetPollPeriod(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); error = otLinkSetPollPeriod(mInstance, static_cast<uint32_t>(value)); } exit: AppendResult(error); } #ifndef OTDLL void Interpreter::ProcessPromiscuous(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { if (otLinkIsPromiscuous(mInstance) && otPlatRadioGetPromiscuous(mInstance)) { mServer->OutputFormat("Enabled\r\n"); } else { mServer->OutputFormat("Disabled\r\n"); } } else { if (strcmp(argv[0], "enable") == 0) { otLinkSetPcapCallback(mInstance, &s_HandleLinkPcapReceive, this); SuccessOrExit(error = otLinkSetPromiscuous(mInstance, true)); } else if (strcmp(argv[0], "disable") == 0) { otLinkSetPcapCallback(mInstance, NULL, NULL); SuccessOrExit(error = otLinkSetPromiscuous(mInstance, false)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } exit: AppendResult(error); } void Interpreter::s_HandleLinkPcapReceive(const otRadioFrame *aFrame, bool aIsTx, void *aContext) { static_cast<Interpreter *>(aContext)->HandleLinkPcapReceive(aFrame, aIsTx); } void Interpreter::HandleLinkPcapReceive(const otRadioFrame *aFrame, bool aIsTx) { OT_UNUSED_VARIABLE(aIsTx); mServer->OutputFormat("\r\n"); for (size_t i = 0; i < 44; i++) { mServer->OutputFormat("="); } mServer->OutputFormat("[len = %3u]", aFrame->mLength); for (size_t i = 0; i < 28; i++) { mServer->OutputFormat("="); } mServer->OutputFormat("\r\n"); for (size_t i = 0; i < aFrame->mLength; i += 16) { mServer->OutputFormat("|"); for (size_t j = 0; j < 16; j++) { if (i + j < aFrame->mLength) { mServer->OutputFormat(" %02X", aFrame->mPsdu[i + j]); } else { mServer->OutputFormat(" .."); } } mServer->OutputFormat("|"); for (size_t j = 0; j < 16; j++) { if (i + j < aFrame->mLength) { if (31 < aFrame->mPsdu[i + j] && aFrame->mPsdu[i + j] < 127) { mServer->OutputFormat(" %c", aFrame->mPsdu[i + j]); } else { mServer->OutputFormat(" ?"); } } else { mServer->OutputFormat(" ."); } } mServer->OutputFormat("|\r\n"); } for (size_t i = 0; i < 83; i++) { mServer->OutputFormat("-"); } mServer->OutputFormat("\r\n"); } #endif #if OPENTHREAD_ENABLE_BORDER_ROUTER otError Interpreter::ProcessPrefixAdd(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otBorderRouterConfig config; int argcur = 0; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); memset(&config, 0, sizeof(otBorderRouterConfig)); char *prefixLengthStr; char *endptr; if ((prefixLengthStr = strchr(argv[argcur], '/')) == NULL) { ExitNow(); } *prefixLengthStr++ = '\0'; SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &config.mPrefix.mPrefix)); config.mPrefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0)); if (*endptr != '\0') { ExitNow(error = OT_ERROR_PARSE); } argcur++; for (; argcur < argc; argcur++) { if (strcmp(argv[argcur], "high") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_HIGH; } else if (strcmp(argv[argcur], "med") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_MED; } else if (strcmp(argv[argcur], "low") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_LOW; } else { for (char *arg = argv[argcur]; *arg != '\0'; arg++) { switch (*arg) { case 'p': config.mPreferred = true; break; case 'a': config.mSlaac = true; break; case 'd': config.mDhcp = true; break; case 'c': config.mConfigure = true; break; case 'r': config.mDefaultRoute = true; break; case 'o': config.mOnMesh = true; break; case 's': config.mStable = true; break; default: ExitNow(error = OT_ERROR_PARSE); } } } } error = otBorderRouterAddOnMeshPrefix(mInstance, &config); exit: return error; } otError Interpreter::ProcessPrefixRemove(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); otError error = OT_ERROR_NONE; struct otIp6Prefix prefix; int argcur = 0; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); memset(&prefix, 0, sizeof(otIp6Prefix)); char *prefixLengthStr; char *endptr; if ((prefixLengthStr = strchr(argv[argcur], '/')) == NULL) { ExitNow(); } *prefixLengthStr++ = '\0'; SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &prefix.mPrefix)); prefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0)); if (*endptr != '\0') { ExitNow(error = OT_ERROR_PARSE); } error = otBorderRouterRemoveOnMeshPrefix(mInstance, &prefix); exit: return error; } otError Interpreter::ProcessPrefixList(void) { otNetworkDataIterator iterator = OT_NETWORK_DATA_ITERATOR_INIT; otBorderRouterConfig config; while (otBorderRouterGetNextOnMeshPrefix(mInstance, &iterator, &config) == OT_ERROR_NONE) { mServer->OutputFormat("%x:%x:%x:%x::/%d ", HostSwap16(config.mPrefix.mPrefix.mFields.m16[0]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[1]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[2]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[3]), config.mPrefix.mLength); if (config.mPreferred) { mServer->OutputFormat("p"); } if (config.mSlaac) { mServer->OutputFormat("a"); } if (config.mDhcp) { mServer->OutputFormat("d"); } if (config.mConfigure) { mServer->OutputFormat("c"); } if (config.mDefaultRoute) { mServer->OutputFormat("r"); } if (config.mOnMesh) { mServer->OutputFormat("o"); } if (config.mStable) { mServer->OutputFormat("s"); } switch (config.mPreference) { case OT_ROUTE_PREFERENCE_LOW: mServer->OutputFormat(" low\r\n"); break; case OT_ROUTE_PREFERENCE_MED: mServer->OutputFormat(" med\r\n"); break; case OT_ROUTE_PREFERENCE_HIGH: mServer->OutputFormat(" high\r\n"); break; } } return OT_ERROR_NONE; } void Interpreter::ProcessPrefix(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { SuccessOrExit(error = ProcessPrefixList()); } else if (strcmp(argv[0], "add") == 0) { SuccessOrExit(error = ProcessPrefixAdd(argc - 1, argv + 1)); } else if (strcmp(argv[0], "remove") == 0) { SuccessOrExit(error = ProcessPrefixRemove(argc - 1, argv + 1)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER #if OPENTHREAD_FTD void Interpreter::ProcessReleaseRouterId(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otThreadReleaseRouterId(mInstance, static_cast<uint8_t>(value))); exit: AppendResult(error); } #endif // OPENTHREAD_FTD void Interpreter::ProcessReset(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otInstanceReset(mInstance); } void Interpreter::ProcessRloc16(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); mServer->OutputFormat("%04x\r\n", otThreadGetRloc16(mInstance)); mServer->OutputFormat("Done\r\n"); } #if OPENTHREAD_ENABLE_BORDER_ROUTER otError Interpreter::ProcessRouteAdd(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otExternalRouteConfig config; int argcur = 0; memset(&config, 0, sizeof(otExternalRouteConfig)); char *prefixLengthStr; char *endptr; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if ((prefixLengthStr = strchr(argv[argcur], '/')) == NULL) { ExitNow(); } *prefixLengthStr++ = '\0'; SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &config.mPrefix.mPrefix)); config.mPrefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0)); if (*endptr != '\0') { ExitNow(error = OT_ERROR_PARSE); } argcur++; for (; argcur < argc; argcur++) { if (strcmp(argv[argcur], "s") == 0) { config.mStable = true; } else if (strcmp(argv[argcur], "high") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_HIGH; } else if (strcmp(argv[argcur], "med") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_MED; } else if (strcmp(argv[argcur], "low") == 0) { config.mPreference = OT_ROUTE_PREFERENCE_LOW; } else { ExitNow(error = OT_ERROR_PARSE); } } error = otBorderRouterAddRoute(mInstance, &config); exit: return error; } otError Interpreter::ProcessRouteRemove(int argc, char *argv[]) { otError error = OT_ERROR_NONE; struct otIp6Prefix prefix; int argcur = 0; memset(&prefix, 0, sizeof(struct otIp6Prefix)); char *prefixLengthStr; char *endptr; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if ((prefixLengthStr = strchr(argv[argcur], '/')) == NULL) { ExitNow(); } *prefixLengthStr++ = '\0'; SuccessOrExit(error = otIp6AddressFromString(argv[argcur], &prefix.mPrefix)); prefix.mLength = static_cast<uint8_t>(strtol(prefixLengthStr, &endptr, 0)); if (*endptr != '\0') { ExitNow(error = OT_ERROR_PARSE); } error = otBorderRouterRemoveRoute(mInstance, &prefix); exit: return error; } otError Interpreter::ProcessRouteList(void) { otNetworkDataIterator iterator = OT_NETWORK_DATA_ITERATOR_INIT; otExternalRouteConfig config; while (otBorderRouterGetNextRoute(mInstance, &iterator, &config) == OT_ERROR_NONE) { mServer->OutputFormat("%x:%x:%x:%x::/%d ", HostSwap16(config.mPrefix.mPrefix.mFields.m16[0]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[1]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[2]), HostSwap16(config.mPrefix.mPrefix.mFields.m16[3]), config.mPrefix.mLength); if (config.mStable) { mServer->OutputFormat("s"); } switch (config.mPreference) { case OT_ROUTE_PREFERENCE_LOW: mServer->OutputFormat(" low\r\n"); break; case OT_ROUTE_PREFERENCE_MED: mServer->OutputFormat(" med\r\n"); break; case OT_ROUTE_PREFERENCE_HIGH: mServer->OutputFormat(" high\r\n"); break; } } return OT_ERROR_NONE; } void Interpreter::ProcessRoute(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { SuccessOrExit(error = ProcessRouteList()); } else if (strcmp(argv[0], "add") == 0) { SuccessOrExit(error = ProcessRouteAdd(argc - 1, argv + 1)); } else if (strcmp(argv[0], "remove") == 0) { SuccessOrExit(error = ProcessRouteRemove(argc - 1, argv + 1)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER #if OPENTHREAD_FTD void Interpreter::ProcessRouter(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otRouterInfo routerInfo; long value; bool isTable; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); isTable = (strcmp(argv[0], "table") == 0); if (isTable || strcmp(argv[0], "list") == 0) { uint8_t maxRouterId; if (isTable) { mServer->OutputFormat( "| ID | RLOC16 | Next Hop | Path Cost | LQ In | LQ Out | Age | Extended MAC |\r\n"); mServer->OutputFormat( "+----+--------+----------+-----------+-------+--------+-----+------------------+\r\n"); } maxRouterId = otThreadGetMaxRouterId(mInstance); for (uint8_t i = 0; i <= maxRouterId; i++) { if (otThreadGetRouterInfo(mInstance, i, &routerInfo) != OT_ERROR_NONE) { continue; } if (isTable) { mServer->OutputFormat("| %2d ", routerInfo.mRouterId); mServer->OutputFormat("| 0x%04x ", routerInfo.mRloc16); mServer->OutputFormat("| %8d ", routerInfo.mNextHop); mServer->OutputFormat("| %9d ", routerInfo.mPathCost); mServer->OutputFormat("| %5d ", routerInfo.mLinkQualityIn); mServer->OutputFormat("| %6d ", routerInfo.mLinkQualityOut); mServer->OutputFormat("| %3d ", routerInfo.mAge); mServer->OutputFormat("| "); for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++) { mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]); } mServer->OutputFormat(" |\r\n"); } else { mServer->OutputFormat("%d ", i); } } mServer->OutputFormat("\r\n"); ExitNow(); } SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otThreadGetRouterInfo(mInstance, static_cast<uint16_t>(value), &routerInfo)); mServer->OutputFormat("Alloc: %d\r\n", routerInfo.mAllocated); if (routerInfo.mAllocated) { mServer->OutputFormat("Router ID: %d\r\n", routerInfo.mRouterId); mServer->OutputFormat("Rloc: %04x\r\n", routerInfo.mRloc16); mServer->OutputFormat("Next Hop: %04x\r\n", static_cast<uint16_t>(routerInfo.mNextHop) << 10); mServer->OutputFormat("Link: %d\r\n", routerInfo.mLinkEstablished); if (routerInfo.mLinkEstablished) { mServer->OutputFormat("Ext Addr: "); for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++) { mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]); } mServer->OutputFormat("\r\n"); mServer->OutputFormat("Cost: %d\r\n", routerInfo.mPathCost); mServer->OutputFormat("Link Quality In: %d\r\n", routerInfo.mLinkQualityIn); mServer->OutputFormat("Link Quality Out: %d\r\n", routerInfo.mLinkQualityOut); mServer->OutputFormat("Age: %d\r\n", routerInfo.mAge); } } exit: AppendResult(error); } void Interpreter::ProcessRouterDowngradeThreshold(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetRouterDowngradeThreshold(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); otThreadSetRouterDowngradeThreshold(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } void Interpreter::ProcessRouterRole(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { if (otThreadIsRouterRoleEnabled(mInstance)) { mServer->OutputFormat("Enabled\r\n"); } else { mServer->OutputFormat("Disabled\r\n"); } } else if (strcmp(argv[0], "enable") == 0) { otThreadSetRouterRoleEnabled(mInstance, true); } else if (strcmp(argv[0], "disable") == 0) { otThreadSetRouterRoleEnabled(mInstance, false); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } void Interpreter::ProcessRouterSelectionJitter(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetRouterSelectionJitter(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); VerifyOrExit(0 < value && value < 256, error = OT_ERROR_INVALID_ARGS); otThreadSetRouterSelectionJitter(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } void Interpreter::ProcessRouterUpgradeThreshold(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetRouterUpgradeThreshold(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); otThreadSetRouterUpgradeThreshold(mInstance, static_cast<uint8_t>(value)); } exit: AppendResult(error); } #endif // OPENTHREAD_FTD void Interpreter::ProcessScan(int argc, char *argv[]) { otError error = OT_ERROR_NONE; uint32_t scanChannels = 0; uint16_t scanDuration = 0; bool energyScan = false; long value; if (argc > 0) { if (strcmp(argv[0], "energy") == 0) { energyScan = true; if (argc > 1) { SuccessOrExit(error = ParseLong(argv[1], value)); scanDuration = static_cast<uint16_t>(value); } } else { SuccessOrExit(error = ParseLong(argv[0], value)); VerifyOrExit((0 <= value) && (value < static_cast<long>(sizeof(scanChannels) * CHAR_BIT)), error = OT_ERROR_INVALID_ARGS); scanChannels = 1 << value; } } if (energyScan) { mServer->OutputFormat("| Ch | RSSI |\r\n"); mServer->OutputFormat("+----+------+\r\n"); SuccessOrExit(error = otLinkEnergyScan(mInstance, scanChannels, scanDuration, &Interpreter::s_HandleEnergyScanResult, this)); } else { mServer->OutputFormat( "| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |\r\n"); mServer->OutputFormat( "+---+------------------+------------------+------+------------------+----+-----+-----+\r\n"); SuccessOrExit(error = otLinkActiveScan(mInstance, scanChannels, scanDuration, &Interpreter::s_HandleActiveScanResult, this)); } return; exit: AppendResult(error); } void OTCALL Interpreter::s_HandleActiveScanResult(otActiveScanResult *aResult, void *aContext) { static_cast<Interpreter *>(aContext)->HandleActiveScanResult(aResult); } void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult) { if (aResult == NULL) { mServer->OutputFormat("Done\r\n"); ExitNow(); } mServer->OutputFormat("| %d ", aResult->mIsJoinable); mServer->OutputFormat("| %-16s ", aResult->mNetworkName.m8); mServer->OutputFormat("| "); OutputBytes(aResult->mExtendedPanId.m8, OT_EXT_PAN_ID_SIZE); mServer->OutputFormat(" "); mServer->OutputFormat("| %04x | ", aResult->mPanId); OutputBytes(aResult->mExtAddress.m8, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat(" | %2d ", aResult->mChannel); mServer->OutputFormat("| %3d ", aResult->mRssi); mServer->OutputFormat("| %3d |\r\n", aResult->mLqi); exit: return; } void OTCALL Interpreter::s_HandleEnergyScanResult(otEnergyScanResult *aResult, void *aContext) { static_cast<Interpreter *>(aContext)->HandleEnergyScanResult(aResult); } void Interpreter::HandleEnergyScanResult(otEnergyScanResult *aResult) { if (aResult == NULL) { mServer->OutputFormat("Done\r\n"); ExitNow(); } mServer->OutputFormat("| %2d | %4d |\r\n", aResult->mChannel, aResult->mMaxRssi); exit: return; } void Interpreter::ProcessSingleton(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; if (otThreadIsSingleton(mInstance)) { mServer->OutputFormat("true\r\n"); } else { mServer->OutputFormat("false\r\n"); } AppendResult(error); } #if OPENTHREAD_ENABLE_SNTP_CLIENT void Interpreter::ProcessSntp(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long port = OT_SNTP_DEFAULT_SERVER_PORT; Ip6::MessageInfo messageInfo; otSntpQuery query; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "query") == 0) { VerifyOrExit(!mSntpQueryingInProgress, error = OT_ERROR_BUSY); messageInfo.mInterfaceId = OT_NETIF_INTERFACE_ID_THREAD; if (argc > 1) { SuccessOrExit(error = messageInfo.GetPeerAddr().FromString(argv[1])); } else { // Use IPv6 address of default SNTP server. SuccessOrExit(error = messageInfo.GetPeerAddr().FromString(OT_SNTP_DEFAULT_SERVER_IP)); } if (argc > 2) { SuccessOrExit(error = ParseLong(argv[2], port)); } messageInfo.SetPeerPort(static_cast<uint16_t>(port)); query.mMessageInfo = static_cast<const otMessageInfo *>(&messageInfo); SuccessOrExit(error = otSntpClientQuery(mInstance, &query, &Interpreter::s_HandleSntpResponse, this)); mSntpQueryingInProgress = true; } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: if (error != OT_ERROR_NONE) { AppendResult(error); } } void Interpreter::s_HandleSntpResponse(void *aContext, uint64_t aTime, otError aResult) { static_cast<Interpreter *>(aContext)->HandleSntpResponse(aTime, aResult); } void Interpreter::HandleSntpResponse(uint64_t aTime, otError aResult) { if (aResult == OT_ERROR_NONE) { // Some Embedded C libraries do not support printing of 64-bit unsigned integers. // To simplify, unix epoch time and era number are printed separately. mServer->OutputFormat("SNTP response - Unix time: %ld (era: %ld)\r\n", static_cast<uint32_t>(aTime & UINT32_MAX), static_cast<uint32_t>(aTime >> 32)); } else { mServer->OutputFormat("SNTP error - %s\r\n", otThreadErrorToString(aResult)); } mSntpQueryingInProgress = false; } #endif void Interpreter::ProcessState(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { switch (otThreadGetDeviceRole(mInstance)) { case OT_DEVICE_ROLE_DISABLED: mServer->OutputFormat("disabled\r\n"); break; case OT_DEVICE_ROLE_DETACHED: mServer->OutputFormat("detached\r\n"); break; case OT_DEVICE_ROLE_CHILD: mServer->OutputFormat("child\r\n"); break; #if OPENTHREAD_FTD case OT_DEVICE_ROLE_ROUTER: mServer->OutputFormat("router\r\n"); break; case OT_DEVICE_ROLE_LEADER: mServer->OutputFormat("leader\r\n"); break; #endif // OPENTHREAD_FTD default: mServer->OutputFormat("invalid state\r\n"); break; } } else { if (strcmp(argv[0], "detached") == 0) { SuccessOrExit(error = otThreadBecomeDetached(mInstance)); } else if (strcmp(argv[0], "child") == 0) { SuccessOrExit(error = otThreadBecomeChild(mInstance)); } #if OPENTHREAD_FTD else if (strcmp(argv[0], "router") == 0) { SuccessOrExit(error = otThreadBecomeRouter(mInstance)); } else if (strcmp(argv[0], "leader") == 0) { SuccessOrExit(error = otThreadBecomeLeader(mInstance)); } #endif // OPENTHREAD_FTD else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } exit: AppendResult(error); } void Interpreter::ProcessThread(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "start") == 0) { SuccessOrExit(error = otThreadSetEnabled(mInstance, true)); } else if (strcmp(argv[0], "stop") == 0) { SuccessOrExit(error = otThreadSetEnabled(mInstance, false)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } void Interpreter::ProcessDataset(int argc, char *argv[]) { otError error; error = mDataset.Process(argc, argv); AppendResult(error); } #ifndef OTDLL void Interpreter::ProcessTxPower(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { int8_t power; SuccessOrExit(error = otPlatRadioGetTransmitPower(mInstance, &power)); mServer->OutputFormat("%d dBm\r\n", power); } else { long value; SuccessOrExit(error = ParseLong(argv[0], value)); SuccessOrExit(error = otPlatRadioSetTransmitPower(mInstance, static_cast<int8_t>(value))); } exit: AppendResult(error); } void Interpreter::ProcessUdp(int argc, char *argv[]) { otError error; error = mUdp.Process(argc, argv); AppendResult(error); } #endif void Interpreter::ProcessVersion(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); otStringPtr version(otGetVersionString()); mServer->OutputFormat("%s\r\n", static_cast<const char *>(version)); AppendResult(OT_ERROR_NONE); } #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD void Interpreter::ProcessCommissioner(int argc, char *argv[]) { otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "start") == 0) { SuccessOrExit(error = otCommissionerStart(mInstance)); } else if (strcmp(argv[0], "stop") == 0) { SuccessOrExit(error = otCommissionerStop(mInstance)); } else if (strcmp(argv[0], "joiner") == 0) { otExtAddress addr; const otExtAddress *addrPtr; VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[2], "*") == 0) { addrPtr = NULL; } else { VerifyOrExit(Hex2Bin(argv[2], addr.m8, sizeof(addr)) == sizeof(addr), error = OT_ERROR_PARSE); addrPtr = &addr; } if (strcmp(argv[1], "add") == 0) { VerifyOrExit(argc > 3, error = OT_ERROR_INVALID_ARGS); // Timeout parameter is optional - if not specified, use default value. unsigned long timeout = kDefaultJoinerTimeout; if (argc > 4) { SuccessOrExit(error = ParseUnsignedLong(argv[4], timeout)); } SuccessOrExit(error = otCommissionerAddJoiner(mInstance, addrPtr, argv[3], static_cast<uint32_t>(timeout))); } else if (strcmp(argv[1], "remove") == 0) { SuccessOrExit(error = otCommissionerRemoveJoiner(mInstance, addrPtr)); } } else if (strcmp(argv[0], "provisioningurl") == 0) { SuccessOrExit(error = otCommissionerSetProvisioningUrl(mInstance, (argc > 1) ? argv[1] : NULL)); } else if (strcmp(argv[0], "announce") == 0) { long mask; long count; long period; otIp6Address address; VerifyOrExit(argc > 4, error = OT_ERROR_INVALID_ARGS); // mask SuccessOrExit(error = ParseLong(argv[1], mask)); // count SuccessOrExit(error = ParseLong(argv[2], count)); // period SuccessOrExit(error = ParseLong(argv[3], period)); // destination SuccessOrExit(error = otIp6AddressFromString(argv[4], &address)); SuccessOrExit(error = otCommissionerAnnounceBegin(mInstance, static_cast<uint32_t>(mask), static_cast<uint8_t>(count), static_cast<uint16_t>(period), &address)); } else if (strcmp(argv[0], "energy") == 0) { long mask; long count; long period; long scanDuration; otIp6Address address; VerifyOrExit(argc > 5, error = OT_ERROR_INVALID_ARGS); // mask SuccessOrExit(error = ParseLong(argv[1], mask)); // count SuccessOrExit(error = ParseLong(argv[2], count)); // period SuccessOrExit(error = ParseLong(argv[3], period)); // scan duration SuccessOrExit(error = ParseLong(argv[4], scanDuration)); // destination SuccessOrExit(error = otIp6AddressFromString(argv[5], &address)); SuccessOrExit(error = otCommissionerEnergyScan(mInstance, static_cast<uint32_t>(mask), static_cast<uint8_t>(count), static_cast<uint16_t>(period), static_cast<uint16_t>(scanDuration), &address, Interpreter::s_HandleEnergyReport, this)); } else if (strcmp(argv[0], "panid") == 0) { long panid; long mask; otIp6Address address; VerifyOrExit(argc > 3, error = OT_ERROR_INVALID_ARGS); // panid SuccessOrExit(error = ParseLong(argv[1], panid)); // mask SuccessOrExit(error = ParseLong(argv[2], mask)); // destination SuccessOrExit(error = otIp6AddressFromString(argv[3], &address)); SuccessOrExit(error = otCommissionerPanIdQuery(mInstance, static_cast<uint16_t>(panid), static_cast<uint32_t>(mask), &address, Interpreter::s_HandlePanIdConflict, this)); } else if (strcmp(argv[0], "mgmtget") == 0) { uint8_t tlvs[32]; long value; int length = 0; for (uint8_t index = 1; index < argc; index++) { VerifyOrExit(static_cast<size_t>(length) < sizeof(tlvs), error = OT_ERROR_NO_BUFS); if (strcmp(argv[index], "locator") == 0) { tlvs[length++] = OT_MESHCOP_TLV_BORDER_AGENT_RLOC; } else if (strcmp(argv[index], "sessionid") == 0) { tlvs[length++] = OT_MESHCOP_TLV_COMM_SESSION_ID; } else if (strcmp(argv[index], "steeringdata") == 0) { tlvs[length++] = OT_MESHCOP_TLV_STEERING_DATA; } else if (strcmp(argv[index], "joinerudpport") == 0) { tlvs[length++] = OT_MESHCOP_TLV_JOINER_UDP_PORT; } else if (strcmp(argv[index], "binary") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); value = static_cast<long>(strlen(argv[index]) + 1) / 2; VerifyOrExit(static_cast<size_t>(value) <= (sizeof(tlvs) - static_cast<size_t>(length)), error = OT_ERROR_NO_BUFS); VerifyOrExit(Interpreter::Hex2Bin(argv[index], tlvs + length, static_cast<uint16_t>(value)) >= 0, error = OT_ERROR_PARSE); length += value; } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } SuccessOrExit(error = otCommissionerSendMgmtGet(mInstance, tlvs, static_cast<uint8_t>(length))); } else if (strcmp(argv[0], "mgmtset") == 0) { otCommissioningDataset dataset; uint8_t tlvs[32]; long value; int length = 0; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); memset(&dataset, 0, sizeof(dataset)); for (uint8_t index = 1; index < argc; index++) { VerifyOrExit(static_cast<size_t>(length) < sizeof(tlvs), error = OT_ERROR_NO_BUFS); if (strcmp(argv[index], "locator") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); dataset.mIsLocatorSet = true; SuccessOrExit(error = Interpreter::ParseLong(argv[index], value)); dataset.mLocator = static_cast<uint16_t>(value); } else if (strcmp(argv[index], "sessionid") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); dataset.mIsSessionIdSet = true; SuccessOrExit(error = Interpreter::ParseLong(argv[index], value)); dataset.mSessionId = static_cast<uint16_t>(value); } else if (strcmp(argv[index], "steeringdata") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); dataset.mIsSteeringDataSet = true; length = static_cast<int>((strlen(argv[index]) + 1) / 2); VerifyOrExit(static_cast<size_t>(length) <= OT_STEERING_DATA_MAX_LENGTH, error = OT_ERROR_NO_BUFS); VerifyOrExit( Interpreter::Hex2Bin(argv[index], dataset.mSteeringData.m8, static_cast<uint16_t>(length)) >= 0, error = OT_ERROR_PARSE); dataset.mSteeringData.mLength = static_cast<uint8_t>(length); length = 0; } else if (strcmp(argv[index], "joinerudpport") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); dataset.mIsJoinerUdpPortSet = true; SuccessOrExit(error = Interpreter::ParseLong(argv[index], value)); dataset.mJoinerUdpPort = static_cast<uint16_t>(value); } else if (strcmp(argv[index], "binary") == 0) { VerifyOrExit(++index < argc, error = OT_ERROR_INVALID_ARGS); length = static_cast<int>((strlen(argv[index]) + 1) / 2); VerifyOrExit(static_cast<size_t>(length) <= sizeof(tlvs), error = OT_ERROR_NO_BUFS); VerifyOrExit(Interpreter::Hex2Bin(argv[index], tlvs, static_cast<uint16_t>(length)) >= 0, error = OT_ERROR_PARSE); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } } SuccessOrExit(error = otCommissionerSendMgmtSet(mInstance, &dataset, tlvs, static_cast<uint8_t>(length))); } else if (strcmp(argv[0], "sessionid") == 0) { mServer->OutputFormat("%d\r\n", otCommissionerGetSessionId(mInstance)); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } void OTCALL Interpreter::s_HandleEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void * aContext) { static_cast<Interpreter *>(aContext)->HandleEnergyReport(aChannelMask, aEnergyList, aEnergyListLength); } void Interpreter::HandleEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength) { mServer->OutputFormat("Energy: %08x ", aChannelMask); for (uint8_t i = 0; i < aEnergyListLength; i++) { mServer->OutputFormat("%d ", static_cast<int8_t>(aEnergyList[i])); } mServer->OutputFormat("\r\n"); } void OTCALL Interpreter::s_HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask, void *aContext) { static_cast<Interpreter *>(aContext)->HandlePanIdConflict(aPanId, aChannelMask); } void Interpreter::HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask) { mServer->OutputFormat("Conflict: %04x, %08x\r\n", aPanId, aChannelMask); } #endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD #if OPENTHREAD_ENABLE_JOINER void Interpreter::ProcessJoiner(int argc, char *argv[]) { otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[0], "start") == 0) { const char *provisioningUrl; VerifyOrExit(argc > 1, error = OT_ERROR_INVALID_ARGS); provisioningUrl = (argc > 2) ? argv[2] : NULL; otJoinerStart(mInstance, argv[1], provisioningUrl, PACKAGE_NAME, OPENTHREAD_CONFIG_PLATFORM_INFO, PACKAGE_VERSION, NULL, &Interpreter::s_HandleJoinerCallback, this); } else if (strcmp(argv[0], "stop") == 0) { otJoinerStop(mInstance); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: AppendResult(error); } void Interpreter::ProcessJoinerId(int argc, char *argv[]) { OT_UNUSED_VARIABLE(argv); otError error = OT_ERROR_NONE; otExtAddress joinerId; VerifyOrExit(argc == 0, error = OT_ERROR_INVALID_ARGS); otJoinerGetId(mInstance, &joinerId); OutputBytes(joinerId.m8, sizeof(joinerId)); mServer->OutputFormat("\r\n"); exit: AppendResult(error); } #endif // OPENTHREAD_ENABLE_JOINER void OTCALL Interpreter::s_HandleJoinerCallback(otError aError, void *aContext) { static_cast<Interpreter *>(aContext)->HandleJoinerCallback(aError); } void Interpreter::HandleJoinerCallback(otError aError) { switch (aError) { case OT_ERROR_NONE: mServer->OutputFormat("Join success\r\n"); break; default: mServer->OutputFormat("Join failed [%s]\r\n", otThreadErrorToString(aError)); break; } } #if OPENTHREAD_FTD void Interpreter::ProcessJoinerPort(int argc, char *argv[]) { otError error = OT_ERROR_NONE; long value; if (argc == 0) { mServer->OutputFormat("%d\r\n", otThreadGetJoinerUdpPort(mInstance)); } else { SuccessOrExit(error = ParseLong(argv[0], value)); error = otThreadSetJoinerUdpPort(mInstance, static_cast<uint16_t>(value)); } exit: AppendResult(error); } #endif #if OPENTHREAD_ENABLE_MAC_FILTER void Interpreter::ProcessMacFilter(int argc, char *argv[]) { otError error = OT_ERROR_NONE; if (argc == 0) { PrintMacFilter(); } else { if (strcmp(argv[0], "addr") == 0) { error = ProcessMacFilterAddress(argc - 1, argv + 1); } #ifndef OTDLL else if (strcmp(argv[0], "rss") == 0) { error = ProcessMacFilterRss(argc - 1, argv + 1); } #endif else { error = OT_ERROR_INVALID_ARGS; } } AppendResult(error); } void Interpreter::PrintMacFilter(void) { otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; otMacFilterAddressMode mode = otLinkFilterGetAddressMode(mInstance); if (mode == OT_MAC_FILTER_ADDRESS_MODE_DISABLED) { mServer->OutputFormat("Address Mode: Disabled\r\n"); } else if (mode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST) { mServer->OutputFormat("Address Mode: Whitelist\r\n"); } else if (mode == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST) { mServer->OutputFormat("Address Mode: Blacklist\r\n"); } while (otLinkFilterGetNextAddress(mInstance, &iterator, &entry) == OT_ERROR_NONE) { OutputBytes(entry.mExtAddress.m8, OT_EXT_ADDRESS_SIZE); if (entry.mRssIn != OT_MAC_FILTER_FIXED_RSS_DISABLED) { #ifndef OTDLL mServer->OutputFormat(" : rss %d (lqi %d)", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); #else mServer->OutputFormat(" : rss %d", entry.mRssIn); #endif // OTDLL } mServer->OutputFormat("\r\n"); } #ifndef OTDLL iterator = OT_MAC_FILTER_ITERATOR_INIT; mServer->OutputFormat("RssIn List:\r\n"); while (otLinkFilterGetNextRssIn(mInstance, &iterator, &entry) == OT_ERROR_NONE) { uint8_t i = 0; for (; i < OT_EXT_ADDRESS_SIZE; i++) { if (entry.mExtAddress.m8[i] != 0xff) { break; } } if (i == OT_EXT_ADDRESS_SIZE) { mServer->OutputFormat("Default rss : %d (lqi %d)\r\n", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); } else { OutputBytes(entry.mExtAddress.m8, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat(" : rss %d (lqi %d)\r\n", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); } } #endif // OTDLL } otError Interpreter::ProcessMacFilterAddress(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otExtAddress extAddr; otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; otMacFilterAddressMode mode = otLinkFilterGetAddressMode(mInstance); long value; if (argc == 0) { if (mode == OT_MAC_FILTER_ADDRESS_MODE_DISABLED) { mServer->OutputFormat("Disabled\r\n"); } else if (mode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST) { mServer->OutputFormat("Whitelist\r\n"); } else if (mode == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST) { mServer->OutputFormat("Blacklist\r\n"); } while (otLinkFilterGetNextAddress(mInstance, &iterator, &entry) == OT_ERROR_NONE) { OutputBytes(entry.mExtAddress.m8, OT_EXT_ADDRESS_SIZE); if (entry.mRssIn != OT_MAC_FILTER_FIXED_RSS_DISABLED) { #ifndef OTDLL mServer->OutputFormat(" : rss %d (lqi %d)", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); #else mServer->OutputFormat(" : rss %d", entry.mRssIn); #endif // OTDLL } mServer->OutputFormat("\r\n"); } } else { if (strcmp(argv[0], "disable") == 0) { VerifyOrExit(argc == 1, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otLinkFilterSetAddressMode(mInstance, OT_MAC_FILTER_ADDRESS_MODE_DISABLED)); } else if (strcmp(argv[0], "whitelist") == 0) { VerifyOrExit(argc == 1, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otLinkFilterSetAddressMode(mInstance, OT_MAC_FILTER_ADDRESS_MODE_WHITELIST)); } else if (strcmp(argv[0], "blacklist") == 0) { VerifyOrExit(argc == 1, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otLinkFilterSetAddressMode(mInstance, OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST)); } else if (strcmp(argv[0], "add") == 0) { VerifyOrExit(argc >= 2, error = OT_ERROR_INVALID_ARGS); VerifyOrExit(Hex2Bin(argv[1], extAddr.m8, OT_EXT_ADDRESS_SIZE) == OT_EXT_ADDRESS_SIZE, error = OT_ERROR_PARSE); error = otLinkFilterAddAddress(mInstance, &extAddr); VerifyOrExit(error == OT_ERROR_NONE || error == OT_ERROR_ALREADY); if (argc > 2) { int8_t rss = 0; VerifyOrExit(argc == 3, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); rss = static_cast<int8_t>(value); SuccessOrExit(error = otLinkFilterAddRssIn(mInstance, &extAddr, rss)); } } else if (strcmp(argv[0], "remove") == 0) { VerifyOrExit(argc == 2, error = OT_ERROR_INVALID_ARGS); VerifyOrExit(Hex2Bin(argv[1], extAddr.m8, OT_EXT_ADDRESS_SIZE) == OT_EXT_ADDRESS_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otLinkFilterRemoveAddress(mInstance, &extAddr)); } else if (strcmp(argv[0], "clear") == 0) { VerifyOrExit(argc == 1, error = OT_ERROR_INVALID_ARGS); otLinkFilterClearAddresses(mInstance); } else { error = OT_ERROR_INVALID_ARGS; } } exit: return error; } #ifndef OTDLL otError Interpreter::ProcessMacFilterRss(int argc, char *argv[]) { otError error = OT_ERROR_NONE; otMacFilterEntry entry; otMacFilterIterator iterator = OT_MAC_FILTER_ITERATOR_INIT; otExtAddress extAddr; long value; int8_t rss; if (argc == 0) { while (otLinkFilterGetNextRssIn(mInstance, &iterator, &entry) == OT_ERROR_NONE) { uint8_t i = 0; for (; i < OT_EXT_ADDRESS_SIZE; i++) { if (entry.mExtAddress.m8[i] != 0xff) { break; } } if (i == OT_EXT_ADDRESS_SIZE) { mServer->OutputFormat("Default rss: %d (lqi %d)\r\n", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); } else { OutputBytes(entry.mExtAddress.m8, OT_EXT_ADDRESS_SIZE); mServer->OutputFormat(" : rss %d (lqi %d)\r\n", entry.mRssIn, otLinkConvertRssToLinkQuality(mInstance, entry.mRssIn)); } } } else { if (strcmp(argv[0], "add-lqi") == 0) { uint8_t linkquality = 0; VerifyOrExit(argc == 3, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); linkquality = static_cast<uint8_t>(value); VerifyOrExit(linkquality <= 3, error = OT_ERROR_PARSE); rss = otLinkConvertLinkQualityToRss(mInstance, linkquality); if (strcmp(argv[1], "*") == 0) { SuccessOrExit(error = otLinkFilterAddRssIn(mInstance, NULL, rss)); } else { VerifyOrExit(Hex2Bin(argv[1], extAddr.m8, OT_EXT_ADDRESS_SIZE) == OT_EXT_ADDRESS_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otLinkFilterAddRssIn(mInstance, &extAddr, rss)); } } else if (strcmp(argv[0], "add") == 0) { VerifyOrExit(argc == 3, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = ParseLong(argv[2], value)); rss = static_cast<int8_t>(value); if (strcmp(argv[1], "*") == 0) { SuccessOrExit(error = otLinkFilterAddRssIn(mInstance, NULL, rss)); } else { VerifyOrExit(Hex2Bin(argv[1], extAddr.m8, OT_EXT_ADDRESS_SIZE) == OT_EXT_ADDRESS_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otLinkFilterAddRssIn(mInstance, &extAddr, rss)); } } else if (strcmp(argv[0], "remove") == 0) { VerifyOrExit(argc == 2, error = OT_ERROR_INVALID_ARGS); if (strcmp(argv[1], "*") == 0) { SuccessOrExit(error = otLinkFilterRemoveRssIn(mInstance, NULL)); } else { VerifyOrExit(Hex2Bin(argv[1], extAddr.m8, OT_EXT_ADDRESS_SIZE) == OT_EXT_ADDRESS_SIZE, error = OT_ERROR_PARSE); SuccessOrExit(error = otLinkFilterRemoveRssIn(mInstance, &extAddr)); } } else if (strcmp(argv[0], "clear") == 0) { otLinkFilterClearRssIn(mInstance); } else { error = OT_ERROR_INVALID_ARGS; } } exit: return error; } #endif // OTDLL #endif // OPENTHREAD_ENABLE_MAC_FILTER #if OPENTHREAD_ENABLE_DIAG void Interpreter::ProcessDiag(int argc, char *argv[]) { char output[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE]; // all diagnostics related features are processed within diagnostics module output[sizeof(output) - 1] = '\0'; otDiagProcessCmd(argc, argv, output, sizeof(output) - 1); mServer->Output(output, static_cast<uint16_t>(strlen(output))); } #endif void Interpreter::ProcessLine(char *aBuf, uint16_t aBufLength, Server &aServer) { char * argv[kMaxArgs] = {NULL}; char * cmd; uint8_t argc = 0, i = 0; mServer = &aServer; VerifyOrExit(aBuf != NULL && strnlen(aBuf, aBufLength + 1) <= aBufLength); VerifyOrExit(Utils::CmdLineParser::ParseCmd(aBuf, argc, argv, kMaxArgs) == OT_ERROR_NONE, mServer->OutputFormat("Error: too many args (max %d)\r\n", kMaxArgs)); VerifyOrExit(argc >= 1, mServer->OutputFormat("Error: no given command.\r\n")); cmd = argv[0]; #if OPENTHREAD_ENABLE_DIAG VerifyOrExit( (!otDiagIsEnabled() || (strcmp(cmd, "diag") == 0)), mServer->OutputFormat("under diagnostics mode, execute 'diag stop' before running any other commands.\r\n")); #endif for (i = 0; i < OT_ARRAY_LENGTH(sCommands); i++) { if (strcmp(cmd, sCommands[i].mName) == 0) { (this->*sCommands[i].mCommand)(argc - 1, &argv[1]); break; } } // Check user defined commands if built-in command // has not been found if (i == OT_ARRAY_LENGTH(sCommands)) { for (i = 0; i < mUserCommandsLength; i++) { if (strcmp(cmd, mUserCommands[i].mName) == 0) { mUserCommands[i].mCommand(argc - 1, &argv[1]); break; } } if (i == mUserCommandsLength) { AppendResult(OT_ERROR_PARSE); } } exit: return; } #if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[]) { otError error = OT_ERROR_NONE; struct otIp6Address address; uint8_t tlvTypes[OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES]; uint8_t count = 0; uint8_t argvIndex = 0; // Include operation, address and type tlv list. VerifyOrExit(argc > 2, error = OT_ERROR_INVALID_ARGS); SuccessOrExit(error = otIp6AddressFromString(argv[1], &address)); argvIndex = 2; while (argvIndex < argc && count < sizeof(tlvTypes)) { long value; SuccessOrExit(error = ParseLong(argv[argvIndex++], value)); tlvTypes[count++] = static_cast<uint8_t>(value); } if (strcmp(argv[0], "get") == 0) { otThreadSendDiagnosticGet(mInstance, &address, tlvTypes, count); ExitNow(); } else if (strcmp(argv[0], "reset") == 0) { otThreadSendDiagnosticReset(mInstance, &address, tlvTypes, count); AppendResult(OT_ERROR_NONE); } else { ExitNow(error = OT_ERROR_INVALID_ARGS); } exit: if (error != OT_ERROR_NONE) { AppendResult(error); } } #endif // OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC #ifndef OTDLL void Interpreter::s_HandleDiagnosticGetResponse(otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext) { static_cast<Interpreter *>(aContext)->HandleDiagnosticGetResponse( *static_cast<Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo)); } void Interpreter::HandleDiagnosticGetResponse(Message &aMessage, const Ip6::MessageInfo &) { uint8_t buf[16]; uint16_t bytesToPrint; uint16_t bytesPrinted = 0; uint16_t length = aMessage.GetLength() - aMessage.GetOffset(); mServer->OutputFormat("DIAG_GET.rsp/ans: "); while (length > 0) { bytesToPrint = (length < sizeof(buf)) ? length : sizeof(buf); aMessage.Read(aMessage.GetOffset() + bytesPrinted, bytesToPrint, buf); OutputBytes(buf, static_cast<uint8_t>(bytesToPrint)); length -= bytesToPrint; bytesPrinted += bytesToPrint; } mServer->OutputFormat("\r\n"); } #endif void Interpreter::SetUserCommands(const otCliCommand *aCommands, uint8_t aLength) { mUserCommands = aCommands; mUserCommandsLength = aLength; } Interpreter &Interpreter::GetOwner(OwnerLocator &aOwnerLocator) { #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES Interpreter &interpreter = (aOwnerLocator.GetOwner<Interpreter>()); #else OT_UNUSED_VARIABLE(aOwnerLocator); Interpreter &interpreter = Server::sServer->GetInterpreter(); #endif return interpreter; } extern "C" void otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength) { Server::sServer->GetInterpreter().SetUserCommands(aUserCommands, aLength); } extern "C" void otCliOutputBytes(const uint8_t *aBytes, uint8_t aLength) { Server::sServer->GetInterpreter().OutputBytes(aBytes, aLength); } extern "C" void otCliOutputFormat(const char *aFmt, ...) { va_list aAp; va_start(aAp, aFmt); Server::sServer->OutputFormatV(aFmt, aAp); va_end(aAp); } extern "C" void otCliOutput(const char *aString, uint16_t aLength) { Server::sServer->Output(aString, aLength); } extern "C" void otCliAppendResult(otError aError) { Server::sServer->GetInterpreter().AppendResult(aError); } extern "C" void otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs) { OT_UNUSED_VARIABLE(aLogLevel); OT_UNUSED_VARIABLE(aLogRegion); VerifyOrExit(Server::sServer != NULL); Server::sServer->OutputFormatV(aFormat, aArgs); Server::sServer->OutputFormat("\r\n"); exit: return; } } // namespace Cli } // namespace ot #if OPENTHREAD_ENABLE_LEGACY extern "C" void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers) { OT_UNUSED_VARIABLE(aHandlers); } extern "C" void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix) { OT_UNUSED_VARIABLE(aUlaPrefix); } extern "C" void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr) { OT_UNUSED_VARIABLE(aExtAddr); } #endif // OPENTHREAD_ENABLE_LEGACY
Snd_DEZ2_Header: smpsHeaderStartSong 3 smpsHeaderVoice Snd_DEZ2_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $01, $00 smpsHeaderDAC Snd_DEZ2_DAC smpsHeaderFM Snd_DEZ2_FM1, $00, $0F smpsHeaderFM Snd_DEZ2_FM2, $00, $0C smpsHeaderFM Snd_DEZ2_FM3, $00, $0F smpsHeaderFM Snd_DEZ2_FM4, $00, $0F smpsHeaderFM Snd_DEZ2_FM5, $00, $16 smpsHeaderPSG Snd_DEZ2_PSG1, $E8, $02, $00, $00 smpsHeaderPSG Snd_DEZ2_PSG2, $E8, $02, $00, $00 smpsHeaderPSG Snd_DEZ2_PSG3, $E8, $02, $00, $00 ; FM1 Data Snd_DEZ2_FM1: smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 Snd_DEZ2_Loop0E: smpsSetvoice $00 dc.b nRst, $18, nG4, $0B, nRst, $0D, nF4, $0B, nRst, $25, nE4, $0C dc.b nF4, nRst, nG4, nRst, nF4, $24, nRst, $18, nG4, $0B, nRst, $0D dc.b nF4, $0B, nRst, $25, nE4, $0C, nF4, nRst, nG4, nRst, nF4, nRst dc.b nF4, $7F, smpsNoAttack, nF4, $29, nE4, $0B, nRst, $0D, nF4, $6C, nA4 dc.b $06, nBb4, nA4, nRst, nG4, nA4, nG4, nRst, nF4, nG4, nF4, nRst dc.b nE4, nF4, nE4, nRst smpsLoop $00, $02, Snd_DEZ2_Loop0E smpsSetvoice $03 Snd_DEZ2_Loop0F: dc.b nAb3, $06, nBb3, nC4, nEb4 smpsLoop $00, $04, Snd_DEZ2_Loop0F Snd_DEZ2_Loop10: dc.b nBb3, $06, nC4, nD4, nF4 smpsLoop $00, $04, Snd_DEZ2_Loop10 dc.b nRst, $60, nRst, $06, nBb4, $12, nA4, $06, nRst, nG4, nRst, nBb4 dc.b nRst, nG4, nA4, nRst, nBb4, $12 Snd_DEZ2_Loop11: dc.b nAb3, $06, nBb3, nC4, nEb4 smpsLoop $00, $04, Snd_DEZ2_Loop11 Snd_DEZ2_Loop12: dc.b nBb3, $06, nC4, nD4, nF4 smpsLoop $00, $04, Snd_DEZ2_Loop12 dc.b nRst, $60, nRst, $06, nBb4, $12, nA4, $06, nRst, nG4, nRst, nBb4 dc.b nG4, nRst, nC5, nRst, nBb4, nRst, nG4 smpsJump Snd_DEZ2_FM1 ; Unreachable smpsStop ; FM2 Data Snd_DEZ2_FM2: smpsSetvoice $01 smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 Snd_DEZ2_Loop0C: dc.b nG1, $0C, nG1, nG1, nF2, $06, nG2, nG1, $0C, nG1, nG1, $06 dc.b nD2, nG1, $0C, nG1, nG1, nG1, nF2, $06, nG2, nG1, $0C, nG1 dc.b nC2, $06, nD2, nG1, $0C, nG1, nG1, nG1, nF2, $06, nG2, nG1 dc.b $0C, nG1, nC2, $06, nD2, nG1, $0C, nG1, nG1, nG1, nF2, $06 dc.b nG2, nG1, $0C, nG1, nC2, $06, nD2, nG1, $0C, nBb1, nBb1, nBb1 dc.b nBb1, nBb1, nBb1, nBb1, nAb1, $06, nBb1, nBb1, $0C, nBb1, nBb1, nBb1 dc.b nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nAb1 dc.b $06, nBb1, nBb1, $0C, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1, nBb1 smpsLoop $00, $02, Snd_DEZ2_Loop0C Snd_DEZ2_Loop0D: dc.b nAb1, $0C, nAb1, nAb1, $03, nRst, nAb2, nRst, nAb1, nRst, nAb2, nRst dc.b nAb1, $0C, nAb1, nAb1, $03, nRst, nAb2, nRst, nAb1, nRst, nAb2, nRst dc.b nBb1, $0C, nBb1, nBb1, $03, nRst, nBb2, nRst, nBb1, nRst, nBb2, nRst dc.b nBb1, $0C, nBb1, nBb1, $03, nRst, nBb2, nRst, nBb1, nRst, nBb2, nRst dc.b nC2, $06, nC2, $03, nRst, nBb2, $06, nC3, $03, nRst, nF2, $06 dc.b nG2, $03, nRst, nC2, nRst, nBb1, nRst, nC2, $06, nBb1, nC2, $03 dc.b nRst, nC2, $06, nRst, nC2, nRst, nC2, nC2, $0C, nC2, nRst, $48 smpsLoop $00, $02, Snd_DEZ2_Loop0D smpsJump Snd_DEZ2_FM2 ; Unreachable smpsStop ; FM3 Data Snd_DEZ2_FM3: smpsSetvoice $02 smpsModSet $0D, $01, $02, $06 smpsPan panRight, $00 Snd_DEZ2_Loop0A: smpsPan panRight, $00 dc.b nG2, $06, nBb2, nG2, nE2, nRst, $30 smpsPan panLeft, $00 dc.b nBb3, $06, nC4, nE4, nC4, nRst, $18 smpsPan panRight, $00 dc.b nEb3, $06, nG3, nF3, nBb3, nRst, $30 smpsPan panLeft, $00 dc.b nG2, $06, nBb2, nG2, nE2, nRst, $30 smpsPan panRight, $00 dc.b nBb3, $06, nC4, nE4, nC4, nRst, $18 smpsPan panLeft, $00 dc.b nEb3, $06, nG3, nF3, nBb3, nRst, $30, nRst, $18 smpsPan panRight, $00 dc.b nBb4, $06, nA4, nBb4, nBb4, nBb5, nA5, nBb5, nBb5, nBb4, nA4, nBb4 dc.b nBb4, nRst, $18 smpsPan panLeft, $00 dc.b nBb3, $06, nF3, nFs3, nD3, nEb3, nE3, nBb2, nB2, nG2, nAb2, nE2 dc.b nFs2, nRst, $18 smpsPan panRight, $00 dc.b nBb4, $06, nA4, nBb4, nBb4, nBb5, nA5, nBb5, nBb5, nBb4, nA4, nBb4 dc.b nBb4, nRst, $18 smpsPan panLeft, $00 dc.b nBb3, $06, nF3, nFs3, nD3, nEb3, nE3, nBb2, nB2, nG2, nAb2, nE2 dc.b nFs2 smpsLoop $00, $02, Snd_DEZ2_Loop0A Snd_DEZ2_Loop0B: dc.b nRst, $60 smpsLoop $00, $08, Snd_DEZ2_Loop0B smpsJump Snd_DEZ2_FM3 ; Unreachable smpsStop ; FM4 Data Snd_DEZ2_FM4: smpsModSet $0D, $01, $02, $06 smpsPan panLeft, $00 smpsSetvoice $00 Snd_DEZ2_Loop05: dc.b nRst, $18, nE4, $0B, nRst, $0D, nD4, $0B, nRst, $25, nC4, $0C dc.b nD4, $0B, nRst, $0D, nE4, $0B, nRst, $0D, nD4, $24, nRst, $18 dc.b nE4, $0B, nRst, $0D, nD4, $0B, nRst, $25, nC4, $0C, nD4, $0B dc.b nRst, $0D, nE4, $0B, nRst, $0D, nD4, $0B, nRst, $0D, nD4, $7F dc.b smpsNoAttack, nD4, $29, nC4, $0B, nRst, $0D, nD4, $6C, nA3, $06, nBb3 dc.b nA3, nRst, nG3, nA3, nG3, nRst, nF3, nG3, nF3, nRst, nE3, nF3 dc.b nE3, nRst smpsLoop $00, $02, Snd_DEZ2_Loop05 smpsSetvoice $03 Snd_DEZ2_Loop06: dc.b nAb2, $06, nBb2, nC3, nEb3 smpsLoop $00, $04, Snd_DEZ2_Loop06 Snd_DEZ2_Loop07: dc.b nBb2, $06, nC3, nD3, nF3 smpsLoop $00, $04, Snd_DEZ2_Loop07 dc.b nRst, $60, nRst, $06, nG4, $12, nF4, $06, nRst, nE4, nRst, nG4 dc.b nRst, nE4, nF4, $05, nRst, $07, nG4, $12 Snd_DEZ2_Loop08: dc.b nAb2, $06, nBb2, nC3, nEb3 smpsLoop $00, $04, Snd_DEZ2_Loop08 Snd_DEZ2_Loop09: dc.b nBb2, $06, nC3, nD3, nF3 smpsLoop $00, $04, Snd_DEZ2_Loop09 dc.b nRst, $60, nRst, $06, nG4, $12, nF4, $06, nRst, nE4, nRst, nG4 dc.b nE4, nRst, nA4, nRst, nG4, nRst, nE4 smpsJump Snd_DEZ2_FM4 ; Unreachable smpsStop ; FM5 Data Snd_DEZ2_FM5: dc.b nRst, $10 Snd_DEZ2_Jump00: smpsModSet $0D, $01, $02, $06 smpsPan panCenter, $00 Snd_DEZ2_Loop00: smpsSetvoice $00 dc.b nRst, $18, nG4, $0B, nRst, $0D, nF4, $0B, nRst, $25, nE4, $0C dc.b nF4, nRst, nG4, nRst, nF4, $24, nRst, $18, nG4, $0B, nRst, $0D dc.b nF4, $0B, nRst, $25, nE4, $0C, nF4, nRst, nG4, nRst, nF4, nRst dc.b nF4, $7F, smpsNoAttack, nF4, $29, nE4, $0B, nRst, $0D, nF4, $6C, nA4 dc.b $06, nBb4, nA4, nRst, nG4, nA4, nG4, nRst, nF4, nG4, nF4, nRst dc.b nE4, nF4, nE4, nRst smpsLoop $00, $02, Snd_DEZ2_Loop00 smpsSetvoice $03 Snd_DEZ2_Loop01: dc.b nAb3, $06, nBb3, nC4, nEb4 smpsLoop $00, $04, Snd_DEZ2_Loop01 Snd_DEZ2_Loop02: dc.b nBb3, $06, nC4, nD4, nF4 smpsLoop $00, $04, Snd_DEZ2_Loop02 dc.b nRst, $60, nRst, $06, nBb4, $12, nA4, $06, nRst, nG4, nRst, nBb4 dc.b nRst, nG4, nA4, nRst, nBb4, $12 Snd_DEZ2_Loop03: dc.b nAb3, $06, nBb3, nC4, nEb4 smpsLoop $00, $04, Snd_DEZ2_Loop03 Snd_DEZ2_Loop04: dc.b nBb3, $06, nC4, nD4, nF4 smpsLoop $00, $04, Snd_DEZ2_Loop04 dc.b nRst, $60, nRst, $06, nBb4, $12, nA4, $06, nRst, nG4, nRst, nBb4 dc.b nG4, nRst, nC5, nRst, nBb4, nRst, nG4 smpsJump Snd_DEZ2_Jump00 ; Unreachable smpsStop ; DAC Data Snd_DEZ2_DAC: dc.b dKickS3, $18, dSnareS3, dKickS3, dSnareS3 smpsLoop $00, $17, Snd_DEZ2_DAC dc.b dSnareS3, $0C, dSnareS3, nRst, $48 smpsJump Snd_DEZ2_DAC ; Unreachable smpsStop ; PSG1 Data Snd_DEZ2_PSG1: smpsStop ; PSG2 Data Snd_DEZ2_PSG2: smpsStop ; Unreachable smpsStop ; PSG3 Data Snd_DEZ2_PSG3: smpsStop Snd_DEZ2_Voices: ; Voice $00 ; $10 ; $42, $51, $66, $41, $1F, $1F, $5F, $1F, $04, $08, $08, $04 ; $00, $0F, $00, $00, $18, $38, $58, $18, $2D, $1E, $19, $85 smpsVcAlgorithm $00 smpsVcFeedback $02 smpsVcUnusedBits $00 smpsVcDetune $04, $06, $05, $04 smpsVcCoarseFreq $01, $06, $01, $02 smpsVcRateScale $00, $01, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $04, $08, $08, $04 smpsVcDecayRate2 $00, $00, $0F, $00 smpsVcDecayLevel $01, $05, $03, $01 smpsVcReleaseRate $08, $08, $08, $08 smpsVcTotalLevel $05, $19, $1E, $2D ; Voice $01 ; $38 ; $75, $13, $71, $11, $1F, $5F, $1F, $1F, $10, $0D, $03, $04 ; $00, $00, $00, $00, $FF, $FF, $FF, $FF, $1F, $16, $1D, $81 smpsVcAlgorithm $00 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $01, $07, $01, $07 smpsVcCoarseFreq $01, $01, $03, $05 smpsVcRateScale $00, $00, $01, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $04, $03, $0D, $10 smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $0F, $0F, $0F, $0F smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $01, $1D, $16, $1F ; Voice $02 ; $02 ; $71, $52, $49, $11, $17, $16, $15, $17, $0A, $07, $0C, $0C ; $00, $00, $00, $00, $FF, $FF, $FF, $FF, $11, $1D, $1D, $83 smpsVcAlgorithm $02 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $01, $04, $05, $07 smpsVcCoarseFreq $01, $09, $02, $01 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $17, $15, $16, $17 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0C, $0C, $07, $0A smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $0F, $0F, $0F, $0F smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $03, $1D, $1D, $11 ; Voice $03 ; $3D ; $43, $05, $23, $71, $11, $16, $55, $D5, $01, $01, $01, $01 ; $08, $00, $09, $00, $89, $F8, $F9, $F8, $1B, $88, $8A, $88 smpsVcAlgorithm $05 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $07, $02, $00, $04 smpsVcCoarseFreq $01, $03, $05, $03 smpsVcRateScale $03, $01, $00, $00 smpsVcAttackRate $15, $15, $16, $11 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $01, $01, $01, $01 smpsVcDecayRate2 $00, $09, $00, $08 smpsVcDecayLevel $0F, $0F, $0F, $08 smpsVcReleaseRate $08, $09, $08, $09 smpsVcTotalLevel $08, $0A, $08, $1B ; Unused voice: ; Voice $04 ; $03 ; $61, $51, $23, $41, $10, $10, $0F, $15, $1C, $01, $06, $05 ; $05, $01, $05, $01, $C9, $0C, $D9, $C9, $18, $17, $17, $83 smpsVcAlgorithm $03 smpsVcFeedback $00 smpsVcUnusedBits $00 smpsVcDetune $04, $02, $05, $06 smpsVcCoarseFreq $01, $03, $01, $01 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $15, $0F, $10, $10 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $05, $06, $01, $1C smpsVcDecayRate2 $01, $05, $01, $05 smpsVcDecayLevel $0C, $0D, $00, $0C smpsVcReleaseRate $09, $09, $0C, $09 smpsVcTotalLevel $03, $17, $17, $18
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; WriteMm7.Asm ; ; Abstract: ; ; AsmWriteMm7 function ; ; Notes: ; ;------------------------------------------------------------------------------ DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; AsmWriteMm7 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmWriteMm7) ASM_PFX(AsmWriteMm7): ; ; 64-bit MASM doesn't support MMX instructions, so use opcode here ; DB 0x48, 0xf, 0x6e, 0xf9 ret
; A021640: Decimal expansion of 1/636. ; 0,0,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2,7,0,4,4,0,2,5,1,5,7,2,3,2 add $0,1 mov $2,10 pow $2,$0 mov $0,$2 div $0,636 mod $0,10
; A213634: n-[n/m], where m is the least nondivisor of n (as in A007978) and [ ] = floor. ; 1,2,2,3,3,5,4,6,5,7,6,10,7,10,8,11,9,14,10,14,11,15,12,20,13,18,14,19,15,23,16,22,17,23,18,29,19,26,20,27,21,32,22,30,23,31,24,39,25,34,26,35,27,41,28,38,29,39,30,52,31,42,32,43,33,50,34,46,35,47,36,58,37,50,38,51,39,59,40,54,41,55,42,68,43,58,44,59,45,68,46,62,47,63,48,77,49,66,50,67,51,77,52,70,53,71,54,87,55,74,56,75,57,86,58,78,59,79,60,103,61,82,62,83,63,95,64,86,65,87,66,106,67,90,68,91,69,104,70,94,71,95,72,116,73,98,74,99,75,113,76,102,77,103,78,125,79,106,80,107,81,122,82,110,83,111,84,135,85,114,86,115,87,131,88,118,89,119,90,155,91,122,92,123,93,140,94,126,95,127,96,154,97,130,98,131,99,149,100,134,101,135,102,164,103,138,104,139,105,158,106,142,107,143,108,173,109,146,110,147,111,167,112,150,113,151,114,183,115,154,116,155,117,176,118,158,119,159,120,206,121,162,122,163,123,185,124,166,125,167 mov $2,$0 cal $0,213633 ; [A000027/A007978], where [ ] = floor. sub $2,$0 add $1,$2 add $1,1
; A294628: a(n) = 8*(sigma(n) - n + (1/2)). ; Submitted by Jon Maiga ; 4,12,12,28,12,52,12,60,36,68,12,132,12,84,76,124,12,172,12,180,92,116,12,292,52,132,108,228,12,340,12,252,124,164,108,444,12,180,140,404,12,436,12,324,268,212,12,612,68,348,172,372,12,532,140,516,188,260,12,868,12,276,332,508,156,628,12,468,220,596,12,988,12,324,396,516,156,724,12,852,324,356,12,1124,188,372,268,740,12,1156,172,612,284,404,204,1252,12,588,460,940 add $0,1 sub $1,$0 mov $2,$0 lpb $0 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 add $1,$3 lpe add $1,1 mov $0,$1 mul $0,8 add $0,4
// Class1.cpp #include "pch.h" #include "Class1.h" using namespace cx_boxing; using namespace Platform; Class1::Class1() { //<snippet01> Object^ obj = 5; //scalar value is implicitly boxed int i = safe_cast<int>(obj); //unboxed with explicit cast. //</snippet01> }
bits 64 default rel stub_offset: dq stub stub_success: dq 0x1111111111111111 ; return address used when the embedded texture is found stub_failed: dq 0x2222222222222222 ; return address to continue searching for the texture in fwTxdStore fragment_store: dq 0x3333333333333333 drawable_store: dq 0x4444444444444444 get_hash_key: dq 0x5555555555555555 ; uint(*)(const char* str, uint startHash) align 16 stub: ; rcx = texture dictionary ; rdx = texture name push rcx push rdx ; save texture names call find_embedded_texture pop rdx ; restore texture names pop rcx test rax, rax jz .failed ; if (texture == null) continue_searching else return texture jmp [stub_success] .failed: mov rdi, rdx ; execute the instructions replaced by the jump hook before jumping back mov r8, rcx jmp [stub_failed] ; params ; const char* texture_dictionary - rcx ; const char* texture_name - rdx ; returns ; rage::grcTexture* texture - rax align 16 find_embedded_texture: sub rsp, 0x38 ; if (texture_dictionary startsWith 'embed:') search else return null xor rax, rax %macro check_char 2 cmp byte [rcx + %1], %2 jne .exit %endmacro check_char 0, 'e' check_char 1, 'm' check_char 2, 'b' check_char 3, 'e' check_char 4, 'd' check_char 5, ':' %unmacro check_char 2 cmp byte [rcx + 6], 0 je .exit lea rcx, [rcx + 6] ; trim 'embed:' mov qword [rsp+0x30], rdx mov qword [rsp+0x28], rcx call find_fragment_embedded_texture test rax, rax jnz .exit mov rcx, qword [rsp+0x28] mov rdx, qword [rsp+0x30] call find_drawable_embedded_texture .exit: add rsp, 0x38 ret fragType_PrimaryDrawable: equ 0x30 rmcDrawableBase_ShaderGroup: equ 0x10 grmShaderGroup_Textures: equ 0x8 pgDictionary_Keys: equ 0x20 pgDictionary_Values: equ 0x30 atArray_Items: equ 0x0 atArray_Count: equ 0x8 fwAssetStore_FindSlot: equ 0x10 fwAssetStore_GetPtr: equ 0x40 ; params ; const char* texture_dictionary - rcx ; const char* texture_name - rdx ; returns ; rage::grcTexture* texture - rax align 16 find_fragment_embedded_texture: push rbx sub rsp, 0x40 ; rsp + 0x38 = strLocalIndex ; rsp + 0x30 = texture_dictionary ; rsp + 0x28 = texture_name mov qword [rsp + 0x30], rcx mov qword [rsp + 0x28], rdx xor rax, rax mov rbx, [fragment_store] ; rbx = fwAssetStore<fragType> test rbx, rbx jz .exit mov rax, [rbx] ; get vtable mov rcx, rbx ; fragment_store lea rdx, qword [rsp + 0x38] ; &index mov r8, qword [rsp + 0x30] ; texture_dictionary call qword [rax + fwAssetStore_FindSlot] ; FindSlot(fragment_store, &index, texture_dictionary) xor rax, rax cmp dword [rsp + 0x38], -1 ; if (index == -1) return null; je .exit mov rax, [rbx] ; get vtable mov rcx, rbx ; fragment_store mov edx, dword [rsp + 0x38] ; index call qword [rax + fwAssetStore_GetPtr] ; fragType* GetPtr(fragment_store, index) test rax, rax jz .exit ; if (fragType == null) return null; ; we found the fragType, search for the textures in its drawables mov rbx, rax ; rbx = fragType mov rcx, qword [rsp + 0x28] ; texture_name xor rdx, rdx ; startHash = 0 call qword [get_hash_key] mov rcx, qword [rbx + fragType_PrimaryDrawable] ; drawable mov edx, eax ; texture_name_hash call search_texture_in_drawable ; search_texture_in_drawable(drawable, texture_name_hash) .exit: add rsp, 0x40 pop rbx ret align 16 find_drawable_embedded_texture: push rbx sub rsp, 0x40 ; rsp + 0x38 = strLocalIndex ; rsp + 0x30 = texture_dictionary ; rsp + 0x28 = texture_name mov qword [rsp + 0x30], rcx mov qword [rsp + 0x28], rdx xor rax, rax mov rbx, [drawable_store] ; rbx = fwAssetStore<rmcDrawable> test rbx, rbx jz .exit mov rax, [rbx] ; get vtable mov rcx, rbx ; drawable_store lea rdx, qword [rsp + 0x38] ; &index mov r8, qword [rsp + 0x30] ; texture_dictionary call qword [rax + fwAssetStore_FindSlot] ; FindSlot(drawable_store, &index, texture_dictionary) xor rax, rax cmp dword [rsp + 0x38], -1 ; if (index == -1) return null; je .exit mov rax, [rbx] ; get vtable mov rcx, rbx ; drawable_store mov edx, dword [rsp + 0x38] ; index call qword [rax + fwAssetStore_GetPtr] ; rmcDrawable* GetPtr(drawable_store, index) test rax, rax jz .exit ; if (drawable == null) return null; ; we found the drawable, search it for the textures mov rbx, rax ; rbx = rmcDrawable mov rcx, qword [rsp + 0x28] ; texture_name xor rdx, rdx ; startHash = 0 call qword [get_hash_key] mov rcx, rbx ; drawable mov edx, eax ; texture_name_hash call search_texture_in_drawable ; search_texture_in_drawable(drawable, texture_name_hash) .exit: add rsp, 0x40 pop rbx ret ; params ; rmcDrawableBase* drawable - rcx ; uint texture_name_hash - edx ; returns ; rage::grcTexture* texture - rax align 16 search_texture_in_drawable: xor rax, rax test rcx, rcx jz .exit mov rcx, qword [rcx + rmcDrawableBase_ShaderGroup] mov rcx, qword [rcx + grmShaderGroup_Textures] lea r9, qword [rcx + pgDictionary_Keys] mov r8, qword [r9 + atArray_Items] ; keys are sorted so binary search could be used, but I don't think any drawable will have enough textures to make it worthy, so just do linear search .loop: ; rax = i cmp ax, word [r9 + atArray_Count] ; while (i < keys.Count) jge .not_found cmp edx, dword [r8 + rax * 4] ; if (texture_name_hash == keys[i]) found else continue je .found add rax, 1 ; i++ jmp .loop .not_found: xor rax, rax jmp .exit .found: lea r9, qword [rcx + pgDictionary_Values] mov r8, qword [r9 + atArray_Items] mov rax, qword [r8 + rax * 8] ; return values[i] .exit: ret
; A191373: Sum of binomial coefficients C(i+j,i) modulo 2 over all pairs (i,j) of positive integers satisfying 5i+j=n. ; Submitted by Jamie Morken(s4) ; 1,1,1,1,1,2,1,2,1,2,2,3,1,2,2,4,1,2,2,4,2,3,3,5,1,3,2,5,2,3,4,6,1,3,2,6,2,3,4,6,2,4,3,7,3,5,5,8,1,4,3,8,2,3,5,8,2,4,3,8,4,6,6,9,1,5,3,9,2,3,6,9,2,4,3,9 lpb $0 sub $0,4 mov $2,$0 add $3,1 bin $2,$3 mod $2,2 add $1,$2 lpe mov $0,$1 add $0,1
; Ti82 Graylib interrupt ;--------------------------------------------------------------------------- ; ; Ported by Stefano Bodrato - Mar 2000 ; ; Recoded -because of strange problems- by Henk Poley - July 2001 ; Based upon vnGrey, a Venus greyscale library (Ti83). ; ; $Id: gray82.asm,v 1.6 2015/01/21 07:05:00 stefano Exp $ ; defc intcount = $8501 ; 1 byte - interrupt variable INCLUDE "int82.asm" ; Put interrupt loader here ; xor a ; We need to intialize variables ld (intcount),a ; by ourself. ; jp jump_over ; Jump over the interrupt code ;----------------- ; Actual interrupt ;----------------- IntProcStart: push af ; ld a,(intcount) ; Check if own interrupt has quited bit 7,a ; correctly, then bit 7 is zero jr nz,int_fix ; If not zero, fix stack... push hl ; push de ; push bc ; push iy ; ld iy,_IY_TABLE ; ; exit_interrupt: in a,(3) ; check vbl int and @00000010 ; jr z,exit_interrupt2 ; ld hl,intcount ; int counter res 7,(hl) ; inc (hl) ; ld a,(hl) ; dec a ; 1 jr z,Display_pic1 ; dec a ; 2 jr z,Display_pic2 ; ld (hl),0 ; reset counter exit_interrupt2: ld hl,intcount ; If a 'direct interrupt' occures set 7,(hl) ; right after the TIOS-int, then ; we want bit 7 to be set... exx ; Swap to shadow registers. ex af,af ; So the TIOS swaps back to the ; normal ones... (the ones we saved ; with push/pops) rst $38 ; di ; 'BIG' HOLE HERE... (TIOS does ei...) ex af,af ; exx ; ; ld hl,intcount ; Interrupt returned correctly, so res 7,(hl) ; we reset our error-condition... ; in a,(3) ; check on interrupt status rra ; ld a,0 ; adc a,9 ; out (3),a ; ld a,$0B ; out (3),a ; ; pop iy ; pop bc ; pop de ; pop hl ; pop af ; ei ; ret ; int_fix: pop af ; Pop AF back ex af,af ; Fix shadowregs back exx ; pop bc ; Pop the returnpoint of RST $38 ; from the stack jr exit_interrupt ; Continue with interrupt Display_pic1: ld hl,(graybit1) ; jr DisplayPicture ; Display_pic2: ld hl,(graybit2) ; DisplayPicture: ld a,$80 ; fastCopy routine out ($10),a ; (Joe Wingbermuehle) ld a,$20 ; ld c,a ; ld de,755 ; add hl,de ; fastCopyAgain: ld b,64 ; inc c ; ld de,-(12*64)+1 ; out ($10),a ; add hl,de ; ld de,10 ; fastCopyLoop: add hl,de ; inc hl ; inc hl ; inc de ; ld a,(hl) ; out ($11),a ; dec de ; push ix ; Little slowdown... pop ix ; ...Needed (?) djnz fastCopyLoop ; ld a,c ; cp $2B+1 ; jr nz,fastCopyAgain ; jr exit_interrupt2 ; IntProcEnd: PUBLIC graybit1 PUBLIC graybit2 graybit1: defw GRAPH_MEM graybit2: defw gbuf2 ; use in-program buffer gbuf2: defs 768 ; allocate space here ;NOTE: APD_BUF can't be used for the buffer, the interrupt table and ; routine reside there, overwriting that space will cause a crash. jump_over: ; Memory usage in APD_BUF: ; ------------------------------------------------------ ; $8228 / $8281 - 90 bytes - free ; $8282 / $83FF - 382 bytes - partialy used by interrupt ; $8400 / $8500 - 256 bytes - IV table ; $8501 - 1 byte - intcount <-- ; $8502 / $8528 - 39 bytes - free ; ------------------------------------------------------
/** * @example oglplus/028_glass_shape.cpp * @brief Show a simple simulation of refractive transparent object * * @oglplus_screenshot{028_glass_shape} * * Copyright 2008-2013 Matus Chochlik. Distributed under the Boost * Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * * @oglplus_example_uses_gl{GL_VERSION_3_3} * @oglplus_example_uses_gl{GL_ARB_separate_shader_objects;GL_EXT_direct_state_access} */ #include <oglplus/gl.hpp> #include <oglplus/all.hpp> #include <oglplus/shapes/plane.hpp> #include <oglplus/shapes/spiral_sphere.hpp> #include <oglplus/bound/texture.hpp> #include <cmath> #include "example.hpp" namespace oglplus { class GlassExample : public Example { private: // helper object building and storing plane drawing instructions shapes::Plane make_plane; shapes::DrawingInstructions plane_instr; shapes::Plane::IndexArray plane_indices; // helper object building and storing shape drawing instructions typedef shapes::SpiralSphere Shape; Shape make_shape; shapes::DrawingInstructions shape_instr; Shape::IndexArray shape_indices; Context gl; VertexShader plane_vs, shape_vs; FragmentShader plane_fs, shape_fs; Program plane_prog, shape_prog; LazyUniform<Mat4f> plane_camera_matrix, plane_model_matrix, shape_camera_matrix, shape_model_matrix; LazyUniform<Vec4f> shape_clip_plane; LazyUniform<GLfloat> shape_clip_direction; VertexArray plane, shape; Buffer plane_verts, plane_texcoords; Buffer shape_verts, shape_normals; // Texture user for the simulation of refraction Texture refract_tex; GLuint width, height, tex_side; public: GlassExample(void) : make_plane(Vec3f(2.0f, 0.0f, 0.0f), Vec3f(0.0f, 0.0f, -2.0f)) , plane_instr(make_plane.Instructions()) , plane_indices(make_plane.Indices()) , make_shape() , shape_instr(make_shape.Instructions()) , shape_indices(make_shape.Indices()) , plane_vs(ObjectDesc("Plane vertex")) , shape_vs(ObjectDesc("Shape vertex")) , plane_fs(ObjectDesc("Plane fragment")) , shape_fs(ObjectDesc("Shape fragment")) , plane_camera_matrix(plane_prog, "CameraMatrix") , plane_model_matrix(plane_prog, "ModelMatrix") , shape_camera_matrix(shape_prog, "CameraMatrix") , shape_model_matrix(shape_prog, "ModelMatrix") , shape_clip_plane(shape_prog, "ClipPlane") , shape_clip_direction(shape_prog, "ClipDirection") , width(512) , height(512) , tex_side(512) { plane_vs.Source( "#version 330\n" "uniform vec3 LightPosition;" "uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;" "in vec4 Position;" "in vec2 TexCoord;" "out vec3 vertLightDir;" "out vec2 vertTexCoord;" "void main(void)" "{" " gl_Position = " " ModelMatrix* " " Position;" " vertLightDir = normalize(" " LightPosition - gl_Position.xyz" " );" " gl_Position = " " ProjectionMatrix *" " CameraMatrix *" " gl_Position;" " vertTexCoord = TexCoord;" "}" ); plane_vs.Compile(); plane_fs.Source( "#version 330\n" "uniform vec3 Normal;" "in vec3 vertLightDir;" "in vec2 vertTexCoord;" "out vec4 fragColor;" "void main(void)" "{" " float checker = (" " int(vertTexCoord.x*18) % 2+" " int(vertTexCoord.y*18) % 2" " ) % 2;" " vec3 color = mix(" " vec3(0.2, 0.4, 0.9)," " vec3(0.2, 0.2, 0.7)," " checker" " );" " float d = dot(" " Normal, " " vertLightDir" " );" " float intensity = 0.5 + pow(1.4*d, 2.0);" " fragColor = vec4(color*intensity, 1.0);" "}" ); plane_fs.Compile(); plane_prog.AttachShader(plane_vs); plane_prog.AttachShader(plane_fs); plane_prog.Link(); plane_prog.Use(); Vec3f lightPos(3.0f, 3.0f, 3.0f); Uniform<Vec3f>(plane_prog, "LightPosition").Set(lightPos); Uniform<Vec3f>(plane_prog, "Normal").Set(make_plane.Normal()); plane.Bind(); plane_verts.Bind(Buffer::Target::Array); { std::vector<GLfloat> data; GLuint n_per_vertex = make_plane.Positions(data); Buffer::Data(Buffer::Target::Array, data); VertexAttribArray attr(plane_prog, "Position"); attr.Setup<GLfloat>(n_per_vertex); attr.Enable(); } plane_texcoords.Bind(Buffer::Target::Array); { std::vector<GLfloat> data; GLuint n_per_vertex = make_plane.TexCoordinates(data); Buffer::Data(Buffer::Target::Array, data); VertexAttribArray attr(plane_prog, "TexCoord"); attr.Setup<GLfloat>(n_per_vertex); attr.Enable(); } shape_vs.Source( "#version 330\n" "uniform vec3 LightPosition;" "uniform mat4 ProjectionMatrix, ModelMatrix, CameraMatrix;" "uniform vec4 ClipPlane;" "uniform float ClipDirection;" "in vec4 Position;" "in vec3 Normal;" "out vec3 vertNormal;" "out vec3 vertLightDir;" "out vec3 vertLightRefl;" "out vec3 vertViewDir;" "out vec2 vertTexCoord;" "void main(void)" "{" " gl_Position = " " ModelMatrix *" " Position;" " gl_ClipDistance[0] = " " ClipDirection* " " dot(ClipPlane, gl_Position);" " vertLightDir = LightPosition - gl_Position.xyz;" " vertNormal = mat3(ModelMatrix)*Normal;" " vertLightRefl = reflect(" " -normalize(vertLightDir)," " normalize(vertNormal)" " );" " vertViewDir = (vec4(0.0, 0.0, 1.0, 1.0)*CameraMatrix).xyz;" " gl_Position = ProjectionMatrix * CameraMatrix * gl_Position;" " vec3 TexOffs = mat3(CameraMatrix)*vertNormal*0.05;" " vertTexCoord = " " vec2(0.5, 0.5) +" " (gl_Position.xy/gl_Position.w)*0.5 +" " (TexOffs.z<0.0 ? TexOffs.xy : -TexOffs.xy);" "}" ); shape_vs.Compile(); shape_fs.Source( "#version 330\n" "uniform sampler2D RefractTex;" "in vec3 vertNormal;" "in vec3 vertLightDir;" "in vec3 vertLightRefl;" "in vec3 vertViewDir;" "in vec2 vertTexCoord;" "out vec4 fragColor;" "float adj_lt(float i)" "{" " return i > 0.0 ? i : -0.7*i;" "}" "void main(void)" "{" " float l = length(vertLightDir);" " float d = dot(" " normalize(vertNormal), " " normalize(vertLightDir)" " ) / l;" " float s = dot(" " normalize(vertLightRefl)," " normalize(vertViewDir)" " );" " vec3 lt = vec3(1.0, 1.0, 1.0);" " vec3 tex = texture(RefractTex, vertTexCoord).rgb;" " fragColor = vec4(" " tex * 0.5 + " " (lt + tex) * 1.5 * adj_lt(d) + " " lt * pow(adj_lt(s), 64), " " 1.0" " );" "}" ); shape_fs.Compile(); shape_prog.AttachShader(shape_vs); shape_prog.AttachShader(shape_fs); shape_prog.Link(); shape_prog.Use(); Uniform<Vec3f>(shape_prog, "LightPosition").Set(lightPos); shape.Bind(); shape_verts.Bind(Buffer::Target::Array); { std::vector<GLfloat> data; GLuint n_per_vertex = make_shape.Positions(data); Buffer::Data(Buffer::Target::Array, data); VertexAttribArray attr(shape_prog, "Position"); attr.Setup<GLfloat>(n_per_vertex); attr.Enable(); } shape_normals.Bind(Buffer::Target::Array); { std::vector<GLfloat> data; GLuint n_per_vertex = make_shape.Normals(data); Buffer::Data(Buffer::Target::Array, data); VertexAttribArray attr(shape_prog, "Normal"); attr.Setup<GLfloat>(n_per_vertex); attr.Enable(); } // Texture::Active(0); UniformSampler(shape_prog, "RefractTex").Set(0); { auto bound_tex = Bind(refract_tex, Texture::Target::_2D); bound_tex.Image2D( 0, PixelDataInternalFormat::RGB, tex_side, tex_side, 0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr ); bound_tex.MinFilter(TextureMinFilter::Linear); bound_tex.MagFilter(TextureMagFilter::Linear); bound_tex.WrapS(TextureWrap::MirroredRepeat); bound_tex.WrapT(TextureWrap::MirroredRepeat); } // gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f); gl.ClearDepth(1.0f); gl.Enable(Capability::DepthTest); } void Reshape(GLuint vp_width, GLuint vp_height) { width = vp_width; height = vp_height; tex_side = width < height ? width : height; gl.Viewport(width, height); Mat4f projection = CamMatrixf::PerspectiveX( Degrees(48), double(width)/height, 1, 15 ); SetProgramUniform(plane_prog, "ProjectionMatrix", projection); SetProgramUniform(shape_prog, "ProjectionMatrix", projection); } void Render(double time) { gl.Clear().ColorBuffer().DepthBuffer(); // auto camera = CamMatrixf::Orbiting( Vec3f(), 5.5, FullCircles(time / 10.0), Degrees(45.0 + SineWave(time / 7.0)*30.0) ); // Render the plane plane_prog.Use(); plane_camera_matrix.Set(camera); plane_model_matrix.Set( ModelMatrixf::Translation(0.0f, -1.1f, 0.0f) ); plane.Bind(); plane_instr.Draw(plane_indices); // Render the shape shape_prog.Use(); auto clip_plane = Planef::FromNormal(Vec3f(Data(camera.Row(2)), 3)); shape_clip_plane.Set(clip_plane.Equation()); shape_camera_matrix.Set(camera); shape_model_matrix.Set( ModelMatrixf::RotationX(FullCircles(time / 12.0)) ); shape.Bind(); gl.Enable(Capability::CullFace); gl.Enable(Functionality::ClipDistance, 0); gl.FrontFace(make_shape.FaceWinding()); GLfloat clip_dirs[2] = {-1.0f, 1.0f}; Face facing_dirs[2] = {Face::Front, Face::Back}; for(int c=0; c!=2; ++c) { shape_clip_direction.Set(clip_dirs[c]); for(int f=0; f!=2; ++f) { Texture::CopyImage2D( Texture::Target::_2D, 0, PixelDataInternalFormat::RGB, tex_side == width ? 0 : (width - tex_side) / 2, tex_side == height? 0 : (height- tex_side) / 2, tex_side, tex_side, 0 ); gl.CullFace(facing_dirs[f]); shape_instr.Draw(shape_indices); } } gl.Disable(Functionality::ClipDistance, 0); gl.Disable(Capability::CullFace); } bool Continue(double time) { return time < 60.0; } }; void setupExample(ExampleParams& /*params*/){ } std::unique_ptr<ExampleThread> makeExampleThread( Example& /*example*/, unsigned /*thread_id*/, const ExampleParams& /*params*/ ){ return std::unique_ptr<ExampleThread>(); } std::unique_ptr<Example> makeExample(const ExampleParams& /*params*/) { return std::unique_ptr<Example>(new GlassExample); } } // namespace oglplus
/* Formatação Monetária https://www.urionlinejudge.com.br/judge/pt/problems/view/1309 */ #include <iostream> #include <iomanip> using namespace std; void printCurrency(int dollars, int cents); void printDollars(int dollars); void printCents(int cents); int main(void) { ios::sync_with_stdio(false); int dollars, cents; while (cin >> dollars >> cents) { printCurrency(dollars, cents); } return 0; } void printCurrency(int dollars, int cents) { printDollars(dollars); printCents(cents); } void printDollars(int dollars) { if (dollars < 1000) { cout << '$' << dollars; } else { printDollars(dollars / 1000); cout << ',' << setw(3) << setfill('0') << (dollars % 1000); } } void printCents(int cents) { cout << '.' << setw(2) << setfill('0') << cents << endl; }
code segment ;octal multiplier by omer cihan benzer 2017400048 ;input read starts here mov ah , 02 mov cx , 22d mov bx , stringone oneloop: mov dl , [bx] int 21h inc bx dec cx jnz oneloop call reader mov oneh , dx ; oneh is the numberOneHigh mov onel , bx ; onel is the numberOneLow mov ah , 02 mov dl , 0A ; print '\n' int 21h mov ah , 02 mov cx , 22d mov bx , stringtwo twoloop: mov dl , [bx] int 21h inc bx dec cx jnz twoloop call reader mov twoh , dx ; twoh is the numberTwoHigh mov twol , bx ; twol is the numberTwoLow mov ah , 02 mov dl , 0A ; print '\n' int 21h ;input read ends here ; just to help with debug push onel push oneh push twol push twoh pop ax pop ax pop ax pop ax ;multiplication starts here mov ax , onel mov bx , twol mul bx ; result is dx:ax mov out1h , dx mov out1l , ax mov ax , onel mov bx , twoh mul bx ;result is dx:ax mov out2h , dx mov out2l , ax mov ax , oneh mov bx , twol mul bx ; result is dx:ax mov out3h , dx mov out3l , ax mov ax , oneh mov bx , twoh mul bx ; result is dx:ax mov out4h , dx mov out4l , ax ;now we add them together to create outd4:outd3:outd2:outd1 mov ax , out1l mov outd1 , ax ;outd1 complete mov ax , 0 mov cx , 0 add ax , cx ;to reset cf mov temp w, 0 mov ax , out1h mov bx , out2l add ax , bx jnc jump21 inc temp w ; if carry, we increase remainder to add to outd3 jump21: push ax mov ax , 0 add ax , cx ;to reset cf pop ax mov bx , out3l add ax , bx jnc jump22 inc temp w ; if carry, we increase remainder to add to outd3 jump22: mov outd2 , ax ; outd2 complete and we have temp as remainder mov ax , 0 add ax , cx ;to reset cf mov ax , temp mov temp , 0 mov bx , out2h add ax , bx jnc jump31 inc temp ; if carry, we increase remainder to add to outd3 jump31: push ax mov ax , 0 mov cx , 0 add ax , cx ;to reset cf pop ax mov bx , out3h add ax , bx jnc jump32 inc temp jump32: push ax mov ax , 0 add ax , cx ;to reset cf pop ax mov bx , out4l add ax , bx jnc jump33 inc temp jump33: mov outd3 , ax ;outd3 complete and we have temp as remainder mov ax , temp mov bx , out4h add ax , bx mov outd4 , ax ;outd4 complete and our number is at outd4:outd3:outd2:outd1 ;multiplication ends here ; just to help with debug push outd1 push outd2 push outd3 push outd4 pop ax pop ax pop ax pop ax ;output write starts here mov cx , 1 ;cx is our counter mov bx , 0 push bx outputloop: call divider mov bx , 0 cmp ax , bx ;ax is outd1 jnz comparerfail mov ax , outd2 cmp ax , bx jnz comparerfail mov ax , outd3 cmp ax , bx jnz comparerfail mov ax , outd4 cmp ax , bx jnz comparerfail jmp outputloopend ; if all of outd1,2,3,4 are 0 jump to end comparerfail: ; else loop continues inc cx push dx jmp outputloop outputloopend: push dx mov ah , 02 outputwriteloop: pop dx add dx , 30h int 21h dec cx mov bx , 0 cmp cx , bx jnz outputwriteloop outputwriteloopend: ;output write ends here ;print method for stringend mov ah , 02 mov cx , 24d mov bx , stringend mov dl , 0A ; echo '\n' int 21h endloop: mov dl , [bx] int 21h inc bx dec cx jnz endloop endend: mov ah , 01 int 21h int 20h reader: mov ax , 0 mov bx , 0 mov cx , 0 mov dx , 0 readerloop: ; dx:bx inputHigh:inputLow mov ah , 01 int 21h cmp al , 0D ; 0D equals to return or '\n' je readerend mov ah , 0 sub al , 30h ; 30h for '0' mov readerd , ax mov ax , dx mov cx , 8d mul cx mov readera , ax mov ax , bx mul cx mov readerb , dx mov readerc , ax ; declaration complete mov ax , 0 mov cx , 0 mov dx , readerb add ax , cx ; to reset cf mov ax , readerc mov bx , readerd add ax , bx jnc readermore inc dx ; the remainder readermore: mov bx , ax mov cx , readera add dx , cx jmp readerloop readerend: ret ; dont forget, number is at dx:bx divider: mov ax , 0 mov bx , 8 ; to divide by bx later mov dx , 0 mov ax , outd4 div bx ; ax is quotient, dx is remainder mov outd4 , ax mov ax , outd3 div bx ; mov outd3 , ax mov ax , outd2 div bx mov outd2 , ax mov ax , outd1 div bx mov outd1 , ax ; remainder is in dx, quotient is in ax ret ; variables: readera dw ? ; lets say dx:bx is the number we have and the input is input readerb dw ? ; as we know the input wont exceed 2^32, dx*8=0000:____ . readerc dw ? ; So we record the mid numbers as such: readerd dw ? ; dx*8 = readera bx*8=readerb:readerc input=readerd oneh dw ? ; number1 high onel dw ? ; number1 low twoh dw ? ; number2 high twol dw ? ; number2 low out1h dw ? ; out1 is onel*twol out1l dw ? ; out2h dw ? ; out2 is onel*twoh out2l dw ? ; out3h dw ? ; out3 is oneh*twol out3l dw ? ; out4h dw ? ; out4 is oneh*twoh out4l dw ? ; outd1 dw ? ; outd's are output in binary state, from lowest to highest outd2 dw ? ; outd3 dw ? ; outd4 dw ? ; temp dw ? ; just a temp to use in multiplication and at the very begginging of the output ;would i use these? outq1 dw ? ; outq's are outd/8 outq2 dw ? ; outq3 dw ? ; so they are the quotients of outd's outq4 dw ? ; outr1 dw ? ; outr's are outd%8 outr2 dw ? ; outr3 dw ? ; so they are the remainders of outd's outr4 dw ? ; stringone: db 'Please enter number 1:' stringtwo: db 'Please enter number 2:' stringend: db 'Press anything to close.' code ends
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++11-compat -verify %s #if __cplusplus < 201103L namespace N { template<typename T> void f(T) {} // expected-note 2{{here}} namespace M { template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}} } } using namespace N; template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}} template<typename T> void g(T) {} // expected-note 2{{here}} namespace M { template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}} } template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}} void g() { auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}} } int n; struct S { char c; } s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}} t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}} #define PRIuS "uS" int printf(const char *, ...); typedef __typeof(sizeof(int)) size_t; void h(size_t foo, size_t bar) { printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar); // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} } #define _x + 1 char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}} #else auto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++1y}} #endif
BITS 16 ORG 0x7C00 main: jmp short start %include "BPB.inc" %include "CommonMacros.inc" LOAD_KERNEL_AT: equ 0x00100000 %ifdef ULTRA_32 KERNEL_ORIGIN: equ 0xC0000000 KERNEL_ENTRYPOINT: equ LOAD_KERNEL_AT %elifdef ULTRA_64 KERNEL_ORIGIN: equ 0xFFFFFFFF80000000 PHYS_MEMORY: equ 0xFFFF800000000000 KERNEL_ENTRYPOINT: equ KERNEL_ORIGIN + LOAD_KERNEL_AT %endif start: ; copy the boot context from VBR push ds xor ax, ax mov ds, ax mov di, boot_context mov cx, BOOT_CONTEXT_SIZE rep movsb ; copy the BPB from VBR xor ax, ax mov ds, ax mov si, VBR_ORIGIN + BPB_OFFSET mov di, BPB mov cx, BPB_SIZE rep movsb pop ds ; ---- try enable the A20 line ---- enable_a20: ; check if its already enabled call is_a20_enabled cmp ax, 1 je a20_success ; try using the BIOS interrupt 15 call try_enable_a20_using_bios call is_a20_enabled cmp ax, 1 je a20_success ; try using the 8042 controller call try_enable_a20_using_8042 call is_a20_enabled cmp ax, 1 je a20_success ; try using fast gate call try_enable_a20_using_fast_gate call is_a20_enabled cmp ax, 1 je a20_success a20_failure: mov si, a20fail_msg call write_string call reboot a20_success: mov si, dskread_msg call write_string mov si, loading_msg call write_string ; read the first sector of the root directory read_root_directory [boot_drive], FAT_DIRECTORY_SEGMENT, 0x0000 read_directory_file_protected LOAD_KERNEL_AT, 1, kernel_file read_directory_file_protected 0x45000, 2, ksyms_file xor ax, ax mov es, ax retrieve_memory_map memory_map_ptr, memory_map.entry_count set_video_mode 1024, 768, 32 %ifdef ULTRA_64 GET_HIGHEST_EXTENDED_FUNCTION: equ 0x80000000 EXTENDED_PROCESSOR_INFO: equ 0x80000001 LONG_MODE_SUPPORTED_BIT: equ 1 << 29 ; TODO: we kinda assmume that CPUID is supported here, should we check for it? mov eax, GET_HIGHEST_EXTENDED_FUNCTION cpuid cmp eax, EXTENDED_PROCESSOR_INFO jl no_long_mode mov eax, EXTENDED_PROCESSOR_INFO cpuid test edx, LONG_MODE_SUPPORTED_BIT jnz long_mode_supported no_long_mode: mov si, no_long_mode_message call write_string call reboot long_mode_supported: NOTIFY_BIOS: equ 0xEC00 LONG_MODE_ONLY: equ 0x2 mov ax, NOTIFY_BIOS mov bl, LONG_MODE_ONLY int 0x15 %endif switch_to_protected %ifdef ULTRA_32 jump_to_kernel: ; move the pointers into higher half add [memory_map.pointer], dword KERNEL_ORIGIN mov eax, context add eax, KERNEL_ORIGIN ; jump to the kernel jmp KERNEL_ENTRYPOINT %elifdef ULTRA_64 PAGE_SIZE: equ 4096 DWORDS_IN_PAGE: equ PAGE_SIZE / 4 PT_ENTRY_SIZE: equ 8 PDT_ENTRY_SIZE: equ 8 ENTRY_COUNT: equ 512 PAE_BIT: equ 1 << 5 EFER_NUMBER: equ 0xC0000080 LONG_MODE_BIT: equ 1 << 8 PAGING_BIT: equ 1 << 31 PRESENT: equ 1 << 0 READWRITE: equ 1 << 1 HUGEPAGE: equ 1 << 7 HUGEPAGE_SIZE: equ 0x200000 switch_to_long_mode: mov edi, PML4 mov cr3, edi xor eax, eax mov ecx, DWORDS_IN_PAGE * 7 ; zero 7 pages rep stosd mov edi, cr3 mov [edi], dword PDPT_0 | PRESENT | READWRITE mov [edi + 256 * 8], dword PDPT_0 | PRESENT | READWRITE mov [edi + 511 * 8], dword PDPT_1 | PRESENT | READWRITE mov edi, dword PDT_GB0 mov ebx, 0x00000000 | PRESENT | READWRITE | HUGEPAGE mov ecx, ENTRY_COUNT * 4 ; 4 tables set_one: mov [edi], ebx add ebx, HUGEPAGE_SIZE add edi, PDT_ENTRY_SIZE loop set_one mov edi, dword PDPT_0 mov [edi + 8 * 0], dword PDT_GB0 | PRESENT | READWRITE mov [edi + 8 * 1], dword PDT_GB1 | PRESENT | READWRITE mov [edi + 8 * 2], dword PDT_GB2 | PRESENT | READWRITE mov [edi + 8 * 3], dword PDT_GB3 | PRESENT | READWRITE mov edi, dword PDPT_1 mov [edi + 8 * 510], dword PDT_GB0 | PRESENT | READWRITE mov [edi + 8 * 511], dword PDT_GB1 | PRESENT | READWRITE mov eax, cr4 or eax, PAE_BIT mov cr4, eax mov ecx, EFER_NUMBER rdmsr or eax, LONG_MODE_BIT wrmsr mov eax, cr0 or eax, PAGING_BIT mov cr0, eax lgdt [gdt_entry] jmp gdt_ptr.code_64:jump_to_kernel BITS 64 jump_to_kernel: mov ax, gdt_ptr.data_32 mov ss, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax ; move the pointers into higher half mov rax, PHYS_MEMORY add rax, [video_mode.framebuffer] mov qword [video_mode.framebuffer], rax mov rax, PHYS_MEMORY add rax, [memory_map.pointer] mov qword [memory_map.pointer], rax mov r8, PHYS_MEMORY add r8, context jmp KERNEL_ENTRYPOINT %else %error Couldn't detect the target architecture %endif BITS 16 %include "Common.inc" %include "LoaderUtils.inc" sectors_to_read: dd 0 sector_offset: dd 0 memory_offset: dd 0 gdt_entry: dw gdt_end - gdt_ptr - 1 dd gdt_ptr boot_context: this_partition: dw 0x0000 data_offset_in_sectors: dd 0x00000000 fat_offset_in_sectors: dd 0x00000000 dskread_msg: db "Reading kernel from disk...", CR, LF, 0 loading_msg: db "Preparing kernel environment...", CR, LF, 0 a20fail_msg: db "Failed to enable A20!", CR, LF, 0 no_file_error: db "Couldn't find the kernel file!", CR, LF, 0 %ifdef ULTRA_64 no_long_mode_message: db "This CPU doesn't support x86_64", CR, LF, 0 PML4: equ 0x10000 PDPT_0: equ 0x11000 ; identity 4 GB PDPT_1: equ 0x12000 ; kernel 2 GB PDT_GB0: equ 0x13000 PDT_GB1: equ 0x14000 PDT_GB2: equ 0x15000 PDT_GB3: equ 0x16000 %endif kernel_file db "KERNEL BIN" ksyms_file db "KSYMS MAP" kernel_sector: times SECTOR_SIZE db 0 gdt_ptr: .null: equ $ - gdt_ptr dq 0x0000000000000000 .code_16: equ $ - gdt_ptr ; 16 bit code segment descriptor dw 0xFFFF ; limit dw 0x0000 ; base db 0x00 ; base db 0x98 ; access db 0x00 ; granularity db 0x00 ; base .data_16: equ $ - gdt_ptr ; 16 bit data segment descriptor dw 0xFFFF ; limit dw 0x0000 ; base db 0x00 ; base db 0x92 ; access db 0x00 ; granularity db 0x00 ; base .code_32: equ $ - gdt_ptr ; 32 bit code segment descriptor dw 0xFFFF ; limit dw 0x0000 ; base db 0x00 ; base db 0x9A ; access db 0xCF ; granularity db 0x00 ; base .data_32: equ $ - gdt_ptr ; 32 bit data segment descriptor dw 0xFFFF ; limit dw 0x0000 ; base db 0x00 ; base db 0x92 ; access db 0xCF ; granularity db 0x00 ; base %ifdef ULTRA_64 .code_64: equ $ - gdt_ptr ; 64 bit code segment dw 0 dw 0 db 0 db 0x9A db 0xAF db 0 %endif gdt_end: best_mode: dw 0 native_width: dw ASSUMED_NATIVE_WIDTH native_height: dw ASSUMED_NATIVE_HEIGHT edid: times 0x38 db 0 ; unused .horizontal_active_lower: db 0 db 0 ; unused .horizontal_active_higher: db 0 .vertical_active_lower: db 0 db 0 ; unused .vertical_active_higher: db 0 times 128 - ($ - edid) db 0 ; unused vbe_info: .signature: db "VBE2" .version: dw 0 .oem: dd 0 .capabilities: dd 0 .modes_offset: dw 0 .modes_segment: dw 0 .video_memory: dw 0 .software_rev: dw 0 .vendor: dd 0 .product_name: dd 0 .product_rev: dd 0 .unused: times 222 + 256 db 0 vbe_mode_info: .attributes: dw 0 .window_a: db 0 .window_b: db 0 .granularity: dw 0 .window_size: dw 0 .segment_a: dw 0 .segment_b: dw 0 .win_func_ptr: dd 0 .pitch: dw 0 .width: dw 0 .height: dw 0 .w_char: db 0 .y_char: db 0 .planes: db 0 .bpp: db 0 .banks: db 0 .memory_model: db 0 .bank_size: db 0 .image_pages: db 0 .reserved_0: db 0 .red_mask: db 0 .red_position: db 0 .green_mask: db 0 .green_position: db 0 .blue_mask: db 0 .blue_position: db 0 .reserved_mask: db 0 .reserved_position: db 0 .direct_color_attributes: db 0 .framebuffer: dd 0 .off_screen_mem_off: dd 0 .off_screen_mem_size: dw 0 .reserved_1: times 206 db 0 BIOS_CONTEXT_TYPE: equ 1 context: %ifdef ULTRA_32 .type: dd BIOS_CONTEXT_TYPE %elifdef ULTRA_64 .type: dq BIOS_CONTEXT_TYPE %endif video_mode: .width: dd 0 .height: dd 0 .pitch: dd 0 .bpp: dd 0 %ifdef ULTRA_32 .framebuffer: dd 0 %elifdef ULTRA_64 .framebuffer: dq 0 %endif memory_map: %ifdef ULTRA_32 .pointer: dd memory_map_ptr %elifdef ULTRA_64 .pointer: dq memory_map_ptr %endif .entry_count: dd 0 memory_map_ptr:
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 009612 move.l D1, (A0)+ [base+ 3A, base+ 4A, base+ 5A, base+ 8A, base+ 9A, base+ AA, base+ BA, base+ EA, base+ FA, base+12A, base+13A, base+16A, base+17A, base+1CA, base+1DA, base+20A, base+21A, base+24A, base+25A, base+28A, base+29A, base+2AA, base+2BA, base+2EA, base+2FA, base+32A, base+33A, base+36A, base+37A, base+3CA, base+3DA, base+40A, base+41A, base+42A] 009614 move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 00968E move.l D1, (A0)+ [base+ 3A, base+ 4A, base+ 5A, base+ 8A, base+ 9A, base+ AA, base+ BA, base+ EA, base+ FA, base+12A, base+13A, base+16A, base+17A, base+1CA, base+1DA, base+20A, base+21A, base+24A, base+25A, base+28A, base+29A, base+2AA, base+2BA, base+2EA, base+2FA, base+32A, base+33A, base+36A, base+37A, base+3CA, base+3DA, base+40A, base+41A, base+42A] 009690 move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 009716 move.l D1, (A0)+ [base+14A, base+16A, base+17A, base+18A, base+1CA, base+1FA, base+22A, base+27A, base+28A, base+2AA, base+2EA, base+32A, base+34A, base+39A, base+3EA, base+3FA, base+42A] 009718 move.l D2, (A0)+ [base+14C, base+14E, base+16C, base+16E, base+17C, base+17E, base+18C, base+18E, base+1CC, base+1CE, base+1FC, base+1FE, base+22C, base+22E, base+27C, base+27E, base+28C, base+28E, base+2AC, base+2AE, base+2EE, base+32C, base+32E, base+34C, base+34E, base+39C, base+39E, base+3EE, base+3FC, base+3FE, base+42C, base+42E] 00977A move.l D1, (A0)+ [base+ 3A, base+ 4A, base+ 5A, base+ 8A, base+ BA, base+11A, base+1BA, base+1DA, base+33A, base+37A, base+39A, base+3BA, base+3FA, base+42A] 00977C move.l D2, (A0)+ [base+ 3C, base+ 3E, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ 8C, base+ 8E, base+ BC, base+ BE, base+11C, base+11E, base+1BC, base+1BE, base+1DC, base+1DE, base+33C, base+33E, base+37C, base+37E, base+39C, base+39E, base+3BC, base+3BE, base+3FC, base+3FE, base+42C, base+42E] 00A61A move.l D1, (A0)+ 00A61C move.l D1, (A0)+ 00A64C move.l D1, (A0)+ [base+ 3A, base+ 4A, base+ 5A, base+ 8A, base+ 9A, base+ AA, base+ BA, base+ EA, base+ FA, base+12A, base+13A, base+16A, base+17A, base+1CA, base+1DA, base+20A, base+21A, base+24A, base+25A, base+28A, base+29A, base+2AA, base+2BA, base+2EA, base+2FA, base+32A, base+33A, base+36A, base+37A, base+3CA, base+3DA, base+40A, base+41A, base+42A] 00A64E move.l D2, (A0)+ [base+ 3C, base+ 4C, base+ 4E, base+ 5C, base+ 5E, base+ EC, base+ EE, base+ FC, base+ FE, base+16C, base+16E, base+17C, base+17E, base+20C, base+20E, base+21C, base+21E, base+28C, base+28E, base+29C, base+29E, base+2AC, base+2AE, base+2BC, base+2BE, base+32C, base+32E, base+33C, base+33E, base+3CC, base+3CE, base+3DC, base+3DE, base+42E] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
; ████████████████████████████████████████████████████████████████████████████████████████████████████ ; Machine: Machine.asm v0.0.0.1 ; http://azmisahin.com ; ════════════════════════════════════════════════════════════════════════════════════════════════════ ; Copyright [email protected] ; Licence (https://github.com/azmisahin) ; ████████████████████████████████████████████████████████████████████████████████████████████████████ org 0x7c00 xor ax, ax ; ax : 0 mov ds, ax ; ds : 0 jmp Initalize ; Go Initalize ; Define ; ---------------------------------------------------------------------------------------------------- Define: message db 'Machine', 13, 10, 0 ; Initalize ; ---------------------------------------------------------------------------------------------------- Initalize: call Screen ; Scrreen Initalize call Welcome ; Welcome Intalize ; Main ; ---------------------------------------------------------------------------------------------------- Main: call Keypress jmp Main ; Scrreen Initalize ; ---------------------------------------------------------------------------------------------------- Screen: mov ah, 06h ; Scroll up function. xor al, al ; Clear entire screen. xor cx,cx ; Upper left corner CH=row, CL=column mov dx, 184fh ; lower right corner DH=row, DL=column mov bh,1eh ; Yellow On Blue int 10h ; ret ; Welcome Initalize ; ---------------------------------------------------------------------------------------------------- Welcome: mov si, message ; Set Source Index Message call Bios_Print ret ; Print Function ; ---------------------------------------------------------------------------------------------------- Bios_Print: lodsb ; Load Memory Byte [ AL ] or al, al ; jz Call_Done ; mov ah, 0x0E ; int 0x10 ; jmp Bios_Print ; ; Progress Done Signal ; ---------------------------------------------------------------------------------------------------- Call_Done: ret ; Keypres ; ---------------------------------------------------------------------------------------------------- Keypress: mov ah, 1 ; int 16h ; jz Keypress ; mov ah, 0 ; int 16h ; call Keypress_Control ; ret ; ; Keypres Control Sub Function ; ---------------------------------------------------------------------------------------------------- Keypress_Control: call Keypress_Escape call Keypress_Print ret ; Keypress_Escape ; ---------------------------------------------------------------------------------------------------- Keypress_Escape: cmp al, 1bh ; Escape jz Exit ; Exit ret ; ; Keypress_Enter ; ---------------------------------------------------------------------------------------------------- Keypress_Enter: ;cmp al, 1C0Dh ; Enter ; Nothing progress ret ; ; Keypres Print Sub Function ; ---------------------------------------------------------------------------------------------------- Keypress_Print: mov ah, 0eh ; Key Write int 10h ret ; Page_Down Sub Function ; ---------------------------------------------------------------------------------------------------- Page_Down: add dh, 1 ; Page Position mov ah, 02h ; Page Change int 10h ret ; Exit ; ---------------------------------------------------------------------------------------------------- Exit: ret ; Zero ; ---------------------------------------------------------------------------------------------------- db 0 ; Sector Done ; ---------------------------------------------------------------------------------------------------- db 0x55 db 0xAA
; A105500: Trajectory of 1 under the morphism 1->{1,2}, 2->{3,2}, 3->{3,4}, 4->{1,4}. ; 1,2,3,2,3,4,3,2,3,4,1,4,3,4,3,2,3,4,1,4,1,2,1,4,3,4,1,4,3,4,3,2,3,4,1,4,1,2,1,4,1,2,3,2,1,2,1,4,3,4,1,4,1,2,1,4,3,4,1,4,3,4,3,2,3,4,1,4,1,2,1,4,1,2,3,2,1,2,1,4,1,2,3,2,3,4,3,2,1,2,3,2,1,2,1,4,3,4,1,4,1,2,1,4,1 mov $4,-19446 cal $0,5811 ; Number of runs in binary expansion of n (n>0); number of 1's in Gray code for n. sub $0,1 mov $5,$0 lpb $4,32768 lpb $0,1 mov $0,0 gcd $0,$4 lpe sub $0,4 mov $5,2 lpe mov $1,$0 add $1,2
;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ include bambi.inc public detect_stacker public detect_stacker_volume public stacker_dd_pointer zseg segment public 'CODE' assume cs:zseg assume ds:nothing st_ptr DD 0 ;pointer to Stacker (0-->not there) stacker_tested db 0 ;havent tested for stacker yet stacker_version dw 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Input: None ; Output:AX=0 --> Stacker not installed ; AX<>0 --> Stacker version*100 (e.g. 1.00 --> 0064H) ; ; Stacker is detected by making an INT 25H call with invalid ; parameters. ; detect_stacker proc cmp cs:stacker_tested,0 je do_stacker_test mov ax,cs:stacker_version ret do_stacker_test: push bp push si push di sub sp,1024 ;use the stack as a temp buffer mov ax,0cdcdh ;invalid drive # mov bx,sp ;DS:BX --> buffer for INT 25H mov cx,1 xor dx,dx ;read boot sector of invalid drive mov word ptr [bx],dx ;clear the "return" value push ds ;(set ES:BP to fix DOS 3 INT 25H bug) pop es mov bp,bx int 25H pop cx ;get rid of flags xor ax,ax ;default is No stacker mov bx,sp ;point at result cmp word ptr [bx],0CDCDH ;Stacker INT 25 fills in some fields. jnz gotres ;Make sure they all match cmp word ptr 2[bx],1 jnz gotres les di,4[bx] ;pointer into Stacker cmp word ptr es:[di],0A55AH ;must find signature jnz gotres mov word ptr st_ptr ,di ;save pointer to show it's found mov word ptr st_ptr+2,es mov ax,es:[di+2] ;stacker version * 100 gotres: add sp,1024 pop di ;restore regs pop si pop bp mov stacker_tested,1 mov stacker_version,ax ret detect_stacker endp ; ; Input: dx->driveno: 0=A, 1=B, 2=C, etc. ; ; Output:AX=1 --> Is a Stacker volume ; AX=0 --> Is not a Stacker volume ; BL = Stacker unit number if AX=1 ; ; Notes: If a multitasking environment is present (such as Windows), you ; must make this a critical section of code! ; ; This method uses the removeable media ioctl call to detect ; Stacker volumes. It does NOT work under DR DOS 5.0, since that ; version of DOS does NOT pass these calls through to the Stacker ; device driver. ; UNIT_OFFS equ 3EH ;offset with Stacker of driveno dw ? detect_stacker_volume proc mov cs:driveno,dx cmp word ptr st_ptr+2,0 ;already found Stacker? jnz stacker_fnd call detect_stacker ;is not, try again xor ax,ax ;return 0 if not found cmp ax,word ptr st_ptr+2 ;is it ther jz retOp ; Here if Stacker IS installed. stacker_fnd: mov ah,30h ;treat DR DOS special int 21h ;(it doesn't pass 4408H through) cmp ax,1F03H mov ax,4408H ;do an ioctl call jnz use08 mov al,0EH ;(DR DOS, Compaq 3.31: 440EH) use08: les di,st_ptr mov byte ptr es:UNIT_OFFS[di],0FFH ;set Stacker unit # mov bx,driveno inc bx ;adjust for default int 21h ;if Stacker drive, will return mov ax,0 jc retOp ;no ioctl support --> not Stacker les di,st_ptr ;see if unit # changed mov bl,byte ptr es:UNIT_OFFS[di] cmp bl,0FFH jz retOp inc ax ;if so, we have a Stacker volume retOp: ret detect_stacker_volume endp ; ; This data structure is part of the Stacker internal data structure ; maintained for each Stacker drive. A pointer to this structure can be ; obtained from the routine stacker_dd_pointer() below. See ST.C for ; an example. Assuming that nothing else has "stolen" the DPB for a drive, ; you can perform a sanity check by comparing the strategy and interrupt ; pointers found here with those found in another DPB (or in the device ; chain). As a quick check, you could also make sure that the segment ; part of dv_strategy is the same as that for dv_interrupt. ; ; To force Stacker to call a different device driver, the following ; fields must be modified: dv_strategy, dv_interrupt, and dv_unit. ; ; STACKER_DD struc dv_strategy dd 1 dup(?) ;physical device driver strategy addr dv_interrupt dd 1 dup(?) ;physical device driver interrupt addr dv_att dw 1 dup(?) ;device driver header attributes dv_cluster0 dw 1 dup(?) ;first file cluster of dv_log2 db 1 dup(?) ;LOG base 2 of physical bytes/sector dv_unit db 1 dup(?) ;physical device driver unit number STACKER_DD ends STACKER_UNIT_DD_OFFSET equ 015CH ; ; C declaration: STACKER_DD far *stacker_dd_pointer(int driveno); ; ; Input: dx->driveno: 0=A, 1=B, 2=C, etc. ; ; Output:DX:AX = far pointer to the STACKER_DD struc (0:0 if error) ; ; Notes: If a multitasking environment is present (such as Windows), you ; must make this a critical section of code! stacker_dd_pointer proc mov cs:driveno,dx push driveno call detect_stacker_volume pop cx ;get rid of driveNo on stack cwd or ax,ax jnz isStacker ret isStacker: les di,st_ptr mov di,es:4[di] ;get unit table pointer xor bh,bh add bx,bx ;multiply unit # by two mov ax,es:[di+bx] ;dx:ax = per unit pointer add ax,STACKER_UNIT_DD_OFFSET mov dx,es ;return pointer ret stacker_dd_pointer endp zseg ends end 
; A175831: Partial sums of ceiling(n^2/12). ; 0,1,2,3,5,8,11,16,22,29,38,49,61,76,93,112,134,159,186,217,251,288,329,374,422,475,532,593,659,730,805,886,972,1063,1160,1263,1371,1486,1607,1734,1868,2009,2156,2311,2473,2642,2819,3004,3196,3397,3606,3823,4049,4284,4527,4780,5042,5313,5594,5885,6185,6496,6817,7148,7490,7843,8206,8581,8967,9364,9773,10194,10626,11071,11528,11997,12479,12974,13481,14002,14536,15083,15644,16219,16807,17410,18027,18658,19304,19965,20640,21331,22037,22758,23495,24248,25016,25801,26602,27419 mov $2,$0 add $2,1 lpb $2 mov $0,0 sub $2,1 sub $0,$2 pow $0,2 mov $3,$0 add $3,11 div $3,12 add $1,$3 lpe mov $0,$1
; A010051: Characteristic function of primes: 1 if n is prime, else 0. ; Submitted by Jamie Morken(s4) ; 0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0 mov $1,$0 mul $0,4 seq $1,38548 ; Number of divisors of n that are at most sqrt(n). cmp $1,1 trn $0,$1 mod $0,2
; A276352: a(n) = 100^n - 10^n. ; 0,90,9900,999000,99990000,9999900000,999999000000,99999990000000,9999999900000000,999999999000000000,99999999990000000000,9999999999900000000000,999999999999000000000000,99999999999990000000000000,9999999999999900000000000000,999999999999999000000000000000 mov $1,10 pow $1,$0 bin $1,2 mul $1,2 mov $0,$1
; A195679: Order of n-th homotopy group of the topological group O(oo), with -1 if the homotopy group is Z. ; 2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2,1,-1,1,1,1,-1,2,2 mod $0,8 mov $1,2 mov $2,$0 lpb $0 add $0,$2 mod $0,4 sub $1,2 lpe div $1,2 add $1,1
INCLUDE \masm32\include\masm32rt.inc INCLUDE \masm32\include\Irvine32.inc INCLUDELIB \masm32\lib\Irvine32.lib INCLUDE \masm32\include\debug.inc INCLUDELIB \masm32\lib\debug.lib .data barray BYTE 6 DUP (?) dwarray DWORD 3 DUP (?) TOTAL_LENGTH = $-barray bdmessage BYTE "Today as stored in a double word", 0dh, 0ah, 0 dwmessage BYTE 0dh, 0ah, "Seeing bytes in a single word", 0dh, 0ah, 0 lengthmessage BYTE 0dh, 0ah, "total bytes used: ", 0 finalmessage BYTE 0dh, 0ah, "Press any key to continue ...", 0 .code main PROC CALL Crlf MOV edx, OFFSET bdmessage CALL WriteString MOV eax, DWORD PTR [barray + 2] CALL WriteDec MOV edx, OFFSET dwmessage CALL WriteString MOVZX eax, WORD PTR [dwarray + 6] CALL WriteDec MOV edx, OFFSET lengthmessage CALL WriteString MOV eax, TOTAL_LENGTH CALL WriteDec MOV edx, OFFSET finalmessage CALL WriteString CALL ReadChar INVOKE ExitProcess, 0 main ENDP END main
; A225566: The set of magic numbers for an idealized harmonic oscillator atomic nucleus with a biaxially deformed prolate ellipsoid shape and an oscillator ratio of 3:1 ; 2,4,6,12,18,24,36,48,60,80,100,120,150,180,210,252,294,336,392,448,504,576,648,720,810,900,990,1100,1210,1320,1452,1584,1716,1872,2028,2184,2366,2548,2730,2940,3150,3360,3600,3840,4080,4352,4624,4896,5202,5508,5814,6156,6498,6840,7220,7600,7980,8400,8820,9240,9702,10164,10626,11132,11638,12144,12696,13248,13800,14400,15000,15600,16250,16900,17550,18252,18954,19656,20412,21168,21924,22736,23548,24360,25230,26100,26970,27900,28830,29760,30752,31744,32736,33792,34848,35904,37026,38148,39270,40460,41650,42840,44100,45360,46620,47952,49284,50616,52022,53428,54834,56316,57798,59280,60840,62400,63960,65600,67240,68880,70602,72324,74046,75852,77658,79464,81356,83248,85140,87120,89100,91080,93150,95220,97290,99452,101614,103776,106032,108288,110544,112896,115248,117600,120050,122500,124950,127500,130050,132600,135252,137904,140556,143312,146068,148824,151686,154548,157410,160380,163350,166320,169400,172480,175560,178752,181944,185136,188442,191748,195054,198476,201898,205320,208860,212400,215940,219600,223260,226920,230702,234484,238266,242172,246078,249984,254016,258048,262080,266240,270400,274560,278850,283140,287430,291852,296274,300696,305252,309808,314364,319056,323748,328440,333270,338100,342930,347900,352870,357840,362952,368064,373176,378432,383688,388944,394346,399748,405150,410700,416250,421800,427500,433200,438900,444752,450604,456456,462462,468468,474474,480636,486798,492960,499280,505600,511920,518400,524880,531360,538002,544644,551286,558092,564898,571704,578676,585648,592620,599760 add $0,2 lpb $0,1 add $2,$0 sub $0,3 sub $2,1 add $3,2 lpb $2,1 add $1,$3 sub $2,1 lpe lpe
; A simple list of all current instructions in order with distinguishable parameters. nop ldr $1,a ldr [$1234],b ldr [HL],h str [$4321],l str [HL],a lda $2345 in $2,a out $3,b inc h dec l ina dea add $4 add a adc $5 adc b sub $6 sub h sbc $7 sbc l and $8 and a or $9 or b xor $a xor h cmp $b cmp l jmp $3456 jmp HL jr $c jr $d,z jr $e,nz in a out b push h pop l jsr $4567 ret halt lsl lsr asr
######################################## # # Retroputer Kernel : IO Map # ######################################## .namespace kiomap { .namespace rtc { # real time clock .const hour 0x00 .const minute 0x01 .const second 0x02 .const centisecond 0x03 .const timer-modes 0x04 .const timer-0-ms-3 0x05 .const timer-0-ms-2 0x06 .const timer-0-ms-1 0x07 .const timer-0-ms-0 0x08 .const timer-1-ms-3 0x09 .const timer-1-ms-2 0x0A .const timer-1-ms-1 0x0B .const timer-1-ms-0 0x0C .const mode 0x0D # .const 0x0E # reserved for expansion .const reset 0x0F } .namespace screen { # screen configuration .const palette-page 0x10 # configure the palette page .const bg-color 0x11 # background color .const layer-0-src 0x12 # lll_ppppp .const layer-0-cfg 0x13 # v_s_ttttt .const layer-0-pos 0x14 # yyyy_xxxx .const layer-0-bg-color 0x15 .const layer-0-fg-color 0x16 .const layer-0-window 0x17 # yyyy_xxxx .const layer-1-src 0x18 .const layer-1-cfg 0x19 .const layer-1-pos 0x1A .const layer-1-bg-color 0x1B .const layer-1-fg-color 0x1C .const layer-1-window 0x1D .const layer-2-src 0x1E .const layer-2-cfg 0x1F .const layer-2-pos 0x20 .const layer-2-bg-color 0x21 .const layer-2-fg-color 0x22 .const layer-2-window 0x23 .const layer-3-src 0x24 .const layer-3-cfg 0x25 .const layer-3-pos 0x26 .const layer-3-bg-color 0x27 .const layer-3-fg-color 0x28 .const layer-3-window 0x29 .const layer-mode 0x2A # 33_22_11_00 .const border-color 0x2B .const border-cfg 0x2C # v_?_yyy_xxx } .namespace keyboard { } .namespace controller { } .namespace mouse { } .namespace audio { } .namespace storage { } .namespace console { .const ctrl 0x80 # control line .const recv 0x81 .const send 0x82 .const ack 0x83 } .namespace com2 { .const ctrl 0x90 # control line .const recv 0x91 .const send 0x92 .const ack 0x93 } .namespace com3 { .const ctrl 0xA0 # control line .const recv 0xA1 .const send 0xA2 .const ack 0xA3 } .namespace com4 { .const ctrl 0xB0 # control line .const recv 0xB1 .const send 0xB2 .const ack 0xB3 } .namespace debugger { } .namespace power { } }
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/app/chrome_watcher_client_win.h" #include "base/bind.h" #include "base/logging.h" #include "base/macros.h" #include "components/browser_watcher/watcher_client_win.h" namespace { // Because we can only bind parameters from the left, |parent_process| must be // the last parameter of the method that we bind into a // BrowserWatcherClient::CommandLineGenerator. The ChromeWatcherClient API is // more intuitive if the ChromeWatcherClient::CommandLineGenerator takes // |parent_process| as its second parameter, so we use this intermediate // function to swap the order. base::CommandLine InvokeCommandLineGenerator( const ChromeWatcherClient::CommandLineGenerator& command_line_generator, HANDLE on_initialized_event, HANDLE parent_process) { return command_line_generator.Run(parent_process, ::GetCurrentThreadId(), on_initialized_event); } } // namespace ChromeWatcherClient::ChromeWatcherClient( const CommandLineGenerator& command_line_generator) : command_line_generator_(command_line_generator) { } ChromeWatcherClient::~ChromeWatcherClient() { } bool ChromeWatcherClient::LaunchWatcher() { // Create an inheritable event that the child process will signal when it has // completed initialization. SECURITY_ATTRIBUTES on_initialized_event_attributes = { sizeof(SECURITY_ATTRIBUTES), // nLength nullptr, // lpSecurityDescriptor TRUE // bInheritHandle }; on_initialized_event_.Set(::CreateEvent(&on_initialized_event_attributes, TRUE, // manual reset FALSE, nullptr)); if (!on_initialized_event_.IsValid()) { DPLOG(ERROR) << "Failed to create an event."; return false; } // Configure the basic WatcherClient, binding in the initialization event // HANDLE. browser_watcher::WatcherClient watcher_client( base::Bind(&InvokeCommandLineGenerator, command_line_generator_, on_initialized_event_.Get())); // Indicate that the event HANDLE should be inherited. watcher_client.AddInheritedHandle(on_initialized_event_.Get()); // Launch the watcher. watcher_client.LaunchWatcher(); // Grab a handle to the watcher so that we may later wait on its // initialization. process_ = watcher_client.process().Duplicate(); if (!process_.IsValid()) on_initialized_event_.Close(); return process_.IsValid(); } bool ChromeWatcherClient::EnsureInitialized() { if (!process_.IsValid()) return false; DCHECK(on_initialized_event_.IsValid()); HANDLE handles[] = {on_initialized_event_.Get(), process_.Handle()}; DWORD result = ::WaitForMultipleObjects(arraysize(handles), handles, FALSE, INFINITE); switch (result) { case WAIT_OBJECT_0: return true; case WAIT_OBJECT_0 + 1: LOG(ERROR) << "Chrome watcher process failed to launch."; return false; case WAIT_FAILED: DPLOG(ERROR) << "Failure while waiting on Chrome watcher process launch."; return false; default: NOTREACHED() << "Unexpected result while waiting on Chrome watcher " "process launch: " << result; return false; } } bool ChromeWatcherClient::WaitForExit(int* exit_code) { return process_.IsValid() && process_.WaitForExit(exit_code); } bool ChromeWatcherClient::WaitForExitWithTimeout(base::TimeDelta timeout, int* exit_code) { return process_.IsValid() && process_.WaitForExitWithTimeout(timeout, exit_code); }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x18c91, %rdx nop nop nop add $35045, %r10 mov (%rdx), %rsi nop nop inc %rdi lea addresses_normal_ht+0x4575, %rsi lea addresses_WT_ht+0x16911, %rdi nop add $6873, %r9 mov $87, %rcx rep movsw and %rdx, %rdx lea addresses_normal_ht+0xb311, %rsi lea addresses_UC_ht+0x12e91, %rdi nop and %r11, %r11 mov $38, %rcx rep movsb nop nop nop nop cmp %r9, %r9 lea addresses_A_ht+0x1c8d0, %rsi lea addresses_normal_ht+0x1a751, %rdi nop nop nop add $5050, %rax mov $91, %rcx rep movsl nop nop nop nop sub %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %rbp push %rbx push %rsi // Faulty Load mov $0x311, %rsi nop nop nop nop and %r10, %r10 mov (%rsi), %r13 lea oracles, %rbx and $0xff, %r13 shlq $12, %r13 mov (%rbx,%r13,1), %r13 pop %rsi pop %rbx pop %rbp pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_P', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_P', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'00': 488} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #define NT2_UNIT_MODULE "nt2 fuzzy toolbox - definitely_less/scalar Mode" ////////////////////////////////////////////////////////////////////////////// // cover test behavior of fuzzy components in scalar mode ////////////////////////////////////////////////////////////////////////////// /// created by jt the 04/03/2011 /// #include <nt2/fuzzy/include/functions/definitely_less.hpp> #include <nt2/include/functions/max.hpp> #include <nt2/sdk/simd/logical.hpp> #include <boost/type_traits/is_same.hpp> #include <nt2/sdk/functor/meta/call.hpp> #include <nt2/sdk/meta/as_integer.hpp> #include <nt2/sdk/meta/as_floating.hpp> #include <nt2/sdk/meta/as_signed.hpp> #include <nt2/sdk/meta/upgrade.hpp> #include <nt2/sdk/meta/downgrade.hpp> #include <nt2/sdk/meta/scalar_of.hpp> #include <boost/dispatch/meta/as_floating.hpp> #include <boost/type_traits/common_type.hpp> #include <nt2/sdk/unit/tests.hpp> #include <nt2/sdk/unit/module.hpp> #include <nt2/sdk/memory/buffer.hpp> #include <nt2/constant/constant.hpp> NT2_TEST_CASE_TPL ( definitely_less_real__3_0, NT2_REAL_TYPES) { using nt2::definitely_less; using nt2::tag::definitely_less_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<definitely_less_(T,T,iT)>::type r_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename nt2::meta::as_logical<T>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; double ulpd; ulpd=0.0; // random verifications static const nt2::uint32_t NR = NT2_NB_RANDOM_TEST; { NT2_CREATE_BUF(tab_a0,T, NR, T(-10), T(10)); NT2_CREATE_BUF(tab_a1,T, NR, T(-10), T(10)); NT2_CREATE_BUF(tab_a2,iT, NR, iT(-10), iT(10)); double ulp0, ulpd ; ulpd=ulp0=0.0; T a0; T a1; iT a2; for(nt2::uint32_t j =0; j < NR; ++j ) { std::cout << "for params " << " a0 = "<< u_t(a0 = tab_a0[j]) << ", a1 = "<< u_t(a1 = tab_a1[j]) << ", a2 = "<< u_t(a2 = tab_a2[j]) << std::endl; NT2_TEST_EQUAL( nt2::definitely_less(a0,a1,a2),nt2::definitely_less(a0,a1,a2)); } } } // end of test for floating_ NT2_TEST_CASE_TPL ( definitely_less_signed_int__3_0, NT2_INTEGRAL_SIGNED_TYPES) { using nt2::definitely_less; using nt2::tag::definitely_less_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<definitely_less_(T,T,iT)>::type r_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename nt2::meta::as_logical<T>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; double ulpd; ulpd=0.0; // random verifications static const nt2::uint32_t NR = NT2_NB_RANDOM_TEST; { NT2_CREATE_BUF(tab_a0,T, NR, T(-10), T(10)); NT2_CREATE_BUF(tab_a1,T, NR, T(-10), T(10)); NT2_CREATE_BUF(tab_a2,iT, NR, iT(-10), iT(10)); double ulp0, ulpd ; ulpd=ulp0=0.0; T a0; T a1; iT a2; for(nt2::uint32_t j =0; j < NR; ++j ) { std::cout << "for params " << " a0 = "<< u_t(a0 = tab_a0[j]) << ", a1 = "<< u_t(a1 = tab_a1[j]) << ", a2 = "<< u_t(a2 = tab_a2[j]) << std::endl; NT2_TEST_EQUAL( nt2::definitely_less(a0,a1,a2),nt2::definitely_less(a0,a1,a2)); } } } // end of test for signed_int_ NT2_TEST_CASE_TPL ( definitely_less_unsigned_int__3_0, NT2_UNSIGNED_TYPES) { using nt2::definitely_less; using nt2::tag::definitely_less_; typedef typename nt2::meta::as_integer<T>::type iT; typedef typename nt2::meta::call<definitely_less_(T,T,iT)>::type r_t; typedef typename nt2::meta::scalar_of<r_t>::type ssr_t; typedef typename nt2::meta::upgrade<T>::type u_t; typedef typename nt2::meta::as_logical<T>::type wished_r_t; // return type conformity test NT2_TEST( (boost::is_same < r_t, wished_r_t >::value) ); std::cout << std::endl; double ulpd; ulpd=0.0; // random verifications static const nt2::uint32_t NR = NT2_NB_RANDOM_TEST; { NT2_CREATE_BUF(tab_a0,T, NR, T(0), T(10)); NT2_CREATE_BUF(tab_a1,T, NR, T(0), T(10)); NT2_CREATE_BUF(tab_a2,iT, NR, iT(0), iT(10)); double ulp0, ulpd ; ulpd=ulp0=0.0; T a0; T a1; iT a2; for(nt2::uint32_t j =0; j < NR; ++j ) { std::cout << "for params " << " a0 = "<< u_t(a0 = tab_a0[j]) << ", a1 = "<< u_t(a1 = tab_a1[j]) << ", a2 = "<< u_t(a2 = tab_a2[j]) << std::endl; NT2_TEST_EQUAL( nt2::definitely_less(a0,a1,a2),nt2::definitely_less(a0,a1,a2)); } } } // end of test for unsigned_int_
////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Vicente J. Botet Escriba 2008-2009,2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/thread for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_THREAD_POLY_LOCKABLE_HPP #define BOOST_THREAD_POLY_LOCKABLE_HPP #include <boost/thread/detail/delete.hpp> #include <boost/chrono/chrono.hpp> namespace boost { //[basic_poly_lockable class basic_poly_lockable { public: virtual ~basic_poly_lockable() = 0; virtual void lock() = 0; virtual void unlock() = 0; }; //] //[poly_lockable class poly_lockable : public basic_poly_lockable { public: virtual ~poly_lockable() = 0; virtual bool try_lock() = 0; }; //] //[timed_poly_lockable class timed_poly_lockable: public poly_lockable { public: virtual ~timed_poly_lockable()=0; virtual bool try_lock_until(chrono::system_clock::time_point const & abs_time)=0; virtual bool try_lock_until(chrono::steady_clock::time_point const & abs_time)=0; template <typename Clock, typename Duration> bool try_lock_until(chrono::time_point<Clock, Duration> const & abs_time) { return try_lock_until(time_point_cast<Clock::time_point>(abs_time)); } virtual bool try_lock_for(chrono::nanoseconds const & relative_time)=0; template <typename Rep, typename Period> bool try_lock_for(chrono::duration<Rep, Period> const & rel_time) { return try_lock_for(duration_cast<Clock::duration>(rel_time)); } }; //] } #endif
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %rbp push %rdx lea addresses_WC_ht+0x170bb, %r11 nop nop add %rbp, %rbp movl $0x61626364, (%r11) nop nop nop nop sub %rdx, %rdx pop %rdx pop %rbp pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %rbx push %rdi push %rdx // Faulty Load lea addresses_WT+0xe0bb, %rdx nop nop nop cmp %rbx, %rbx mov (%rdx), %rdi lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rdx pop %rdi pop %rbx pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_WC_ht'}} {'c0': 2, '00': 245, 'ff': 19065, '53': 443, '02': 190, '50': 50, '3c': 1832, 'b4': 2} 3c 3c ff ff ff 53 ff ff ff ff 53 ff ff 3c ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 ff ff ff ff ff ff ff ff ff 53 ff ff 3c ff ff ff ff ff 3c ff ff ff ff 53 ff ff 3c ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff 3c ff ff ff ff ff 3c ff ff ff ff ff ff ff 3c ff ff ff 3c ff ff 53 ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff 3c 3c ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c 53 ff ff 00 ff ff 53 53 3c ff 3c ff ff ff ff ff 50 ff ff ff ff ff ff ff ff ff 53 ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff 00 ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff 3c ff 3c ff ff ff ff ff ff ff 00 ff ff ff ff ff ff 3c ff ff ff 02 ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 53 ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff 3c ff 3c ff ff ff ff ff ff ff 3c ff ff ff ff 3c ff ff ff ff ff ff ff ff ff 53 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 ff ff ff ff 3c ff 53 ff ff ff ff ff ff ff 00 ff ff ff ff ff ff 3c ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 53 ff 3c 53 ff ff ff ff ff ff ff ff ff ff ff ff 3c ff 53 3c ff ff ff ff ff ff ff 3c ff ff 3c 3c ff ff ff ff ff ff ff ff ff ff ff ff 53 ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff 3c ff ff ff ff 3c ff ff ff 3c ff ff 3c ff ff ff 3c ff ff ff ff ff 3c ff ff ff ff ff 53 ff ff ff ff ff ff ff ff ff ff ff ff 3c ff 53 ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff 3c ff ff ff ff 53 ff ff ff ff ff ff ff ff 3c 3c ff ff ff ff 3c ff ff ff ff ff ff ff 3c ff ff ff ff 3c ff ff 3c ff ff ff ff ff ff ff ff 3c ff ff ff ff ff 3c 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff 3c ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 53 ff ff 02 ff ff 53 ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff 53 ff ff ff ff ff ff ff ff ff ff ff ff 3c 3c ff ff ff ff ff 3c 3c ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff 3c 00 ff 3c ff ff 3c ff ff ff ff ff ff 3c 3c 02 ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 53 ff ff ff 3c ff ff ff 00 3c 3c ff ff ff ff 3c ff ff ff 3c ff ff ff 53 53 ff ff ff 53 ff 53 3c ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3c ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff */
/* * DebugEngineInterpreter_impl.hpp * * * @date 12-07-2020 * @author Teddy DIDE * @version 1.00 * Debug Interpreter generated by gensources. */ #define A(str) encode<EncodingT,ansi>(str) #define C(str) encode<ansi,EncodingT>(str) NAMESPACE_BEGIN(interp) template <class EncodingT> DebugEngineInterpreter<EncodingT>::DebugEngineInterpreter() { m_debugClient = NULL; m_eventCallback = NULL; m_debugControl = NULL; m_debugSystemObjects = NULL; m_debugSymbols = NULL; } template <class EncodingT> DebugEngineInterpreter<EncodingT>::~DebugEngineInterpreter() { tidyValue(); } template <class EncodingT> void DebugEngineInterpreter<EncodingT>::tidyValue() { terminate(); } template <class EncodingT> typename EncodingT::string_t DebugEngineInterpreter<EncodingT>::toString() const { return EncodingT::EMPTY; } template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::clone() const { return boost::shared_ptr< Base<EncodingT> >(new DebugEngineInterpreter<EncodingT>(*this)); } template <class EncodingT> typename EncodingT::string_t DebugEngineInterpreter<EncodingT>::getClassName() const { return UCS("DebugEngine"); } template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::invoke(const typename EncodingT::string_t& method, std::vector< boost::shared_ptr< Base<EncodingT> > >& params) { boost::shared_ptr< Base<EncodingT> > obj(new Base<EncodingT>()); ParameterArray args, ret; if (check_parameters_array(params, args)) { if (tryInvoke(this, UCS("DebugEngine"), method, args, ret) || tryInvoke(this, UCS("Base"), method, args, ret)) { find_parameter(ret, FACTORY_RETURN_PARAMETER, obj); for (size_t i = 0; i < params.size(); ++i) { find_parameter(ret, i, params[i]); } } else { Category* logger = &Category::getInstance(LOGNAME); logger->errorStream() << "Unexpected call in DebugEngine, no method \"" << A(method) << "\" exists."; } } return obj; } // Initialise le moteur de débogage. template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::initialize() { if (m_debugClient == NULL) { HRESULT hr = DebugCreate(IID_IDebugClient, (void**)&m_debugClient); if(SUCCEEDED(hr)) { hr = m_debugClient->QueryInterface(IID_IDebugControl3, (void**)&m_debugControl); if (SUCCEEDED(hr)) { m_eventCallback = new EventCallbacks<EncodingT>(this, m_debugControl); hr = m_debugClient->SetEventCallbacks(m_eventCallback); } hr = m_debugClient->QueryInterface(IID_IDebugSystemObjects, (void**)&m_debugSystemObjects); hr = m_debugClient->QueryInterface(IID_IDebugSymbols, (void**)&m_debugSymbols); } } return boost::shared_ptr< Base<EncodingT> > (new Bool<EncodingT>(m_debugClient != NULL)); } // Libère les objets debug. template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::terminate() { m_triggeredBreakpoints.clear(); if(m_debugSymbols != NULL) { m_debugSymbols->Release(); m_debugSymbols = NULL; } if(m_debugSystemObjects != NULL) { m_debugSystemObjects->Release(); m_debugSystemObjects = NULL; } if (m_eventCallback != NULL) { delete m_eventCallback; m_eventCallback = NULL; } if(m_debugControl != NULL) { m_debugControl->Release(); m_debugControl = NULL; } if(m_debugClient != NULL) { m_debugClient->EndSession(DEBUG_END_PASSIVE); m_debugClient->Release(); m_debugClient = NULL; } return boost::shared_ptr< Base<EncodingT> > (new Bool<EncodingT>(m_debugClient == NULL)); } // Allocate additional memory to the target process. template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::dvAlloc(const boost::shared_ptr< Base<EncodingT> >& size) { boost::shared_ptr< Base<EncodingT> > res(new Numeric<EncodingT>()); if (m_debugSystemObjects != NULL) { unsigned long nativeSize; if (check_numeric_i(size, nativeSize)) { unsigned long long hProcess; HRESULT hr = m_debugSystemObjects->GetCurrentProcessHandle(&hProcess); if (SUCCEEDED(hr)) { res.reset(new Numeric<EncodingT>((unsigned long long) VirtualAllocEx((HANDLE) hProcess, NULL, nativeSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE))); } } } return res; } // Frees a memory allocation owned by the target process. template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::dvFree(const boost::shared_ptr< Base<EncodingT> >& baseAddress, const boost::shared_ptr< Base<EncodingT> >& size) { boost::shared_ptr< Base<EncodingT> > res(new Bool<EncodingT>(false)); if (m_debugSystemObjects != NULL) { unsigned long nativeSize; int nativeBaseAddress; if (check_numeric_i(baseAddress, nativeBaseAddress) && check_numeric_i(size, nativeSize)) { unsigned long long hProcess; HRESULT hr = m_debugSystemObjects->GetCurrentProcessHandle(&hProcess); if (SUCCEEDED(hr)) { res.reset(new Bool<EncodingT>(VirtualFreeEx((HANDLE) hProcess, (LPVOID)nativeBaseAddress, nativeSize, MEM_RELEASE))); } } } return res; } // Retourne l'objet DebugClient template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getDebugClient() const { return boost::shared_ptr< Base<EncodingT> > (new IDebugClientPtrInterpreter<EncodingT>(IDebugClientPtr(m_debugClient))); } // Retourne l'objet DebugControl template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getDebugControl() const { return boost::shared_ptr< Base<EncodingT> > (new IDebugControlPtrInterpreter<EncodingT>(IDebugControlPtr(m_debugControl))); } // Retourne l'objet DebugSystemObjects template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getDebugSystemObjects() const { return boost::shared_ptr< Base<EncodingT> > (new IDebugSystemObjectsPtrInterpreter<EncodingT>(IDebugSystemObjectsPtr(m_debugSystemObjects))); } // Retourne l'objet DebugSymbols template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getDebugSymbols() const { return boost::shared_ptr< Base<EncodingT> > (new IDebugSymbolsPtrInterpreter<EncodingT>(IDebugSymbolsPtr(m_debugSymbols))); } // Ajoute l'objet TriggeredBreakpoint template <class EncodingT> void DebugEngineInterpreter<EncodingT>::AddTriggeredBreakpoint(IDebugBreakpoint* const breakpoint) { m_triggeredBreakpoints.push_back(breakpoint); } // Réinitialise l'objet DebugBreakpoint template <class EncodingT> void DebugEngineInterpreter<EncodingT>::ResetTriggeredBreakpoint() { m_triggeredBreakpoints.clear(); } // Retourne le nombre d'objet DebugBreakpoint template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getTriggeredBreakpointsCount() const { return boost::shared_ptr< Base<EncodingT> > (new Numeric<EncodingT>(m_triggeredBreakpoints.size())); } // Retourne l'objet TriggeredBreakpoint template <class EncodingT> boost::shared_ptr< Base<EncodingT> > DebugEngineInterpreter<EncodingT>::getTriggeredBreakpoint(const boost::shared_ptr< Base<EncodingT> >& i) const { IDebugBreakpoint * bp = NULL; size_t index = 0; if (check_numeric_i(i, index)) { if (check_index(index, m_triggeredBreakpoints.size())) { bp = m_triggeredBreakpoints[index]; } } return boost::shared_ptr< Base<EncodingT> > (new IDebugBreakpointPtrInterpreter<EncodingT>(bp)); } NAMESPACE_END template <class EncodingT> EventCallbacks<EncodingT>::EventCallbacks(interp::DebugEngineInterpreter<EncodingT> *owner, IDebugControl3 *control) : m_Owner(owner), m_Control(control), m_Breakpoint(NULL) { } template <class EncodingT> EventCallbacks<EncodingT>::~EventCallbacks() { if (m_Control && m_Breakpoint) { HRESULT status = m_Control->RemoveBreakpoint(m_Breakpoint); if (status == S_OK) { m_Breakpoint = NULL; } } } template <class EncodingT> STDMETHODIMP_(ULONG) EventCallbacks<EncodingT>::AddRef( THIS ) // event callback method 1 { return 1; } template <class EncodingT> STDMETHODIMP_(ULONG) EventCallbacks<EncodingT>::Release( THIS ) //event callback method 2 { return 0; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::Breakpoint( THIS_ IN PDEBUG_BREAKPOINT Bp ) //event callback method 3 { if (m_Owner != NULL) { m_Owner->AddTriggeredBreakpoint(Bp); } return DEBUG_STATUS_BREAK; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::CreateProcess(THIS_ IN ULONG64 ImageFileHandle, IN ULONG64 Handle, IN ULONG64 BaseOffset,IN ULONG ModuleSize,IN PCSTR ModuleName,IN PCSTR ImageName, IN ULONG CheckSum, IN ULONG TimeDateStamp,IN ULONG64 InitialThreadHandle, IN ULONG64 ThreadDataOffset, IN ULONG64 StartOffset ) //event callback method 4 and so on till method 16 { if (m_Control) { HRESULT status = 0; //we are setting a break point in Address Of Entrypoint of the debuggee IDebugBreakpoint* breakpoint = NULL; if ((status = m_Control->AddBreakpoint(DEBUG_BREAKPOINT_CODE,DEBUG_ANY_ID, &breakpoint)) == S_OK) { if (( status = breakpoint->SetOffset(StartOffset)) == S_OK) { if (( status = breakpoint->SetFlags(DEBUG_BREAKPOINT_ENABLED)) == S_OK) { m_Breakpoint = breakpoint; } } } } return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::CreateThread( THIS_ IN ULONG64 Handle, IN ULONG64 DataOffset, IN ULONG64 StartOffset ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::Exception( THIS_ IN PEXCEPTION_RECORD64 Exception, IN ULONG FirstChance ) { HRESULT hres = DEBUG_STATUS_BREAK; if (Exception != NULL && Exception->ExceptionCode == 0x406D1388) { hres = DEBUG_STATUS_NO_CHANGE; } return hres; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::ExitProcess (THIS_ IN ULONG ExitCode ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::ExitThread (THIS_ IN ULONG ExitCode ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::GetInterestMask( THIS_ OUT PULONG Mask ) { *Mask = DEBUG_EVENT_BREAKPOINT | DEBUG_EVENT_EXCEPTION | DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD | DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS | DEBUG_EVENT_LOAD_MODULE | DEBUG_EVENT_UNLOAD_MODULE | DEBUG_EVENT_SYSTEM_ERROR | DEBUG_EVENT_SESSION_STATUS | DEBUG_EVENT_CHANGE_DEBUGGEE_STATE | DEBUG_EVENT_CHANGE_ENGINE_STATE | DEBUG_EVENT_CHANGE_SYMBOL_STATE; return S_OK; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::LoadModule( THIS_ IN ULONG64 ImageFileHandle, IN ULONG64 BaseOffset, IN ULONG ModuleSize,IN PCSTR ModuleName, IN PCSTR ImageName, IN ULONG CheckSum, IN ULONG TimeDateStamp ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::SystemError( THIS_ IN ULONG Error, IN ULONG Level ) { return DEBUG_STATUS_BREAK; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::UnloadModule( THIS_ IN PCSTR ImageBaseName, IN ULONG64 BaseOffset ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::SessionStatus( THIS_ IN ULONG SessionStatus ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::ChangeDebuggeeState( THIS_ IN ULONG Flags, IN ULONG64 Argument ) { return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::ChangeEngineState( THIS_ IN ULONG Flags, IN ULONG64 Argument ) { if ((m_Owner != NULL) && (DEBUG_CES_EXECUTION_STATUS == Flags) && (DEBUG_STATUS_BREAK != Argument) && (DEBUG_STATUS_NO_CHANGE != Argument) && (DEBUG_STATUS_NO_DEBUGGEE != Argument)) { m_Owner->ResetTriggeredBreakpoint(); } return DEBUG_STATUS_NO_CHANGE; } template <class EncodingT> STDMETHODIMP EventCallbacks<EncodingT>::ChangeSymbolState( THIS_ IN ULONG Flags, IN ULONG64 Argument ) // method 16 { return DEBUG_STATUS_NO_CHANGE; } #undef A #undef C
; v1.0.1 by KirbyMIMI NTSC translation by Colt Zero updated by magi 10/29/21 ; Assembly AR Code .open "sys/main.dol" ; m_Do_controller_pad__mDoCPd_Create + 0x4C .org 0x80007ABC ; 04007ABC nop ;v 60000000 ; m_Do_controller_pad__mDoCPd_Create + 0x60 .org 0x80007AD0 ; 04007AD0 li r4,0x1 ;v 38800001 ; m_Do_controller_pad__mDoCPd_Create + 0x74 .org 0x80007AE4 ; 04007AE4 stw r0,0x4(r3) ;v 90030004 ; m_Do_graphic__drawDepth .org 0x80008F34 ; 04008F34 blr ;v 4E800020 ; m_Do_graphic__mDoGph_Painter + 0x74 .org 0x8000AFA0 ; 0400AFA0 bl JFWDisplay__beginRender ;v 4824A92D lis r3,-0x7FFD ;v 3C608003 ori r4,r3,0xE318 ;v 6064E318 ori r3,r3,0xE338 ;v 6063E338 bl f_pc_draw__fpcDw_Handler ;v 4803551D ; m_Do_graphic__mDoGph_Painter + 0x198 .org 0x8000B0C4 ; 0400B0C4 bl TRK_MINNOW_DOLPHIN__TRKNubMainLoop_B0 ;v 48325ED1 ; m_Do_graphic__mDoGph_Painter + 0xCCC .org 0x8000BBF8 ; 0400BBF8 lwz r3,-0x6D50(r13) ;v 806D92B0 nop ;v 60000000 bl JFWDisplay__endRender ;v 48249EB9 ; m_Do_graphic__mDoGph_Painter + 0xCF0 .org 0x8000BC1C ; 0400BC1C bl TRK_MINNOW_DOLPHIN__TRKInitializeNub_44 ;v 48325679 ; m_Do_machine__mDoMch_Create + 0xB4 ; comment the below two lines for default memory .org 0x8000C7C0 ; 0400C7C0 nop ;v 60000000 ; m_Do_machine__mDoMch_Create + 0x13C ; comment the below two lines for default memory .org 0x8000C848 ; 0400C848 lis r0, 0x6C ;v 3C00006C ; m_Do_machine__mDoMch_Create + 0x2D0 ; uncomment the below two lines for default memory ;.org 0x8000C9DC ; 0400C9DC ; lis r3,0x9A ;v 3C60009A ; m_Do_machine__mDoMch_Create + 0x2E0 .org 0x8000C9EC ; 0400C9EC lis r3,0x37 ;v 3C600037 ; fopAcM_searchActorAngleY + 0x10 .org 0x80025260 ; 04025260 bl TRK_MINNOW_DOLPHIN__TRKMessageSend_40 ;v 4830C165 ; fopAcM_searchActorDistance .org 0x800252BC ; 040252BC b TRK_MINNOW_DOLPHIN__TRKInitializeNub_A4 ;v 4830C038 ; fopAcM_searchActorDistanceXZ .org 0x800253C0 ; 040253C0 b TRK_MINNOW_DOLPHIN__TRKInitializeNub_10C ;v 4830BF9C ; f_pc_manager__fpcM_Management + 0xDC .org 0x8003ED60 ; 0403ED60 nop ;v 60000000 ; d_stage__dStage_playerInit + 0x31C .org 0x80041E10 ; 04041E10 bl TRK_MINNOW_DOLPHIN__TRKGetNextEvent_78 ;v 482EF361 ; d_stage__dStage_cameraInit + 0x10 .org 0x80041E94 ; 04041E94 li r31,0x0 ;v 3BE00000 addi r4,r4,0x4 ;v 38840004 stw r4,0x4(r3) ;v 90830004 ; d_stage__dStage_cameraInit_1C li r4,0x0 ;v 38800000 li r5,0x0 ;v 38A00000 bl d_stage__dStage_cameraCreate ;v 4BFFF7F5 cmpwi r31,0x0 ;v 2C1F0000 li r31,0x1 ;v 3BE00001 beq d_stage__dStage_cameraInit_1C ;v 4182FFEC lwz r31,0xC(r1) ;v 83E1000C addi r1,r1,0x10 ;v 38210010 lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; dEvent_exception_c__setStartDemo + 0xE8 .org 0x800738DC ; 040738DC bl TRK_MINNOW_DOLPHIN__TRKGetNextEvent_64 ;v 482BD881 ; dEvent_manager_c__startProc + 0xA4 .org 0x80074094 ; 04074094 bl TRK_MINNOW_DOLPHIN__TRKGetNextEvent_1C ;v 482BD081 ; dEvent_manager_c__startProc + 0x114 .org 0x80074104 ; 04074104 b TRK_MINNOW_DOLPHIN__TRKInitializeNub_78 ;v 482BD1C4 ; dEvent_manager_c__closeProc + 0x8 .org 0x80074110 ; 04074110 b TRK_MINNOW_DOLPHIN__TRKInitializeNub_88 ;v 482BD1C8 ; dDlst_shadowControl_c__imageDraw + 0xD0 .org 0x80084EBC ; 04084EBC nop ;v 60000000 ; dAttention_c__dAttention_c + 0x14 .org 0x8009D2F4 ; 0409D2F4 bl TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_8 ;v 48293EC1 ; d_attention__select_attention .org 0x8009E2CC ; 0409E2CC mr r6,r3 ;v 7C661B78 li r3,0x0 ;v 38600000 lwz r5,0x10(r6) ;v 80A60010 lis r0,-0x7FC8 ;v 3C008038 ori r0,r0,0xFD8C ; d_a_player_main__g_profile_PLAYER ;v 6000FD8C cmpw r0,r5 ;v 7C002800 beqlr ;v 4D820020 mr r3,r4 ;v 7C832378 mr r4,r6 ;v 7CC43378 b dAttention_c__SelectAttention ;v 4800004C ; dAttention_c__judgementButton + 0x74 .org 0x8009EE34 ; 0409EE34 lwz r4,0x190(r3) ;v 80830190 ; dAttention_c__judgementButton + 0xA8 .org 0x8009EE68 ; 0409EE68 lwz r4,0x190(r3) ;v 80830190 ; dAttention_c__judgementStatusSw + 0x88 .org 0x8009EFC8 ; 0409EFC8 lwz r3,0x190(r31) ;v 807F0190 ; dAttention_c__Run + 0xF8 .org 0x8009F2CC ; 0409F2CC lwz r3,0x190(r31) ;v 807F0190 ; dAttention_c__Run + 0x168 .org 0x8009F33C ; 0409F33C lwz r3,0x190(r31) ;v 807F0190 ; d_a_item__itemGetCallBack + 0x24 .org 0x800F5000 ; 040F5000 lhz r31,0x12(r29) ;v A3FD0012 ; d_a_item__itemGetCallBack + 0x40 .org 0x800F501C ; 040F501C cmplwi r31,0xFD8C ; d_a_player_main__g_profile_PLAYER ;v 281FFD8C ; daPy_py_c__changePlayer + 0x30 .org 0x8010292C ; 0410292C nop ;v 60000000 ; daPy_lk_c__draw + 0x588 .org 0x80107890 ; 04107890 bl TRK_MINNOW_DOLPHIN__TRKMessageSend_124 ;v 48229C19 ; daPy_lk_c__draw + 0x608 .org 0x80107910 ; 04107910 bl TRK_MINNOW_DOLPHIN__TRKMessageSend_124 ;v 48229B99 ; daPy_lk_c__draw + 0x70C .org 0x80107A14 ; 04107A14 bl TRK_MINNOW_DOLPHIN__TRKMessageSend_124 ;v 48229A95 ; daPy_lk_c__draw + 0x78C .org 0x80107A94 ; 04107A94 bl TRK_MINNOW_DOLPHIN__TRKMessageSend_124 ;v 48229A15 ; daPy_lk_c__setAtnList + 0x24 .org 0x80108248 ; 04108248 nop ;v 60000000 ; daPy_lk_c__checkNextActionFromButton + 0x87C .org 0x8010E3D4 ; 0410E3D4 nop ;v 60000000 ; daPy_lk_c__changeWaitProc + 0x58 .org 0x80110008 ; 04110008 b daPy_lk_c__changeWaitProc_64 ;v 4800000C ; daPy_lk_c__changeDamageProc + 0xE4 .org 0x80110738 ; 04110738 nop ;v 60000000 ; daPy_lk_c__setStickData + 0x3C .org 0x8011F9FC ; 0411F9FC b daPy_lk_c__setStickData_50 ;v 48000014 ; daPy_lk_c__setStickData + 0x194 .org 0x8011FB54 ; 0411FB54 lwz r3,0x4C28(r29) ;v 807D4C28 ; daPy_lk_c__setStickData + 0x1C8 .org 0x8011FB88 ; 0411FB88 lwz r3,0x4C28(r29) ;v 807D4C28 ; daPy_lk_c__setStickData + 0x1F4 .org 0x8011FBB4 ; 0411FBB4 bl TRK_MINNOW_DOLPHIN__TRKDestructEvent_20 ;v 48211449 ; daPy_lk_c__setStickData + 0x218 .org 0x8011FBD8 ; 0411FBD8 lwz r5,0x4C28(r29) ;v 80BD4C28 ; daPy_lk_c__setStickData + 0x248 .org 0x8011FC08 ; 0411FC08 lwz r4,0x4C28(r29) ;v 809D4C28 ; daPy_lk_c__setStickData + 0x32C .org 0x8011FCEC ; 0411FCEC lwz r3,0x4C28(r29) ;v 807D4C28 ; daPy_lk_c__setStickData + 0x34C .org 0x8011FD0C ; 0411FD0C lwz r3,0x4C28(r29) ;v 807D4C28 ; daPy_lk_c__setStickData + 0x374 .org 0x8011FD34 ; 0411FD34 lwz r5,0x4C28(r29) ;v 80BD4C28 ; daPy_lk_c__setStickData + 0x420 .org 0x8011FDE0 ; 0411FDE0 lwz r3,0x4C28(r29) ;v 807D4C28 ; daPy_lk_c__execute + 0x154 .org 0x801219C4 ; 041219C4 b daPy_lk_c__execute_1A4 ;v 48000050 ; daPy_lk_c__execute + 0x2F0 .org 0x80121B60 ; 04121B60 nop ;v 60000000 ; daPy_lk_c__execute + 0x2F8 .org 0x80121B68 ; 04121B68 nop ;v 60000000 ; daPy_lk_c__execute + 0x300 .org 0x80121B70 ; 04121B70 nop ;v 60000000 ; daPy_lk_c__execute + 0x308 .org 0x80121B78 ; 04121B78 nop ;v 60000000 ; daPy_lk_c__execute + 0x314 .org 0x80121B84 ; 04121B84 nop ;v 60000000 ; daPy_lk_c__execute + 0x31C .org 0x80121B8C ; 04121B8C nop ;v 60000000 ; daPy_lk_c__execute + 0x324 .org 0x80121B94 ; 04121B94 nop ;v 60000000 ; daPy_lk_c__execute + 0x330 .org 0x80121BA0 ; 04121BA0 nop ;v 60000000 ; daPy_lk_c__execute + 0x338 .org 0x80121BA8 ; 04121BA8 nop ;v 60000000 ; daPy_lk_c__execute + 0x133C .org 0x80122BAC ; 04122BAC b daPy_lk_c__execute_1350 ;v 48000014 ; d_a_player_main__daPy_Execute + 0x1C .org 0x80122D4C ; 04122D4C b TRK_MINNOW_DOLPHIN__TRKMessageSend_154 ;v 4820E78C ; daPy_lk_c__playerInit + 0x5C4 .org 0x8012525C ; 0412525C bl TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_38 ;v 4820BF89 ; d_a_player_main__phase_1 + 0x1C .org 0x80125CE4 ; 04125CE4 bl TRK_MINNOW_DOLPHIN__TRKGetNextEvent_4C ;v 4820B461 nop ;v 60000000 ; daPy_lk_c__daPy_lk_c + 0x1148 .org 0x80126EFC ; 04126EFC b TRK_MINNOW_DOLPHIN__TRKNubMainLoop ;v 48209FE8 ; daPy_lk_c__dProcGetItem + 0x14 .org 0x8012E8C4 ; 0412E8C4 bl TRK_MINNOW_DOLPHIN__TRKInitializeNub_90 ;v 48202A1D ; daPy_lk_c__changeSwimProc + 0x48 .org 0x8013D008 ; 0413D008 nop ;v 60000000 ; daPy_lk_c__swimOutAfter + 0x44 .org 0x8013D2F0 ; 0413D2F0 nop ;v 60000000 ; dCamera_c__dCamera_c + 0x48 .org 0x801617D8 ; 041617D8 bl TRK_MINNOW_DOLPHIN__TRKNubMainLoop_D0 ;v 481CF7DD ; dCamera_c__dCamera_c + 0x124 .org 0x801618B4 ; 041618B4 b TRK_MINNOW_DOLPHIN__TRKNubMainLoop_68 ;v 481CF698 ; dCamera_c__updatePad + 0x54 .org 0x801623F4 ; 041623F4 lwz r3,0x9D4(r31) ;v 807F09D4 ; dCamera_c__updatePad + 0x70 .org 0x80162410 ; 04162410 lwz r4,0x9D4(r31) ;v 809F09D4 ; dCamera_c__updatePad + 0xD8 .org 0x80162478 ; 04162478 lwz r3,0x9D4(r31) ;v 807F09D4 ; dCamera_c__updatePad + 0x128 .org 0x801624C8 ; 041624C8 lwz r4,0x9D4(r31) ;v 809F09D4 ; dCamera_c__updatePad + 0x1D0 .org 0x80162570 ; 04162570 lwz r4,0x9D4(r31) ;v 809F09D4 ; dCamera_c__updatePad + 0x280 .org 0x80162620 ; 04162620 lwz r0,0x9D4(r31) ;v 801F09D4 ; dCamera_c__Att + 0x38 .org 0x80163328 ; 04163328 bl TRK_MINNOW_DOLPHIN__TRKTerminateNub_8 ;v 481CDF0D ; dCamera_c__Run + 0x174 .org 0x80163688 ; 04163688 bl TRK_MINNOW_DOLPHIN__TRKInitializeNub_4 ;v 481CDBCD ; dCamera_c__nextMode + 0x24 .org 0x801641B0 ; 041641B0 bl TRK_MINNOW_DOLPHIN__TRKInitializeNub_24 ;v 481CD0C5 ; dKy_setLight + 0x2C .org 0x80194C08 ; 04194C08 bl TRK_MINNOW_DOLPHIN__TRKGetNextEvent_88 ;v 4819C579 ; d_mesg__dMesg_finalize + 0x48 .org 0x801E5B24 ; 041E5B24 bl dMesg_tSequenceProcessor__dMesg_tSequenceProcessor_destructor ;v 48000095 ; d_mesg__dMesg_finalize + 0x68 .org 0x801E5B44 ; 041E5B44 bl dMesg_tRenderingProcessor__dMesg_tRenderingProcessor_destructor ;v 48000015 ; d_mesg__dMsg_Delete + 0x1C0 .org 0x801E7100 ; 041E7100 bl JMessage__TParse__TParse_destructor ;v 480B8D91 ; d_message_paper__dMsg3_textPosition + 0x30 .org 0x801EC8FC ; 041EC8FC bl d_message_paper__dMsg3_arrowMove_20 ;v 48000115 ; d_meter__dMeter_swimMove + 0xBC .org 0x802009B0 ; 042009B0 nop ;v 60000000 ; d_meter__dMeter_swimMove + 0xC8 .org 0x802009BC ; 042009BC nop ;v 60000000 ; d_s_play__dScnPly_Draw + 0x40C .org 0x80234FA8 ; 04234FA8 bl TRK_MINNOW_DOLPHIN__TRKPostEvent_D0 ;v 480FC141 ; d_s_play__dScnPly_Execute + 0xA4 .org 0x80235074 ; 04235074 bl TRK_MINNOW_DOLPHIN__TRKPostEvent_A0 ;v 480FC045 ; d_s_play__dScnPly_Execute + 0xC0 .org 0x80235090 ; 04235090 bl TRK_MINNOW_DOLPHIN__TRKPostEvent_58 ;v 480FBFE1 ; cXyz__normalize + 0x34 .org 0x80245B10 ; 04245B10 b cXyz__normalize_68 ;v 48000034 ; gx__GXSetViewportJitter .org 0x803270C4 ; 043270C4 b TRK_MINNOW_DOLPHIN__TRKMessageSend_1A0 ;v 4800A460 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop .org 0x80330EE4 ; 04330EE4 lis r4,-0x7FC1 ;v 3C80803F lbz r6,0x1F00(r4) ;v 88C41F00 lis r5,-0x7FC6 ;v 3CA0803A ori r5,r5,0x4DF0 ;v 60A54DF0 cmpwi r6,0x1 ;v 2C060001 bne TRK_MINNOW_DOLPHIN__TRKNubMainLoop_28 ;v 40820014 stw r5,0x4C28(r3) ;v 90A34C28 li r0,0x0 ;v 38000000 stb r0,0x1F00(r4) ;v 98041F00 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_28 stw r3,0x3EA0(r4) ;v 90643EA0 addi r5,r5,0x3C ;v 38A5003C stw r5,0x4C28(r3) ;v 90A34C28 li r0,0x1 ;v 38000001 stb r0,0x1F00(r4) ;v 98041F00 blr ;v 4E800020 lis r4,-0x7FC1 ;v 3C80803F lbz r0,0x1F00(r4) ;v 88041F00 cmpwi r0,0x1 ;v 2C000001 bne TRK_MINNOW_DOLPHIN__TRKNubMainLoop_5C ;v 40820010 li r0,0x2 ;v 38000002 stb r0,0x1F00(r4) ;v 98041F00 b m_Do_graphic__mDoGph_Painter_78 ;v 4BCDA068 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_5C li r3,0x1 ;v 38600001 stb r3,0x1F00(r4) ;v 98641F00 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_68 lis r4,-0x7FC1 ;v 3C80803F lbz r6,0x1F00(r4) ;v 88C41F00 lis r5,-0x7FC6 ;v 3CA0803A ori r5,r5,0x4DF0 ;v 60A54DF0 cmpwi r6,0x1 ;v 2C060001 bne TRK_MINNOW_DOLPHIN__TRKNubMainLoop_90 ;v 40820014 stw r5,0x9D4(r3) ;v 90A309D4 li r0,0x0 ;v 38000000 stb r0,0x1F00(r4) ;v 98041F00 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_90 nop ;v 60000000 addi r5,r5,0x3C ;v 38A5003C stw r5,0x9D4(r3) ;v 90A309D4 li r0,0x1 ;v 38000001 stb r0,0x1F00(r4) ;v 98041F00 lwz r4,0x3EA0(r4) ;v 80843EA0 stw r4,0x128(r3) ;v 90830128 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_B0 lis r4,-0x7FC1 ;v 3C80803F lbz r0,0x1F00(r4) ;v 88041F00 cmpwi r0,0x1 ;v 2C000001 bne TRK_MINNOW_DOLPHIN__TRKNubMainLoop_C8 ;v 4082000C lwz r28,0x5B10(r3) ;v 83835B10 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_C8 lwz r28,0x3E9C(r4) ;v 83843E9C blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop_D0 lis r3,-0x7FC1 ;v 3C60803F lbz r0,0x1F00(r3) ;v 88031F00 cmpwi r0,0x0 ;v 2C000000 beqlr ;v 4D820020 stw r31,0x3E9C(r3) ;v 93E33E9C blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop + 0xE8 lis r4,-0x7FC1 ;v 3C80803F lbz r0,0x1F00(r4) ;v 88041F00 cmpwi r0,0x2 ;v 2C000002 bne TRK_MINNOW_DOLPHIN__TRKDestructEvent_10 ;v 40820014 lwz r4,0x3E9C(r4) ;v 80843E9C cmpw r4,r3 ;v 7C041800 bnelr ;v 4C820020 b d_camera__camera_draw ;v 4BE4B368 ; TRK_MINNOW_DOLPHIN__TRKDestructEvent_10 lwz r4,0x3E9C(r4) ;v 80843E9C cmpw r4,r3 ;v 7C041800 beqlr ;v 4D820020 b d_camera__camera_draw ;v 4BE4B358 ; TRK_MINNOW_DOLPHIN__TRKDestructEvent_20 lwz r4,0x36C(r3) ;v 8083036C cmpw r29,r4 ;v 7C1D2000 beq TRK_MINNOW_DOLPHIN__TRKConstructEvent_10 ;v 4182000C lis r3,-0x7FC1 ;v 3C60803F lwz r3,0x3E9C(r3) ;v 80633E9C ; TRK_MINNOW_DOLPHIN__TRKConstructEvent_10 lha r3,0x2B0(r3) ;v A86302B0 blr ;v 4E800020 mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0x30(r1) ;v 9421FFD0 stmw r27,0x8(r1) ;v BF610008 li r27,0x0 ;v 3B600000 mr r31,r3 ;v 7C7F1B78 mr r30,r5 ;v 7CBE2B78 mr r29,r6 ;v 7CDD3378 mr r28,r4 ;v 7C9C2378 ; TRK_MINNOW_DOLPHIN__TRKPostEvent_24 bl d_stage__dStage_playerInit ;v 4BD10AB9 addi r27,r27,0x1 ;v 3B7B0001 cmpwi r27,0x2 ;v 2C1B0002 mr r3,r31 ;v 7FE3FB78 mr r5,r30 ;v 7FC5F378 mr r6,r29 ;v 7FA6EB78 mr r4,r28 ;v 7F84E378 bne TRK_MINNOW_DOLPHIN__TRKPostEvent_24 ;v 4082FFE4 lmw r27,0x8(r1) ;v BB610008 addi r1,r1,0x30 ;v 38210030 lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKPostEvent_58 li r5,0x0 ;v 38A00000 lis r4,-0x7FC1 ;v 3C80803F lwz r3,0x3EA4(r4) ;v 80643EA4 lwz r4,0x3EA0(r4) ;v 80843EA0 b dAttention_c__dAttention_c ;v 4BD6C260 ; TRK_MINNOW_DOLPHIN__TRKPostEvent_A0 .org 0x803310B8 ; 043310B8 mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0xC(r1) ;v 9421FFF4 bl dAttention_c__Run ;v 4BD6E111 lis r3,-0x7FC1 ;v 3C60803F lwz r3,0x3EA4(r3) ;v 80633EA4 li r4,-0x1 ;v 3880FFFF bl dAttention_c__Run ;v 4BD6E101 addi r1,r1,0xC ;v 3821000C lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKPostEvent_D0 mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0xC(r1) ;v 9421FFF4 bl dAttention_c__Draw ;v 4BD6E36D lis r3,-0x7FC1 ;v 3C60803F lwz r3,0x3EA4(r3) ;v 80633EA4 bl dAttention_c__Draw ;v 4BD6E361 addi r1,r1,0xC ;v 3821000C lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_1C stw r0,0x1C4(r3) ;v 900301C4 lis r4,-0x7FC1 ;v 3C80803F lwz r4,0x3EA0(r4) ;v 80843EA0 cmpw r3,r4 ;v 7C032000 beq TRK_MINNOW_DOLPHIN__TRKGetNextEvent_40 ;v 41820014 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_30 lwz r0,0x1C4(r4) ;v 800401C4 ori r0,r0,0x8000 ;v 60008000 stw r0,0x1C4(r4) ;v 900401C4 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_40 lwz r4,0x18(r4) ;v 80840018 addi r4,r4,-0x18 ;v 3884FFE8 b TRK_MINNOW_DOLPHIN__TRKGetNextEvent_30 ;v 4BFFFFE8 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_4C lwz r0,0x5B44(r4) ;v 80045B44 cmpwi r0,0x0 ;v 2C000000 bnelr ;v 4C820020 stw r31,0x5B44(r4) ;v 93E45B44 stw r31,0x5B4C(r4) ;v 93E45B4C blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_64 lis r6,-0x7FC1 ;v 3CC0803F lbz r6,0x1F00(r6) ;v 88C61F00 cmpwi r6,0x0 ;v 2C060000 beqlr ;v 4D820020 b STControl__checkTrigger_28C ;v 4BD27460 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_78 lwz r0,0x1C(r1) ;v 8001001C cmpwi r0,0x1 ;v 2C000001 beqlr ;v 4D820020 b f_op_msg_mng__fopMsgM_Create ;v 4BCFD088 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_88 lis r4,-0x7FC1 ;v 3C80803F lbz r0,0x1F00(r4) ;v 88041F00 cmpwi r0,0x1 ;v 2C000001 bne TRK_MINNOW_DOLPHIN__TRKGetNextEvent_A0 ;v 4082000C lwz r30,0x5B10(r3) ;v 83C35B10 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKGetNextEvent_A0 lwz r30,0x3E9C(r4) ;v 83C43E9C blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_8 .org 0x803311B4 ; 043311B4 mr r31,r3 ;v 7C7F1B78 lwz r0,0x54(r1) ;v 80010054 lis r6,-0x7FDD ;v 3CC08023 ori r6,r6,0x5094 ;v 60C65094 cmpw r0,r6 ;v 7C003000 lis r6,-0x7FC6 ;v 3CC0803A ori r6,r6,0x4DF0 ;v 60C64DF0 bne TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_2C ;v 40820008 addi r6,r6,0x3C ;v 38C6003C ; TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_2C stw r6,0x190(r31) ;v 90DF0190 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeEventQueue_38 .org 0x803311E4 ; 043311E4 lis r4,-0x7FCD ;v 3C808033 lbz r3,0x11E2(r4) ;v 886411E2 xori r0,r3,0x1 ;v 68600001 stb r0,0x11E2(r4) ;v 980411E2 cmpwi r3,0x1 ;v 2C030001 addi r3,r30,0x5808 ;v 387E5808 bne TRK_MINNOW_DOLPHIN__TRKTerminateNub ;v 40820030 mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0xC(r1) ;v 9421FFF4 li r3,-0x4 ;v 3860FFFC li r4,0x1A0 ;v 388001A0 bl cMl__memalignB ;v 4BF100E5 lis r4,-0x7FC1 ;v 3C80803F stw r3,0x3EA4(r4) ;v 90643EA4 addi r1,r1,0xC ;v 3821000C lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 stw r3,0x3480(r31) ;v 907F3480 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKTerminateNub_8 addi r31,r3,0x5808 ;v 3BE35808 lwz r0,0x128(r30) ;v 801E0128 lwz r4,0x0(r31) ;v 809F0000 cmpw r4,r0 ;v 7C040000 beqlr ;v 4D820020 lis r31,-0x7FC1 ;v 3FE0803F lwz r31,0x3EA4(r31) ;v 83FF3EA4 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_4 addi r31,r31,0x5808 ;v 3BFF5808 lwz r0,0x128(r28) ;v 801C0128 lwz r4,0x0(r31) ;v 809F0000 cmpw r4,r0 ;v 7C040000 beqlr ;v 4D820020 lis r31,-0x7FC1 ;v 3FE0803F lwz r31,0x3EA4(r31) ;v 83FF3EA4 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_24 addi r31,r29,0x5808 ;v 3BFD5808 lwz r0,0x128(r26) ;v 801A0128 lwz r4,0x0(r31) ;v 809F0000 cmpw r4,r0 ;v 7C040000 beqlr ;v 4D820020 lis r31,-0x7FC1 ;v 3FE0803F lwz r31,0x3EA4(r31) ;v 83FF3EA4 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_44 lis r4,-0x7FC1 ;v 3C80803F lwz r0,0x3EA8(r4) ;v 80043EA8 cmpwi r0,0x0 ;v 2C000000 bnelr ;v 4C820020 lbz r0,0x1F00(r4) ;v 88041F00 cmpwi r0,0x1 ;v 2C000001 bne TRK_MINNOW_DOLPHIN__TRKInitializeNub_6C ;v 40820010 li r0,0x2 ;v 38000002 stb r0,0x1F00(r4) ;v 98041F00 b m_Do_graphic__mDoGph_Painter_78 ;v 4BCD9CEC ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_6C li r3,0x1 ;v 38600001 stb r3,0x1F00(r4) ;v 98641F00 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_78 li r0,0x1 ;v 38000001 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_7C lis r9,-0x7FC1 ;v 3D20803F stw r0,0x3EA8(r9) ;v 90093EA8 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_88 li r0,0x0 ;v 38000000 b TRK_MINNOW_DOLPHIN__TRKInitializeNub_7C ;v 4BFFFFF0 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_90 mr r30,r3 ;v 7C7E1B78 lwz r0,0x20(r30) ;v 801E0020 cmpwi r0,0x0 ;v 2C000000 bnelr ;v 4C820020 b daPy_lk_c__dProcGetItem_3E4 ;v 4BDFD9A4 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_A4 lis r6,-0x7FC3 ;v 3CC0803D lwz r6,-0x58B4(r6) ;v 80C6A74C cmpw r4,r6 ;v 7C043000 beq TRK_MINNOW_DOLPHIN__TRKInitializeNub_BC ;v 4182000C stwu r1,-0x30(r1) ;v 9421FFD0 b fopAcM_searchActorDistance_4 ;v 4BCF3FB8 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_BC mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0x14(r1) ;v 9421FFEC stw r3,0x8(r1) ;v 90610008 stwu r1,-0x30(r1) ;v 9421FFD0 bl fopAcM_searchActorDistance_4 ;v 4BCF3FA1 stfs f1,0xC(r1) ;v D021000C lwz r3,0x8(r1) ;v 80610008 lis r4,-0x7FC1 ;v 3C80803F lwz r4,0x3EA0(r4) ;v 80843EA0 stwu r1,-0x30(r1) ;v 9421FFD0 bl fopAcM_searchActorDistance_4 ;v 4BCF3F89 lfs f2,0xC(r1) ;v C041000C fcmpo cr0,f1,f2 ;v FC011040 ble TRK_MINNOW_DOLPHIN__TRKInitializeNub_FC ;v 40810008 fmr f1,f2 ;v FC201090 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_FC addi r1,r1,0x14 ;v 38210014 lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_10C lis r6,-0x7FC3 ;v 3CC0803D lwz r6,-0x58B4(r6) ;v 80C6A74C cmpw r4,r6 ;v 7C043000 beq TRK_MINNOW_DOLPHIN__TRKInitializeNub_124 ;v 4182000C stwu r1,-0x30(r1) ;v 9421FFD0 b fopAcM_searchActorDistanceXZ_4 ;v 4BCF4054 ; TRK_MINNOW_DOLPHIN__TRKInitializeNub_124 mflr r0 ;v 7C0802A6 stw r0,0x4(r1) ;v 90010004 stwu r1,-0x14(r1) ;v 9421FFEC stw r3,0x8(r1) ;v 90610008 stwu r1,-0x30(r1) ;v 9421FFD0 bl fopAcM_searchActorDistanceXZ_4 ;v 4BCF403D stfs f1,0xC(r1) ;v D021000C lwz r3,0x8(r1) ;v 80610008 lis r4,-0x7FC1 ;v 3C80803F lwz r4,0x3EA0(r4) ;v 80843EA0 stwu r1,-0x30(r1) ;v 9421FFD0 bl fopAcM_searchActorDistanceXZ_4 ;v 4BCF4025 lfs f2,0xC(r1) ;v C041000C fcmpo cr0,f1,f2 ;v FC011040 ble TRK_MINNOW_DOLPHIN__TRKMessageSend_30 ;v 40810008 fmr f1,f2 ;v FC201090 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_30 addi r1,r1,0x14 ;v 38210014 lwz r0,0x4(r1) ;v 80010004 mtlr r0 ;v 7C0803A6 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_40 lis r6,-0x7FC3 ;v 3CC0803D lwz r6,-0x58B4(r6) ;v 80C6A74C cmpw r4,r6 ;v 7C043000 beq TRK_MINNOW_DOLPHIN__TRKMessageSend_58 ;v 4182000C addi r4,r4,0x1F8 ;v 388401F8 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_58 lfs f1,0x0(r3) ;v C0230000 lfs f2,0x0(r3) ;v C0430000 lis r6,-0x7FCB ;v 3CC08035 lfs f0,-0x448(r6) ;v C006FBB8 lfs f3,0x1F8(r4) ;v C06401F8 lfs f4,0x200(r4) ;v C0840200 fsubs f3,f3,f1 ;v EC630828 fsubs f4,f4,f2 ;v EC841028 fcmpo cr0,f3,f0 ;v FC030040 bge TRK_MINNOW_DOLPHIN__TRKMessageSend_84 ;v 40800008 fneg f3,f3 ;v FC601850 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_84 fcmpo cr0,f4,f0 ;v FC040040 bge TRK_MINNOW_DOLPHIN__TRKMessageSend_90 ;v 40800008 fneg f4,f4 ;v FC802050 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_90 fadds f5,f3,f4 ;v ECA3202A lis r5,-0x7FC1 ;v 3CA0803F lwz r5,0x3EA0(r5) ;v 80A53EA0 lfs f3,0x1F8(r5) ;v C06501F8 lfs f4,0x200(r5) ;v C0850200 fsubs f3,f3,f1 ;v EC630828 fsubs f4,f4,f2 ;v EC841028 fcmpo cr0,f3,f0 ;v FC030040 bge TRK_MINNOW_DOLPHIN__TRKMessageSend_B8 ;v 40800008 fneg f3,f3 ;v FC601850 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_B8 fcmpo cr0,f4,f0 ;v FC040040 bge TRK_MINNOW_DOLPHIN__TRKMessageSend_C4 ;v 40800008 fneg f4,f4 ;v FC802050 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_C4 fadds f6,f3,f4 ;v ECC3202A fcmpo cr0,f6,f5 ;v FC062840 ble TRK_MINNOW_DOLPHIN__TRKMessageSend_D8 ;v 4081000C addi r4,r4,0x1F8 ;v 388401F8 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_D8 addi r4,r5,0x1F8 ;v 388501F8 blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_124 .org 0x803314A8 ; 043314A8 lis r6,-0x7FC1 ;v 3CC0803F lwz r6,0x3EA0(r6) ;v 80C63EA0 cmpw r6,r31 ;v 7C06F800 bne TRK_MINNOW_DOLPHIN__TRKMessageSend_140 ;v 40820010 lwz r0,0x0(r4) ;v 80040000 stw r0,0x8(r4) ;v 90040008 addi r4,r4,0x8 ;v 38840008 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_140 b J3DDrawBuffer__entryImm ;v 4BFBB800 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_154 .org 0x803314D8 ; 043314D8 lwz r4,0x4C28(r30) ;v 809E4C28 lbz r0,0x30(r4) ;v 88040030 cmpwi r0,0x26 ;v 2C000026 bnelr ;v 4C820020 lis r4,-0x7FC1 ;v 3C80803F lwz r4,0x3EA0(r4) ;v 80843EA0 cmpw r4,r30 ;v 7C04F000 bne TRK_MINNOW_DOLPHIN__TRKMessageSend_17C ;v 4082000C lis r4,-0x7FC3 ;v 3C80803D lwz r4,-0x58AC(r4) ;v 8084A754 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_17C lwz r0,0x1F8(r4) ;v 800401F8 stw r0,0x1F8(r30) ;v 901E01F8 lwz r0,0x200(r4) ;v 80040200 stw r0,0x200(r30) ;v 901E0200 lfs f0,0x1FC(r3) ;v C00301FC lfs f1,-0x7FFC(r2) ;v C0228004 fadds f0,f0,f1 ;v EC00082A stfs f0,0x1FC(r30) ;v D01E01FC blr ;v 4E800020 ; TRK_MINNOW_DOLPHIN__TRKMessageSend_1A0 lis r5,-0x7FC1 ;v 3CA0803F lwz r0,0x3EA8(r5) ;v 80053EA8 cmpwi r0,0x0 ;v 2C000000 bne TRK_MINNOW_DOLPHIN__TRKMessageSend_1CC ;v 40820020 lbz r0,0x1F00(r5) ;v 88051F00 cmpwi r0,0x1 ;v 2C000001 blt TRK_MINNOW_DOLPHIN__TRKMessageSend_1CC ;v 41800014 lfs f0,-0x7F78(r2) ;v C0028088 fdivs f4,f4,f0 ;v EC840024 bgt TRK_MINNOW_DOLPHIN__TRKMessageSend_1CC ;v 41810008 fadds f2,f2,f4 ;v EC42202A ; TRK_MINNOW_DOLPHIN__TRKMessageSend_1CC mflr r0 ;v 7C0802A6 b gx__GXSetViewportJitter_4 ;v 4BFF5B74 ; d_stage__l_funcTable$5322 + 0x2C .org 0x803750DC ; 043750DC .long 0x80331018 ; TRKPostEvent orig: d_stage__dStage_playerInit ;v 80331018 ; d_stage__l_funcTable$5327 + 0x8 .org 0x80375250 ; 04375250 .long 0x80331018 ; TRKPostEvent orig: d_stage__dStage_playerInit ;v 80331018 ; d_a_player_main__g_profile_PLAYER + 0x10 .org 0x8038FD9C ; 0438FD9C .long 0x4C38 ; orig + 0x10 ;v 00004C38 ; d_camera__method + 0x10 .org 0x80390F28 ; 04390F28 .long 0x80330FCC ; TRK_MINNOW_DOLPHIN__TRKNubMainLoop + 0xE8 ;v 80330FCC ; d_camera__g_profile_CAMERA + 0x10 .org 0x80390F3C ; 04390F3C .long 0x9E0 ; orig + 0x10 ;v 000009E0 .close
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/dynamodb/model/SSEStatus.h> #include <aws/core/utils/HashingUtils.h> #include <aws/core/Globals.h> #include <aws/core/utils/EnumParseOverflowContainer.h> using namespace Aws::Utils; namespace Aws { namespace DynamoDB { namespace Model { namespace SSEStatusMapper { static const int ENABLING_HASH = HashingUtils::HashString("ENABLING"); static const int ENABLED_HASH = HashingUtils::HashString("ENABLED"); static const int DISABLING_HASH = HashingUtils::HashString("DISABLING"); static const int DISABLED_HASH = HashingUtils::HashString("DISABLED"); static const int UPDATING_HASH = HashingUtils::HashString("UPDATING"); SSEStatus GetSSEStatusForName(const Aws::String& name) { int hashCode = HashingUtils::HashString(name.c_str()); if (hashCode == ENABLING_HASH) { return SSEStatus::ENABLING; } else if (hashCode == ENABLED_HASH) { return SSEStatus::ENABLED; } else if (hashCode == DISABLING_HASH) { return SSEStatus::DISABLING; } else if (hashCode == DISABLED_HASH) { return SSEStatus::DISABLED; } else if (hashCode == UPDATING_HASH) { return SSEStatus::UPDATING; } EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { overflowContainer->StoreOverflow(hashCode, name); return static_cast<SSEStatus>(hashCode); } return SSEStatus::NOT_SET; } Aws::String GetNameForSSEStatus(SSEStatus enumValue) { switch(enumValue) { case SSEStatus::ENABLING: return "ENABLING"; case SSEStatus::ENABLED: return "ENABLED"; case SSEStatus::DISABLING: return "DISABLING"; case SSEStatus::DISABLED: return "DISABLED"; case SSEStatus::UPDATING: return "UPDATING"; default: EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); if(overflowContainer) { return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); } return {}; } } } // namespace SSEStatusMapper } // namespace Model } // namespace DynamoDB } // namespace Aws