max_stars_repo_path
stringlengths
4
261
max_stars_repo_name
stringlengths
6
106
max_stars_count
int64
0
38.8k
id
stringlengths
1
6
text
stringlengths
7
1.05M
src/latin_utils/latin_utils.ads
spr93/whitakers-words
204
22405
<gh_stars>100-1000 -- WORDS, a Latin dictionary, by <NAME> (USAF, Retired) -- -- Copyright <NAME> (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. --------------------------------------------------------------------------- -- Main package of library-like utilities used all over the WORDS. --------------------------------------------------------------------------- package Latin_Utils is --------------------------------------------------------------------------- pragma Pure (Latin_Utils); --------------------------------------------------------------------------- end Latin_Utils;
libsrc/_DEVELOPMENT/math/float/math32/lm32/c/sdcc/acos.asm
jpoikela/z88dk
0
81856
SECTION code_fp_math32 PUBLIC _acos EXTERN cm32_sdcc_acos defc _acos = cm32_sdcc_acos
megalz_dec40.asm
uniabis/z80depacker
25
104425
<filename>megalz_dec40.asm ;Z80 depacker for megalz V4 packed files (C) fyrex^mhm ; DESCRIPTION: ; ; Depacker is fully relocatable, not self-modifying, ;it's length is 110 bytes starting from DEC40. ;Register usage: AF,AF',BC,DE,HL. Must be CALL'ed, return is done by RET. ;Provide extra stack location for store 2 bytes (1 word). Depacker does not ;disable or enable interrupts, as well as could be interrupted at any time ;(no f*cking wicked stack usage :). ; USAGE: ; ; - put depacker anywhere you want, ; - put starting address of packed block in HL, ; - put location where you want data to be depacked in DE, ; (much like LDIR command, but without BC) ; - make CALL to depacker (DEC40). ; - enjoy! ;) ; PRECAUTIONS: ; ; Be very careful if packed and depacked blocks coincide somewhere in memory. ;Here are some advices: ; ; 1. put packed block to the highest addresses possible. ; Best if last byte of packed block has address #FFFF. ; ; 2. Leave some gap between ends of packed and depacked block. ; For example, last byte of depacked block at #FF00, ; last byte of packed block at #FFFF. ; ; 3. Place nonpackable data to the end of block. ; ; 4. Always check whether depacking occurs OK and neither corrupts depacked data ; nor hangs computer. ; DEC40 LD A,#80 EX AF,AF' MS LDI M0 LD BC,#2FF M1 EX AF,AF' M1X ADD A,A JR NZ,M2 LD A,(HL) INC HL RLA M2 RL C JR NC,M1X EX AF,AF' DJNZ X2 LD A,2 SRA C JR C,N1 INC A INC C JR Z,N2 LD BC,#33F JR M1 X2 DJNZ X3 SRL C JR C,MS INC B JR M1 X6 ADD A,C N2 LD BC,#4FF JR M1 N1 INC C JR NZ,M4 EX AF,AF' INC B N5 RR C RET C RL B ADD A,A JR NZ,N6 LD A,(HL) INC HL RLA N6 JR NC,N5 EX AF,AF' ADD A,B LD B,6 JR M1 X3 DJNZ X4 LD A,1 JR M3 X4 DJNZ X5 INC C JR NZ,M4 LD BC,#51F JR M1 X5 DJNZ X6 LD B,C M4 LD C,(HL) INC HL M3 DEC B PUSH HL LD L,C LD H,B ADD HL,DE LD C,A LD B,0 LDIR POP HL JR M0 END_DEC40
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/fe_inlining_helper.ads
best08618/asylo
7
20026
-- { dg-excess-errors "no code generated" } generic procedure FE_Inlining_Helper;
test/interaction/Issue1130.agda
hborum/agda
3
1526
-- {-# OPTIONS -v tc.with:40 #-} id : (A : Set) → A → A id A = {!id′!} -- C-c C-h produces: id′ : ∀ {A} → A -- when it should produce: id′ : ∀ {A} → A → A f : (A : Set) (B : A → Set) (a : A) → B a f A B a = {!g A a!} -- Before: ∀ {A} {B : A → Set} A₁ (a : A₁) → B a -- After: ∀ A (a : A) {B : A → Set} → B a
oberon0/src/main/antlr4/Oberon0.g4
amanjpro/languages-a-la-carte
8
415
grammar Oberon0; // PARSER selector : ('.' Identifier | '[' expression ']') ; number : Integer ; booleanValue : value=('TRUE'| 'FALSE') ; select : Identifier selector* ; factor : select | number | booleanValue | '(' expression ')' | '~' factor ; term : factor term2* ; term2 : op=('*' | 'DIV' | 'MOD' | '&') factor ; simpleExpression : (sign=('+' | '-'))? term simpleExpression2* ; simpleExpression2 : op=('+' | '-' | 'OR') term ; expression : simpleExpression (op=('=' | '#' | '<' | '<=' | '>' | '>=') simpleExpression)? ; assignment : select ':=' expression ; actualParameters : '(' (expression (',' expression)* )? ')' ; procedureCall : select actualParameters? ; ifStatement : 'IF' expression 'THEN' statementSequence elseIf* elsep ; elseIf : 'ELSEIF' expression 'THEN' statementSequence ; elsep : ('ELSE' statementSequence)? 'END' ; whileStatement : 'WHILE' expression 'DO' statementSequence 'END' ; statement : (assignment | procedureCall | ifStatement | whileStatement)? ; statementSequence : statement (';' statement)* ; identList : Identifier (',' Identifier)* ; arrayType : 'ARRAY' expression 'OF' type ; fieldList : (identList ':' type)? ; recordType : 'RECORD' fieldList (';' fieldList)* 'END' ; type : Identifier | arrayType | recordType ; fpSection : 'VAR'? identList ':' type ; formalParameters : '(' (fpSection (';' fpSection)* )? ')' ; procedureHeading : 'PROCEDURE' name formalParameters? ; procedureBody : declarations ('BEGIN' statementSequence)? 'END' name ; procedureDeclaration : procedureHeading ';' procedureBody ; declarations : constDeclaration? typeDeclaration? varDeclaration? (procedureDeclaration ';')* ; constDeclaration : 'CONST' (Identifier '=' expression ';')* ; typeDeclaration : 'TYPE' (Identifier '=' type ';')* ; varDeclaration : 'VAR' (identList ':' type ';')* ; name : Identifier ; module : 'MODULE' name ';' declarations ('BEGIN' statementSequence)? 'END' name '.' ; // LEXER // keywords TRUE : 'TRUE' ; FALSE : 'FALSE' ; DIV : 'DIV' ; MOD : 'MOD' ; OR : 'OR' ; IF : 'IF' ; THEN : 'THEN' ; ELSEIF : 'ELSEIF' ; ELSE : 'ELSE' ; END : 'END' ; BEGIN : 'BEGIN' ; WHILE : 'WHILE' ; DO : 'DO' ; ARRAY : 'ARRAY' ; OF : 'OF' ; RECORD : 'RECORD' ; VAR : 'VAR' ; PROCEDURE : 'PROCEDURE' ; CONST : 'CONST' ; TYPE : 'TYPE' ; MODULE : 'MODULE' ; // Punctuations and operators DOT : '.' ; LBRACKET : '[' ; RBRACKET : ']' ; LPAREN : '(' ; RPAREN : ')' ; TILDA : '~' ; MUL : '*' ; AND : '&' ; PLUS : '+' ; MINUS : '-' ; EQUAL : '=' ; SHARP : '#' ; LT : '<' ; LE : '<=' ; GT : '>' ; GE : '>=' ; ASSIGN : ':=' ; COMA : ',' ; SEMI : ';' ; COLON : ':' ; Identifier : Letter (Letter | Digit)* ; Integer : Digit+ ; Digit : [0-9] ; Letter : [a-zA-Z_] ; // Whitespace and comments // WS : [ \t\r\n\u000C]+ -> skip ; COMMENT : '/*' .*? '*/' -> skip ; LINE_COMMENT : '//' ~[\r\n]* -> skip ;
orka/src/orka/interface/orka-rendering-buffers-mdi.ads
onox/orka
52
2829
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <<EMAIL>> -- -- 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. with Orka.Rendering.Buffers.Mapped.Unsynchronized; package Orka.Rendering.Buffers.MDI is pragma Preelaborate; package UB renames Mapped.Unsynchronized; type Batch (Vertex_Kind : Types.Numeric_Type; Index_Kind : Types.Index_Type) is tagged record -- Attributes Data : UB.Unsynchronized_Mapped_Buffer (Kind => Vertex_Kind, Mode => Mapped.Write); Indices : UB.Unsynchronized_Mapped_Buffer (Kind => Index_Kind, Mode => Mapped.Write); Commands : UB.Unsynchronized_Mapped_Buffer (Kind => Types.Elements_Command_Type, Mode => Mapped.Write); Index_Offset : Natural := 0; Vertex_Offset : Natural := 0; Draw_Index : Natural := 0; Instance_Index : Natural := 0; end record; procedure Append (Object : in out Batch; Instances : Natural; Vertices : Natural; Indices : Natural; Append_Vertices : not null access procedure (Offset, Count : Natural); Append_Indices : not null access procedure (Offset, Count : Natural)); function Create_Batch (Vertex_Kind : Types.Numeric_Type; Index_Kind : Types.Index_Type; Parts, Vertex_Data, Indices : Positive) return Batch; procedure Finish_Batch (Object : in out Batch); ----------------------------------------------------------------------------- function Create_Batch (Parts, Vertices, Indices : Positive) return Batch with Post => Create_Batch'Result.Vertex_Kind = Types.Half_Type and Create_Batch'Result.Index_Kind = Types.UInt_Type; procedure Append (Object : in out Batch; Positions : not null Indirect.Half_Array_Access; Normals : not null Indirect.Half_Array_Access; UVs : not null Indirect.Half_Array_Access; Indices : not null Indirect.UInt_Array_Access) with Pre => Object.Vertex_Kind = Types.Half_Type and Object.Index_Kind = Types.UInt_Type; end Orka.Rendering.Buffers.MDI;
oeis/158/A158738.asm
neoneye/loda-programs
11
24558
; A158738: a(n) = 72*n^2 - 1. ; Submitted by <NAME> ; 71,287,647,1151,1799,2591,3527,4607,5831,7199,8711,10367,12167,14111,16199,18431,20807,23327,25991,28799,31751,34847,38087,41471,44999,48671,52487,56447,60551,64799,69191,73727,78407,83231,88199,93311,98567,103967,109511,115199,121031,127007,133127,139391,145799,152351,159047,165887,172871,179999,187271,194687,202247,209951,217799,225791,233927,242207,250631,259199,267911,276767,285767,294911,304199,313631,323207,332927,342791,352799,362951,373247,383687,394271,404999,415871,426887,438047 add $0,1 pow $0,2 mul $0,72 sub $0,1
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/modular4.adb
best08618/asylo
7
10322
<reponame>best08618/asylo -- { dg-do compile } -- { dg-options "-O" } with Modular4_Pkg; use Modular4_Pkg; procedure Modular4 is begin for I in Zero .. F mod 8 loop raise Program_Error; end loop; end;
projects/batfish/src/main/antlr4/org/batfish/vendor/a10/grammar/A10_slb_template.g4
jeffkala/batfish
0
4890
<gh_stars>0 parser grammar A10_slb_template; import A10_common; options { tokenVocab = A10Lexer; } ss_template: TEMPLATE ( sst_port ) ; sst_port: PORT name = template_name NEWLINE sstp_definition* ; sstp_definition: sstp_conn_limit ; sstp_conn_limit: CONN_LIMIT limit = connection_limit NEWLINE;
Appl/Games/Sokoban/sokobanScores.asm
steakknife/pcgeos
504
4093
<gh_stars>100-1000 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: sokoban FILE: sokobanScores.asm AUTHOR: <NAME>, Jun 15, 1993 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/15/93 Initial revision DESCRIPTION: $Id: sokobanScores.asm,v 1.1 97/04/04 15:12:56 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ScoreCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UpdateScoreList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Attempt to add the user's score to the HS list. CALLED BY: SokobanDetachUIFromDocument PASS: ds = dgroup RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UpdateScoreList proc far uses ax,bx,cx,dx,si,di,bp,es .enter ; ; Make a data block to hold stats string. ; mov ax, STAT_STRING_LENGTH mov cx, (mask HAF_ZERO_INIT shl 8) or ALLOC_DYNAMIC_LOCK call MemAlloc ; bx = handle, ax = segment ; ; Convert level to ascii. ; mov es, ax clr di, cx, dx ; ptr, flags, high word of score mov ax, ds:[scoreLevel] call UtilHex32ToAscii ; cx = length add di, cx ; move to end ; ; Put in a "/" character. ; mov ax, C_SLASH LocalPutChar esdi, ax ; ; Convert the moves to ascii. ; mov ax, ds:[scoreMoves] clr cx ; flags call UtilHex32ToAscii ; cx = length add di, cx ; move to end ; ; Put in a "/" character. ; mov ax, C_SLASH LocalPutChar esdi, ax ; ; Convert the pushes to ascii and null-terminate the string ; mov cx, mask UHTAF_NULL_TERMINATE mov ax, ds:[scorePushes] call UtilHex32ToAscii call MemUnlock mov bp, bx ; ; Send their score to the controller. dx is still zero. ; call ConvertStatsToScore ; dx:cx = score GetResourceHandleNS SokobanHighScoreControl, bx mov si, offset SokobanHighScoreControl mov di, mask MF_CALL mov ax, MSG_HIGH_SCORE_ADD_SCORE call ObjMessage ; ; If the score was added (carry set), act accordingly. ; jnc done call CongratulateUser done: .leave ret UpdateScoreList endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ConvertStatsToScore %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Compute a score based on the user's level, moves & pushes. CALLED BY: UpdateScoreList PASS: ds = dgroup RETURN: dx:cx = dword-sized score DESTROYED: nothing PSEUDO CODE/STRATEGY: The algorithm I'm using is: Score = 10,000 * level + 10,000 * (1 - .9(moves/8192)) + 1,000 * (1 - pushes/4096) Thus: - each level is worth 10,000 - moves are worth between 1,000 and 10,000 (moves are truncated to 8192, just for the hell of it) - pushes are worth between 0 and 1,000, with any pushes over 4096 not mattering (it's still 0 points). This is a pretty easy algorithm to calculate, and the weights are about right: higher level always overrides lower level regardless of moves and pushes, and lower moves *almost* always overriding higher moves, except in a few bizarre cases where the number of pushes is vastly different). A slightly better algorithm, which would achieve a better distribution of points over the ranges (1-10k for moves, 0-1k for pushes) would be: Score = 10,000 * level + 10,000 * (1 - sin(pi * moves/8192)) + 1,000 * (1 - sin(pi * pushes/4096)) This calculation takes advantage of the fact that the sine function is changing very rapidly over values close to zero, and less rapidly over values close to pi. Since the average level will have between ~200 and ~1500 moves, representing the bottom of the 0-8192 range, the fraction of the total score determined by moves will vary between 5,000-10,000, instead of (say) 9,000-10,000. REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ConvertStatsToScore proc near uses ax,bx .enter ; ; Calculate the level portion of the score. ; mov ax, ds:[scoreLevel] ; ax = level mov dx, BASE_LEVEL_SCORE_FACTOR ; score per level mul dx ; dx.ax = level score movdw bxcx, dxax ; cx.dx = total ; ; Calculate the moves portion of the score. First truncate ; the moves to 8192 if necessary. ; mov ax, ds:[scoreMoves] cmp ax, MAX_SIGNIFICANT_MOVES ; moves above this jbe movesOK ; don't affect scoring mov ax, MAX_SIGNIFICANT_MOVES movesOK: mov dx, EXTRA_MOVES_SCORE_FACTOR ; the ".9" above mul dx ; dx.ax = 9000*moves ; ; Shift the quantity in dxax right 13 bits (52 cycles, not ; counting prefetch queue, which probably kills us). ; shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax ; ax = 9000*moves/8192 mov dx, BASE_MOVES_SCORE_FACTOR ; max poss. moves score sub dx, ax ; dx = moves score mov_tr ax, dx ; ax = moves score clr dx ; dx.ax = moves score ; ; Add the moves & level scores. ; adddw bxcx, dxax ; ; Compute the pushes score, first truncating pushes to 4096. ; mov ax, ds:[scorePushes] cmp ax, MAX_SIGNIFICANT_PUSHES jbe pushesOK mov ax, MAX_SIGNIFICANT_PUSHES pushesOK: mov dx, BASE_PUSHES_SCORE_FACTOR mul dx ; dx.ax = 1000*pushes ; ; Shift dxax right 12 bits (dividing by 4096). ; shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax shrdw dxax ; ax = 1000*pushes/4096 mov dx, BASE_PUSHES_SCORE_FACTOR sub dx, ax ; dx = pushes score mov_tr ax, dx ; ax = pushes score clr dx ; dx.ax = pushes score ; ; Add in the pushes score to the total. ; adddw bxcx, dxax ; bxcx = score mov dx, bx ; dxcx = score (return) .leave ret ConvertStatsToScore endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SokobanHighScoreGetName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the user's name from the map block. CALLED BY: MSG_HIGH_SCORE_GET_NAME PASS: *ds:si = SokobanHighScoreClass object ds:di = SokobanHighScoreClass instance data es = dgroup dx:bp = ptr to buffer to hold MAX_USER_NAME_SIZE characters plus one null RETURN: cx = string length, not counting null DESTROYED: ax, dx, bp PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SokobanHighScoreGetName method dynamic SokobanHighScoreClass, MSG_HIGH_SCORE_GET_NAME .enter ; ; Get the name and copy it to the passed buffer. ; pushdw dxbp ; save passed buffer mov bx, es:[vmFileHandle] ; game vm file call VMGetMapBlock ; ax = map block call VMLock ; ax = segment mov ds, ax mov si, offset SMB_name ; ds:si = source segmov es, ds, ax mov di, si call LocalStringLength ; cx = length w/o null mov ax, cx inc cx ; include NULL popdw esdi ; es:di = dest buffer rep movsb call VMUnlock mov_tr cx, ax ; return length .leave ret SokobanHighScoreGetName endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CongratulateUser %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Put up a dialog and play a song. CALLED BY: SokobanHighScoreGetName PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CongratulateUser proc near uses ax,bx,cx,si,es .enter ; ; Start the song a-playin'. ; GetResourceSegmentNS dgroup, es mov cx, SS_HIGH_SCORE call SoundPlaySound ; ; Put up the dialog. ; GetResourceHandleNS CongratsDialog, bx mov si, offset CongratsDialog call UserDoDialog .leave ret CongratulateUser endp ScoreCode ends
base/mvdm/dos/v86/dev/himem/himem.asm
npocmaka/Windows-Server-2003
17
84981
<gh_stars>10-100 ;/* himem.asm ; * ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1988-1991 ; * All Rights Reserved. ; * ; * Modification History ; * ; * Sudeepb 14-May-1991 Ported for NT XMS support ; * ; * williamh 25-Sept-1992 Added RequestUMB and ReleaseUMB ; */ page 95,160 title 'HIMEM.SYS - Microsoft XMS Device Driver' ;***************************************************************************** ;* * ;* HIMEM.ASM - * ;* * ;* Extended Memory Specification Driver - * ;* * ;***************************************************************************** ; ; himem.inc - global equates, macros, structures, opening segment ; himem.asm - main driver entry, interrupt hooks, a20/HMA functions ; himem1.asm - a20 switching code ; himem2.asm - driver initialization ; himem3.asm - messages for driver initialization ; himem4.asm - extended memory allocation functions ; himem5.asm - memory move function ; ; for revision history prior to 1990, see version 2.37 or earlier ; ; 2.35 - Removed a few push/pops from IsA20On, misc 01/14/90 ; source code reformatting ; 2.36 - Include Int 6Dh vector in shadow RAM disable 01/18/90 ; check, also allow disable if video Ints already ; point at C000h segment. Also added some CLD's near ; string instructions. ; 2.37 - Removed 2.33 'fix' for All Chargecard. They 01/23/89 ; now do Global and Local enables to turn on A20, and ; the previous 'fix' caused us to never didle A20 again ; after running Windows real mode twice (Windows does ; Global enables/disables too). Also, GetParms needed to ; check for LF in addition to CR for end of line. ;; ;;; Following changes synced from \402\dev\himem tree ;; ; 2.50 - Revised version # for Windows 3.0 release. 02/05/90 ; "" - Ignore 'super'-extended memory on EISA memory 02/08/90 ; memory boards (mem > 16 meg). Software that ; uses 24 bit (80286) descriptors doesn't do ; well with memory @ 16 meg. ; "" - Himem will now try to control A20 by default, 02/12/90 ; even if A20 is already enabled when himem is ; loaded. Added /A20CONTROL: ON | OFF switch to ; override this if necessary (ON is default and ; means we take control, OFF means we take control ; unless A20 was already on, in which case we ; don't mess with it). ; ; 2.60 - Added special A20 routine for Toshiba 1600 02/22/90 ; laptop, and revised driver version number to ; be later than Compaq's (2.50) so Windows ; setup will install ours. ; "" - Clear bit 15 in device attributes word of 02/28/90 ; device header if driver is being flushed. The ; MS-DOS Encylopedia says to do this, and a ; system with DOS 3.21 was hanging when loading ; the driver after himem if himem flushed itself. ; "" - Added special A20 handler for Wyse 12.5 MHz 03/27/90 ; 286 machine. Almost the same as AT, but ; a little different. ; "" - Now displays a msg indicating which A20 04/05/90 ; handler is installed, and allows numbers for the ; /MACHINE: parameter. ;; ;;; End of \402\dev\himem changes ;; ; ; "" - Added /INT15=xxxx option to reserve xxxxK of 04/13/90 ; extended memory for INT 15. Himem will reserve xxxx K ; (64 K of HMA inclusive) for apps which use Ext Mem thru ; int 15 interface. The HMA portion of the INT 15 ext memory ; should be protected by a VDISK header. Apps which ; do not recognize VDISK headers may destroy the HMA. ; ; "" - When there is a /INT15=xxxx option on the 04/20/90 ; command line, the HMA is made unavailable to the ; apps. But DOS 5.0 goes ahead and checks for INT 15 ; memory if the alloc HMA call fails. And if INT 15 memory ; is present it uses the first 64 K for loading itself ; high (simulated HMA) ; ; "" - ORGed the movable segment to high value for flexibility ; in loading into HMA. Added code to be flexible enough to ; run from HMA as well as low memory. public Interrupt public dd_int_loc public fHMAExists public PrevInt15 public fA20Check public OldStackSeg public pPPFIRET public EnableCount public pReqHdr public MinHMASize public Int2fHandler public fHMAMayExist public MemCorr public PrevInt2f public MoveIt public fCanChangeA20 ifndef NEC_98 public IsVDISKIn public fVDISK endif ;NEC_98 public LocalEnableA20 public LocalDisableA20 public FLclEnblA20 public FLclDsblA20 public xLocalEnableA20 public xLocalDisableA20 public IsA20On public winbug_fix ifndef NEC_98 public ATA20Delay else ;NEC_98 public fAltA20Routine endif ;NEC_98 public AddMem public TopOfTextSeg public A20State public Int15Handler ; Define a direct call to the Phoenix Cascade BIOS for A20 handling ; Note: if these segments are not defined here, the Int13Handler ; definition in segment Zero in the 386 memory move will generate ; bad code. PTL_Seg segment at 0f000h PTL_Seg ends BiosSeg SEGMENT AT 40h ; Used to locate 6300 PLUS reset address BiosSeg ends include himem.inc ; define structures, macros, open seg. include xmssvc.inc include vint.inc extrn EndText:byte _text ends funky segment para public 'funky' assume cs:funky ; externals from himem4 extrn Version:near extrn MoveBlock:near extrn QueryExtMemory:near extrn AllocExtMemory:near extrn FreeExtMemory:near extrn LockExtMemory:near extrn UnlockExtMemory:near extrn GetExtMemoryInfo:near extrn ReallocExtMemory:near extrn RequestUMB:near extrn ReleaseUMB:near extrn cHandles:word extrn KiddValley:word ; externals from himem5 funky ends ; ;------ the following segment should be the last in the sys file ; This segment is read by the stripdd utility to remove ; the zeroes introduced by the hi ORG in the movable segment ZZZ segment para 'ZZZ' dw 16 ; len of this segment dw offset _text:EndText ; len of text seg in double word dw 0 dw HISEG_ORG ; number of zeroes to be stripped dw -1 dw -1 ; terminator db (4) dup (55h) ; filler ZZZ ends _text segment word public 'code' assume cs:_text ; externals from himem1 extrn A20Handler:near ; externals from himem2 extrn InitInterrupt:near public DevAttr public Int15MemSize public fInHMA ; The Driver Header definition. Header dd -1 ; Link to next driver, -1 = end of list DevAttr dw 1010000000000000b ; Char device & Output until busy(?) dw Strategy ; "Stategy" entry point dd_int_loc dw InitInterrupt ; "Interrupt" entry point db 'XMSXXXX0' ; Device name ;************************************************************************ ;* * ;* Global Variables * ;* * ;************************************************************************ if keep_cs callers_cs dw 0 endif TopOfTextSeg dw 0 ; size of retained driver pPPFIRet dw PPFIRet ; The offset of an IRET for the POPFF macro pReqHdr dd ? ; Pointer to MSDOS Request Header structure ifndef NEC_98 pInt15Vector dw 15h*4,0 ; Pointer to the INT 15 Vector else ;NEC_98 pInt15Vector dw 1fh*4,0 ; Pointer to the INT 15 Vector endif ;NEC_98 PrevInt15 dd 0 ; Original INT 15 Vector PrevInt2f dd 0 ; Original INT 2f Vector ifdef NEC_98 pInt220Vector dw 0dch*4,0; Pointer to the INT 220 Vector PrevInt220 dd 0 ; Original INT 220 Vector pInt20Vector dw 20h*4,0 ; Pointer to the INT 20 Vector PrevInt20 dd 0 ; Original INT 20 Vector pInt21Vector dw 21h*4,0 ; Pointer to the INT 21 Vector PrevInt21 dd 0 ; Original INT 21 Vector endif ;NEC_98 fHMAInUse db 0 ; High Memory Control Flag, != 0 -> In Use fCanChangeA20 db 1 ; A20 Enabled at start? (assume changable) fHMAMayExist db 0 ; True if the HMA could exist at init time fHMAExists db 0 ; True if the HMA exists fInstalled db 0 ; True if ext mem has been allocated fInHMA db 0 ; true if hiseg is in HMA fVDISK db 0 ; True if a VDISK device was found fA20Check db 0 ; True if A20 handler supports On/Off check ifndef NEC_98 ATA20Delay db 0 ; Type of AT A20 delay in use (0 - NUM_ALT_A20) else ;NEC_98 fAltA20Routine db 0 ; True if alternative A20 routine in use endif ;NEC_98 EnableCount dw 0 ; A20 Enable/Disable counter fGlobalEnable dw 0 ; Global A20 Enable/Disable flag MinHMASize dw 0 ; /HMAMIN= parameter value Int15MemSize dw 0 ; Memory size reserved for INT 15 MemCorr dw 0 ; KB of memory at FA0000 on AT&T 6300 Plus. ; This is used to correct INT 15h, ; Function 88h return value. OldStackSeg dw 0 ; Stack segment save area for 6300 Plus. ; Needed during processor reset. ifndef NEC_98 if NUM_A20_RETRIES A20Retries db 0 ; Count of retires remaining on A20 diddling endif else ;NEC_98 I2fCheckNH_Tbl dd 0 ; Old Pointer (ES:BX) for Windows ins NEC <91.09.27> db 3,0 ; version db 01h ; type for instance is INT Vector db 0 ; R.F.U dw offset _text:PrevInt15 ; offset I2f_seg dw 0 ; dw 4 ; dw 1fh ; dd -1 ; endif ;NEC_98 A20State db 0 ; recored the current A20 state ifndef NEC_98 public lpExtA20Handler lpExtA20Handler dd 0 ; Far entry point to an external A20 handler endif ;NEC_98 ;*----------------------------------------------------------------------* ;* * ;* Strategy - * ;* * ;* Called by MS-DOS when ever the driver is accessed. * ;* * ;* ARGS: ES:BX = Address of Request Header * ;* RETS: Nothing * ;* REGS: Preserved * ;* * ;*----------------------------------------------------------------------* Strategy proc far assume ds:nothing ; Save the address of the request header. mov word ptr [pReqHdr],bx mov word ptr [pReqHdr][2],es ret Strategy endp ;*----------------------------------------------------------------------* ;* * ;* Interrupt - * ;* * ;* Called by MS-DOS immediately after Strategy routine * ;* * ;* ARGS: None * ;* RETS: Return code in Request Header's Status field * ;* REGS: Preserved * ;* * ;* This is our permanent entry point. By this time, the only * ;* useful function done by the device driver (initializing us) * ;* has been done by a previous call. There are no more valid * ;* uses for this entry point. All we have to do is decide * ;* whether to ignore the call or generate an error. * ;* * ;*----------------------------------------------------------------------* Interrupt proc far assume ds:nothing push bx ; save minimal register set push ds lds bx,[pReqHdr] ; ds:bx = Request Header cmp ds:[bx].Command,16 ; legal DOS function? (approx???) mov ds:[bx].Status,100h ; "Done" for healthy calls jbe FuncOk or ds:[bx].Status,8003h ; Return "Unknown Command" error FuncOk: pop ds pop bx ret Interrupt endp ;*----------------------------------------------------------------------* ;* * ;* Int2fHandler - * ;* * ;* Hooks Function 43h, Subfunction 10h to return the * ;* address of the High Memory Manager Control function. * ;* Also returns 80h if Function 43h, Subfunction 0h is requested. * ;* * ;* ARGS: AH = Function, AL = Subfunction * ;* RETS: ES:BX = Address of XMMControl function (if AX=4310h) * ;* AL = 80h (if AX=4300) * ;* REGS: Preserved except for ES:BX (if AX=4310h) * ;* Preserved except for AL (if AX=4300h) * ;* * ;*----------------------------------------------------------------------* Int2fHandler proc far assume ds:nothing call DOSTI ; Flush any queued interrupts cmp ah,43h ; Function 43h? ifndef NEC_98 jne I2fNextInt else ;NEC_98 jne I2fChk_NH ; check for Windows 3.0 function INS NEC <91.09.27> endif ;NEC_98 or al,al ; Subfunction 0? jne I2fNextSub ; No, continue mov al,80h ; Return 80h in AL (XMS Installed) PPFIRet: jmp DOIRET ; Label sets up the POPFF macro I2fNextSub: cmp al,10h ; Subfunction 10? jne I2fNextInt ; No, goto next handler push cs ; return XMS entry in es:bx pop es mov bx,offset XMMControl jmp DOIRET ; Continue down the Int 2f chain. I2fNextInt: call DOCLI ; Disable interrupts again jmp [PrevInt2f] ifdef NEC_98 ; check N/H depend data for Windows 3.0 ;INS NEC <91.09.27> I2fChk_NH: ; check N/H depended data cmp ax,167fh jne I2fNextInt ; No, goto next handler cmp dx,0 ; check sub function jne I2fNextInt ; No, goto next handler mov word ptr [I2fCheckNH_Tbl], bx ; offset mov bx,es ; mov word ptr [I2fCheckNH_Tbl+2],bx ; segment mov bx,cs ; mov [I2f_Seg],bx ; push cs ; pop es ; mov bx,offset I2fCheckNH_Tbl ; jmp I2fNextInt ; goto next handler endif ;NEC_98 Int2fHandler endp ;*----------------------------------------------------------------------* ;* * ;* ControlJumpTable - * ;* * ;* Contains the address for each of the XMS Functions. * ;* * ;* **************** WARNING ********************** * ;* * ;* Assumes that offsets of functions in lo mem seg are < 8000h * ;* & that offsets of segment in Hiseg are >= 8000h * ;* * ;*----------------------------------------------------------------------* ControlJumpTable label word dw Version ; Function 00h dw RequestHMA ; Function 01h dw ReleaseHMA ; Function 02h dw GlobalEnableA20 ; Function 03h dw GlobalDisableA20 ; Function 04h xLocalEnableA20 dw LocalEnableA20 ; Function 05h xLocalDisableA20 dw LocalDisableA20 ; Function 06h dw IsA20On ; Function 07h dw QueryExtMemory ; Function 08h dw AllocExtMemory ; Function 09h FreeMem dw FreeExtMemory ; Function 0Ah MoveIt dw MoveBlock ; Function 0Bh dw LockExtMemory ; Function 0Ch dw UnlockExtMemory ; Function 0Dh dw GetExtMemoryInfo ; Function 0Eh dw ReallocExtMemory ; Function 0Fh dw RequestUMB ; Function 10h dw ReleaseUMB ; Function 11h NumFns = ((offset $) - (offset ControlJumpTable))/2 ;*----------------------------------------------------------------------* ;* * ;* XMMControl - * ;* * ;* Main Entry point for the Extended Memory Manager * ;* * ;* ARGS: AH = Function, AL = Optional parm * ;* RETS: AX = Function Success Code, BL = Optional Error Code * ;* REGS: AX, BX, DX and ES may not be preserved depending on func. * ;* * ;* INTERNALLY REENTRANT * ;* * ;*----------------------------------------------------------------------* XMMControl proc far jmp short XCControlEntry ; For "hookability" nop ; NOTE: The jump must be a nop ; short jump to indicate nop ; the end of any hook chain. ; The nop's allow a far jump ; to be patched in. XCControlEntry: if keep_cs ;-------------------------------------------------------- push bp mov bp,sp mov bp,4[bp] ; get caller's cs mov callers_cs,bp ; (debug only) pop bp endif ;-------------------------------------------------------- push cx ; preserve some registers push si push di push ds push es pushf cld push ds ; save ds in es pop es ; NOTE: ES cannot be used for parms! push cs ; ds=cs pop ds assume ds:_text push ax ; save the function number if debug_vers call debug_dump endif or ah,ah ; GetXMSVersion? jz XCCallFunc ; Yes, don't hook INT 15h yet cmp ah,NumFns ; valid function number?? jb XCCheckHook pop ax ; No, Un-preserve AX and return an error xor ax,ax mov bl,ERR_NOTIMPLEMENTED jmp short XCExit XCCheckHook: pushf ; Is INT 15h already hooked? call DOCLI ; This is a critical section cmp word ptr [PrevInt15][2],0 ; Is the segment non-zero? jne XCCheckVD push dx ; save callers DX call HookInt15 ; claim all remaining ext mem pop dx ifdef NEC_98 call HookInt220 ; start emulating Int220 endif ;NEC_98 XCCheckVD: popff ; End of critical section ifndef NEC_98 cmp [fVDISK],0 ; was VDISK found? je XCCallFunc pop ax ; Yes, Un-preserve AX and return error xor ax,ax mov bl,ERR_VDISKFOUND xor dx,dx jmp short XCExit endif ;NEC_98 ; Call the appropriate API function. XCCallFunc: pop ax ; Restore AX push ax ; save ax so functions get both ah & al mov al,ah xor ah,ah shl ax,1 mov di,ax ; NOTE: DI cannot be used for parms! pop ax ; restore callers ax for function mov di,ControlJumpTable[di] ; get function address ifndef NEC_98 or di,di jns CallLowSegFn ; brif it's in the low segment else ;NEC_98 cmp di,HISEG_ORG jb CallLowSegFn ; brif it's in the low segment endif ;NEC_98 cmp fInHMA, 0 ; is the hiseg in HMA ? jz InLoMem ; ;------ Turn on the A20 line if it is off ; push si push di push ax push bx push cx call LocalEnableA20 ; Note: This is always necessary cmp ax, 1 pop cx ; for the Memory Move function. In pop bx ; the case where this driver loads pop ax ; high, it is necessary for all calls pop di ; to the high segment. pop si jne a20_error InLoMem: push cs ; set up far return call call_hi_in_di ; and call the function cmp fInHMA, 0 ; is the hiseg in HMA ? jz XCExit push ax ; save the registers which may be push bx ; returning values call LocalDisableA20 ; and restore a20 cmp ax, 1 pop bx pop ax je short XCExit a20_error: xor ax, ax xor dx, dx mov bl, ERR_A20 jmp short XCExit CallLowSegFn: call di ; call routine in this segment XCExit: ; if debug_vers or tdump ;------------------------------------ ; pusha ; call dump_tables ; popa ; endif ;------------------------------------------------------ popff ; NOTE: Flags must be restored pop es ; immedately after call API functions. pop ds pop di pop si pop cx ; if debug_vers ;--------------------------------------------------- ; pushf ; pusha ; mov al,'.' ; call cofa ; mov al,cs:byte ptr fun_number ; sub al,0bh ; don't get key on 0bh, 0ch or 0dh ; cmp al,2 ; jbe no_keywait ; mov ah,1 ; wait for console key now!!!!!! ;; int 21h ;no_keywait: ; popa ; popf ; endif ;------------------------------------------------------ ret XMMControl endp if tdump or debug_vers ;------------------------------------ fun_number db 0 ; function number for debug info dump_tables: if not tdump cmp fun_number,9 ; only display on allocate calls jnz dd_done ; unless full tdump is enabled endif mov dx,offset heading mov ah,9 int 21h push es mov es,hiseg assume es:funky mov si,[KiddValley] mov cx,[cHandles] mov bx,SIZE Handle xlup: mov al,[si].Flags ; get flags cmp al,4 ; don't show UNUSED entries jz x_entry_done mov dx,offset msg_FREE cmp al,1 ; free? jz x_showflags mov dx,offset msg_USED cmp al,2 ; used? jz x_showflags mov dx,offset msg_BAD x_showflags: mov ah,9 int 21h mov al,[si].cLock ; get lock count call hex_byte call space mov ax,[si].Base ; get base call hex_word call space mov ax,[si].Len ; get length call hex_word if keep_cs call space mov ax,[si].Acs ; get the allocator's cs: call hex_word endif x_newline: mov al,13 call cofa mov al,10 call cofa x_entry_done: add si,bx loop xlup pop es assume es:nothing mov dx,offset donemsg mov ah,9 int 21h dd_done: ret heading db 'Flags Lock Base Len CS:',13,10,'$' msg_FREE db 'FREE $' msg_USED db 'USED $' msg_BAD db 'BAD $' donemsg db 'End of XMS table$' endif if debug_vers debug_dump proc near pusha mov fun_number,ah ; save (non-reentrantly!) function number ; ; so that we can display different debug ; ; information on exit depending on which ; ; function we've been doing mov al,ah ; just display function number call hex_nib popa ret if 0 ; enable this if you want to see the ; ; command block for memory moves cmp ah,0bh ; memory move? jnz debug_dump_done ; done if not pusha call crlf mov ax,es:2[si] ; get count-hi call hex_word mov ax,es:[si] ; get count-low call hex_word add si,4 ; point to source address field mov cx,2 ; now display two handle/addresses dd1: call space lods es:word ptr [si] ; get a handle call hex_word mov al,'-' call cofa mov ax,es:2[si] ; get high address call hex_word mov al,':' call cofa lods es:word ptr [si] ; get low address call hex_word add si,2 ; skip to next entry for loop loop dd1 popa debug_dump_done: endif ret debug_dump endp endif if debug_vers or tdump ifdef NEC_98 RowCol dw 1700H ; ins NEC <90.07.11> Y.Ueno endif ;NEC_98 hex_word: push ax mov al,ah call hex_byte pop ax hex_byte: push ax shr ax,4 ; XMS present implies '286 or better call hex_nib pop ax hex_nib: and al,0fh add al,90h daa adc al,3ah daa cofa: ; mov dl,al ; mov ah,2 ; int 21h ifndef NEC_98 mov ah,0eh mov bx,7 int 10h ret else ;NEC_98 ;======================CHG NEC <90.07.11> Y.Ueno ============================= push bx ; save callers regs push cx push dx push si push di push es push ds push dx ; save this segment for later mov ds, dx ; DS -> data segment mov dx, ds:[RowCol] ; DX = current row/col cmp al, CR ; is character a CR? jne short kp1 mov dl, 0 ; yes, go to column 0 jmp short kp3 ; jump to common code kp1: cmp al, LF ; is character a LF? jne short kp2 inc dh ; yes, go to next row jmp short kp3 ; jump to common code kp2: cmp al, TAB ; is it a tab jne short kp12 and dl, 0f8h ; mask off low 3 bits (8 ch) add dl, 8 ; move to next tab position jmp short kp3 ; jmp to common code kp12: cmp al, BS ; is it backspace jne short kp13 dec dl ; back up one column jmp short kp3 ; goto common code kp13: ; Must be ordinary character. Write it to screen, update position ;@@@ XOR AH,AH ; push ax ; save char/attr mov al, dh ; AL = row mov ah, 80 ; multiplier, 80 char per row mul ah ; AX = cell at start of row mov bh, 0 mov bl, dl ; BX = column add bx, ax ; BX = cell shl bx, 1 ; BX = byte offset of cell mov ax, 0a000h ; screen para for real mode mov es, ax ; ES -> screen pop es:[bx] ; write character inc dl ; update column kp3: ; Common code, first check for line wrap: cmp dl, 80 ; beyond rhs of screen? jl short kp4 mov dl, 0 ; go to col 0 inc dh ; and move to next line kp4: ; Now check for scroll needed: cmp dh, 24 ; are we off end of screen? jl short kp5 ; Now scroll screen mov ax, 0a000h ; screen para for real mode mov ds, ax ; DS -> screen mov es, ax ; ES -> screen mov di, 0 ; ES:DI = copy destination mov si, 160 ; DS:SI = copy source mov cx, 2000-160 ; copy word count cld rep movsw ; scroll ; Blank bottom line mov al, ' ' ;@@@ mov ah, 0 ; AX = blank character mov cx, 80 ; number of cells to blank mov di, 4000-320 ; ES:DI = start point rep stosw ; Update position mov dh, 23 ; new row kp5: pop ds ; set DS to data again mov ds:[RowCol], dx ; update row/col ;@@@ call SetCursor pop ds ; restore regs pop es pop di pop si pop dx pop cx pop bx ret ;*** SetCursor - updates cursor position ; ; This routine reprograms the 6845 cursor position, and ; stores the new cursor position in the ROM bios data area. ; ; ENTRY DUAL MODE ; DH, DL = row, col ; ; EXIT cursor updated ; ; USES ax, bx, cx, flags ; CRT_COLS equ 04ah CURSOR_POSN equ 050h CRT_START equ 04eh ADDR_6845 equ 063h push ds mov bx, 40h mov ds, bx ; Save new position in BIOS data area mov ds:[CURSOR_POSN], dx ; Calculate offset on screen mov al, dh ; row ; mul byte ptr ds:[CRT_COLS] ; row * cols MOV AH,80 mul AH ; row * cols mov bl, dl ; bl = column mov bh, 0 ; bx = column add ax, bx ; ax = offset in screen sal ax, 1 ; double for attribute bytes ; mov cx, ds:[CRT_START] ; cx = start point of screen mov cx, 0h ; cx = start point of screen ADD AX,CX MOV DX,AX ; sar cx, 1 ; convert to char count only ; Now program 6845 mov al,49h JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 OUT 62H,AL MOV AX,DX SHR AX,1 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 OUT 60H,AL MOV AL,AH JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 JMP SHORT $+2 OUT 60H,AL POP DS RET ;============================================================================= endif ;NEC_98 space: mov al,' ' jmp cofa crlf: mov al,13 call cofa mov al,10 jmp cofa endif ;------------------------------------------------------ ; little utility stub for calling routine in the other segment. ; called with the branch offset address in di ; a far return address is already on the stack. Now branch to ; hiseg:(di) public hiseg ; allow initialization code to relocate hiseg hiseg dw funky public call_hi_in_di call_hi_in_di proc near push hiseg push di call_hi_in_di endp call_hi_far proc far ret call_hi_far endp ;*----------------------------------------------------------------------* ;* * ;* HookInt15 - * ;* * ;* Insert the INT 15 hook * ;* * ;* ARGS: None * ;* RETS: None * ;* REGS: AX, BX, CX, DX, DI, SI, and Flags are clobbered * ;* * ;* EXTERNALLY NON-REENTRANT * ;* Interrupts must be disabled before calling this function. * ;* * ;*----------------------------------------------------------------------* HookInt15 proc near push es ifndef NEC_98 call IsVDISKIn ; has a VDISK been installed? cmp [fVDISK],0 je HINoVD ; No, continue pop es ; Yes, return without hooking ret HINoVD: ; notify softpc of hooking I15 mov ax,offset Int15Handler ; args: cs:di new I15 vector XMSSVC XMS_NOTIFYHOOKI15 ; returns CX=ExtMem in K ; Save the curr INT 15 vector, and put ours in the IVT les si,dword ptr pInt15Vector xchg ax,es:[si][0] mov word ptr [PrevInt15][0],ax mov ax,cs xchg ax,es:[si][2] mov word ptr [PrevInt15][2],ax mov ax, cx cmp ax,15*1024 ; Limit himem.sys to using 15 meg jb @f ; of extended memory for apps mov ax,15*1024 ; that don't deal with > 24 bit @@: ; addresses sub ax,[MemCorr] ; 6300 Plus may have memory at FA0000h else ;NEC_98 ;====================== chg NEC <90.07.11> Y.Ueno ====================== push es mov ax,40h mov es,ax sub ah,ah mov al,byte ptr es:[0001] ; get extend memory size shl ax,7 ; convert to k byte size pop es endif ;NEC_98 cmp ax,64 jb HIInitMemory ; Less than 64K free? Then no HMA. cmp Int15MemSize, 0 ; are we supporting int 15 memory jnz HIInitMemory ; then we dont support HMA mov [fHMAExists],1 HIInitMemory: ; Init the first handle to be one huge free block. ifndef NEC_98 or ax, ax ; don't do it if no Int 15 memory avail jz HISkipInit endif ;NEC_98 mov cx,1024 ; base is just above 1 meg xor bx, bx ; assume no HMA cmp [fHMAExists],0 ; Reserve room for HMA if it exists je @f mov bx, 64 @@: cmp bx, Int15MemSize jae @f mov bx, Int15MemSize @@: add cx,bx sub ax,bx ifdef NEC_98 push es push ax mov ax, 40h mov es, ax pop ax push ax add ax,127 ; set 128k boundly shr ax,7 sub byte ptr es:[0001h],al pop ax pop es endif ;NEC_98 call AddMem ; add that to memory table ifndef NEC_98 HISkipInit: else ;NEC_98 ; Save the current INT 15 vector. les si,dword ptr pInt15Vector ; Exchange the old vector with the new one. mov ax,offset Int15Handler xchg ax,es:[si][0] mov word ptr [PrevInt15][0],ax mov ax,cs xchg ax,es:[si][2] mov word ptr [PrevInt15][2],ax endif ;NEC_98 pop es ret HookInt15 endp ifndef NEC_98 ;*----------------------------------------------------------------------* ;* * ;* IsVDISKIn - * ;* * ;* Looks for drivers which use the IBM VDISK method of allocating * ;* Extended Memory. XMS is incompatible with the VDISK method. It is * ;* necessary to check two different locations since some programs only * ;* one or the other, although they should do both. * ;* * ;* ARGS: None * ;* RETS: None. Sets "fVDISK" accordingly * ;* REGS: AX, BX, CX, SI, DI and Flags are clobbered * ;* * ;* INTERNALLY REENTRANT * ;* * ;*----------------------------------------------------------------------* pVDISK label dword dw 00013h dw 0FFFFh szVDISK db 'VDISK' IsVDISKIn proc near ; Look for "VDISK" signature at offset 12h in Int 19h segment push es xor ax,ax mov es,ax mov es,es:[(19h * 4)+2] mov di,12h mov si,offset szVDISK mov cx,5 cld repz cmpsb pop es jz IVIFoundIt ; Look for "VDISK" starting at the 4th byte of extended memory. call LocalEnableA20 ; Turn on A20 push es les di,cs:pVDISK ; set up the comparison mov si,offset szVDISK mov cx,5 cld repz cmpsb ; Do the comparison pop es pushf call LocalDisableA20 popff jz IVIFoundIt mov [fVDISK],0 ; No VDISK device found ret IVIFoundIt: mov [fVDISK],1 ; "VDISK" was found ret IsVDISKIn endp endif ;NEC_98 ;*----------------------------------------------------------------------* ;* * ;* Int15Handler - * ;* * ;* Hooks Function 88h to return zero as the amount of extended * ;* memory available in the system. * ;* * ;* Hooks Function 87h and preserves the state of A20 across the * ;* block move. * ;* * ;* ARGS: AH = Function, AL = Subfunction * ;* RETS: AX = 0 (if AH == 88h) * ;* REGS: AX is clobbered * ;* * ;*----------------------------------------------------------------------* ifdef NEC_98 I15RegSave dw ? endif ;NEC_98 Int15Handler proc far ifndef NEC_98 cmp ah,88h ; request == report free ext mem? je I15ExtMem cmp ah,87h ; Block move? je I15BlkMov jmp cs:[PrevInt15] ; continue down the int 15h chain I15ExtMem: mov ax, cs:Int15MemSize ; return 'free' Int 15h extended memory jmp DOIRET I15BlkMov: call DOCLI ; Make sure interrupts are off sub sp,4 ; Make space for A20 flag & flags word pusha ; Preserve the caller's registers call IsA20On ; Get current A20 state mov bp,sp ; Stk= [pusha] [fl] [a20] [ip] [cs] [fl] mov [bp+18],ax ; Save A20 state mov ax,[bp+24] ; Get caller's entry flags and save on mov [bp+16],ax ; stack, forms part of iret frame popa ; Restore the caller's registers ; Simulate an interrupt to lower level Int 15h handler. Note that ; the flags image is already on the stack from code above. The Int ; 15h handler may or may return with interrupts enabled. call cs:[PrevInt15] push ax ; Save returned AX pushf ; Save flags returned from lower level push bp ; Stack = mov bp,sp ; [bp] [fl] [ax] [a20] [ip] [cs] [fl] mov ax,[bp+2] ; Setup to pass lower level flags mov [bp+12],ax ; back to caller on iret cmp word ptr [bp+6],0 ; While we're here test old A20 state pop bp pop ax ; Discard flags pop ax ; Restore AX jz I15HExit ; A20 was off, don't mess with it call DOCLI ; A20 handlers called with ints off pusha ; Preserve previous handler's return mov ax,1 call A20Handler ; turn A20 back on popa ; Restore the previous handler's return I15HExit: add sp,2 ; 'pop' A20 state flag jmp DOIRET ; Uses flags from lower level handler else ;NEC_98 cmp ah,90h ; Is it a Block Move ? jne I15HNext ; No , continue call DOCLI ; Make sure interrupts are off pusha ; Preserve the registers mov al, 8 ; ins NEC <90.11.14> Y.Ueno out 37h, al ; " call IsA20On mov cs:[I15RegSave],ax ; store A20's state popa ; Restore the registers ; Call the previous Int 15h handler. pushf ; Simualate an interrupt call cs:[PrevInt15] pushf ; bug ? ins NEC <90.07.12> Y.Ueno pusha ; Preserve previous handler's return cmp cs:[I15RegSave],0 ; Restore A20 je I15HExit ; It was off, continue mov ax,1 call A20Handler ; turn A20 back on I15HExit: mov al, 09h ; ins NEC <90.11.14> Y.Ueno out 37h, al ; " popa ; Restore the previous handler's return popf ; bug ? chg NEC <90.07.12> Y.Ueno retf 2 ; " ;;; iret ; " I15HNext: jmp cs:[PrevInt15] ; continue down the int 15h chain endif ;NEC_98 Int15Handler endp ifdef NEC_98 ;*----------------------------------------------------------------------* ;* * ;* HookInt220 - * ;* * ;* Insert the INT 220 hook * ;* * ;* ARGS: None * ;* * ;* RETS: None * ;* * ;* REGS: AX, SI, and Flags are clobbered * ;* * ;* EXTERNALLY NON-REENTRANT * ;* Interrupts must be disabled before calling this function. * ;* * ;*----------------------------------------------------------------------* HookInt220 proc near push cx mov cl,81h xor ax,ax int 220 ; Get size of extended memory pop cx or ax,ax ; no extendec memory? jz HI220Exit ; don't hook Int220 ; Exchange the old vector with the new one. push es les si,dword ptr pInt220Vector ; ES:SI points Int220 vector mov ax,offset Int220Handler xchg ax,es:[si][0] mov word ptr [PrevInt220][0],ax mov ax,cs xchg ax,es:[si][2] mov word ptr [PrevInt220][2],ax pop es HI220Exit: ret HookInt220 endp ;*----------------------------------------------------------------------* ;* * ;* Int220Handler - * ;* * ;* Hooks Function 81h/82h and emulate it by twiddling EMB table * ;* * ;* ARGS: CL = Function, AX = Subfunction * ;* BX = Size of memory requested in 128k block, if function 81h* ;* * ;* RETS: Function 81h * ;* AX = 0 (if success) * ;* BX = Start addr * ;* DX = End addr * ;* * ;* AX = 01h (if fail) * ;* BX = size of available memory in blocks of 128k * ;* * ;* Function 82h * ;* AX = size of availabel memory in blocks of 128k * ;* BX = Start addr * ;* DX = End addr * ;* * ;* REGS: AX, BX, (DX) is clobbered * ;* * ;*----------------------------------------------------------------------* USER_DX equ 6 USER_BX equ 10 USER_AX equ 12 I220EmlTbl dw offset Eml_81 dw offset Eml_82 Int220Handler proc far cmp cl,81h ; Function 81h? jne I220HCmp82 ; cmp ax,0001h ; Sub function 01h? jne I220HNext ; jmp short I220HStart ; yes I220HCmp82: cmp cl,82h ; Function 82h? jne I220HNext ; cmp ax,0000h ; Subfunction 00Hh? jne I220HNext ; ; I220HStart: ; yes sti push es push ds push ax push bx push cx push dx push di push si push bp mov bp,sp mov dx,ss mov es,dx push cs pop ds mov si,offset I220EmlTbl sub cl,81h xor ch,ch shl cx,1 add si,cx call [si] ; call our Int 220 handler. pop bp pop si pop di pop dx pop cx pop bx pop ax pop ds pop es iret I220HNext: jmp cs:[PrevInt220] ; continue down the int 220 chain Int220Handler endp ;*----------------------------------------------------------------------* ;* * ;* EML_81 - * ;* * ;* Emulate Int220h Function 81h * ;* * ;* ARGS: Int 220 regs but DS, ES, BP, CX * ;* * ;* RETS: Values are set into AX, BX, DX on the stacks * ;* * ;* REGS: AX, BX, CX, DX, SI, DI and Flags are clobbered * ;* * ;*----------------------------------------------------------------------* EML_81 proc near push bx ; save size of memory requested mov ax,bx call GetInt220mem ; return available memory size in CX ; handle in DX, SI pop ax cmp cx,ax ; is there enough memory? jb E81Nomem ; no or ax,ax ; requested size = 0 ? jz E81ReqZero ; yes mov bx,dx ; ax:size,bx:free handle,si:unused handle call AllocInt220mem ; allocate memory for this Int 220 mov [bp].USER_BX,bx ; start addr mov [bp].USER_DX,dx ; ending addr mov word ptr [bp].USER_AX,0000h ; indicates sucsess jmp short E81Exit E81ReqZero: mov word ptr [bp].USER_BX,0010h ; start addr mov word ptr [bp].USER_DX,0010h ; ending addr mov word ptr [bp].USER_AX,0000h ; indicates sucsess jmp short E81Exit E81Nomem: mov [bp].USER_BX,cx ; size of abailable memories mov word ptr [bp].USER_AX,0001h ; indicate not enough memories E81Exit: ret EML_81 endp ;*----------------------------------------------------------------------* ;* * ;* EML_82 - * ;* * ;* Emulate Int220h Function 82h * ;* * ;* ARGS: Int 220 regs but DS, ES, BP, CX * ;* * ;* RETS: Values are set into AX, BX, DX on the stacks * ;* * ;* REGS: AX, BX, CX, DX, SI, DI and Flags are clobbered * ;* * ;*----------------------------------------------------------------------* OwnersPSP dw 0 ; OwnersHandle dw 0 ; EML_82 proc near mov ax,0ffffh ; fake request size call GetInt220mem ; return maximum available memory in AX ; handle in BX, SI or ax,ax ; available size = 0 ? jz E82Nomem ; yes ; ax:size,bx:free handle,si:unused handle call AllocInt220mem ; allocate memory for this Int 220 mov [bp].USER_BX,bx ; start addr mov [bp].USER_DX,dx ; ending addr mov [bp].USER_AX,ax ; size of memory allocated mov [OwnersHandle],cx ; save handle of allocated block mov ax,6200h int 21h mov [OwnersPSP],bx ; save current process's PSP ; we'll hook INt20h/21h from now on ; Exchange the old vector with the new one. push es cli les si,dword ptr pInt20Vector ; replace Int20h vector mov ax,offset Int20_Hooker ; with addr of Int20_Hooker xchg ax,es:[si][0] ; mov word ptr [PrevInt20][0],ax ; mov ax,cs ; xchg ax,es:[si][2] ; mov word ptr [PrevInt20][2],ax ; les si,dword ptr pInt21Vector ; replace Int21h vector mov ax,offset Int21_Hooker ; with addr of Int21_Hooker xchg ax,es:[si][0] ; mov word ptr [PrevInt21][0],ax ; mov ax,cs ; xchg ax,es:[si][2] ; mov word ptr [PrevInt21][2],ax ; sti pop es jmp short E82Exit E82Nomem: mov word ptr [bp].USER_BX,0010h ; start addr mov word ptr [bp].USER_DX,0010h ; ending addr mov word ptr [bp].USER_AX,0000h ; no blocks was allocated E82Exit: ret EML_82 endp ;*----------------------------------------------------------------------* ;* * ;* Int20_Hooker - * ;* Int21_Hooker - * ;* * ;* Hooks Int20h/21h * ;* * ;* ARGS: AH = Function * ;* * ;* REGS: All Regs are preserved * ;* * ;* EXIT: Fall through previous Int20h/21h handler * ;* * ;*----------------------------------------------------------------------* Intnum db 0 ; number of Int we are handling Int21_Hooker proc far mov cs:[Intnum],21h cmp ah,00h je I2xHStart cmp ah,4ch jne I2xHNext Int20_Hooker proc far I2xHStart: push ax push bx mov ax,6200h pushf call cs:[PrevInt21] ; Int21h GetPSP Function cmp bx,cs:[OwnersPSP] ; this process own memory block? pop bx pop ax jne I2xHNext push ax push bx push cx push dx push di push si push ds push cs pop ds ; ds <- _text seg push es mov es,[hiseg] ; es <- funky seg mov dx,[OwnersHandle] ; handle of block owned by this process mov di,FreeMem ; get funtion in funky segment push cs ; set up far return call call_hi_in_di ; call into high segment ;------------------------------------------------------------------------------ ; Restore the old vector. ; we won't hook Int20h/21h no longer. cli les di,dword ptr pInt20Vector ; restore Int20h vector mov ax,word ptr [PrevInt20][0] ; stosw ; mov ax,word ptr [PrevInt20][2] ; stosw ; les di,dword ptr pInt21Vector ; restore Int21h vector mov ax,word ptr [PrevInt21][0] ; stosw ; mov ax,word ptr [PrevInt21][2] ; stosw ; ;------------------------------------------------------------------------------ pop es pop ds pop si pop di pop dx pop cx pop bx pop ax I2xHNext: cmp cs:[Intnum],21h je I21HNext I20HNext: jmp cs:[PrevInt20] ; continue down the int 20h chain I21HNext: mov cs:[Intnum],0 jmp cs:[PrevInt21] ; continue down the int 21h chain Int20_Hooker endp Int21_Hooker endp assume ds:_text ;*----------------------------------------------------------------------* ;* * ;* GetInt220mem - * ;* * ;* Serach for available memory block for Int220 in EMB table * ;* * ;* ARGS: AX = size of memories requested in blocks of 128k * ;* * ;* RETS: AX = size of maximam EMB block in blocks of 128k * ;* BX = handle of maximam availabel EMB block * ;* CX = size of available EMB block whith the nearest * ;* size to request, in blocks of 128k * ;* DX = handle of available EMB block whith the nearest * ;* size to request * ;* SI = handle of unused EMB block * ;* * ;* REGS: AX, BX, CX, DX, SI, DI and Flags are clobbered * ;* * ;*----------------------------------------------------------------------* hMax dw 0 ; Handle of block that has max size MaxSize dw 0 ; Max. size found so far hNearest dw 0 ; Handle of block that has nearest size ; with request size NearestSize dw 0 ; Nearest size with request size hUnused dw 0 ; Handle of unused block GetInt220mem proc near mov [hMax],0000h mov [MaxSize],0000h mov [hNearest],0000h mov [NearestSize],0ffffh mov [hUnused],0000h ; scan for largest FREE block push es mov es,[hiseg] assume es:funky mov bx,[KiddValley] mov cx,[cHandles] ; Loop through the handle table GI220Loop: cmp [bx].Flags,FREEFLAG ; Is this block free? jne GI220Anused ; no mov di,[bx].base mov si,di add si,[bx].Len ; si has end addr of free block and si,0ff80h ; round off to 128k boundary add di,127 ; di had start addr of free block and di,0ff80h ; 128k boundary sub si,di ; available size in kbytes jnc GI220Gotmem xor si,si ; size = 0 GI220Gotmem: shr si,7 ; convert to number of blocks cmp si,[MaxSize] ; is this the largest so far? jbe GI220Nearest mov [MaxSize],si ; Yes, save it away mov [hMax],bx ; save handle GI220Nearest: cmp si,ax ; is this larger than request? jb GI220Bottom cmp si,[NearestSize] ; is this the nearest so far? jae GI220Bottom mov [NearestSize],si ; Yes save it away mov [hNearest],bx ; save handle jmp short GI220Bottom GI220Anused: cmp [bx].Flags,UNUSEDFLAG ; Is this block unused? jne GI220Bottom cmp [hUnused],0 ; did we already find an unused handle? jne GI220Bottom mov [hUnused],bx ; save this guy away GI220Bottom: add bx,SIZE Handle loop GI220Loop cmp [hMax],0 ; Is there some free blocks je GI220Nomem ; no mov ax,[MaxSize] mov bx,[hMax] mov cx,[MaxSize] mov dx,[hMax] mov si,[hUnused] cmp [hNearest],0 je GI220Exit mov cx,[NearestSize] mov dx,[hNearest] jmp short GI220Exit GI220Nomem: xor ax,ax ; no memory available xor cx,cx ; GI220Exit: pop es assume es:nothing ret GetInt220mem endp ;*----------------------------------------------------------------------* ;* * ;* AllocInt220mem - * ;* * ;* Set memory block for Int220 onto EMB table * ;* * ;* ARGS: AX = size of memories requested in blocks of 128k * ;* BX = handle of free EMB block * ;* SI = handle of unused EMB block * ;* * ;* RETS: AX = size of EMB blocks allocated in blocks of 128k * ;* BX = start addr of allocated memories * ;* DX = ending addr of allocated memoies * ;* CX = handle of allocated EMB block * ;* * ;* REGS: AX, BX, CX, DX and Flags are clobbered * ;* * ;*----------------------------------------------------------------------* AllocInt220mem proc near push es mov es,[hiseg] assume es:funky shl ax,7 ; request size in kbytes or si,si ; is there a unused block? jz AI220AllocAll ; no, allocate entire block cmp ax,[bx].Len je AI220AllocAll mov dx,[bx].Base mov cx,dx add dx,[bx].Len ; end of free block and dx,007fh ; size beyond 128k boundary add dx,ax mov [si].Len,dx sub [bx].Len,dx add cx,[bx].Len mov [si].Base,cx mov bx,si AI220AllocAll: mov [bx].Flags,USEDFLAG ; New.Flags = USED shr ax,7 ; size of block allocated mov cx,bx ; handle of block allocated mov dx,[bx].Base add dx,[bx].Len and dx,0ff80h shr dx,6 ; end addr mov bx,dx sub bx,ax sub bx,ax ; start addr pop es assume es:nothing ret AllocInt220mem endp endif ;NEC_98 ;*----------------------------------------------------------------------* ;* * ;* RequestHMA - FUNCTION 01h * ;* * ;* Give caller control of the High Memory Area if it is available. * ;* * ;* ARGS: DX = HMA space requested in bytes * ;* RETS: AX = 1 if the HMA was reserved, 0 otherwise. BL = Error * ;* REGS: AX, BX and Flags clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* winbug_fix dw 0 ; storage for windows bug workaround RequestHMA proc near call DOCLI ; This is a non-reentrant function. ; Flags are restored after the return. mov bl,ERR_HMAINUSE ; *************************** ; ** There's a problem with WIN386 2.11. It calls XMS driver ; ** incorrectly and then goes ahead and uses the memory ; ** it didn't properly allocate. In order to convince it ; ** not to go ahead and use the extended memory, we must ; ** fail this function when it calls us. We know that ; ** al=40h and dx=free memory returned from QueryExtMemory ; ** when we're called from windows. Hopefully no legitimate ; ** caller will happen to have that exact same 24 bit code ; ** in al/dx when they call this function because they will fail. ; *************************** cmp al,40h ; called from win386 2.11? jnz not_winbug cmp dx,winbug_fix ; dx=last result from QueryExtMem? jz RHRetErr ; fail if so not_winbug: cmp [fHMAInUse],1 ; Is the HMA already allocated? je RHRetErr mov bl,ERR_HMANOTEXIST cmp [fHMAExists],0 ; Is the HMA available? je RHRetErr mov bl,ERR_HMAMINSIZE cmp dx,[MinHMASize] ; Is this guy allowed in? jb RHRetErr mov ax,1 mov [fHMAInUse],al ; Reserve the High Memory Area xor bl,bl ; Clear the error code ret RHRetErr: xor ax,ax ; Return failure with error code in BL ret RequestHMA endp ;*----------------------------------------------------------------------* ;* * ;* ReleaseHMA - FUNCTION 02h * ;* * ;* Caller is releasing control of the High Memory area * ;* * ;* ARGS: None * ;* RETS: AX = 1 if control is released, 0 otherwise. BL = Error * ;* REGS: AX, BX and Flags clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* ReleaseHMA proc near call DOCLI ; This is a non-reentrant function mov al,[fHMAInUse] ; HMA currently in use? or al,al jz RLHRetErr ; No, return error mov [fHMAInUse],0 ; Release the HMA and return success mov ax,1 xor bl,bl ret RLHRetErr: xor ax,ax mov bl,ERR_HMANOTALLOCED ret ReleaseHMA endp ;*----------------------------------------------------------------------* ;* * ;* GlobalEnableA20 - FUNCTION 03h * ;* * ;* Globally enable the A20 line * ;* * ;* ARGS: None * ;* RETS: AX = 1 if the A20 line is enabled, 0 otherwise. BL = Error * ;* REGS: AX, BX CX, SI, DI and Flags clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* GlobalEnableA20 proc near call DOCLI ; This is a non-reentrant function cmp [fGlobalEnable],1 ; Is A20 already globally enabled? je GEARet GEAEnable: call LocalEnableA20 ; Attempt to enable A20 or ax,ax jz GEAA20Err mov [fGlobalEnable],1 ; Mark A20 global enabled GEARet: mov ax,1 ; return success xor bl,bl ret GEAA20Err: mov bl,ERR_A20 ; some A20 error occurred xor ax,ax ret GlobalEnableA20 endp ;*----------------------------------------------------------------------* ;* * ;* GlobalDisableA20 - FUNCTION 04h * ;* * ;* Globally disable the A20 line * ;* * ;* ARGS: None * ;* RETS: AX=1 if the A20 line is disabled, 0 otherwise. BL = Error * ;* REGS: AX, BX, CX, SI, DI and Flags are clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* GlobalDisableA20 proc near call DOCLI ; This is a non-reentrant function cmp [fGlobalEnable],0 ; Is A20 already global-disabled? je GDARet call LocalDisableA20 ; Attempt to disable it or ax,ax ; (also zaps CX, SI, DI) jz GDAA20Err mov [fGlobalEnable],0 ; mark as global-disabled GDARet: mov ax,1 ; return success xor bl,bl ret GDAA20Err: mov bl,ERR_A20 ; some A20 error occurred xor ax,ax ret GlobalDisableA20 endp ;*----------------------------------------------------------------------* ;* * ;* LocalEnableA20 - FUNCTION 05h * ;* * ;* Locally enable the A20 line * ;* * ;* ARGS: None * ;* RETS: AX = 1 if the A20 line is enabled, 0 otherwise. BL = Error * ;* REGS: AX, BX, CX, SI, DI and Flags clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* LocalEnableA20 proc near ifndef NEC_98 call DOCLI ; This is a non-reentrant function cmp [fCanChangeA20],1 ; Can we change A20? jne LEARet ; No, don't touch A20 if NUM_A20_RETRIES mov A20Retries,NUM_A20_RETRIES endif cmp [EnableCount],0 ; If enable count == 0, go set it jz LEASetIt ; without bothering to check 1st if NUM_A20_RETRIES LEATestIt: endif call IsA20On ; If A20 is already on, don't do or ax,ax ; it again, but if it isn't on, jnz LEAIncIt ; then make it so LEASetIt: mov ax,1 ; attempt to turn A20 on call A20Handler ; Call machine-specific A20 handler ife NUM_A20_RETRIES or ax,ax ; If we're not doing retries, then jz LEAA20Err ; use A20 handler's error return else dec A20Retries ; Any retries remaining? If so, go jnz LEATestIt ; test current state, else return jmp short LEAA20Err ; an error condition endif LEAIncIt: inc [EnableCount] LEARet: mov ax,1 ; return success xor bl,bl ret LEAA20Err: mov bl,ERR_A20 ; some A20 error occurred xor ax,ax if debug_vers disp_a20_err: pusha mov al,'#' call cofa popa endif ret else ;NEC_98 call DOCLI ; This is a non-reentrant function cmp [fCanChangeA20],1 ; Can we change A20? jne LEARet ; No, don't touch A20 ; From 2.14 - 2.25 the following 3 lines were commented out. This caused ; at least four (seemingly different) bugs on PS/2 systems. The problem ; seems to be that the PS2_A20Handler returns an error code if called to ; enable when A20 is already on (other handlers do this also!). JimMat call IsA20On ; If A20 is already on, don't do or ax,ax ; it again, but if it isn't on, jnz LEAIncIt ; then make it so mov ax,1 ; attempt to turn A20 on call A20Handler ; Call machine-specific A20 handler or ax,ax jz LEAA20Err LEAIncIt: inc [EnableCount] LEARet: mov ax,1 ; return success xor bl,bl ret LEAA20Err: mov bl,ERR_A20 ; some A20 error occurred xor ax,ax if debug_vers disp_a20_err: pusha mov al,'#' call cofa popa endif ret endif ;NEC_98 LocalEnableA20 endp ;*----------------------------------------------------------------------* ;* * ;* LocalDisableA20 - FUNCTION 06h * ;* * ;* Locally disable the A20 line * ;* * ;* ARGS: None * ;* RETS: AX=1 if the A20 line is disabled, 0 otherwise. BL = Error * ;* REGS: AX, BX, CX, SI, DI and Flags are clobbered * ;* * ;* INTERNALLY NON-REENTRANT * ;* * ;*----------------------------------------------------------------------* LocalDisableA20 proc near call DOCLI ; This is a non-reentrant function cmp [fCanChangeA20],0 ; Can we change A20? je LDARet ; No, don't touch A20 cmp [EnableCount],0 ; make sure the count's not zero je LDAA20Err ifndef NEC_98 if NUM_A20_RETRIES mov A20Retries,NUM_A20_RETRIES LDATestIt: endif endif ;NEC_98 call IsA20On ; Currently on or off? cmp [EnableCount],1 ; Only if the count = 1 should A20 be jnz LDAStayOn ; turned off, otherwise it stays on or ax,ax ; If A20 is already off, don't jz LDADecIt ; bother to turn off again xor ax,ax ; It's on, but should be turned off jmp short LDASetIt LDAStayOn: or ax,ax ; A20 must stay on, if it is on, just jnz LDADecIt ; dec count, else force A20 on mov ax,1 LDASetIt: call A20Handler ; Call machine-specific A20 handler ifndef NEC_98 ife NUM_A20_RETRIES or ax,ax ; If we're not doing retries, then jz LDAA20Err ; use A20 handler's error return else dec A20Retries ; Any retries remaining? If so, go jnz LDATestIt ; test current state, else return jmp short LDAA20Err ; an error condition endif else ;NEC_98 or ax,ax ; If we're not doing retries, then jz LDAA20Err ; use A20 handler's error return endif ;NEC_98 LDADecIt: dec [EnableCount] LDARet: mov ax,1 ; return success xor bl,bl ret LDAA20Err: mov bl,ERR_A20 ; some A20 error occurred xor ax,ax if debug_vers jmp disp_a20_err endif ret LocalDisableA20 endp ; ;--------------------------------------------------------------------------- ; procedure : FLclEnblA20 ; procedure : FLclDsblA20 ; ; Called from the Block move functions. Serves 2 purposes ; 1. Interfaces a far call for a near routine ; 2. If funky is in HMA does a dummy success return ;--------------------------------------------------------------------------- ; FLclEnblA20 proc far cmp cs:fInHMA, 0 jz @f mov ax, 1 ret @@: call LocalEnableA20 ret FLclEnblA20 endp FLclDsblA20 proc far cmp cs:fInHMA, 0 jz @f mov ax, 1 ret @@: call LocalDisableA20 ret FLclDsblA20 endp ; ;*----------------------------------------------------------------------* ;* * ;* IsA20On - FUNCTION 07h * ;* * ;* Returns the state of the A20 line * ;* * ;* ARGS: None * ;* RETS: AX = 1 if the A20 line is enabled, 0 otherwise * ;* BL = 0 * ;* REGS: AX, BL, CX, SI, DI and Flags clobbered * ;* * ;* INTERNALLY REENTRANT * ;* * ;*----------------------------------------------------------------------* ; NOTE: When this routine is called from the Int15 handler, ds is undefined. ; Hence the CS: overrides on data references. IsA20On proc near mov al, cs:A20State cbw xor bl, bl ret IsA20On endp ;*----------------------------------------------------------------------* ;* * ;* AddMem - add memory to free pool * ;* * ;* The trick here is that we're going to check for overlapping * ;* or adjacent blocks and crunch them together. The thinking * ;* here is that we may be informed of a memory resource from * ;* more than one source. In any case, we NEVER want the same * ;* memory to appear in our resource table more than once. * ;* * ;* Note: there's presently no way of reporting errors if the * ;* handle table is full. If it happens, we'll just lose the * ;* memory block. This should not be a problem as long as * ;* we're only being called during program initialization. * ;* * ;* It would be nice if we could throw this code away after * ;* initialization, unfortunately this is actually invoked * ;* at HookInt15 time, so it's too late to do away with * ;* obsolete code. * ;* * ;* ARGS: CX - base of block in 1K increments * ;* AX - length of block in 1K increments * ;* TRASHES: AX,BX,CX,DX,SI,DI * ;* * ;* messes with handle table - not reentrant - assumes ints disabled * ;* * ;*----------------------------------------------------------------------* AddMem proc near ; We might as well be scanning for a free handle while we're ; at it since we're normally going to need one at the end mov dx,ax ; save new block length in dx mov si,cx ; save new block base in si xor di,di ; haven't found free handle yet push es mov es,hiseg assume es:funky mov bx,[KiddValley] ; prepare to loop thru handle tab mov cx,[cHandles] AM01: cmp [bx].Flags,UNUSEDFLAG ; is this handle available? jnz AM02 ; skip if not or di,di ; use the first free handle we jnz AM05 ; find. skip if we've got one mov di,bx ; save the unused handle in di jmp short AM05 AM02: ; Note: Normally all handles will be either UNUSED or FREE at ; this point. However, in the case of checking for Zenith memory, ; it may have a temporarily allocated dummy block. Therefore ; we'll only be merging blocks marked as FREE. cmp [bx].Flags,FREEFLAG jnz AM05 ; ignore USED blocks ; First check for new block being entirely after block at [bx] mov ax,[bx].Base add ax,[bx].Len cmp ax,si ; is [bx].end < new.Base? jb AM05 ; done checking this entry if so ; Now check for new block being entirely before block at [bx] mov ax,si ; new.base add ax,dx ; + new.len = new.end cmp ax,[bx].Base jb AM05 ; brif no overlap at all ; Now put the block at [bx] up into our block in registers so ; that we can continue the scan. There may be other adjacent ; blocks, even in the case of no overlap, fr'instance when a ; block is added which entirely fills the gap between two others. cmp si,[bx].Base ; Find base of combined block jbe AM03 ; Brif new block on bottom add dx,si ; Add new.base - [bx].base to mov si,[bx].Base ; new.len, set new.base=[bx].Base sub dx,si ; new.len AM03: mov ax,[bx].Base ; see which block ends later add ax,[bx].Len ; get [bx].end sub ax,dx ; less new.len sub ax,si ; compare to new.Base jbe AM04 ; brif new.end >= [bx].end ; now ax has the amount our block must grow by add dx,ax AM04: mov [bx].Flags,UNUSEDFLAG ; mark the block unused or di,di ; did we find an unused handle yet? jnz AM05 ; brif so mov di,bx ; save this one if not AM05: add bx,SIZE handle loop AM01 or di,di ; did we find a free handle? jz AM06 ; error! no handles free! mov [di].cLock,0 mov [di].Flags,FREEFLAG ; create the free memory block mov [di].Base,si mov [di].Len,dx AM06: pop es assume es:nothing ret AddMem endp PUBLIC DOCLI DOCLI: FCLI ret PUBLIC DOSTI DOSTI: FSTI ret PUBLIC DOIRET DOIRET: FIRET _text ends end 
theorems/cohomology/CupProduct/Definition.agda
AntoineAllioux/HoTT-Agda
294
6735
<filename>theorems/cohomology/CupProduct/Definition.agda {-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.CupProduct.OnEM.InAllDegrees open import cohomology.CupProduct.OnEM.CommutativityInAllDegrees open import cohomology.EMModel open import cohomology.Theory open import groups.ToOmega open import homotopy.EilenbergMacLane open import homotopy.EilenbergMacLaneFunctor open import homotopy.Freudenthal open import homotopy.SuspensionLoopSpaceInverse module cohomology.CupProduct.Definition {i} (X : Ptd i) where private module M {k} (A : AbGroup k) = CohomologyTheory (EM-Cohomology A) open M ⊙×-diag : X ⊙→ X ⊙× X ⊙×-diag = (λ x → x , x) , idp smin-map : ∀ {j k} {Y : Ptd j} {Z : Ptd k} → X ⊙→ Y → X ⊙→ Z → X ⊙→ Y ⊙× Z smin-map f g = ⊙×-fmap f g ⊙∘ ⊙×-diag smin-map-⊙×-swap : ∀ {j k} (Y : Ptd j) (Z : Ptd k) (f : X ⊙→ Y) (g : X ⊙→ Z) → ⊙×-swap ⊙∘ smin-map g f == smin-map f g smin-map-⊙×-swap Y Z (_ , idp) (_ , idp) = idp module _ (G : AbGroup i) (H : AbGroup i) where private module G⊗H = TensorProduct G H module H⊗G = TensorProduct H G open EMExplicit ⊙Ω×-cp-seq : ∀ (m n : ℕ) → (⊙Ω (⊙EM G (S m)) ⊙× ⊙Ω (⊙EM H (S n))) ⊙–→ ⊙Ω (⊙EM G⊗H.abgroup (S (m + n))) ⊙Ω×-cp-seq m n = ⊙<– (spectrum G⊗H.abgroup (m + n)) ◃⊙∘ ⊙×-cp G H m n ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf ⊙Ω×-cp : ∀ (m n : ℕ) → ⊙Ω (⊙EM G (S m)) ⊙× ⊙Ω (⊙EM H (S n)) ⊙→ ⊙Ω (⊙EM G⊗H.abgroup (S (m + n))) ⊙Ω×-cp m n = ⊙compose (⊙Ω×-cp-seq m n) _∪_ : ∀ {m n : ℕ} → CEl G (pos m) X → CEl H (pos n) X → CEl G⊗H.abgroup (pos (m + n)) X _∪_ {m} {n} = Trunc-fmap2 {n = 0} (λ s' t' → ⊙Ω×-cp m n ⊙∘ smin-map s' t') module _ (G : AbGroup i) (H : AbGroup i) where private module G⊗H = TensorProduct G H module H⊗G = TensorProduct H G open EMExplicit abstract ⊙Ω×-cp-comm : ∀ (m n : ℕ) → ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ◃⊙∘ ⊙Ω×-cp G H m n ◃⊙idf =⊙∘ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙Ω×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙idf ⊙Ω×-cp-comm m n = ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ◃⊙∘ ⊙Ω×-cp G H m n ◃⊙idf =⊙∘⟨ 2 & 1 & ⊙expand (⊙Ω×-cp-seq G H m n) ⟩ ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ◃⊙∘ ⊙<– (spectrum G⊗H.abgroup (m + n)) ◃⊙∘ ⊙×-cp G H m n ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘⟨ 1 & 2 & !⊙∘ $ ⊙<–-spectrum-natural G⊗H.abgroup H⊗G.abgroup G⊗H.swap (m + n) ⟩ ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙<– (spectrum H⊗G.abgroup (m + n)) ◃⊙∘ ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (m + n) ◃⊙∘ ⊙×-cp G H m n ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘⟨ 0 & 2 & !⊙∘ $ ⊙transport-natural-=⊙∘ (+-comm m n) (λ k → ⊙<– (spectrum H⊗G.abgroup k)) ⟩ ⊙<– (spectrum H⊗G.abgroup (n + m)) ◃⊙∘ ⊙transport (λ k → ⊙EM H⊗G.abgroup k) (+-comm m n) ◃⊙∘ ⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (m + n) ◃⊙∘ ⊙×-cp G H m n ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘⟨ 1 & 3 & ⊙×-cp-comm G H m n ⟩ ⊙<– (spectrum H⊗G.abgroup (n + m)) ◃⊙∘ ⊙cond-neg H⊗G.abgroup (n + m) (and (odd m) (odd n)) ◃⊙∘ ⊙×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘⟨ 0 & 2 & ⊙transport-natural-=⊙∘ (Bool-elim (inv-path H⊗G.abgroup) idp (and (odd m) (odd n))) (λ A → ⊙<– (spectrum A (n + m))) ⟩ ⊙transport (λ A → ⊙Ω (⊙EM A (S (n + m)))) neg ◃⊙∘ ⊙<– (spectrum H⊗G.abgroup (n + m)) ◃⊙∘ ⊙×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘₁⟨ 0 & 1 & ⊙transport-⊙coe (λ A → ⊙Ω (⊙EM A (S (n + m)))) neg ∙ ap ⊙coe (ap-∘ ⊙Ω (λ A → ⊙EM A (S (n + m))) neg) ∙ ! (⊙transport-⊙coe ⊙Ω (ap (λ A → ⊙EM A (S (n + m))) neg)) ∙ ⊙transport-⊙Ω (ap (λ A → ⊙EM A (S (n + m))) neg) ∙ ap ⊙Ω-fmap (! (⊙transport-⊙coe (λ A → ⊙EM A (S (n + m))) neg)) ⟩ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙<– (spectrum H⊗G.abgroup (n + m)) ◃⊙∘ ⊙×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙∘ ⊙×-fmap (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ◃⊙idf =⊙∘⟨ 3 & 2 & =⊙∘-in {gs = ⊙×-fmap (⊙–> (spectrum H n)) (⊙–> (spectrum G m)) ◃⊙∘ ⊙×-swap ◃⊙idf} $ ! $ ⊙λ= $ ⊙×-swap-natural (⊙–> (spectrum G m)) (⊙–> (spectrum H n)) ⟩ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙<– (spectrum H⊗G.abgroup (n + m)) ◃⊙∘ ⊙×-cp H G n m ◃⊙∘ ⊙×-fmap (⊙–> (spectrum H n)) (⊙–> (spectrum G m)) ◃⊙∘ ⊙×-swap ◃⊙idf =⊙∘⟨ 1 & 3 & ⊙contract ⟩ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙Ω×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙idf ∎⊙∘ where neg : H⊗G.abgroup == H⊗G.abgroup neg = Bool-elim (inv-path H⊗G.abgroup) idp (and (odd m) (odd n)) ∪-swap : ∀ (m n : ℕ) → CEl G⊗H.abgroup (pos (m + n)) X → CEl H⊗G.abgroup (pos (n + m)) X ∪-swap m n = transport (λ k → CEl H⊗G.abgroup (pos k) X) (+-comm m n) ∘ EM-CEl-coeff-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (pos (m + n)) X maybe-inv : ∀ (n : ℤ) → Bool → CEl H⊗G.abgroup n X → CEl H⊗G.abgroup n X maybe-inv n = Bool-rec (Group.inv (C H⊗G.abgroup n X)) (idf _) private _G∪H_ = _∪_ G H _H∪G_ = _∪_ H G ∪-comm : ∀ {m n : ℕ} (s : CEl G (pos m) X) (t : CEl H (pos n) X) → ∪-swap m n (s G∪H t) == maybe-inv (pos (n + m)) (and (odd m) (odd n)) (t H∪G s) ∪-comm {m} {n} = Trunc-elim {{λ s → Π-level (λ t → =-preserves-level Trunc-level)}} $ λ s' → Trunc-elim {{λ t → =-preserves-level Trunc-level}} $ λ t' → transport (λ k → CEl H⊗G.abgroup (pos k) X) (+-comm m n) [ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ⊙∘ ⊙Ω×-cp G H m n ⊙∘ smin-map s' t' ] =⟨ app= step₁ [ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ⊙∘ ⊙Ω×-cp G H m n ⊙∘ smin-map s' t' ] ⟩ [ ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ⊙∘ ⊙Ω×-cp G H m n ⊙∘ smin-map s' t' ] =⟨ ap [_] (=⊙∘-out (step₂ s' t')) ⟩ Trunc-fmap (⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ⊙∘_) [ ⊙Ω×-cp H G n m ⊙∘ smin-map t' s' ] =⟨ app= (step₃ (n + m) (and (odd m) (odd n))) [ ⊙Ω×-cp H G n m ⊙∘ smin-map t' s' ] ⟩ maybe-inv (pos (n + m)) (and (odd m) (odd n)) [ ⊙Ω×-cp H G n m ⊙∘ smin-map t' s' ] =∎ where step₁ : transport (λ k → CEl H⊗G.abgroup (pos k) X) (+-comm m n) == Trunc-fmap (⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ⊙∘_) step₁ = transport (λ k → CEl H⊗G.abgroup (pos k) X) (+-comm m n) =⟨ ap coe (ap-∘ (Trunc 0) (λ k → X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) ⟩ transport (Trunc 0) (ap (λ k → X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) =⟨ transport-Trunc (ap (λ k → X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) ⟩ Trunc-fmap (transport (λ k → X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) =⟨ ap (Trunc-fmap ∘ coe) (ap-∘ (X ⊙→_) (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) ⟩ Trunc-fmap (transport (X ⊙→_) (ap (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n))) =⟨ ap Trunc-fmap $ λ= $ transport-post⊙∘ X (ap (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) ⟩ Trunc-fmap (⊙coe (ap (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n)) ⊙∘_) =⟨ ap (λ g → Trunc-fmap (g ⊙∘_)) $ ! $ ⊙transport-⊙coe (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ⟩ Trunc-fmap (⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ⊙∘_) =∎ step₂ : ∀ (s' : X ⊙→ ⊙Ω (⊙EM G (S m))) (t' : X ⊙→ ⊙Ω (⊙EM H (S n))) → ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ◃⊙∘ ⊙Ω×-cp G H m n ◃⊙∘ smin-map s' t' ◃⊙idf =⊙∘ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙Ω×-cp H G n m ◃⊙∘ smin-map t' s' ◃⊙idf step₂ s' t' = ⊙transport (λ k → ⊙Ω (⊙EM H⊗G.abgroup (S k))) (+-comm m n) ◃⊙∘ ⊙Ω-fmap (⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap (S (m + n))) ◃⊙∘ ⊙Ω×-cp G H m n ◃⊙∘ smin-map s' t' ◃⊙idf =⊙∘⟨ 0 & 3 & ⊙Ω×-cp-comm m n ⟩ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙Ω×-cp H G n m ◃⊙∘ ⊙×-swap ◃⊙∘ smin-map s' t' ◃⊙idf =⊙∘⟨ 2 & 2 & =⊙∘-in {gs = smin-map t' s' ◃⊙idf} $ smin-map-⊙×-swap (⊙Ω (⊙EM H (S n))) (⊙Ω (⊙EM G (S m))) t' s' ⟩ ⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S (n + m)) (and (odd m) (odd n))) ◃⊙∘ ⊙Ω×-cp H G n m ◃⊙∘ smin-map t' s' ◃⊙idf ∎⊙∘ step₃ : ∀ (k : ℕ) (b : Bool) → Trunc-fmap (⊙Ω-fmap (⊙cond-neg H⊗G.abgroup (S k) b) ⊙∘_) == maybe-inv (pos k) b step₃ k false = Trunc-fmap (⊙Ω-fmap (⊙idf (⊙EM H⊗G.abgroup (S k))) ⊙∘_) =⟨ ap (λ g → Trunc-fmap (g ⊙∘_)) ⊙Ω-fmap-idf ⟩ Trunc-fmap (⊙idf (⊙Ω (⊙EM H⊗G.abgroup (S k))) ⊙∘_) =⟨ ap Trunc-fmap (λ= (⊙λ= ∘ ⊙∘-unit-l)) ⟩ Trunc-fmap (idf (X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k)))) =⟨ λ= Trunc-fmap-idf ⟩ idf (Trunc 0 (X ⊙→ ⊙Ω (⊙EM H⊗G.abgroup (S k)))) =∎ step₃ k true = Trunc-fmap (⊙Ω-fmap (⊙transport (λ A → ⊙EM A (S k)) (inv-path H⊗G.abgroup)) ⊙∘_) =⟨ ap (λ f → Trunc-fmap (⊙Ω-fmap f ⊙∘_)) $ ⊙transport-⊙EM-uaᴬᴳ H⊗G.abgroup H⊗G.abgroup (inv-iso H⊗G.abgroup) (S k) ⟩ Trunc-fmap (⊙Ω-fmap (⊙EM-fmap H⊗G.abgroup H⊗G.abgroup (inv-hom H⊗G.abgroup) (S k)) ⊙∘_) =⟨ ap GroupHom.f (EM-C-coeff-fmap-inv-hom H⊗G.abgroup (pos k) X) ⟩ Group.inv (C H⊗G.abgroup (pos k) X) =∎
src/open_weather_map.ads
Jellix/open_weather_map_api
1
27899
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); limited with Ada.Calendar.Time_Zones; limited with Ada.Containers.Vectors; limited with Ada.Real_Time; limited with Ada.Strings.Unbounded; with Types; private with Ada.Characters.Handling; private with GNATCOLL.Traces; -------------------------------------------------------------------------------- --% @summary --% Top-level package of the implementation to access openweathermap.org's API. -- --% @description --% Provides basic types, restrictions, and information about the API, its --% implementation, and limitations. -------------------------------------------------------------------------------- package Open_Weather_Map is ----------------------------------------------------------------------------- -- API restrictions as documented on their web page ----------------------------------------------------------------------------- Default_Cache_Interval : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Seconds (10); --% Default value for the time the values of a query shall be retained before --% we refresh the data from the server. -- According to openweathermap.org/price the limit on API calls per minute -- per account (regardless of API keys) is 60 calls even for the free model, -- so we can in theory run at least one query each second. To be on the safe -- side, we restrict it to a tenth of that, i.e. one query every ten -- seconds. This leaves open the possibility to run a couple of queries in -- parallel. Default_Rate_Limit : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (500); --% Default value for the minimum temporal separation of queries sent to the --% server over the same connection. -- We limit the number of consecutive requests per HTTP connection to be at -- least that apart. subtype Max_Group_Size is Positive range 1 .. 20; --% Maximum number of ids in a group query. -- API limitation. ----------------------------------------------------------------------------- -- API types ----------------------------------------------------------------------------- subtype API_Key is String (1 .. 32) with Dynamic_Predicate => (for all C of API_Key => Ada.Characters.Handling.Is_Hexadecimal_Digit (C)), Predicate_Failure => (raise Constraint_Error with """" & API_Key & """ is not a 32 character hexadecimal string"); --% API key is a hexadecimal representation of a 128 bit value. Invalid_API_Key : constant API_Key; --% Denotes the all '0' key. -- We're presuming that this key will be invalid for anyone. type City_Id is range 1 .. 99_999_999; --% City ids. -- Not sure about the actual range, though. ----------------------------------------------------------------------------- -- Support types ----------------------------------------------------------------------------- type Group_List is array (Max_Group_Size range <>) of City_Id; --% Type representing a list of ids (for a group query). type Geo_Coordinates is record Latitude : Types.Latitude; Longitude : Types.Longitude; end record; --% Type representing geographical 2-D coordinates. --% @field Latitude --% The latitude part of the coordinates. --% @field Longitude --% The longitude part of the coordinates. type City_Data is record Location : Geo_Coordinates; Temperature : Types.Kelvin; Humidity : Types.Humidity; Pressure : Types.Pressure; Name : Ada.Strings.Unbounded.Unbounded_String; Sunrise : Ada.Calendar.Time; Sunset : Ada.Calendar.Time; Time_Zone : Ada.Calendar.Time_Zones.Time_Offset; Last_Update : Ada.Calendar.Time; end record; --% Type representing the set of data returned as per city/location. -- May depend on the query issued, but that's the general idea. --% @field Location --% The geographical location of the city/location. --% @field Temperature --% The temperature at the location. --% @field Humidity --% The relative humidity at the location. --% @field Pressure --% The atmospheric pressure at the location. --% @field Name --% Name of the city (may be empty, if no city is associated with the --% coordinates). --% @field Sunrise --% UTC of sunrise at that location. --% @field Sunset --% UTC of sunset at that location. --% @field Time_Zone --% Local time zone of the location. --% @field Last_Update --% UTC of when the data was last updated on the server. package City_Lists is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => City_Data); --% @field Valid --% Indicates if the object actually contains data. --% @field Cities --% List of cities in the data set. type Data_Set (Valid : Boolean := False) is record case Valid is when False => null; when True => Cities : City_Lists.Vector; end case; end record; -- TODO: This should become either a tagged type, or part of the query -- objects with suitable accessor functions to cater for the dynamic -- nature of the data being returned. Invalid_Data_Set : constant Data_Set; --% An empty (invalid) data set. ----------------------------------------------------------------------------- -- Enumeration of (implemented) API services. ----------------------------------------------------------------------------- type API_Services is (Current_By_Id, -- "weather?id={city_id}" Current_By_Coordinates, -- "weather?lat={latitude}&lon={longitude}" Current_By_Group); -- "group?id={city_id}[,{city_id} ...] --% List of implemented API services. --% @value Current_By_Id --% Current weather data for a city Id. --% @value Current_By_Coordinates --% Current weather data for a location. --% @value Current_By_Group --% Current weather data for a list of city ids. -- -- Utility functions -- ----------------------------------------------------------------------------- -- Application_Directory ----------------------------------------------------------------------------- function Application_Directory return String with Global => null; --% Returns the (system-dependent) local directory where the application --% expects the configuration and log files and such. --% @return The directory where configuration and log files should be stored. -- The underlying implementation uses a constant evaluated at elaboration -- time, hence the Global aspect of null. private OWM_Debug : constant not null GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create (Unit_Name => "Open_Weather_Map"); --% Debug trace for top level package. API_Host : constant String := "http://api.openweathermap.org"; --% The actual server we're supposed to talk to. API_Path : constant String := "/data/2.5/"; --% Query path to the currently implemented version of the API. Invalid_API_Key : constant API_Key := API_Key'(others => '0'); Invalid_Data_Set : constant Data_Set := Data_Set'(Valid => False); ----------------------------------------------------------------------------- -- Config_Names -- -- Expected names of fields in the configuration file. -- Nested package to improve readability when using these constants. ----------------------------------------------------------------------------- package Config_Names is -- Proxy configuration fields. Env_Network_Address : constant String := "http_proxy"; Field_Network_Address : constant String := "proxy.url"; Field_User : constant String := "proxy.user"; Field_Password : constant String := "<PASSWORD>"; -- Account configuration fields. Field_API_Key : constant String := "api.key"; end Config_Names; ----------------------------------------------------------------------------- -- To_Service_Name ----------------------------------------------------------------------------- --% @param Service The service to be translated into an API URL. --% @return The part of the API URL denoting the name of the service being --% called. function To_Service_Name (Service : in API_Services) return String with Global => null; ----------------------------------------------------------------------------- -- To_Service_Name ----------------------------------------------------------------------------- function To_Service_Name (Service : in API_Services) return String is (case Service is when Current_By_Id | Current_By_Coordinates => "weather", when Current_By_Group => "group"); end Open_Weather_Map;
Cubical/Structures/MultiSet.agda
dan-iel-lee/cubical
0
7556
<gh_stars>0 {-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Structures.MultiSet where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Foundations.SIP open import Cubical.Functions.FunExtEquiv open import Cubical.Structures.Auto open import Cubical.Data.Nat open import Cubical.Data.Sigma private variable ℓ : Level module _ (A : Type ℓ) (Aset : isSet A) where CountStructure : Type ℓ → Type ℓ CountStructure X = A → X → ℕ CountEquivStr = AutoEquivStr CountStructure countUnivalentStr : UnivalentStr _ CountEquivStr countUnivalentStr = autoUnivalentStr CountStructure Count : Type (ℓ-suc ℓ) Count = TypeWithStr ℓ CountStructure MultiSetStructure : Type ℓ → Type ℓ MultiSetStructure X = X × (A → X → X) × (A → X → ℕ) MultiSetEquivStr = AutoEquivStr MultiSetStructure multiSetUnivalentStr : UnivalentStr _ MultiSetEquivStr multiSetUnivalentStr = autoUnivalentStr MultiSetStructure MultiSet : Type (ℓ-suc ℓ) MultiSet = TypeWithStr ℓ MultiSetStructure
agda/Text/Greek/SBLGNT/3John.agda
scott-fleischman/GreekGrammar
44
8533
<filename>agda/Text/Greek/SBLGNT/3John.agda module Text.Greek.SBLGNT.3John where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΙΩΑΝΝΟΥ-Γ : List (Word) ΙΩΑΝΝΟΥ-Γ = word (Ὁ ∷ []) "3John.1.1" ∷ word (π ∷ ρ ∷ ε ∷ σ ∷ β ∷ ύ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ς ∷ []) "3John.1.1" ∷ word (Γ ∷ α ∷ ΐ ∷ ῳ ∷ []) "3John.1.1" ∷ word (τ ∷ ῷ ∷ []) "3John.1.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ῷ ∷ []) "3John.1.1" ∷ word (ὃ ∷ ν ∷ []) "3John.1.1" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "3John.1.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ ῶ ∷ []) "3John.1.1" ∷ word (ἐ ∷ ν ∷ []) "3John.1.1" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.1" ∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.2" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "3John.1.2" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.2" ∷ word (ε ∷ ὔ ∷ χ ∷ ο ∷ μ ∷ α ∷ ί ∷ []) "3John.1.2" ∷ word (σ ∷ ε ∷ []) "3John.1.2" ∷ word (ε ∷ ὐ ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "3John.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.2" ∷ word (ὑ ∷ γ ∷ ι ∷ α ∷ ί ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.2" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "3John.1.2" ∷ word (ε ∷ ὐ ∷ ο ∷ δ ∷ ο ∷ ῦ ∷ τ ∷ α ∷ ί ∷ []) "3John.1.2" ∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.2" ∷ word (ἡ ∷ []) "3John.1.2" ∷ word (ψ ∷ υ ∷ χ ∷ ή ∷ []) "3John.1.2" ∷ word (ἐ ∷ χ ∷ ά ∷ ρ ∷ η ∷ ν ∷ []) "3John.1.3" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "3John.1.3" ∷ word (∙λ ∷ ί ∷ α ∷ ν ∷ []) "3John.1.3" ∷ word (ἐ ∷ ρ ∷ χ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "3John.1.3" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ῶ ∷ ν ∷ []) "3John.1.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.3" ∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ο ∷ ύ ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.3" ∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.3" ∷ word (τ ∷ ῇ ∷ []) "3John.1.3" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.3" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "3John.1.3" ∷ word (σ ∷ ὺ ∷ []) "3John.1.3" ∷ word (ἐ ∷ ν ∷ []) "3John.1.3" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.3" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.3" ∷ word (μ ∷ ε ∷ ι ∷ ζ ∷ ο ∷ τ ∷ έ ∷ ρ ∷ α ∷ ν ∷ []) "3John.1.4" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.4" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "3John.1.4" ∷ word (ἔ ∷ χ ∷ ω ∷ []) "3John.1.4" ∷ word (χ ∷ α ∷ ρ ∷ ά ∷ ν ∷ []) "3John.1.4" ∷ word (ἵ ∷ ν ∷ α ∷ []) "3John.1.4" ∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ω ∷ []) "3John.1.4" ∷ word (τ ∷ ὰ ∷ []) "3John.1.4" ∷ word (ἐ ∷ μ ∷ ὰ ∷ []) "3John.1.4" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "3John.1.4" ∷ word (ἐ ∷ ν ∷ []) "3John.1.4" ∷ word (τ ∷ ῇ ∷ []) "3John.1.4" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.4" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ []) "3John.1.4" ∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.5" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "3John.1.5" ∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.5" ∷ word (ὃ ∷ []) "3John.1.5" ∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "3John.1.5" ∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ σ ∷ ῃ ∷ []) "3John.1.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "3John.1.5" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.5" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.5" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "3John.1.5" ∷ word (ξ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.5" ∷ word (ο ∷ ἳ ∷ []) "3John.1.6" ∷ word (ἐ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ η ∷ σ ∷ ά ∷ ν ∷ []) "3John.1.6" ∷ word (σ ∷ ο ∷ υ ∷ []) "3John.1.6" ∷ word (τ ∷ ῇ ∷ []) "3John.1.6" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "3John.1.6" ∷ word (ἐ ∷ ν ∷ ώ ∷ π ∷ ι ∷ ο ∷ ν ∷ []) "3John.1.6" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "3John.1.6" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "3John.1.6" ∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ς ∷ []) "3John.1.6" ∷ word (π ∷ ο ∷ ι ∷ ή ∷ σ ∷ ε ∷ ι ∷ ς ∷ []) "3John.1.6" ∷ word (π ∷ ρ ∷ ο ∷ π ∷ έ ∷ μ ∷ ψ ∷ α ∷ ς ∷ []) "3John.1.6" ∷ word (ἀ ∷ ξ ∷ ί ∷ ω ∷ ς ∷ []) "3John.1.6" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.6" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "3John.1.6" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "3John.1.7" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "3John.1.7" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.7" ∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "3John.1.7" ∷ word (ἐ ∷ ξ ∷ ῆ ∷ ∙λ ∷ θ ∷ ο ∷ ν ∷ []) "3John.1.7" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "3John.1.7" ∷ word (∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "3John.1.7" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "3John.1.7" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "3John.1.7" ∷ word (ἐ ∷ θ ∷ ν ∷ ι ∷ κ ∷ ῶ ∷ ν ∷ []) "3John.1.7" ∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.8" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "3John.1.8" ∷ word (ὀ ∷ φ ∷ ε ∷ ί ∷ ∙λ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.8" ∷ word (ὑ ∷ π ∷ ο ∷ ∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.8" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.8" ∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.8" ∷ word (ἵ ∷ ν ∷ α ∷ []) "3John.1.8" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ο ∷ ὶ ∷ []) "3John.1.8" ∷ word (γ ∷ ι ∷ ν ∷ ώ ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "3John.1.8" ∷ word (τ ∷ ῇ ∷ []) "3John.1.8" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "3John.1.8" ∷ word (Ἔ ∷ γ ∷ ρ ∷ α ∷ ψ ∷ ά ∷ []) "3John.1.9" ∷ word (τ ∷ ι ∷ []) "3John.1.9" ∷ word (τ ∷ ῇ ∷ []) "3John.1.9" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "3John.1.9" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "3John.1.9" ∷ word (ὁ ∷ []) "3John.1.9" ∷ word (φ ∷ ι ∷ ∙λ ∷ ο ∷ π ∷ ρ ∷ ω ∷ τ ∷ ε ∷ ύ ∷ ω ∷ ν ∷ []) "3John.1.9" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "3John.1.9" ∷ word (Δ ∷ ι ∷ ο ∷ τ ∷ ρ ∷ έ ∷ φ ∷ η ∷ ς ∷ []) "3John.1.9" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "3John.1.9" ∷ word (ἐ ∷ π ∷ ι ∷ δ ∷ έ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "3John.1.9" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "3John.1.9" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "3John.1.10" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "3John.1.10" ∷ word (ἐ ∷ ὰ ∷ ν ∷ []) "3John.1.10" ∷ word (ἔ ∷ ∙λ ∷ θ ∷ ω ∷ []) "3John.1.10" ∷ word (ὑ ∷ π ∷ ο ∷ μ ∷ ν ∷ ή ∷ σ ∷ ω ∷ []) "3John.1.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "3John.1.10" ∷ word (τ ∷ ὰ ∷ []) "3John.1.10" ∷ word (ἔ ∷ ρ ∷ γ ∷ α ∷ []) "3John.1.10" ∷ word (ἃ ∷ []) "3John.1.10" ∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ []) "3John.1.10" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ι ∷ ς ∷ []) "3John.1.10" ∷ word (π ∷ ο ∷ ν ∷ η ∷ ρ ∷ ο ∷ ῖ ∷ ς ∷ []) "3John.1.10" ∷ word (φ ∷ ∙λ ∷ υ ∷ α ∷ ρ ∷ ῶ ∷ ν ∷ []) "3John.1.10" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "3John.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10" ∷ word (μ ∷ ὴ ∷ []) "3John.1.10" ∷ word (ἀ ∷ ρ ∷ κ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "3John.1.10" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "3John.1.10" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "3John.1.10" ∷ word (ο ∷ ὔ ∷ τ ∷ ε ∷ []) "3John.1.10" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "3John.1.10" ∷ word (ἐ ∷ π ∷ ι ∷ δ ∷ έ ∷ χ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "3John.1.10" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.10" ∷ word (β ∷ ο ∷ υ ∷ ∙λ ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.10" ∷ word (κ ∷ ω ∷ ∙λ ∷ ύ ∷ ε ∷ ι ∷ []) "3John.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.10" ∷ word (ἐ ∷ κ ∷ []) "3John.1.10" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "3John.1.10" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "3John.1.10" ∷ word (ἐ ∷ κ ∷ β ∷ ά ∷ ∙λ ∷ ∙λ ∷ ε ∷ ι ∷ []) "3John.1.10" ∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ έ ∷ []) "3John.1.11" ∷ word (μ ∷ ὴ ∷ []) "3John.1.11" ∷ word (μ ∷ ι ∷ μ ∷ ο ∷ ῦ ∷ []) "3John.1.11" ∷ word (τ ∷ ὸ ∷ []) "3John.1.11" ∷ word (κ ∷ α ∷ κ ∷ ὸ ∷ ν ∷ []) "3John.1.11" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "3John.1.11" ∷ word (τ ∷ ὸ ∷ []) "3John.1.11" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ό ∷ ν ∷ []) "3John.1.11" ∷ word (ὁ ∷ []) "3John.1.11" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ο ∷ π ∷ ο ∷ ι ∷ ῶ ∷ ν ∷ []) "3John.1.11" ∷ word (ἐ ∷ κ ∷ []) "3John.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "3John.1.11" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "3John.1.11" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "3John.1.11" ∷ word (ὁ ∷ []) "3John.1.11" ∷ word (κ ∷ α ∷ κ ∷ ο ∷ π ∷ ο ∷ ι ∷ ῶ ∷ ν ∷ []) "3John.1.11" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "3John.1.11" ∷ word (ἑ ∷ ώ ∷ ρ ∷ α ∷ κ ∷ ε ∷ ν ∷ []) "3John.1.11" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "3John.1.11" ∷ word (θ ∷ ε ∷ ό ∷ ν ∷ []) "3John.1.11" ∷ word (Δ ∷ η ∷ μ ∷ η ∷ τ ∷ ρ ∷ ί ∷ ῳ ∷ []) "3John.1.12" ∷ word (μ ∷ ε ∷ μ ∷ α ∷ ρ ∷ τ ∷ ύ ∷ ρ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "3John.1.12" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "3John.1.12" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "3John.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "3John.1.12" ∷ word (α ∷ ὐ ∷ τ ∷ ῆ ∷ ς ∷ []) "3John.1.12" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "3John.1.12" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "3John.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12" ∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "3John.1.12" ∷ word (δ ∷ ὲ ∷ []) "3John.1.12" ∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ο ∷ ῦ ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.12" ∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ ς ∷ []) "3John.1.12" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "3John.1.12" ∷ word (ἡ ∷ []) "3John.1.12" ∷ word (μ ∷ α ∷ ρ ∷ τ ∷ υ ∷ ρ ∷ ί ∷ α ∷ []) "3John.1.12" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "3John.1.12" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ή ∷ ς ∷ []) "3John.1.12" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "3John.1.12" ∷ word (Π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "3John.1.13" ∷ word (ε ∷ ἶ ∷ χ ∷ ο ∷ ν ∷ []) "3John.1.13" ∷ word (γ ∷ ρ ∷ ά ∷ ψ ∷ α ∷ ι ∷ []) "3John.1.13" ∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.13" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "3John.1.13" ∷ word (ο ∷ ὐ ∷ []) "3John.1.13" ∷ word (θ ∷ έ ∷ ∙λ ∷ ω ∷ []) "3John.1.13" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "3John.1.13" ∷ word (μ ∷ έ ∷ ∙λ ∷ α ∷ ν ∷ ο ∷ ς ∷ []) "3John.1.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.13" ∷ word (κ ∷ α ∷ ∙λ ∷ ά ∷ μ ∷ ο ∷ υ ∷ []) "3John.1.13" ∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.13" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "3John.1.13" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "3John.1.14" ∷ word (δ ∷ ὲ ∷ []) "3John.1.14" ∷ word (ε ∷ ὐ ∷ θ ∷ έ ∷ ω ∷ ς ∷ []) "3John.1.14" ∷ word (σ ∷ ε ∷ []) "3John.1.14" ∷ word (ἰ ∷ δ ∷ ε ∷ ῖ ∷ ν ∷ []) "3John.1.14" ∷ word (κ ∷ α ∷ ὶ ∷ []) "3John.1.14" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "3John.1.14" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "3John.1.14" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "3John.1.14" ∷ word (∙λ ∷ α ∷ ∙λ ∷ ή ∷ σ ∷ ο ∷ μ ∷ ε ∷ ν ∷ []) "3John.1.14" ∷ word (Ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "3John.1.15" ∷ word (σ ∷ ο ∷ ι ∷ []) "3John.1.15" ∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ ί ∷ []) "3John.1.15" ∷ word (σ ∷ ε ∷ []) "3John.1.15" ∷ word (ο ∷ ἱ ∷ []) "3John.1.15" ∷ word (φ ∷ ί ∷ ∙λ ∷ ο ∷ ι ∷ []) "3John.1.15" ∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ υ ∷ []) "3John.1.15" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "3John.1.15" ∷ word (φ ∷ ί ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "3John.1.15" ∷ word (κ ∷ α ∷ τ ∷ []) "3John.1.15" ∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "3John.1.15" ∷ []
programs/oeis/197/A197605.asm
karttu/loda
0
86950
; A197605: Floor( ( n + 1/n )^6 ). ; 64,244,1371,5892,19770,54992,132810,287700,572042,1061520,1861242,3112580,5000730,7762992,11697770,17174292,24643050,34646960,47833242,64966020,86939642,114792720,149722890,193102292,246493770,311667792,390620090,485590020,599079642,733873520,893059242,1080048660,1298599850,1552839792,1847287770,2186879492,2576991930,3023468880,3532647242,4111384020,4767084042,5507728400,6341903610,7278831492,8328399770,9501193392,10808526570,12262475540,13875912042,15662537520,17636918042,19814519940,22211746170,24845973392,27735589770,30900033492,34359832010,38136642000,42253290042,46733814020,51603505242,56888951280,62618079530,68820201492,75526057770,82767863792,90579356250,98995840260,108054237242,117793133520,128252829642,139475390420,151504695690,164386491792,178168443770,192900188292,208633387290,225421782320,243321249642,262389856020,282687915242,304278045360,327225226650,351596860292,377462827770,404895550992,433970053130,464764020180,497357863242,531834781520,568280826042,606784964100,647439144410,690338362992,735580729770,783267535892,833503321770,886395945840,942056654042,1000600150020,1062144666042,1126812034640,1194727760970,1266021095892,1340825109770,1419276766992,1501517001210,1587690791300,1677947238042,1772439641520,1871325579242,1974766984980,2082930228330,2195986194992,2314110367770,2437482908292,2566288739450,2700717628560,2840964271242,2987228376020,3139714749642,3298633383120,3464199538490,3636633836292,3816162343770,4003016663792,4197434024490,4399657369620,4609935449642,4828522913520,5055680401242,5291674637060,5536778523450,5791271235792,6055438317770,6329571777492,6613970184330,6908938766480,7214789509242,7531841254020,7860419798042,8200857994800,8553495855210,8918680649492,9296767009770,9688117033392,10093100386970,10512094411140,10945484226042,11393662837520,11857031244042,12335998544340,12830982045770,13342407373392,13870708579770,14416328255492,14979717640410,15561336735600,16161654416042,16781148544020,17420306083242,18079623213680,18759605447130,19460767743492,20183634627770,20928740307792,21696628792650,22487854011860,23302979935242,24142580693520,25007240699642,25897554770820,26814128251290,27757577135792,28728528193770,29727619094292,30755498531690,31812826351920,32900273679642,34018523046020,35168268517242,36350215823760,37565082490250,38813597966292,40096503757770,41414553558992,42768513385530,44159161707780,45587289585242,47053700801520,48559212000042,50104652820500,51690866036010,53318707690992,54989047239770,56702767685892,58460765722170,60263951871440,62113250628042,64009600600020,65953954652042,67947280049040,69990558600570,72084786805892,74230975999770,76430152498992,78683357749610,80991648474900,83356096824042,85777790521520,88257833017242,90797343637380,93397457735930,96059326846992,98784118837770,101573018062292,104427225515850,107347958990160,110336453229242,113393960086020,116521748679642,119721105553520,122993334834090,126339758390292,129761715993770,133260565479792,136837682908890,140494462729220,144232317939642,148052680253520,151957000263242,155946747605460,160023411127050,164188499051792,168443539147770,172790078895492,177229685656730,181763946844080,186394470091242,191122883424020,195950835432042,200879995441200,205912053686810,211048721487492,216291731419770,221642837493392,227103815327370,232676462326740,238362597860042,244164063437520 mov $3,$0 add $3,$0 trn $3,2 mov $5,$0 mov $0,$3 add $0,4 mov $2,4 sub $2,$3 trn $2,1 trn $3,1 add $3,2 lpb $0,1 sub $0,1 mov $1,$3 add $1,4 mov $3,$2 mov $2,4 add $3,$1 lpe add $1,35 mov $4,42 mov $6,$5 lpb $4,1 add $1,$6 sub $4,1 lpe mov $8,$5 lpb $8,1 add $7,$6 sub $8,1 lpe mov $4,66 mov $6,$7 lpb $4,1 add $1,$6 sub $4,1 lpe mov $7,0 mov $8,$5 lpb $8,1 add $7,$6 sub $8,1 lpe mov $4,44 mov $6,$7 lpb $4,1 add $1,$6 sub $4,1 lpe mov $7,0 mov $8,$5 lpb $8,1 add $7,$6 sub $8,1 lpe mov $4,21 mov $6,$7 lpb $4,1 add $1,$6 sub $4,1 lpe mov $7,0 mov $8,$5 lpb $8,1 add $7,$6 sub $8,1 lpe mov $4,6 mov $6,$7 lpb $4,1 add $1,$6 sub $4,1 lpe mov $7,0 mov $8,$5 lpb $8,1 add $7,$6 sub $8,1 lpe mov $4,1 mov $6,$7 lpb $4,1 add $1,$6 sub $4,1 lpe
antlr/Java9/Java.g4
sanyaade-teachings/spresensedroplet
3
6645
/* * [The "BSD license"] * Copyright (c) 2014 <NAME> * Copyright (c) 2014 <NAME> * Copyright (c) 2017 <NAME> * Updated 2018 by <NAME> * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ /** * A Java 9 grammar for ANTLR 4 derived from the Java Language Specification * * $ antlr4 Java.g4 * $ javac *.java * $ grun Java compilationUnit *.java * */ grammar Java; /* * Productions from §3 (Lexical Structure) */ literal : IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral ; /* * Productions from §4 (Types, Values, and Variables) */ primitiveType : annotation* numericType | annotation* 'boolean' ; numericType : integralType | floatingPointType ; integralType : 'byte' | 'short' | 'int' | 'long' | 'char' ; floatingPointType : 'float' | 'double' ; referenceType : classOrInterfaceType | typeVariable | arrayType ; /*classOrInterfaceType : classType | interfaceType ; */ classOrInterfaceType : ( classType_lfno_classOrInterfaceType | interfaceType_lfno_classOrInterfaceType ) ( classType_lf_classOrInterfaceType | interfaceType_lf_classOrInterfaceType )* ; classType : annotation* identifier typeArguments? | classOrInterfaceType '.' annotation* identifier typeArguments? ; classType_lf_classOrInterfaceType : '.' annotation* identifier typeArguments? ; classType_lfno_classOrInterfaceType : annotation* identifier typeArguments? ; interfaceType : classType ; interfaceType_lf_classOrInterfaceType : classType_lf_classOrInterfaceType ; interfaceType_lfno_classOrInterfaceType : classType_lfno_classOrInterfaceType ; typeVariable : annotation* identifier ; arrayType : primitiveType dims | classOrInterfaceType dims | typeVariable dims ; dims : annotation* '[' ']' (annotation* '[' ']')* ; typeParameter : typeParameterModifier* identifier typeBound? ; typeParameterModifier : annotation ; typeBound : 'extends' typeVariable | 'extends' classOrInterfaceType additionalBound* ; additionalBound : '&' interfaceType ; typeArguments : '<' typeArgumentList '>' ; typeArgumentList : typeArgument (',' typeArgument)* ; typeArgument : referenceType | wildcard ; wildcard : annotation* '?' wildcardBounds? ; wildcardBounds : 'extends' referenceType | 'super' referenceType ; /* * Productions from §6 (Names) */ moduleName : identifier | moduleName '.' identifier ; packageName : identifier | packageName '.' identifier ; typeName : identifier | packageOrTypeName '.' identifier ; packageOrTypeName : identifier | packageOrTypeName '.' identifier ; expressionName : identifier | ambiguousName '.' identifier ; methodName : identifier ; ambiguousName : identifier | ambiguousName '.' identifier ; /* * Productions from §7 (Packages) */ compilationUnit : ordinaryCompilation | modularCompilation ; ordinaryCompilation : packageDeclaration? importDeclaration* typeDeclaration* EOF ; modularCompilation : importDeclaration* moduleDeclaration ; packageDeclaration : packageModifier* 'package' packageName ';' ; packageModifier : annotation ; importDeclaration : singleTypeImportDeclaration | typeImportOnDemandDeclaration | singleStaticImportDeclaration | staticImportOnDemandDeclaration ; singleTypeImportDeclaration : 'import' typeName ';' ; typeImportOnDemandDeclaration : 'import' packageOrTypeName '.' '*' ';' ; singleStaticImportDeclaration : 'import' 'static' typeName '.' identifier ';' ; staticImportOnDemandDeclaration : 'import' 'static' typeName '.' '*' ';' ; typeDeclaration : classDeclaration | interfaceDeclaration | ';' ; moduleDeclaration : annotation* 'open'? 'module' moduleName '{' moduleDirective* '}' ; moduleDirective : 'requires' requiresModifier* moduleName ';' | 'exports' packageName ('to' moduleName (',' moduleName)*)? ';' | 'opens' packageName ('to' moduleName (',' moduleName)*)? ';' | 'uses' typeName ';' | 'provides' typeName 'with' typeName (',' typeName)* ';' ; requiresModifier : 'transitive' | 'static' ; /* * Productions from §8 (Classes) */ classDeclaration : normalClassDeclaration | enumDeclaration ; normalClassDeclaration : classModifier* 'class' identifier typeParameters? superclass? superinterfaces? classBody ; classModifier : annotation | 'public' | 'protected' | 'private' | 'abstract' | 'static' | 'final' | 'strictfp' ; typeParameters : '<' typeParameterList '>' ; typeParameterList : typeParameter (',' typeParameter)* ; superclass : 'extends' classType ; superinterfaces : 'implements' interfaceTypeList ; interfaceTypeList : interfaceType (',' interfaceType)* ; classBody : '{' classBodyDeclaration* '}' ; classBodyDeclaration : classMemberDeclaration | instanceInitializer | staticInitializer | constructorDeclaration ; classMemberDeclaration : fieldDeclaration | methodDeclaration | classDeclaration | interfaceDeclaration | ';' ; fieldDeclaration : fieldModifier* unannType variableDeclaratorList ';' ; fieldModifier : annotation | 'public' | 'protected' | 'private' | 'static' | 'final' | 'transient' | 'volatile' ; variableDeclaratorList : variableDeclarator (',' variableDeclarator)* ; variableDeclarator : variableDeclaratorId ('=' variableInitializer)? ; variableDeclaratorId : identifier dims? ; variableInitializer : expression | arrayInitializer ; unannType : unannPrimitiveType | unannReferenceType ; unannPrimitiveType : numericType | 'boolean' ; unannReferenceType : unannClassOrInterfaceType | unannTypeVariable | unannArrayType ; /*unannClassOrInterfaceType : unannClassType | unannInterfaceType ; */ unannClassOrInterfaceType : ( unannClassType_lfno_unannClassOrInterfaceType | unannInterfaceType_lfno_unannClassOrInterfaceType ) ( unannClassType_lf_unannClassOrInterfaceType | unannInterfaceType_lf_unannClassOrInterfaceType )* ; unannClassType : identifier typeArguments? | unannClassOrInterfaceType '.' annotation* identifier typeArguments? ; unannClassType_lf_unannClassOrInterfaceType : '.' annotation* identifier typeArguments? ; unannClassType_lfno_unannClassOrInterfaceType : identifier typeArguments? ; unannInterfaceType : unannClassType ; unannInterfaceType_lf_unannClassOrInterfaceType : unannClassType_lf_unannClassOrInterfaceType ; unannInterfaceType_lfno_unannClassOrInterfaceType : unannClassType_lfno_unannClassOrInterfaceType ; unannTypeVariable : identifier ; unannArrayType : unannPrimitiveType dims | unannClassOrInterfaceType dims | unannTypeVariable dims ; methodDeclaration : methodModifier* methodHeader methodBody ; methodModifier : annotation | 'public' | 'protected' | 'private' | 'abstract' | 'static' | 'final' | 'synchronized' | 'native' | 'strictfp' ; methodHeader : result methodDeclarator throws_? | typeParameters annotation* result methodDeclarator throws_? ; result : unannType | 'void' ; methodDeclarator : identifier '(' formalParameterList? ')' dims? ; formalParameterList : formalParameters ',' lastFormalParameter | lastFormalParameter | receiverParameter ; formalParameters : formalParameter (',' formalParameter)* | receiverParameter (',' formalParameter)* ; formalParameter : variableModifier* unannType variableDeclaratorId ; variableModifier : annotation | 'final' ; lastFormalParameter : variableModifier* unannType annotation* '...' variableDeclaratorId | formalParameter ; receiverParameter : annotation* unannType (identifier '.')? 'this' ; throws_ : 'throws' exceptionTypeList ; exceptionTypeList : exceptionType (',' exceptionType)* ; exceptionType : classType | typeVariable ; methodBody : block | ';' ; instanceInitializer : block ; staticInitializer : 'static' block ; constructorDeclaration : constructorModifier* constructorDeclarator throws_? constructorBody ; constructorModifier : annotation | 'public' | 'protected' | 'private' ; constructorDeclarator : typeParameters? simpleTypeName '(' formalParameterList? ')' ; simpleTypeName : identifier ; constructorBody : '{' explicitConstructorInvocation? blockStatements? '}' ; explicitConstructorInvocation : typeArguments? 'this' '(' argumentList? ')' ';' | typeArguments? 'super' '(' argumentList? ')' ';' | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' ; enumDeclaration : classModifier* 'enum' identifier superinterfaces? enumBody ; enumBody : '{' enumConstantList? ','? enumBodyDeclarations? '}' ; enumConstantList : enumConstant (',' enumConstant)* ; enumConstant : enumConstantModifier* identifier ('(' argumentList? ')')? classBody? ; enumConstantModifier : annotation ; enumBodyDeclarations : ';' classBodyDeclaration* ; /* * Productions from §9 (Interfaces) */ interfaceDeclaration : normalInterfaceDeclaration | annotationTypeDeclaration ; normalInterfaceDeclaration : interfaceModifier* 'interface' identifier typeParameters? extendsInterfaces? interfaceBody ; interfaceModifier : annotation | 'public' | 'protected' | 'private' | 'abstract' | 'static' | 'strictfp' ; extendsInterfaces : 'extends' interfaceTypeList ; interfaceBody : '{' interfaceMemberDeclaration* '}' ; interfaceMemberDeclaration : constantDeclaration | interfaceMethodDeclaration | classDeclaration | interfaceDeclaration | ';' ; constantDeclaration : constantModifier* unannType variableDeclaratorList ';' ; constantModifier : annotation | 'public' | 'static' | 'final' ; interfaceMethodDeclaration : interfaceMethodModifier* methodHeader methodBody ; interfaceMethodModifier : annotation | 'public' | 'private'//Introduced in Java 9 | 'abstract' | 'default' | 'static' | 'strictfp' ; annotationTypeDeclaration : interfaceModifier* '@' 'interface' identifier annotationTypeBody ; annotationTypeBody : '{' annotationTypeMemberDeclaration* '}' ; annotationTypeMemberDeclaration : annotationTypeElementDeclaration | constantDeclaration | classDeclaration | interfaceDeclaration | ';' ; annotationTypeElementDeclaration : annotationTypeElementModifier* unannType identifier '(' ')' dims? defaultValue? ';' ; annotationTypeElementModifier : annotation | 'public' | 'abstract' ; defaultValue : 'default' elementValue ; annotation : normalAnnotation | markerAnnotation | singleElementAnnotation ; normalAnnotation : '@' typeName '(' elementValuePairList? ')' ; elementValuePairList : elementValuePair (',' elementValuePair)* ; elementValuePair : identifier '=' elementValue ; elementValue : conditionalExpression | elementValueArrayInitializer | annotation ; elementValueArrayInitializer : '{' elementValueList? ','? '}' ; elementValueList : elementValue (',' elementValue)* ; markerAnnotation : '@' typeName ; singleElementAnnotation : '@' typeName '(' elementValue ')' ; /* * Productions from §10 (Arrays) */ arrayInitializer : '{' variableInitializerList? ','? '}' ; variableInitializerList : variableInitializer (',' variableInitializer)* ; /* * Productions from §14 (Blocks and Statements) */ block : '{' blockStatements? '}' ; blockStatements : blockStatement+ ; blockStatement : localVariableDeclarationStatement | classDeclaration | statement ; localVariableDeclarationStatement : localVariableDeclaration ';' ; localVariableDeclaration : variableModifier* unannType variableDeclaratorList ; statement : statementWithoutTrailingSubstatement | labeledStatement | ifThenStatement | ifThenElseStatement | whileStatement | forStatement ; statementNoShortIf : statementWithoutTrailingSubstatement | labeledStatementNoShortIf | ifThenElseStatementNoShortIf | whileStatementNoShortIf | forStatementNoShortIf ; statementWithoutTrailingSubstatement : block | emptyStatement | expressionStatement | assertStatement | switchStatement | doStatement | breakStatement | continueStatement | returnStatement | synchronizedStatement | throwStatement | tryStatement ; emptyStatement : ';' ; labeledStatement : identifier ':' statement ; labeledStatementNoShortIf : identifier ':' statementNoShortIf ; expressionStatement : statementExpression ';' ; statementExpression : assignment | preIncrementExpression | preDecrementExpression | postIncrementExpression | postDecrementExpression | methodInvocation | classInstanceCreationExpression ; ifThenStatement : 'if' '(' expression ')' statement ; ifThenElseStatement : 'if' '(' expression ')' statementNoShortIf 'else' statement ; ifThenElseStatementNoShortIf : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf ; assertStatement : 'assert' expression ';' | 'assert' expression ':' expression ';' ; switchStatement : 'switch' '(' expression ')' switchBlock ; switchBlock : '{' switchBlockStatementGroup* switchLabel* '}' ; switchBlockStatementGroup : switchLabels blockStatements ; switchLabels : switchLabel+ ; switchLabel : 'case' constantExpression ':' | 'case' enumConstantName ':' | 'default' ':' ; enumConstantName : identifier ; whileStatement : 'while' '(' expression ')' statement ; whileStatementNoShortIf : 'while' '(' expression ')' statementNoShortIf ; doStatement : 'do' statement 'while' '(' expression ')' ';' ; forStatement : basicForStatement | enhancedForStatement ; forStatementNoShortIf : basicForStatementNoShortIf | enhancedForStatementNoShortIf ; basicForStatement : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement ; basicForStatementNoShortIf : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf ; forInit : statementExpressionList | localVariableDeclaration ; forUpdate : statementExpressionList ; statementExpressionList : statementExpression (',' statementExpression)* ; enhancedForStatement : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement ; enhancedForStatementNoShortIf : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf ; breakStatement : 'break' identifier? ';' ; continueStatement : 'continue' identifier? ';' ; returnStatement : 'return' expression? ';' ; throwStatement : 'throw' expression ';' ; synchronizedStatement : 'synchronized' '(' expression ')' block ; tryStatement : 'try' block catches | 'try' block catches? finally_ | tryWithResourcesStatement ; catches : catchClause+ ; catchClause : 'catch' '(' catchFormalParameter ')' block ; catchFormalParameter : variableModifier* catchType variableDeclaratorId ; catchType : unannClassType ('|' classType)* ; finally_ : 'finally' block ; tryWithResourcesStatement : 'try' resourceSpecification block catches? finally_? ; resourceSpecification : '(' resourceList ';'? ')' ; resourceList : resource (';' resource)* ; resource : variableModifier* unannType variableDeclaratorId '=' expression | variableAccess//Introduced in Java 9 ; variableAccess : expressionName | fieldAccess ; /* * Productions from §15 (Expressions) */ /*primary : primaryNoNewArray | arrayCreationExpression ; */ primary : ( primaryNoNewArray_lfno_primary | arrayCreationExpression ) ( primaryNoNewArray_lf_primary )* ; primaryNoNewArray : literal | classLiteral | 'this' | typeName '.' 'this' | '(' expression ')' | classInstanceCreationExpression | fieldAccess | arrayAccess | methodInvocation | methodReference ; primaryNoNewArray_lf_arrayAccess : ; primaryNoNewArray_lfno_arrayAccess : literal | typeName ('[' ']')* '.' 'class' | 'void' '.' 'class' | 'this' | typeName '.' 'this' | '(' expression ')' | classInstanceCreationExpression | fieldAccess | methodInvocation | methodReference ; primaryNoNewArray_lf_primary : classInstanceCreationExpression_lf_primary | fieldAccess_lf_primary | arrayAccess_lf_primary | methodInvocation_lf_primary | methodReference_lf_primary ; primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary : ; primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary : classInstanceCreationExpression_lf_primary | fieldAccess_lf_primary | methodInvocation_lf_primary | methodReference_lf_primary ; primaryNoNewArray_lfno_primary : literal | typeName ('[' ']')* '.' 'class' | unannPrimitiveType ('[' ']')* '.' 'class' | 'void' '.' 'class' | 'this' | typeName '.' 'this' | '(' expression ')' | classInstanceCreationExpression_lfno_primary | fieldAccess_lfno_primary | arrayAccess_lfno_primary | methodInvocation_lfno_primary | methodReference_lfno_primary ; primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary : ; primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary : literal | typeName ('[' ']')* '.' 'class' | unannPrimitiveType ('[' ']')* '.' 'class' | 'void' '.' 'class' | 'this' | typeName '.' 'this' | '(' expression ')' | classInstanceCreationExpression_lfno_primary | fieldAccess_lfno_primary | methodInvocation_lfno_primary | methodReference_lfno_primary ; classLiteral : (typeName|numericType|'boolean') ('[' ']')* '.' 'class' | 'void' '.' 'class' ; classInstanceCreationExpression : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? | primary '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? ; classInstanceCreationExpression_lf_primary : '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? ; classInstanceCreationExpression_lfno_primary : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? ; typeArgumentsOrDiamond : typeArguments | '<' '>' ; fieldAccess : primary '.' identifier | 'super' '.' identifier | typeName '.' 'super' '.' identifier ; fieldAccess_lf_primary : '.' identifier ; fieldAccess_lfno_primary : 'super' '.' identifier | typeName '.' 'super' '.' identifier ; /*arrayAccess : expressionName '[' expression ']' | primaryNoNewArray '[' expression ']' ; */ arrayAccess : ( expressionName '[' expression ']' | primaryNoNewArray_lfno_arrayAccess '[' expression ']' ) ( primaryNoNewArray_lf_arrayAccess '[' expression ']' )* ; arrayAccess_lf_primary : ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' ) ( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' )* ; arrayAccess_lfno_primary : ( expressionName '[' expression ']' | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' ) ( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']' )* ; methodInvocation : methodName '(' argumentList? ')' | typeName '.' typeArguments? identifier '(' argumentList? ')' | expressionName '.' typeArguments? identifier '(' argumentList? ')' | primary '.' typeArguments? identifier '(' argumentList? ')' | 'super' '.' typeArguments? identifier '(' argumentList? ')' | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' ; methodInvocation_lf_primary : '.' typeArguments? identifier '(' argumentList? ')' ; methodInvocation_lfno_primary : methodName '(' argumentList? ')' | typeName '.' typeArguments? identifier '(' argumentList? ')' | expressionName '.' typeArguments? identifier '(' argumentList? ')' | 'super' '.' typeArguments? identifier '(' argumentList? ')' | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' ; argumentList : expression (',' expression)* ; methodReference : expressionName '::' typeArguments? identifier | referenceType '::' typeArguments? identifier | primary '::' typeArguments? identifier | 'super' '::' typeArguments? identifier | typeName '.' 'super' '::' typeArguments? identifier | classType '::' typeArguments? 'new' | arrayType '::' 'new' ; methodReference_lf_primary : '::' typeArguments? identifier ; methodReference_lfno_primary : expressionName '::' typeArguments? identifier | referenceType '::' typeArguments? identifier | 'super' '::' typeArguments? identifier | typeName '.' 'super' '::' typeArguments? identifier | classType '::' typeArguments? 'new' | arrayType '::' 'new' ; arrayCreationExpression : 'new' primitiveType dimExprs dims? | 'new' classOrInterfaceType dimExprs dims? | 'new' primitiveType dims arrayInitializer | 'new' classOrInterfaceType dims arrayInitializer ; dimExprs : dimExpr+ ; dimExpr : annotation* '[' expression ']' ; constantExpression : expression ; expression : lambdaExpression | assignmentExpression ; lambdaExpression : lambdaParameters '->' lambdaBody ; lambdaParameters : identifier | '(' formalParameterList? ')' | '(' inferredFormalParameterList ')' ; inferredFormalParameterList : identifier (',' identifier)* ; lambdaBody : expression | block ; assignmentExpression : conditionalExpression | assignment ; assignment : leftHandSide assignmentOperator expression ; leftHandSide : expressionName | fieldAccess | arrayAccess ; assignmentOperator : '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|=' ; conditionalExpression : conditionalOrExpression | conditionalOrExpression '?' expression ':' (conditionalExpression|lambdaExpression) ; conditionalOrExpression : conditionalAndExpression | conditionalOrExpression '||' conditionalAndExpression ; conditionalAndExpression : inclusiveOrExpression | conditionalAndExpression '&&' inclusiveOrExpression ; inclusiveOrExpression : exclusiveOrExpression | inclusiveOrExpression '|' exclusiveOrExpression ; exclusiveOrExpression : andExpression | exclusiveOrExpression '^' andExpression ; andExpression : equalityExpression | andExpression '&' equalityExpression ; equalityExpression : relationalExpression | equalityExpression '==' relationalExpression | equalityExpression '!=' relationalExpression ; relationalExpression : shiftExpression | relationalExpression '<' shiftExpression | relationalExpression '>' shiftExpression | relationalExpression '<=' shiftExpression | relationalExpression '>=' shiftExpression | relationalExpression 'instanceof' referenceType ; shiftExpression : additiveExpression | shiftExpression '<' '<' additiveExpression | shiftExpression '>' '>' additiveExpression | shiftExpression '>' '>' '>' additiveExpression ; additiveExpression : multiplicativeExpression | additiveExpression '+' multiplicativeExpression | additiveExpression '-' multiplicativeExpression ; multiplicativeExpression : unaryExpression | multiplicativeExpression '*' unaryExpression | multiplicativeExpression '/' unaryExpression | multiplicativeExpression '%' unaryExpression ; unaryExpression : preIncrementExpression | preDecrementExpression | '+' unaryExpression | '-' unaryExpression | unaryExpressionNotPlusMinus ; preIncrementExpression : '++' unaryExpression ; preDecrementExpression : '--' unaryExpression ; unaryExpressionNotPlusMinus : postfixExpression | '~' unaryExpression | '!' unaryExpression | castExpression ; /*postfixExpression : primary | expressionName | postIncrementExpression | postDecrementExpression ; */ postfixExpression : ( primary | expressionName ) ( postIncrementExpression_lf_postfixExpression | postDecrementExpression_lf_postfixExpression )* ; postIncrementExpression : postfixExpression '++' ; postIncrementExpression_lf_postfixExpression : '++' ; postDecrementExpression : postfixExpression '--' ; postDecrementExpression_lf_postfixExpression : '--' ; castExpression : '(' primitiveType ')' unaryExpression | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus | '(' referenceType additionalBound* ')' lambdaExpression ; /** * Droplet modifications for Java 9 to handle EOF */ literal_DropletFile : IntegerLiteral EOF | FloatingPointLiteral EOF | BooleanLiteral EOF | CharacterLiteral EOF | StringLiteral EOF | NullLiteral EOF ; /* * Productions from §4 (Types, Values, and Variables) */ primitiveType_DropletFile : annotation* numericType EOF | annotation* 'boolean' EOF ; numericType_DropletFile : integralType EOF | floatingPointType EOF ; integralType_DropletFile : 'byte' EOF | 'short' EOF | 'int' EOF | 'long' EOF | 'char' EOF ; floatingPointType_DropletFile : 'float' EOF | 'double' EOF ; referenceType_DropletFile : classOrInterfaceType EOF | typeVariable EOF | arrayType EOF ; /*classOrInterfaceType_DropletFile : classType EOF | interfaceType EOF ; */ classOrInterfaceType_DropletFile : ( classType_lfno_classOrInterfaceType | interfaceType_lfno_classOrInterfaceType ) ( classType_lf_classOrInterfaceType | interfaceType_lf_classOrInterfaceType )* EOF ; classType_DropletFile : annotation* identifier typeArguments? EOF | classOrInterfaceType '.' annotation* identifier typeArguments? EOF ; classType_lf_classOrInterfaceType_DropletFile : '.' annotation* identifier typeArguments? EOF ; classType_lfno_classOrInterfaceType_DropletFile : annotation* identifier typeArguments? EOF ; interfaceType_DropletFile : classType EOF ; interfaceType_lf_classOrInterfaceType_DropletFile : classType_lf_classOrInterfaceType EOF ; interfaceType_lfno_classOrInterfaceType_DropletFile : classType_lfno_classOrInterfaceType EOF ; typeVariable_DropletFile : annotation* identifier EOF ; arrayType_DropletFile : primitiveType dims EOF | classOrInterfaceType dims EOF | typeVariable dims EOF ; dims_DropletFile : annotation* '[' ']' (annotation* '[' ']')* EOF ; typeParameter_DropletFile : typeParameterModifier* identifier typeBound? ; typeParameterModifier_DropletFile : annotation EOF ; typeBound_DropletFile : 'extends' typeVariable EOF | 'extends' classOrInterfaceType additionalBound* EOF ; additionalBound_DropletFile : '&' interfaceType EOF ; typeArguments_DropletFile : '<' typeArgumentList '>' EOF ; typeArgumentList_DropletFile : typeArgument (',' typeArgument)* EOF ; typeArgument_DropletFile : referenceType EOF | wildcard EOF ; wildcard_DropletFile : annotation* '?' wildcardBounds? EOF ; wildcardBounds_DropletFile : 'extends' referenceType EOF | 'super' referenceType EOF ; /* * Productions from §6 (Names) */ moduleName_DropletFile : identifier EOF | moduleName '.' identifier EOF ; packageName_DropletFile : identifier EOF | packageName '.' identifier EOF ; typeName_DropletFile : identifier EOF | packageOrTypeName '.' identifier EOF ; packageOrTypeName_DropletFile : identifier EOF | packageOrTypeName '.' identifier EOF ; expressionName_DropletFile : identifier EOF | ambiguousName '.' identifier EOF ; methodName_DropletFile : identifier EOF ; ambiguousName_DropletFile : identifier EOF | ambiguousName '.' identifier EOF ; /* * Productions from §7 (Packages) */ compilationUnit_DropletFile : ordinaryCompilation EOF | modularCompilation EOF ; ordinaryCompilation_DropletFile : packageDeclaration? importDeclaration* typeDeclaration* EOF ; modularCompilation_DropletFile : importDeclaration* moduleDeclaration EOF ; packageDeclaration_DropletFile : packageModifier* 'package' packageName ';' EOF ; packageModifier_DropletFile : annotation EOF ; importDeclaration_DropletFile : singleTypeImportDeclaration EOF | typeImportOnDemandDeclaration EOF | singleStaticImportDeclaration EOF | staticImportOnDemandDeclaration EOF ; singleTypeImportDeclaration_DropletFile : 'import' typeName ';' EOF ; typeImportOnDemandDeclaration_DropletFile : 'import' packageOrTypeName '.' '*' ';' EOF ; singleStaticImportDeclaration_DropletFile : 'import' 'static' typeName '.' identifier ';' EOF ; staticImportOnDemandDeclaration_DropletFile : 'import' 'static' typeName '.' '*' ';' EOF ; typeDeclaration_DropletFile : classDeclaration EOF | interfaceDeclaration EOF | ';' EOF ; moduleDeclaration_DropletFile : annotation* 'open'? 'module' moduleName '{' moduleDirective* '}' EOF ; moduleDirective_DropletFile : 'requires' requiresModifier* moduleName ';' EOF | 'exports' packageName ('to' moduleName (',' moduleName)*)? ';' EOF | 'opens' packageName ('to' moduleName (',' moduleName)*)? ';' EOF | 'uses' typeName ';' EOF | 'provides' typeName 'with' typeName (',' typeName)* ';' EOF ; requiresModifier_DropletFile : 'transitive' EOF | 'static' EOF ; /* * Productions from §8 (Classes) */ classDeclaration_DropletFile : normalClassDeclaration EOF | enumDeclaration EOF ; normalClassDeclaration_DropletFile : classModifier* 'class' identifier typeParameters? superclass? superinterfaces? classBody EOF ; classModifier_DropletFile : annotation EOF | 'public' EOF | 'protected' EOF | 'private' EOF | 'abstract' EOF | 'static' EOF | 'final' EOF | 'strictfp' EOF ; typeParameters_DropletFile : '<' typeParameterList '>' EOF ; typeParameterList_DropletFile : typeParameter (',' typeParameter)* EOF ; superclass_DropletFile : 'extends' classType EOF ; superinterfaces_DropletFile : 'implements' interfaceTypeList EOF ; interfaceTypeList_DropletFile : interfaceType (',' interfaceType)* EOF ; classBody_DropletFile : '{' classBodyDeclaration* '}' EOF ; classBodyDeclaration_DropletFile : classMemberDeclaration EOF | instanceInitializer EOF | staticInitializer EOF | constructorDeclaration EOF ; classMemberDeclaration_DropletFile : fieldDeclaration EOF | methodDeclaration EOF | classDeclaration EOF | interfaceDeclaration EOF | ';' EOF ; fieldDeclaration_DropletFile : fieldModifier* unannType variableDeclaratorList ';' EOF ; fieldModifier_DropletFile : annotation EOF | 'public' EOF | 'protected' EOF | 'private' EOF | 'static' EOF | 'final' EOF | 'transient' EOF | 'volatile' EOF ; variableDeclaratorList_DropletFile : variableDeclarator (',' variableDeclarator)* EOF ; variableDeclarator_DropletFile : variableDeclaratorId ('=' variableInitializer)? EOF ; variableDeclaratorId_DropletFile : identifier dims? EOF ; variableInitializer_DropletFile : expression EOF | arrayInitializer EOF ; unannType_DropletFile : unannPrimitiveType EOF | unannReferenceType EOF ; unannPrimitiveType_DropletFile : numericType EOF | 'boolean' EOF ; unannReferenceType_DropletFile : unannClassOrInterfaceType EOF | unannTypeVariable EOF | unannArrayType EOF ; /*unannClassOrInterfaceType_DropletFile : unannClassType EOF | unannInterfaceType EOF ; */ unannClassOrInterfaceType_DropletFile : ( unannClassType_lfno_unannClassOrInterfaceType EOF | unannInterfaceType_lfno_unannClassOrInterfaceType EOF ) ( unannClassType_lf_unannClassOrInterfaceType EOF | unannInterfaceType_lf_unannClassOrInterfaceType EOF )* ; unannClassType_DropletFile : identifier typeArguments? EOF | unannClassOrInterfaceType '.' annotation* identifier typeArguments? EOF ; unannClassType_lf_unannClassOrInterfaceType_DropletFile : '.' annotation* identifier typeArguments? EOF ; unannClassType_lfno_unannClassOrInterfaceType_DropletFile : identifier typeArguments? EOF ; unannInterfaceType_DropletFile : unannClassType EOF ; unannInterfaceType_lf_unannClassOrInterfaceType_DropletFile : unannClassType_lf_unannClassOrInterfaceType EOF ; unannInterfaceType_lfno_unannClassOrInterfaceType_DropletFile : unannClassType_lfno_unannClassOrInterfaceType EOF ; unannTypeVariable_DropletFile : identifier EOF ; unannArrayType_DropletFile : unannPrimitiveType dims EOF | unannClassOrInterfaceType dims EOF | unannTypeVariable dims EOF ; methodDeclaration_DropletFile : methodModifier* methodHeader methodBody EOF ; methodModifier_DropletFile : annotation EOF | 'public' EOF | 'protected' EOF | 'private' EOF | 'abstract' EOF | 'static' EOF | 'final' EOF | 'synchronized' EOF | 'native' EOF | 'strictfp' EOF ; methodHeader_DropletFile : result methodDeclarator throws_? EOF | typeParameters annotation* result methodDeclarator throws_? EOF ; result_DropletFile : unannType EOF | 'void' EOF ; methodDeclarator_DropletFile : identifier '(' formalParameterList? ')' dims? EOF ; formalParameterList_DropletFile : formalParameters ',' lastFormalParameter EOF | lastFormalParameter EOF | receiverParameter EOF ; formalParameters_DropletFile : formalParameter (',' formalParameter)* EOF | receiverParameter (',' formalParameter)* EOF ; formalParameter_DropletFile : variableModifier* unannType variableDeclaratorId EOF ; variableModifier_DropletFile : annotation EOF | 'final' EOF ; lastFormalParameter_DropletFile : variableModifier* unannType annotation* '...' variableDeclaratorId EOF | formalParameter EOF ; receiverParameter_DropletFile : annotation* unannType (identifier '.')? 'this' EOF ; throws__DropletFile : 'throws' exceptionTypeList EOF ; exceptionTypeList_DropletFile : exceptionType (',' exceptionType)* EOF ; exceptionType_DropletFile : classType EOF | typeVariable EOF ; methodBody_DropletFile : block EOF | ';' EOF ; instanceInitializer_DropletFile : block EOF ; staticInitializer_DropletFile : 'static' block EOF ; constructorDeclaration_DropletFile : constructorModifier* constructorDeclarator throws_? constructorBody EOF ; constructorModifier_DropletFile : annotation EOF | 'public' EOF | 'protected' EOF | 'private' EOF ; constructorDeclarator_DropletFile : typeParameters? simpleTypeName '(' formalParameterList? ')' EOF ; simpleTypeName_DropletFile : identifier EOF ; constructorBody_DropletFile : '{' explicitConstructorInvocation? blockStatements? '}' EOF ; explicitConstructorInvocation_DropletFile : typeArguments? 'this' '(' argumentList? ')' ';' EOF | typeArguments? 'super' '(' argumentList? ')' ';' EOF | expressionName '.' typeArguments? 'super' '(' argumentList? ')' ';' EOF | primary '.' typeArguments? 'super' '(' argumentList? ')' ';' EOF ; enumDeclaration_DropletFile : classModifier* 'enum' identifier superinterfaces? enumBody EOF ; enumBody_DropletFile : '{' enumConstantList? ','? enumBodyDeclarations? '}' EOF ; enumConstantList_DropletFile : enumConstant (',' enumConstant)* EOF ; enumConstant_DropletFile : enumConstantModifier* identifier ('(' argumentList? ')')? classBody? EOF ; enumConstantModifier_DropletFile : annotation EOF ; enumBodyDeclarations_DropletFile : ';' classBodyDeclaration* EOF ; /* * Productions from §9 (Interfaces) */ interfaceDeclaration_DropletFile : normalInterfaceDeclaration EOF | annotationTypeDeclaration EOF ; normalInterfaceDeclaration_DropletFile : interfaceModifier* 'interface' identifier typeParameters? extendsInterfaces? interfaceBody EOF ; interfaceModifier_DropletFile : annotation EOF | 'public' EOF | 'protected' EOF | 'private' EOF | 'abstract' EOF | 'static' EOF | 'strictfp' EOF ; extendsInterfaces_DropletFile : 'extends' interfaceTypeList EOF ; interfaceBody_DropletFile : '{' interfaceMemberDeclaration* '}' EOF ; interfaceMemberDeclaration_DropletFile : constantDeclaration EOF | interfaceMethodDeclaration EOF | classDeclaration EOF | interfaceDeclaration EOF | ';' EOF ; constantDeclaration_DropletFile : constantModifier* unannType variableDeclaratorList ';' EOF ; constantModifier_DropletFile : annotation EOF | 'public' EOF | 'static' EOF | 'final' EOF ; interfaceMethodDeclaration_DropletFile : interfaceMethodModifier* methodHeader methodBody EOF ; interfaceMethodModifier_DropletFile : annotation EOF | 'public' EOF | 'private' EOF //Introduced in Java 9 | 'abstract' EOF | 'default' EOF | 'static' EOF | 'strictfp' EOF ; annotationTypeDeclaration_DropletFile : interfaceModifier* '@' 'interface' identifier annotationTypeBody EOF ; annotationTypeBody_DropletFile : '{' annotationTypeMemberDeclaration* '}' EOF ; annotationTypeMemberDeclaration_DropletFile : annotationTypeElementDeclaration EOF | constantDeclaration EOF | classDeclaration EOF | interfaceDeclaration EOF | ';' EOF ; annotationTypeElementDeclaration_DropletFile : annotationTypeElementModifier* unannType identifier '(' ')' dims? defaultValue? ';' EOF ; annotationTypeElementModifier_DropletFile : annotation EOF | 'public' EOF | 'abstract' EOF ; defaultValue_DropletFile : 'default' elementValue EOF ; annotation_DropletFile : normalAnnotation EOF | markerAnnotation EOF | singleElementAnnotation EOF ; normalAnnotation_DropletFile : '@' typeName '(' elementValuePairList? ')' EOF ; elementValuePairList_DropletFile : elementValuePair (',' elementValuePair)* EOF ; elementValuePair_DropletFile : identifier '=' elementValue EOF ; elementValue_DropletFile : conditionalExpression EOF | elementValueArrayInitializer EOF | annotation EOF ; elementValueArrayInitializer_DropletFile : '{' elementValueList? ','? '}' EOF ; elementValueList_DropletFile : elementValue (',' elementValue)* EOF ; markerAnnotation_DropletFile : '@' typeName EOF ; singleElementAnnotation_DropletFile : '@' typeName '(' elementValue ')' EOF ; /* * Productions from §10 (Arrays) */ arrayInitializer_DropletFile : '{' variableInitializerList? ','? '}' EOF ; variableInitializerList_DropletFile : variableInitializer (',' variableInitializer)* EOF ; /* * Productions from §14 (Blocks and Statements) */ block_DropletFile : '{' blockStatements? '}' EOF ; blockStatements_DropletFile : blockStatement+ EOF ; blockStatement_DropletFile : localVariableDeclarationStatement EOF | classDeclaration EOF | statement EOF ; localVariableDeclarationStatement_DropletFile : localVariableDeclaration ';' EOF ; localVariableDeclaration_DropletFile : variableModifier* unannType variableDeclaratorList EOF ; statement_DropletFile : statementWithoutTrailingSubstatement EOF | labeledStatement EOF | ifThenStatement EOF | ifThenElseStatement EOF | whileStatement EOF | forStatement EOF ; statementNoShortIf_DropletFile : statementWithoutTrailingSubstatement EOF | labeledStatementNoShortIf EOF | ifThenElseStatementNoShortIf EOF | whileStatementNoShortIf EOF | forStatementNoShortIf EOF ; statementWithoutTrailingSubstatement_DropletFile : block EOF | emptyStatement EOF | expressionStatement EOF | assertStatement EOF | switchStatement EOF | doStatement EOF | breakStatement EOF | continueStatement EOF | returnStatement EOF | synchronizedStatement EOF | throwStatement EOF | tryStatement EOF ; emptyStatement_DropletFile : ';' EOF ; labeledStatement_DropletFile : identifier ':' statement EOF ; labeledStatementNoShortIf_DropletFile : identifier ':' statementNoShortIf EOF ; expressionStatement_DropletFile : statementExpression ';' EOF ; statementExpression_DropletFile : assignment EOF | preIncrementExpression EOF | preDecrementExpression EOF | postIncrementExpression EOF | postDecrementExpression EOF | methodInvocation EOF | classInstanceCreationExpression EOF ; ifThenStatement_DropletFile : 'if' '(' expression ')' statement EOF ; ifThenElseStatement_DropletFile : 'if' '(' expression ')' statementNoShortIf 'else' statement EOF ; ifThenElseStatementNoShortIf_DropletFile : 'if' '(' expression ')' statementNoShortIf 'else' statementNoShortIf EOF ; assertStatement_DropletFile : 'assert' expression ';' EOF | 'assert' expression ':' expression ';' EOF ; switchStatement_DropletFile : 'switch' '(' expression ')' switchBlock EOF ; switchBlock_DropletFile : '{' switchBlockStatementGroup* switchLabel* '}' EOF ; switchBlockStatementGroup_DropletFile : switchLabels blockStatements EOF ; switchLabels_DropletFile : switchLabel+ EOF ; switchLabel_DropletFile : 'case' constantExpression ':' EOF | 'case' enumConstantName ':' EOF | 'default' ':' EOF ; enumConstantName_DropletFile : identifier EOF ; whileStatement_DropletFile : 'while' '(' expression ')' statement EOF ; whileStatementNoShortIf_DropletFile : 'while' '(' expression ')' statementNoShortIf EOF ; doStatement_DropletFile : 'do' statement 'while' '(' expression ')' ';' EOF ; forStatement_DropletFile : basicForStatement EOF | enhancedForStatement EOF ; forStatementNoShortIf_DropletFile : basicForStatementNoShortIf EOF | enhancedForStatementNoShortIf EOF ; basicForStatement_DropletFile : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statement EOF ; basicForStatementNoShortIf_DropletFile : 'for' '(' forInit? ';' expression? ';' forUpdate? ')' statementNoShortIf EOF ; forInit_DropletFile : statementExpressionList EOF | localVariableDeclaration EOF ; forUpdate_DropletFile : statementExpressionList EOF ; statementExpressionList_DropletFile : statementExpression (',' statementExpression)* EOF ; enhancedForStatement_DropletFile : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statement EOF ; enhancedForStatementNoShortIf_DropletFile : 'for' '(' variableModifier* unannType variableDeclaratorId ':' expression ')' statementNoShortIf ; breakStatement_DropletFile : 'break' identifier? ';' EOF ; continueStatement_DropletFile : 'continue' identifier? ';' EOF ; returnStatement_DropletFile : 'return' expression? ';' EOF ; throwStatement_DropletFile : 'throw' expression ';' EOF ; synchronizedStatement_DropletFile : 'synchronized' '(' expression ')' block EOF ; tryStatement_DropletFile : 'try' block catches EOF | 'try' block catches? finally_ EOF | tryWithResourcesStatement EOF ; catches_DropletFile : catchClause+ EOF ; catchClause_DropletFile : 'catch' '(' catchFormalParameter ')' block EOF ; catchFormalParameter_DropletFile : variableModifier* catchType variableDeclaratorId EOF ; catchType_DropletFile : unannClassType ('|' classType)* EOF ; finally__DropletFile : 'finally' block EOF ; tryWithResourcesStatement_DropletFile : 'try' resourceSpecification block catches? finally_? EOF ; resourceSpecification_DropletFile : '(' resourceList ';'? ')' EOF ; resourceList_DropletFile : resource (';' resource)* EOF ; resource_DropletFile : variableModifier* unannType variableDeclaratorId '=' expression EOF | variableAccess EOF //Introduced in Java 9 ; variableAccess_DropletFile : expressionName EOF | fieldAccess EOF ; /* * Productions from §15 (Expressions) */ /*primary_DropletFile : primaryNoNewArray EOF | arrayCreationExpression EOF ; */ primary_DropletFile : ( primaryNoNewArray_lfno_primary EOF | arrayCreationExpression EOF ) ( primaryNoNewArray_lf_primary EOF )* ; primaryNoNewArray_DropletFile : literal EOF | classLiteral EOF | 'this' EOF | typeName '.' 'this' EOF | '(' expression ')' EOF | classInstanceCreationExpression EOF | fieldAccess EOF | arrayAccess EOF | methodInvocation EOF | methodReference EOF ; primaryNoNewArray_lf_arrayAccess_DropletFile : ; primaryNoNewArray_lfno_arrayAccess_DropletFile : literal EOF | typeName ('[' ']')* '.' 'class' EOF | 'void' '.' 'class' EOF | 'this' | typeName '.' 'this' EOF | '(' expression ')' EOF | classInstanceCreationExpression EOF | fieldAccess EOF | methodInvocation EOF | methodReference EOF ; primaryNoNewArray_lf_primary_DropletFile : classInstanceCreationExpression_lf_primary EOF | fieldAccess_lf_primary EOF | arrayAccess_lf_primary EOF | methodInvocation_lf_primary EOF | methodReference_lf_primary EOF ; primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary_DropletFile : ; primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary_DropletFile : classInstanceCreationExpression_lf_primary EOF | fieldAccess_lf_primary EOF | methodInvocation_lf_primary EOF | methodReference_lf_primary EOF ; primaryNoNewArray_lfno_primary_DropletFile : literal EOF | typeName ('[' ']')* '.' 'class' EOF | unannPrimitiveType ('[' ']')* '.' 'class' EOF | 'void' '.' 'class' EOF | 'this' EOF | typeName '.' 'this' EOF | '(' expression ')' EOF | classInstanceCreationExpression_lfno_primary EOF | fieldAccess_lfno_primary EOF | arrayAccess_lfno_primary EOF | methodInvocation_lfno_primary EOF | methodReference_lfno_primary EOF ; primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary_DropletFile : ; primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary_DropletFile : literal EOF | typeName ('[' ']')* '.' 'class' EOF | unannPrimitiveType ('[' ']')* '.' 'class' EOF | 'void' '.' 'class' EOF | 'this' EOF | typeName '.' 'this' EOF | '(' expression ')' EOF | classInstanceCreationExpression_lfno_primary EOF | fieldAccess_lfno_primary EOF | methodInvocation_lfno_primary EOF | methodReference_lfno_primary EOF ; classLiteral_DropletFile : (typeName|numericType|'boolean') ('[' ']')* '.' 'class' EOF | 'void' '.' 'class' EOF ; classInstanceCreationExpression_DropletFile : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF | primary '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF ; classInstanceCreationExpression_lf_primary_DropletFile : '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF ; classInstanceCreationExpression_lfno_primary_DropletFile : 'new' typeArguments? annotation* identifier ('.' annotation* identifier)* typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF | expressionName '.' 'new' typeArguments? annotation* identifier typeArgumentsOrDiamond? '(' argumentList? ')' classBody? EOF ; typeArgumentsOrDiamond_DropletFile : typeArguments EOF | '<' '>' EOF ; fieldAccess_DropletFile : primary '.' identifier EOF | 'super' '.' identifier EOF | typeName '.' 'super' '.' identifier EOF ; fieldAccess_lf_primary_DropletFile : '.' identifier EOF ; fieldAccess_lfno_primary_DropletFile : 'super' '.' identifier EOF | typeName '.' 'super' '.' identifier EOF ; /*arrayAccess_DropletFile : expressionName '[' expression ']' EOF | primaryNoNewArray '[' expression ']' EOF ; */ arrayAccess_DropletFile : ( expressionName '[' expression ']' EOF | primaryNoNewArray_lfno_arrayAccess '[' expression ']' EOF ) ( primaryNoNewArray_lf_arrayAccess '[' expression ']' EOF )* ; arrayAccess_lf_primary_DropletFile : ( primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary '[' expression ']' EOF ) ( primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary '[' expression ']' EOF )* ; arrayAccess_lfno_primary_DropletFile : ( expressionName '[' expression ']' EOF | primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary '[' expression ']' EOF ) ( primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary '[' expression ']' EOF )* ; methodInvocation_DropletFile : methodName '(' argumentList? ')' EOF | typeName '.' typeArguments? identifier '(' argumentList? ')' EOF | expressionName '.' typeArguments? identifier '(' argumentList? ')' EOF | primary '.' typeArguments? identifier '(' argumentList? ')' EOF | 'super' '.' typeArguments? identifier '(' argumentList? ')' EOF | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' EOF ; methodInvocation_lf_primary_DropletFile : '.' typeArguments? identifier '(' argumentList? ')' EOF ; methodInvocation_lfno_primary_DropletFile : methodName '(' argumentList? ')' EOF | typeName '.' typeArguments? identifier '(' argumentList? ')' EOF | expressionName '.' typeArguments? identifier '(' argumentList? ')' EOF | 'super' '.' typeArguments? identifier '(' argumentList? ')' EOF | typeName '.' 'super' '.' typeArguments? identifier '(' argumentList? ')' EOF ; argumentList_DropletFile : expression (',' expression)* EOF ; methodReference_DropletFile : expressionName '::' typeArguments? identifier EOF | referenceType '::' typeArguments? identifier EOF | primary '::' typeArguments? identifier EOF | 'super' '::' typeArguments? identifier EOF | typeName '.' 'super' '::' typeArguments? identifier EOF | classType '::' typeArguments? 'new' EOF | arrayType '::' 'new' EOF ; methodReference_lf_primary_DropletFile : '::' typeArguments? identifier EOF ; methodReference_lfno_primary_DropletFile : expressionName '::' typeArguments? identifier EOF | referenceType '::' typeArguments? identifier EOF | 'super' '::' typeArguments? identifier EOF | typeName '.' 'super' '::' typeArguments? identifier EOF | classType '::' typeArguments? 'new' EOF | arrayType '::' 'new' EOF ; arrayCreationExpression_DropletFile : 'new' primitiveType dimExprs dims? EOF | 'new' classOrInterfaceType dimExprs dims? EOF | 'new' primitiveType dims arrayInitializer EOF | 'new' classOrInterfaceType dims arrayInitializer EOF ; dimExprs_DropletFile : dimExpr+ EOF ; dimExpr_DropletFile : annotation* '[' expression ']' EOF ; constantExpression_DropletFile : expression EOF ; expression_DropletFile : lambdaExpression EOF | assignmentExpression EOF ; lambdaExpression_DropletFile : lambdaParameters '->' lambdaBody EOF ; lambdaParameters_DropletFile : identifier EOF | '(' formalParameterList? ')' EOF | '(' inferredFormalParameterList ')' EOF ; inferredFormalParameterList_DropletFile : identifier (',' identifier)* EOF ; lambdaBody_DropletFile : expression EOF | block EOF ; assignmentExpression_DropletFile : conditionalExpression EOF | assignment EOF ; assignment_DropletFile : leftHandSide assignmentOperator expression EOF ; leftHandSide_DropletFile : expressionName EOF | fieldAccess EOF | arrayAccess EOF ; assignmentOperator_DropletFile : '=' EOF | '*=' EOF | '/=' EOF | '%=' EOF | '+=' EOF | '-=' EOF | '<<=' EOF | '>>=' EOF | '>>>=' EOF | '&=' EOF | '^=' EOF | '|=' EOF ; conditionalExpression_DropletFile : conditionalOrExpression EOF | conditionalOrExpression '?' expression ':' (conditionalExpression|lambdaExpression) EOF ; conditionalOrExpression_DropletFile : conditionalAndExpression EOF | conditionalOrExpression '||' conditionalAndExpression EOF ; conditionalAndExpression_DropletFile : inclusiveOrExpression EOF | conditionalAndExpression '&&' inclusiveOrExpression EOF ; inclusiveOrExpression_DropletFile : exclusiveOrExpression EOF | inclusiveOrExpression '|' exclusiveOrExpression EOF ; exclusiveOrExpression_DropletFile : andExpression EOF | exclusiveOrExpression '^' andExpression EOF ; andExpression_DropletFile : equalityExpression EOF | andExpression '&' equalityExpression EOF ; equalityExpression_DropletFile : relationalExpression EOF | equalityExpression '==' relationalExpression EOF | equalityExpression '!=' relationalExpression EOF ; relationalExpression_DropletFile : shiftExpression EOF | relationalExpression '<' shiftExpression EOF | relationalExpression '>' shiftExpression EOF | relationalExpression '<=' shiftExpression EOF | relationalExpression '>=' shiftExpression EOF | relationalExpression 'instanceof' referenceType EOF ; shiftExpression_DropletFile : additiveExpression EOF | shiftExpression '<' '<' additiveExpression EOF | shiftExpression '>' '>' additiveExpression EOF | shiftExpression '>' '>' '>' additiveExpression EOF ; additiveExpression_DropletFile : multiplicativeExpression EOF | additiveExpression '+' multiplicativeExpression EOF | additiveExpression '-' multiplicativeExpression EOF ; multiplicativeExpression_DropletFile : unaryExpression EOF | multiplicativeExpression '*' unaryExpression EOF | multiplicativeExpression '/' unaryExpression EOF | multiplicativeExpression '%' unaryExpression EOF ; unaryExpression_DropletFile : preIncrementExpression EOF | preDecrementExpression EOF | '+' unaryExpression EOF | '-' unaryExpression EOF | unaryExpressionNotPlusMinus EOF ; preIncrementExpression_DropletFile : '++' unaryExpression EOF ; preDecrementExpression_DropletFile : '--' unaryExpression EOF ; unaryExpressionNotPlusMinus_DropletFile : postfixExpression EOF | '~' unaryExpression EOF | '!' unaryExpression EOF | castExpression EOF ; /*postfixExpression_DropletFile : primary EOF | expressionName EOF | postIncrementExpression EOF | postDecrementExpression EOF ; */ postfixExpression_DropletFile : ( primary EOF | expressionName EOF ) ( postIncrementExpression_lf_postfixExpression EOF | postDecrementExpression_lf_postfixExpression EOF )* ; postIncrementExpression_DropletFile : postfixExpression '++' EOF ; postIncrementExpression_lf_postfixExpression_DropletFile : '++' EOF ; postDecrementExpression_DropletFile : postfixExpression '--' EOF ; postDecrementExpression_lf_postfixExpression_DropletFile : '--' EOF ; castExpression_DropletFile : '(' primitiveType ')' unaryExpression EOF | '(' referenceType additionalBound* ')' unaryExpressionNotPlusMinus EOF | '(' referenceType additionalBound* ')' lambdaExpression EOF ; // LEXER identifier : Identifier | 'to' | 'module' | 'open' | 'with'; // §3.9 Keywords ABSTRACT : 'abstract'; ASSERT : 'assert'; BOOLEAN : 'boolean'; BREAK : 'break'; BYTE : 'byte'; CASE : 'case'; CATCH : 'catch'; CHAR : 'char'; CLASS : 'class'; CONST : 'const'; CONTINUE : 'continue'; DEFAULT : 'default'; DO : 'do'; DOUBLE : 'double'; ELSE : 'else'; ENUM : 'enum'; EXTENDS : 'extends'; FINAL : 'final'; FINALLY : 'finally'; FLOAT : 'float'; FOR : 'for'; IF : 'if'; GOTO : 'goto'; IMPLEMENTS : 'implements'; IMPORT : 'import'; INSTANCEOF : 'instanceof'; INT : 'int'; INTERFACE : 'interface'; LONG : 'long'; NATIVE : 'native'; NEW : 'new'; PACKAGE : 'package'; PRIVATE : 'private'; PROTECTED : 'protected'; PUBLIC : 'public'; RETURN : 'return'; SHORT : 'short'; STATIC : 'static'; STRICTFP : 'strictfp'; SUPER : 'super'; SWITCH : 'switch'; SYNCHRONIZED : 'synchronized'; THIS : 'this'; THROW : 'throw'; THROWS : 'throws'; TRANSIENT : 'transient'; TRY : 'try'; VOID : 'void'; VOLATILE : 'volatile'; WHILE : 'while'; UNDER_SCORE : '_';//Introduced in Java 9 // §3.10.1 Integer Literals IntegerLiteral : DecimalIntegerLiteral | HexIntegerLiteral | OctalIntegerLiteral | BinaryIntegerLiteral ; fragment DecimalIntegerLiteral : DecimalNumeral IntegerTypeSuffix? ; fragment HexIntegerLiteral : HexNumeral IntegerTypeSuffix? ; fragment OctalIntegerLiteral : OctalNumeral IntegerTypeSuffix? ; fragment BinaryIntegerLiteral : BinaryNumeral IntegerTypeSuffix? ; fragment IntegerTypeSuffix : [lL] ; fragment DecimalNumeral : '0' | NonZeroDigit (Digits? | Underscores Digits) ; fragment Digits : Digit (DigitsAndUnderscores? Digit)? ; fragment Digit : '0' | NonZeroDigit ; fragment NonZeroDigit : [1-9] ; fragment DigitsAndUnderscores : DigitOrUnderscore+ ; fragment DigitOrUnderscore : Digit | '_' ; fragment Underscores : '_'+ ; fragment HexNumeral : '0' [xX] HexDigits ; fragment HexDigits : HexDigit (HexDigitsAndUnderscores? HexDigit)? ; fragment HexDigit : [0-9a-fA-F] ; fragment HexDigitsAndUnderscores : HexDigitOrUnderscore+ ; fragment HexDigitOrUnderscore : HexDigit | '_' ; fragment OctalNumeral : '0' Underscores? OctalDigits ; fragment OctalDigits : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? ; fragment OctalDigit : [0-7] ; fragment OctalDigitsAndUnderscores : OctalDigitOrUnderscore+ ; fragment OctalDigitOrUnderscore : OctalDigit | '_' ; fragment BinaryNumeral : '0' [bB] BinaryDigits ; fragment BinaryDigits : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? ; fragment BinaryDigit : [01] ; fragment BinaryDigitsAndUnderscores : BinaryDigitOrUnderscore+ ; fragment BinaryDigitOrUnderscore : BinaryDigit | '_' ; // §3.10.2 Floating-Point Literals FloatingPointLiteral : DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral ; fragment DecimalFloatingPointLiteral : Digits '.' Digits? ExponentPart? FloatTypeSuffix? | '.' Digits ExponentPart? FloatTypeSuffix? | Digits ExponentPart FloatTypeSuffix? | Digits FloatTypeSuffix ; fragment ExponentPart : ExponentIndicator SignedInteger ; fragment ExponentIndicator : [eE] ; fragment SignedInteger : Sign? Digits ; fragment Sign : [+-] ; fragment FloatTypeSuffix : [fFdD] ; fragment HexadecimalFloatingPointLiteral : HexSignificand BinaryExponent FloatTypeSuffix? ; fragment HexSignificand : HexNumeral '.'? | '0' [xX] HexDigits? '.' HexDigits ; fragment BinaryExponent : BinaryExponentIndicator SignedInteger ; fragment BinaryExponentIndicator : [pP] ; // §3.10.3 Boolean Literals BooleanLiteral : 'true' | 'false' ; // §3.10.4 Character Literals CharacterLiteral : '\'' SingleCharacter '\'' | '\'' EscapeSequence '\'' ; fragment SingleCharacter : ~['\\\r\n] ; // §3.10.5 String Literals StringLiteral : '"' StringCharacters? '"' ; fragment StringCharacters : StringCharacter+ ; fragment StringCharacter : ~["\\\r\n] | EscapeSequence ; // §3.10.6 Escape Sequences for Character and String Literals fragment EscapeSequence : '\\' [btnfr"'\\] | OctalEscape | UnicodeEscape // This is not in the spec but prevents having to preprocess the input ; fragment OctalEscape : '\\' OctalDigit | '\\' OctalDigit OctalDigit | '\\' ZeroToThree OctalDigit OctalDigit ; fragment ZeroToThree : [0-3] ; // This is not in the spec but prevents having to preprocess the input fragment UnicodeEscape : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit ; // §3.10.7 The Null Literal NullLiteral : 'null' ; // §3.11 Separators LPAREN : '('; RPAREN : ')'; LBRACE : '{'; RBRACE : '}'; LBRACK : '['; RBRACK : ']'; SEMI : ';'; COMMA : ','; DOT : '.'; ELLIPSIS : '...'; AT : '@'; COLONCOLON : '::'; // §3.12 Operators ASSIGN : '='; GT : '>'; LT : '<'; BANG : '!'; TILDE : '~'; QUESTION : '?'; COLON : ':'; ARROW : '->'; EQUAL : '=='; LE : '<='; GE : '>='; NOTEQUAL : '!='; AND : '&&'; OR : '||'; INC : '++'; DEC : '--'; ADD : '+'; SUB : '-'; MUL : '*'; DIV : '/'; BITAND : '&'; BITOR : '|'; CARET : '^'; MOD : '%'; //LSHIFT : '<<'; //RSHIFT : '>>'; //URSHIFT : '>>>'; ADD_ASSIGN : '+='; SUB_ASSIGN : '-='; MUL_ASSIGN : '*='; DIV_ASSIGN : '/='; AND_ASSIGN : '&='; OR_ASSIGN : '|='; XOR_ASSIGN : '^='; MOD_ASSIGN : '%='; LSHIFT_ASSIGN : '<<='; RSHIFT_ASSIGN : '>>='; URSHIFT_ASSIGN : '>>>='; // §3.8 Identifiers (must appear after all keywords in the grammar) Identifier : JavaLetter JavaLetterOrDigit* ; fragment JavaLetter : [a-zA-Z$_] // these are the "java letters" below 0x7F | // covers all characters above 0x7F which are not a surrogate ~[\u0000-\u007F\uD800-\uDBFF] // {Character.isJavaIdentifierStart(_input.LA(-1))}? | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF [\uD800-\uDBFF] [\uDC00-\uDFFF] // {Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? ; fragment JavaLetterOrDigit : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F | // covers all characters above 0x7F which are not a surrogate ~[\u0000-\u007F\uD800-\uDBFF] // {Character.isJavaIdentifierPart(_input.LA(-1))}? | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF [\uD800-\uDBFF] [\uDC00-\uDFFF] // {Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)))}? ; // // Whitespace and comments // WS : [ \t\r\n\u000C]+ -> skip ; COMMENT : '/*' .*? '*/' -> channel(HIDDEN) ; LINE_COMMENT : '//' ~[\r\n]* -> channel(HIDDEN) ;
PRG/prg007.asm
narfman0/smb3_pp1
0
179034
<filename>PRG/prg007.asm ; Super Mario Bros. 3 Full Disassembly by Southbird 2012 ; For more info, see http://www.sonicepoch.com/sm3mix/ ; ; PLEASE INCLUDE A CREDIT TO THE SOUTHBIRD DISASSEMBLY ; AND THE ABOVE LINK SOMEWHERE IN YOUR WORKS :) ; ; Original disassembler source generated by DCC6502 version v1.4 ; (With labels, comments, and some syntax corrections for nesasm by Southbird) ; For more info about DCC6502, e-mail <EMAIL> ; ; This source file last updated: 2012-02-13 22:44:39.225983982 -0600 ; Distribution package date: Fri Apr 6 23:46:16 UTC 2012 ;--------------------------------------------------------------------------- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Player_DoLavaDonutArrowBounce ; ; Handles the Player coming into contact with lava, donut lifts, ; or arrow platforms (supported in vertical level only) ; This also checks to see if the Player should bounce because the ; block beneath his feet bounced (by checking for the ; TILEA_BLOCKBUMP_CLEAR tile...) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Specifies which kind of arrow lift should be created relative to which tile ; the Player stepped on. Note the zero near the end; if you look at tileset #8 ; the donut lift appears right between what would be the multidirectional lift. ArrowPlat_ByTile: .byte OBJ_ARROWONE, OBJ_ARROWONE, OBJ_ARROWONE, OBJ_ARROWONE, OBJ_ARROWONE, OBJ_ARROWONE, OBJ_ARROWANY, $00, OBJ_ARROWANY ; Sets the direction value as used by the arrow platform ArrowPlat_DirByTile: .byte $00, $00, $03, $03, $01, $01, $00, $00, $00 ArrowPlat_XOff: .byte 0, -16, 0, -16, 0, -16, 0, 0, -16 Player_DoLavaDonutArrowBounce: LDA <Player_IsDying BNE PRG007_A06F ; If Player is dying, jump to PRG007_A06F (RTS) LDA Level_7Vertical BEQ PRG007_A027 ; If this is NOT a vertically-oriented level, jump to PRG007_A027 JMP PRG007_A0DE ; Otherwise, jump to PRG007_A0DE PRG007_A027: ; Not vertically oriented level... LDA <Player_Y ; Get Player Y ADD #32 ; +32 AND #$f0 ; Align to tile grid STA <Temp_Var5 ; -> Temp_Var5 LDA <Player_YHi BMI PRG007_A06F ; If Player is up off the top of the screen, jump to PRG007_A06F (RTS) ADC #$00 ; Apply carry AND #$01 ; Only bit 0 is valid anyway in non-vertical mode STA <Temp_Var3 ; -> Temp_Var3 LDA <Player_X ; Get Player X ADD #$08 ; +8 AND #$f0 ; Align to tile grid STA <Temp_Var4 ; -> Temp_Var4 LDA <Player_XHi ADC #$00 ; Apply carry STA <Temp_Var6 ; -> Temp_Var6 CMP #16 ; 16 screens are the max!! BCS PRG007_A06F ; If Player is really far to the right (somehow), jump to PRG007_A06F (RTS) ASL A ; 2 byte index for current screen TAY ; -> 'Y' ; Store high byte of screen address -> Temp_Var1 LDA Tile_Mem_Addr,Y STA <Temp_Var1 ; Store low byte of screen address + Player's Y Hi -> Temp_Var2 LDA Tile_Mem_Addr+1,Y ADD <Temp_Var3 STA <Temp_Var2 ; Calculate a proper offset into the tile memory for the X/Y position of the Player LDA <Temp_Var4 LSR A LSR A LSR A LSR A ORA <Temp_Var5 TAY ; -> 'Y' LDA [Temp_Var1],Y ; Get the tile here CMP #TILEA_BLOCKBUMP_CLEAR BNE PRG007_A070 ; If this is not a bumped block tile, jump to PRG007_A070 ; Otherwise, bounce Player! LDA #-$30 STA <Player_YVel PRG007_A06F: RTS ; Return PRG007_A070: CMP #TILE2_LAVATOP BNE PRG007_A082 ; If this is not (possibly) a lava tile, jump to PRG007_A082 LDY Level_Tileset CPY #11 BEQ PRG007_A07F ; If this is tileset 11 (Giant World; Interesting! Green bubbly death here), jump to PRG007_A07F CPY #2 BNE PRG007_A082 ; If this is NOT tileset 2 (Fortress style), jump to PRG007_A082 PRG007_A07F: JMP PRG007_A183 ; Jump to PRG007_A183 (Player dies!) PRG007_A082: CMP #TILE2_DONUTLIFT BNE PRG007_A0DD ; If this is not (possibly) a Donut Lift, jump to PRG007_A0DD (RTS) PRG007_A086: ; If this is tileset 4, 8, 12, or 2 (all valid for Donut Lift), jump to PRG007_A099, otherwise jump to PRG007_A06F (RTS) LDY Level_Tileset CPY #4 BEQ PRG007_A099 CPY #8 BEQ PRG007_A099 CPY #12 BEQ PRG007_A099 CPY #2 BNE PRG007_A06F PRG007_A099: LDA Level_ChgTileEvent BNE PRG007_A06F ; If there's already a tile change event queued, jump to PRG007_A06F (RTS) JSR PrepareNewObjectOrAbort ; Prepare a new object or don't come back! ; This is a falling donut lift! LDA #OBJ_DONUTLIFTSHAKEFALL STA Level_ObjectID,X ; Set donut lift Y LDA <Temp_Var5 SUB #$01 STA <Objects_Y,X LDA <Temp_Var3 SBC #$00 STA <Objects_YHi,X ; Set donut lift X LDA <Temp_Var4 STA <Objects_X,X LDA <Temp_Var6 STA <Objects_XHi,X ; Set donut lift object's Var5 = $20 LDA #$20 STA <Objects_Var5,X ; Set sprite attribute = 3 LDA #$03 STA Objects_SprAttr,X ; Do tile change event to clear the tile version of the donut lift LDA #$02 STA Level_ChgTileEvent LDA <Temp_Var3 STA Level_BlockChgYHi LDA <Temp_Var5 STA Level_BlockChgYLo LDA <Temp_Var4 STA Level_BlockChgXLo LDA <Temp_Var6 STA Level_BlockChgXHi PRG007_A0DD: RTS ; Return PRG007_A0DE: ; Vertically oriented level... LDA <Player_Y ; Get Player Y ADD #33 ; +33 AND #$f0 ; Aligned to tile grid STA <Temp_Var1 ; -> Temp_Var1 STA <Temp_Var5 ; -> Temp_Var5 LDA <Player_YHi BMI PRG007_A0DD ; If Player is up off the top of the level, jump to PRG007_A0DD (RTS) ADC #$00 ; Apply carry STA <Temp_Var3 ; -> Temp_Var3 ; High byte of Tile_Mem -> Temp_Var2 ORA #HIGH(Tile_Mem) STA <Temp_Var2 LDA <Player_X ; Get Player X ADD #$08 ; +8 AND #$f0 ; Aligned to tile grid STA <Temp_Var4 ; -> Temp_Var4 ; Construct tile offset LSR A LSR A LSR A LSR A ORA <Temp_Var1 STA <Temp_Var1 ; Temp_Var6 = 0 (would be "X Hi", which is always zero in vertical level) LDY #$00 STY <Temp_Var6 LDA [Temp_Var1],Y ; Get tile here CMP #TILE2_DONUTLIFT BNE PRG007_A113 ; If this is not donut lift tile, jump to PRG007_A113 JMP PRG007_A086 ; Otherwise, jump to PRG007_A086 PRG007_A113: LDY <Player_InAir BNE PRG007_A0DD ; If Player is mid-air, jump to PRG007_A0DD (RTS) LDY ArrowPlat_IsActive BNE PRG007_A0DD ; If an arrow platform is already active, jump to PRG007_A0DD (RTS) ; If not standing on some kind of arrow platform tile, jump to PRG007_A0DD (RTS) CMP #TILE8_ARROWLIFT_UPL BLT PRG007_A0DD CMP #(TILE8_ARROWLIFT_RANDOMR+1) BGE PRG007_A0DD SUB #TILE8_ARROWLIFT_UPL TAY ; Y = relative index of tile for arrow platform ; Temp_Var3 = $FF LDA #$ff STA <Temp_Var3 LDX #$04 ; X = 4 PRG007_A12E: LDA Objects_State,X BEQ PRG007_A144 ; If this object slot is dead/empty, jump to PRG007_A144 ; If this object slot is not some type of arrow platform, jump to PRG007_A146 LDA Level_ObjectID,X CMP #OBJ_ARROWONE BLT PRG007_A146 CMP #(OBJ_ARROWANY+1) BGE PRG007_A146 ; There's another arrow platform already active in this slot... JSR Object_SetDeadEmpty ; Set this slot as dead/empty JMP PRG007_A144 ; Jump to PRG007_A144 ; ^ I think the above is partially a mistake; they probably wanted to jump to something ; that would set 'X' and exit the loop. This logic works as-is, but it requires another ; frame before the arrow lift will actually come into existence... unless another dead/ ; empty object appears forward of this position... PRG007_A144: STX <Temp_Var3 ; Temp_Var3 = index we just searched PRG007_A146: DEX ; X-- BPL PRG007_A12E ; While X >= 0, loop! LDX <Temp_Var3 ; X = free object slot! BMI PRG007_A182 ; If no free object slot was found, jump to PRG007_A182 ; Set this to "Normal!" LDA #OBJSTATE_NORMAL STA Objects_State,X ; Create the correct arrow platform by the tile LDA ArrowPlat_ByTile,Y STA Level_ObjectID,X ; Set the direction value by tile LDA ArrowPlat_DirByTile,Y STA <Objects_Var4,X ; Arrow platform Y LDA <Temp_Var1 AND #$f0 SUB #$01 STA <Objects_Y,X LDA <Temp_Var2 SBC #$00 AND #$0f STA <Objects_YHi,X ; Arrow platform X LDA <Temp_Var1 ASL A ASL A ASL A ASL A ADD ArrowPlat_XOff,Y STA <Objects_X,X LDA #$00 STA <Objects_XHi,X ; Arrow platform's Var5 (lifespan counter) = $FF LDA #$ff STA <Objects_Var5,X PRG007_A182: RTS ; Return PRG007_A183: ; Player hit death tile! ; Zap suit LDA #$01 STA Player_QueueSuit JMP Player_Die ; Player dies and don't come back! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ColorRotation_Do ; ; Performs the palette color rotation effects per RotatingColor_Cnt ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The palette color forcefully applied in a color rotation Rotation_Colors: .byte $26, $2A, $22, $36 ColorRotation_Do: LDX Graphics_BufCnt ; X = Graphics_BufCnt LDA RotatingColor_Cnt BEQ PRG007_A1EA ; If RotatingColor_Cnt = 0 (No color rotation active), jump to PRG007_A1EA (RTS) PHA ; Save rotation value AND #$03 TAY ; Y = 0 to 3, based on rotation value DEC RotatingColor_Cnt ; RotatingColor_Cnt-- PLA ; Restore rotation value BPL PRG007_A1EB ; If bit 7 not set on rotation value, jump to PRG007_A1EB ; Bit 7 set on RotatingColor_Cnt AND #%01111111 ; Ignore bit 7 BNE PRG007_A1A8 ; If does not amount to zero, jump to PRG007_A1A8 STA RotatingColor_Cnt ; Otherwise, clear RotatingColor_Cnt PRG007_A1A8: ; Address of palette to modify LDA #$3f STA Graphics_Buffer+$00,X LDA #$04 STA Graphics_Buffer+$01,X ; 8 bytes to go LDA #$08 STA Graphics_Buffer+$02,X ; Set the rotation colors into the buffer LDA Rotation_Colors,Y STA Graphics_Buffer+$04,X STA Graphics_Buffer+$05,X STA Graphics_Buffer+$06,X STA Graphics_Buffer+$08,X LDA Palette_Buffer+$4 STA Graphics_Buffer+$03,X LDA Palette_Buffer+$8 STA Graphics_Buffer+$07,X LDA Palette_Buffer+$A STA Graphics_Buffer+$09,X LDA Palette_Buffer+$B STA Graphics_Buffer+$0A,X ; Terminator LDA #$00 STA Graphics_Buffer+$0B,X ; Add to the graphics buffer counter TXA ADD #$0b STA Graphics_BufCnt PRG007_A1EA: RTS ; Return PRG007_A1EB: ; Bit 7 not set on RotatingColor_Cnt LDA RotatingColor_Cnt BEQ PRG007_A1F5 ; If RotatingColor_Cnt = 0, jump to PRG007_A1F5 ; Set the rotation colors into the buffer LDA Rotation_Colors,Y BNE PRG007_A1F8 ; Jump (technically always) to PRG007_A1F8 PRG007_A1F5: LDA Palette_Buffer+$10 PRG007_A1F8: STA Graphics_Buffer+$03,X LDA #$10 STA Graphics_Buffer+$01,X LDA Palette_Buffer+$11 STA Graphics_Buffer+$04,X LDA Palette_Buffer+$12 STA Graphics_Buffer+$05,X LDA Palette_Buffer+$13 STA Graphics_Buffer+$06,X ; Address of palette to modify LDA #$3f STA Graphics_Buffer+$00,X LDA #$04 STA Graphics_Buffer+$02,X ; Terminator LDA #$00 STA Graphics_Buffer+$07,X ; Add to the graphics buffer counter TXA ADD #$07 STA Graphics_BufCnt RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Gameplay_UpdateAndDrawMisc ; ; Color rotation effects, lava, donut lifts, arrow platforms, ; brick busts, water/waterfall visual effects, bubbles, splashes, ; pop-up coins, Special Objects, Cannon Fires, Player Projectiles, ; and, last but not least (well, maybe least), "shell kill flashes"! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Gameplay_UpdateAndDrawMisc: JSR ColorRotation_Do ; Do color rotation effects, if any JSR Player_DoLavaDonutArrowBounce ; Handle Lava, Donut Lifts, and Arrow platforms JSR BrickBusts_DrawAndUpdate ; Draw and update brick bust effects JSR Player_WaterOrWaterfallVizFX ; Standing in a waterfall splashing or periodic bubbles underwater JSR Bubbles_UpdateAndDraw ; Update and draw underwater bubbles JSR Splash_UpdateAndDraw ; Update and draw water surface splashes JSR CoinPUps_DrawAndUpdate ; Update and draw coins that have popped out of boxes JSR SpecialObjs_UpdateAndDraw ; Update and draw Special objects JSR CannonFire_UpdateAndDraw ; Update and draw the Cannon Fires JSR PlayerProjs_UpdateAndDraw ; Update and draw Player's weapon projectiles LDA <Player_Suit CMP #PLAYERSUIT_HAMMER BEQ PRG007_A251 ; If Player is wearing a Hammer Suit, jump to PRG007_A251 CMP #PLAYERSUIT_FIRE BNE PRG007_A268 ; If Player is not Fire, jump to PRG007_A268 PRG007_A251: ; Player wearing a Hammer Suit or Fire LDA Player_HaltTick ; If Player is not halted ... ORA Player_IsDucking ; ... Player is ducking ... ORA Player_Kick ; ... Player is kicking ... ORA Player_InPipe ; ... Player is in a pipe ... ORA <Player_HaltGame ; ... gameplay is halted ... BNE PRG007_A268 ; ... then jump to PRG007_A268 BIT <Pad_Input BVC PRG007_A268 ; If Player is NOT pressing B, jump to PRG007_A268 JSR PlayerProj_ThrowWeapon ; Player throws weapon, whatever's appropriate PRG007_A268: LDA ShellKillFlash_Cnt BEQ PRG007_A2AE ; If ShellKillFlash_Cnt = 0, jump to PRG007_A2AE (RTS) DEC ShellKillFlash_Cnt ; ShellKillFlash_Cnt-- LDY #$00 ; Y = 0 ; Set the shell kill flash left/right sprite Y LDA ShellKillFlash_Y SUB Level_VertScroll STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y ; Set left sprite X LDA ShellKillFlash_X SUB <Horz_Scroll STA Sprite_RAM+$03,Y ; Set right sprite X ADD #$08 STA Sprite_RAM+$07,Y ; Set left/right sprite pattern LDA #$57 STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y ; Temp_Var1 = toggled vertical flip bit LDA <Counter_1 LSR A LSR A LSR A ROR A AND #SPR_VFLIP STA <Temp_Var1 ; OR in a palette cycle LDA <Counter_1 AND #$03 ORA <Temp_Var1 ; Set left sprite attribute STA Sprite_RAM+$02,Y ; Set right sprite attribute EOR #(SPR_HFLIP | SPR_VFLIP) STA Sprite_RAM+$06,Y PRG007_A2AE: RTS ; Return PlayerProj_ThrowWeapon: LDX #$01 ; X = 1 PRG007_A2B1: LDA PlayerProj_ID,X BEQ PRG007_A2BA ; If this Player projectile slot is free DEX ; X-- BPL PRG007_A2B1 ; While X >= 0, loop! RTS ; Return PRG007_A2BA: ; Player "fire" sound LDA Sound_QPlayer ORA #SND_PLAYERFIRE STA Sound_QPlayer ; Player should use "fire" frame! LDA #$0b STA Player_FireCount ; Set projectile X LDA <Player_X ADD #$04 STA PlayerProj_X,X ; Set projectile Y Hi LDA <Player_Y STA PlayerProj_Y,X LDA <Player_YHi STA PlayerProj_YHi,X LDA #$01 ; A = 1 LDY <Player_Suit CPY #PLAYERSUIT_HAMMER SEC ; Set carry (if NOT wearing the hammer suit) BNE PRG007_A2E3 ; If Player is NOT wearing the Hammer Suit, jump to PRG007_A2E3 ASL A ; Clears carry, also A = 2 PRG007_A2E3: STA PlayerProj_ID,X ; Set projectile as type 1 or 2 ; Set Player Projectile Y velocity LDA #$03 ; A = $03 (Fireballs are thrown down) BCS PRG007_A2EC ; If Player is NOT wearing Hammer Suit, jump to PRG007_A2EC LDA #-$03 ; A = -$03 (Hammers are thrown up) PRG007_A2EC: STA PlayerProj_YVel,X ; Temp_Var1 = 0 (no offset for fireballs) LDA #$00 STA <Temp_Var1 LDA #$03 ; A = $03 (Fire) BCS PRG007_A304 ; If Player is NOT wearing Hammer Suit, jump to PRG007_A304 ; Calculate the hammer X velocity offset LDA <Player_FlipBits ; Keep in mind this is generally only $00 or $40 since Player doesn't vertically flip/etc. ASL A ; ... so this makes a positive or negative sign EOR <Player_XVel ; XOR in the Player's X velocity BPL PRG007_A302 ; If result is positive, jump to PRG007_A302 ; Otherwise, set Temp_Var1 = Player_XVel LDA <Player_XVel STA <Temp_Var1 PRG007_A302: LDA #$10 ; A = $10 (Hammer) PRG007_A304: LDY <Player_FlipBits ; Keep in mind this is generally only $00 or $40 since Player doesn't vertically flip/etc. BNE PRG007_A30B ; If Player is horizontally flipped, jump to PRG007_A30B JSR Negate ; If Player is turned around, negate value PRG007_A30B: ADD <Temp_Var1 ; Add Temp_Var1 (X Velocity offset, if applicable) STA PlayerProj_XVel,X ; Store Projectile X velocity ; PlayerProj_Cnt = 0 LDA #$00 STA PlayerProj_Cnt,X RTS ; Return PlayerFireball_Pats: .byte $65, $67, $65, $67 PlayerFireball_FlipBits: .byte SPR_PAL1, SPR_PAL1, SPR_PAL1 | SPR_HFLIP | SPR_VFLIP, SPR_PAL1 | SPR_HFLIP | SPR_VFLIP PlayerHammer_FlipBits: .byte $00, SPR_VFLIP, SPR_HFLIP | SPR_VFLIP, SPR_HFLIP PlayerHammer_YOff: .byte $00 ; NOTE: Next three values overlap into following table) PlayerHammer_XOff: .byte $06, $06, $00, $00 PRG007_A328: RTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; PlayerProjs_UpdateAndDraw ; ; Update and draw Player Projectiles ; (weapons, i.e. fireballs/hammers/fireball poofs) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PlayerProjs_UpdateAndDraw: LDX #$01 ; X = 1 STX <SlotIndexBackup ; SlotIndexBackup = 1 JSR PlayerProj_UpdateAndDraw ; Update and draw this Player Projectile DEC <SlotIndexBackup ; SlotIndexBackup = 0 DEX ; X = 0 PlayerProj_UpdateAndDraw: LDA PlayerProj_ID,X BEQ PRG007_A328 ; If Player Projectile slot is empty, jump to PRG007_A328 (RTS) CMP #$03 BLT PRG007_A33F ; If Player Projectile ID < 3 (not the fireball poof), jump to PRG007_A33F JMP PRG007_A705 ; Jump to PRG007_A705 PRG007_A33F: ; Hammer or Fireball... LDA AScrlURDiag_WrapState_Copy BEQ PRG007_A361 ; If diagonal scroller is not wrapping, jump to PRG007_A361 LDA <Player_HaltGame BNE PRG007_A361 ; If gameplay is halted, jump to PRG007_A361 ; Offset Player projectile to compensate for the diagonal autoscroller's wrap LDA PlayerProj_X,X ADD AScrlURDiag_OffsetX STA PlayerProj_X,X LDA PlayerProj_Y,X ADD AScrlURDiag_OffsetY STA PlayerProj_Y,X BCC PRG007_A361 INC PlayerProj_YHi,X ; Apply carry PRG007_A361: LDY <Player_HaltGame BNE PRG007_A3DB ; If gameplay halted, jump to PRG007_A3DB LDA PlayerProj_YVel,X LDY Level_AScrlConfig BEQ PRG007_A371 ; If no auto scroll effect is active, jump to PRG007_A371 ADD Level_ScrollDiffV ; Add auto scroll's vertical delta to Player's Y velocity PRG007_A371: PHA ; Save Projectile Y Velocity LDY #$00 ; Y = $00 (16-bit sign extension) PLA ; Restore Projectile Y Velocity BPL PRG007_A378 ; If not negative, jump to PRG007_A378 DEY ; Y = $FF (16-bit sign extension) PRG007_A378: ADD PlayerProj_Y,X ; Apply Y velocity STA PlayerProj_Y,X ; Update Y ; Cascade into Y Hi TYA ADC PlayerProj_YHi,X STA PlayerProj_YHi,X INC PlayerProj_Cnt,X ; PlayerProj_Cnt++ LDA PlayerProj_ID,X CMP #$02 BNE PRG007_A3C0 ; If this is NOT the hammer, jump to PRG007_A3C0 ; Hammer specific velocity code... LDA PlayerProj_XVel,X ASL A ASL A ASL A ASL A ; Fractional part shifted up ADD PlayerProj_XVelFrac,X STA PlayerProj_XVelFrac,X ; Add to object's X vel fractional accumulator PHP ; Save CPU status LDA PlayerProj_XVel,X ; Get X Velocity LSR A LSR A LSR A LSR A ; Whole part shifted down (integer) CMP #%00001000 ; Check the sign bit BLT PRG007_A3AC ; If the value was not negatively signed, jump to PRG007_A3AC ORA #%11110000 ; Otherwise, apply a sign extension PRG007_A3AC: PLP ; Restore CPU status ADC PlayerProj_X,X ; Apply X velocity STA PlayerProj_X,X ; Update X LDA PlayerProj_Cnt,X AND #$07 BNE PRG007_A3BD ; 1:8 ticks proceed, otherwise jump to PRG007_A3BD INC PlayerProj_YVel,X ; Increase Y velocity (gravity) PRG007_A3BD: JMP PRG007_A3DB ; Jump to PRG007_A3DB PRG007_A3C0: ; Fireball specific velocity code... ; X velocity is applied as integer (no fractional accumulator) LDA PlayerProj_X,X ADD PlayerProj_XVel,X STA PlayerProj_X,X LDA PlayerProj_YVel,X CMP #$04 BEQ PRG007_A3DB ; If fireball's Y velocity = 4, jump to PRG007_A3DB LDA PlayerProj_Cnt,X AND #$03 BNE PRG007_A3DB ; 1:4 ticks proceed, otherwise jump to PRG007_A3DB INC PlayerProj_YVel,X ; Increase Y velocity (gravity) PRG007_A3DB: ; Fireball/Hammer common... ; Temp_Var2 = scroll relative X LDA PlayerProj_X,X SUB <Horz_Scroll STA <Temp_Var2 ADD #11 CMP #19 BGE PRG007_A3F0 ; If Player Projectile X >= 19, jump to PRG007_A3F0 PRG007_A3EA: ; Otherwise remove it and let's get out of here! LDA #$00 STA PlayerProj_ID,X PRG007_A3EF: RTS ; Return PRG007_A3F0: ADC #-$08 ; X Relative - 8 STA <Temp_Var14 ; -> Temp_Var14 LDA PlayerProj_ID,X CMP #$01 BNE PRG007_A400 ; If this is NOT the fireball, jump to PRG007_A400 ; Fireball only... LDA PlayerProj_YVel,X BMI PRG007_A40E ; If fireball is moving upward, jump to PRG007_A40E PRG007_A400: LDA PlayerProj_Y,X CMP Level_VertScroll LDA PlayerProj_YHi,X SBC Level_VertScrollH BMI PRG007_A3EF ; If Player projectile is vertically off-screen, jump to PRG007_A3EF (RTS) PRG007_A40E: TXA ASL A ASL A ; A = Player Projectile slot index * 4 ADD Object_SprRAM+6 ; Offset into high end Sprite RAM TAY ; -> 'Y' ; Set projectile sprite X LDA <Temp_Var2 STA Sprite_RAM+$03,Y LDA PlayerProj_Y,X SUB Level_VertScroll CMP #192 BGE PRG007_A3EA ; If projectile relative Y >= 192, jump to PRG007_A3EA (too low, remove projectile) ; Set projectile sprite Y STA Sprite_RAM+$00,Y ADC #14 ; Y + 14 STA <Temp_Var13 ; -> Temp_Var13 ; Temp_Var3 = initial sprite attribute by Player's travel direction LDA PlayerProj_XVel,X LSR A ; Sign bit shifted right AND #SPR_HFLIP STA <Temp_Var3 LDA PlayerProj_ID,X CMP #$02 BNE PRG007_A471 ; If this is NOT the hammer, jump to PRG007_A471 ; Hammer only... LDA <Player_Suit CMP #PLAYERSUIT_HAMMER BNE PlayerProj_ChangeToPoof ; If Player is NOT wearing the Hammer Suit anymore (uh oh), jump to PlayerProj_ChangeToPoof LDA PlayerProj_Cnt,X LSR A LSR A AND #$03 TAX ; X = 0 to 3 LDA PlayerHammer_XOff,X ; Get X offset BIT <Temp_Var3 ; Check for horizontal flip BVC PRG007_A453 ; If no flip, jump to PRG007_A453 EOR #$06 ; Otherwise, invert X offset PRG007_A453: ADD <Temp_Var2 ; Apply X offset STA Sprite_RAM+$03,Y ; Set Hammer X LDA PlayerHammer_YOff,X ; Get Y offset ADD Sprite_RAM+$00,Y ; Add to Sprite Y STA Sprite_RAM+$00,Y ; Update Sprite Y ; Hammer pattern LDA #$d7 STA Sprite_RAM+$01,Y LDA <Temp_Var3 ; Get horizontal flip bit EOR PlayerHammer_FlipBits,X ; XOR in the hammer flip bits SEC ; Set carry (hammer) JMP PRG007_A485 ; Jump to PRG007_A485 PRG007_A471: ; Fireball only... LDA Level_NoStopCnt LSR A LSR A AND #$03 TAX ; X = 0 to 3 ; Set fireball pattern LDA PlayerFireball_Pats,X STA Sprite_RAM+$01,Y ; Set fireball attributes LDA <Temp_Var3 ; Get horizontal flip bit EOR PlayerFireball_FlipBits,X ; XOR in the fireball flip bits CLC ; Clear carry (fireball) PRG007_A485: LDX Player_Behind BEQ PRG007_A48C ; If Player is not "behind the scenes", jump to PRG007_A48C ORA #SPR_BEHINDBG ; Set priority PRG007_A48C: STA Sprite_RAM+$02,Y ; Set Player Projectile attributes LDX <SlotIndexBackup ; X = Player Projectile slot index LDA <Player_HaltGame BNE PRG007_A4A2 ; If gameplay is halted, jump to PRG007_A4A2 ; Gameplay not halted... BCS PRG007_A49A ; If this is the hammer, jump to PRG007_A49A (PlayerProj_HitEnemies) JSR Fireball_DetectWorld ; Hit tests for fireball (bounce, poof, etc.) PRG007_A49A: JMP PlayerProj_HitEnemies ; Jump to PlayerProj_HitEnemies PlayerProj_ChangeToPoof: ; Change Player Projectile to "Poof" LDA #$03 STA PlayerProj_ID,X PRG007_A4A2: RTS ; Return Fireball_DetectWorld: LDA Level_7Vertical BEQ PRG007_A4CF ; If this is not a vertically oriented level, jump to PRG007_A4CF ; Vertical level... LDA <Temp_Var13 ; Detect Y of fireball ADD Level_VertScroll ; Apply vertical scroll STA <Temp_Var6 ; -> Temp_Var6 AND #$f0 ; Aligned to grid row STA <Temp_Var3 ; -> Temp_Var3 ; Temp_Var2 = high byte of tile memory LDA Level_VertScrollH ; Current vertical scroll high ADC #HIGH(Tile_Mem) ; Add the upper byte of the Tile_Mem address STA <Temp_Var2 ; -> Temp_Var2 ; Temp_Var14 = fireball X + 4 LDA PlayerProj_X,X ADC #$04 STA <Temp_Var14 ; Temp_Var1 = Row/Column offset value LSR A LSR A LSR A LSR A ORA <Temp_Var3 STA <Temp_Var1 LDY #$00 ; Y = 0 (don't need additional offset) JMP PRG007_A52D ; Jump to PRG007_A52D PRG007_A4CF: ; Non-vertical level... LDA Player_PartDetEn BEQ PRG007_A4E7 ; If Player_PartDetEn is not enabled, jump to PRG007_A4E7 ; When fireball Y >= 160, force detection of bottom two rows of tiles LDA <Temp_Var13 ; Detect Y of fireball CMP #160 BLT PRG007_A4E9 ; If < 160, jump to PRG007_A4E9 SBC #16 ; Detect Y - 16 STA <Temp_Var6 ; -> Temp_Var6 AND #$f0 ; Aligned to grid row STA <Temp_Var3 ; -> Temp_Var3 LDA #$01 ; A = 1 (force bottom tiles) JMP PRG007_A4F8 ; Jump to PRG007_A4F8 PRG007_A4E7: LDA <Temp_Var13 ; Detect Y of fireball PRG007_A4E9: ADD Level_VertScroll ; Apply vertical scroll STA <Temp_Var6 ; -> Temp_Var6 AND #$f0 ; Aligned to grid row STA <Temp_Var3 ; -> Temp_Var3 LDA Level_VertScrollH ; Current vertical scroll high ADC #$00 ; Apply carry PRG007_A4F8 STA <Temp_Var4 ; -> Temp_Var4 BEQ PRG007_A506 ; If vertical high = 0, jump to PRG007_A506 CMP #$02 BGE PRG007_A557 ; If vertical high >= 2 (way too low), jump to PRG007_A557 LDA <Temp_Var3 CMP #$B0 BGE PRG007_A557 ; If at or lower than $1B0 (too low), jump to PRG007_A557 PRG007_A506: LDA <Temp_Var14 ; Fireball detect X ADD <Horz_Scroll ; Apply horizontal scroll STA <Temp_Var5 ; -> Temp_Var5 LDA <Horz_Scroll_Hi ADC #$00 STA <Temp_Var7 ; High value -> Temp_Var7 ASL A ; Multiply by 2 for Tile_Mem_Addr index TAY ; -> 'Y' ; Temp_Var1 = low byte of Tile_Mem_Addr LDA Tile_Mem_Addr,Y STA <Temp_Var1 ; Temp_Var2 = high byte of Tile_Mem_Addr LDA <Temp_Var4 AND #$01 ; Only 0 or 1 is valid in non-vertical ADD Tile_Mem_Addr+1,Y STA <Temp_Var2 ; Y = row/column offset index LDA <Temp_Var5 LSR A LSR A LSR A LSR A ORA <Temp_Var3 TAY PRG007_A52D: LDA [Temp_Var1],Y ; Get the tile at the Player Projectile JSR PSwitch_SubstTileAndAttr ; Handle P-Switch changed tiles PHA ; Save adjusted tile ASL A ROL A ROL A AND #$03 TAY ; Y = quadrant of tile STY <Temp_Var2 ; -> Temp_Var2 PLA ; Restore adjusted tile STA <Temp_Var1 ; -> Temp_Var1 CMP Tile_AttrTable,Y BLT PRG007_A557 ; If this tile is not solid on top, jump to PRG007_A557 ; Tile is solid on top... CMP Tile_AttrTable+4,Y BLT PRG007_A59F ; If this tile is not solid on the sides/bottom, jump to PRG007_A59F ; Tile is solid all around LDY Level_TilesetIdx CPY #$0b BNE PRG007_A566 ; If this is not an Ice level, jump to PRG007_A566 CMP #TILE12_FROZENMUNCHER BNE PRG007_A55D ; If the fireball did not hit a frozen muncher, jump to PRG007_A55D ; Fireball hit a frozen muncher! LDA #CHNGTILE_FROZENMUNCHER BNE PRG007_A563 ; Jump (technically always) to PRG007_A563 PRG007_A557: ; Fireball_HitChkPass = 0 LDA #$00 STA Fireball_HitChkPass,X RTS ; Return PRG007_A55D: CMP #TILE12_FROZENCOIN BNE PRG007_A566 ; If the fireball did not hit a frozen coin, jump to PRG007_A566 ; Fireball hit a frozen coin! LDA #CHNGTILE_FROZENCOIN PRG007_A563: JSR Fireball_ThawTile ; Thaw the frozen tile! PRG007_A566: LDA <Temp_Var1 LDY Level_SlopeEn BEQ PRG007_A579 ; If this level is NOT sloped, jump to PRG007_A579 ; If this is a slope level and fireball hit level ground, jump to PRG007_A594 CMP #TILE14_ABOVE_MIDGROUND BEQ PRG007_A594 CMP #TILE3_MIDGROUND BEQ PRG007_A594 CMP #TILE3_WMIDGROUND BEQ PRG007_A594 PRG007_A579: INC Fireball_HitChkPass,X ; Fireball_HitChkPass++ LDA Fireball_HitChkPass,X CMP #$02 BNE PRG007_A586 ; If Fireball_HitChkPass <> 2, jump to PRG007_A586 ; Fireball has been through hit check too many times, it's obviously done JMP PRG007_A637 ; Jump to PRG007_A637 ("Poof" away, fireball..) PRG007_A586: ; Fireball Y -= 2 LDA PlayerProj_Y,X SUB #$02 STA PlayerProj_Y,X BCS PRG007_A594 DEC PlayerProj_YHi,X ; Apply carry PRG007_A594: ; Bounce fireball! LDA #-$03 PRG007_A596: STA PlayerProj_YVel,X ; Reset counter to 3 LDA #$03 STA PlayerProj_Cnt,X RTS ; Return PRG007_A59F: ; Tile not solid on sides/bottom... LDA Level_SlopeEn BNE PRG007_A5DC ; If this is a sloped level, jump to PRG007_A5DC ; Not a sloped level... LDA <Temp_Var6 ; Relative Y of fireball AND #$0f ; Within tile CMP #$05 BLT PRG007_A594 ; If fireball is high enough on the top-solid-only tile, then bounce! (Jump to PRG007_A594) RTS ; Return Fireball_ThawTile: STA Level_ChgTileEvent ; Queue tile change event! JSR BrickBust_MoveOver ; Open up a brick bust ; Brick bust "poof" style (over top of the changing tile) LDA #$01 STA BrickBust_En ; Set block change Y LDA <Temp_Var3 STA Level_BlockChgYLo ; Set poof Y SBC Level_VertScroll STA BrickBust_YUpr ; Set block change Y Hi LDA <Temp_Var4 STA Level_BlockChgYHi ; Set block change X LDA <Temp_Var5 AND #$f0 STA Level_BlockChgXLo ; Set poof X SBC <Horz_Scroll STA BrickBust_X ; Set block change X Hi LDA <Temp_Var7 STA Level_BlockChgXHi JMP PlayerProj_ChangeToPoof ; Change the projectile itself into a poof PRG007_A5DC: ; Temp_Var6 will remain as "Y offset within tile" LDA <Temp_Var6 AND #$0f STA <Temp_Var6 ; Temp_Var5 will remain as "X offset within tile" LDA <Temp_Var5 AND #$0f STA <Temp_Var5 LDY <Temp_Var2 ; Y = tile quadrant TYA ASL A TAX ; X = tile quadrant * 2 (2 byte index into Level_SlopeSetByQuad) ; Temp_Var3/4 pointer into appropriate Level_SlopeSetByQuad LDA Level_SlopeSetByQuad,X STA <Temp_Var3 LDA Level_SlopeSetByQuad+1,X STA <Temp_Var4 LDX <SlotIndexBackup ; X = Player Projectile index LDA <Temp_Var1 SUB Tile_AttrTable,Y TAY ; Y = tile made relative to solid set LDA [Temp_Var3],Y TAY ; Y = slope offset for this tile LDA Slope_ObjectVel_Effect,Y CMP #$80 BEQ PRG007_A637 ; If this tile has no effect, jump to PRG007_A637 ("Poof" away, fireball..) STA <Temp_Var7 ; Effect value -> Temp_Var7 TYA ASL A ASL A ASL A ASL A ; Multiply relative tile index by 16 (because 16 slope values exist across each 16x16 tile) ADD <Temp_Var5 ; Add specific offset across tile TAY ; -> 'Y' ; Lower 4 bits of Slope_LUT (the "sloped floor height" component) -> Temp_Var2 LDA Slope_LUT,Y AND #$0f STA <Temp_Var2 LDA <Temp_Var6 CMP #12 BGE PRG007_A626 ; If fireball is deeper than 12 pixels into the tile, jump to PRG007_A626 CMP <Temp_Var2 BLT PRG007_A645 ; If fireball is higher than the slope height, jump to PRG007_A645 (RTS) PRG007_A626: LDA <Temp_Var7 BEQ PRG007_A642 ; If effect value = 0, jump to PRG007_A642 LDY #-$05 ; Y = -$05 (high bounce velocity) EOR PlayerProj_XVel,X BMI PRG007_A633 LDY #-$02 ; Y = -$02 (low bounce velocity) PRG007_A633: TYA JMP PRG007_A596 ; Jump to PRG007_A596 PRG007_A637: ; "Bump" sound LDA Sound_QPlayer ORA #SND_PLAYERBUMP STA Sound_QPlayer JMP PlayerProj_ChangeToPoof ; Turn into a "poof" and don't come back! PRG007_A642: JMP PRG007_A594 ; Jump to PRG007_A594 (another pass through the hit routines, should cause it to "poof" out) PRG007_A645: RTS ; Return PlayerProj_HitEnemies: ; Fireball/hammer common... LDY #$04 ; Y = 4 (enemies only exist in the lower slots) PRG007_A648: LDA Objects_SprHVis,Y ORA Objects_SprVVis,Y BNE PRG007_A667 ; If object has sprites horizontally or vertically off-screen, jump to PRG007_A667 (Forget it!) LDX Objects_State,Y ; X = object's state LDA Obj2Obj_EnByState,X BNE PRG007_A667 ; If this state does not support object-to-object (object-to-Projectile), jump to PRG007_A667 (Forget it!) LDX Level_ObjectID,Y ; X = object's ID LDA Object_AttrFlags,X STA <Temp_Var1 ; Object attribute flags -> Temp_Var1 AND #OAT_WEAPONIMMUNITY BNE PRG007_A667 ; If object is immune to Player weapons, jump to PRG007_A667 JSR PlayerProj_HitObject ; See if Player Project hit an object and respond! PRG007_A667: DEY ; Y-- BPL PRG007_A648 ; While Y >= 0, loop LDX <SlotIndexBackup ; X = Player Projectile slot index PRG007_A66C: RTS ; Return ; A Y range per bounding box index Projectile_BBoxY: .byte $18, $18, $28, $18, $18, $18, $18, $18, $18, $18, $20, $18, $18, $28, $18, $18 ; An X range per bounding box index Projectile_BBoxX: .byte $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, $10, $18, $10, $10 PlayerProj_HitObject: LDA <Temp_Var1 AND #OAT_BOUNDBOXMASK TAX ; X = Object's bounding box index STX <Temp_Var2 ; -> Temp_var2 LDA <Temp_Var13 ; Detect Y of projectile SUB Objects_SpriteY,Y ; Difference against this object's Sprite Y CMP Projectile_BBoxY,X LDX <SlotIndexBackup ; X = Player Projectile slot index BGE PRG007_A66C ; If projectile is out of range vertically, jump to PRG007_A66C (RTS) LDA <Temp_Var14 ; Detect X of projectile SUB Objects_SpriteX,Y ; Difference against this object's Sprite X LDX <Temp_Var2 ; X = bounding box index CMP Projectile_BBoxX,X LDX <SlotIndexBackup ; X = Player Projectile slot index BGE PRG007_A6FD ; If projectile is out of range horizontally, jump to PRG007_A6FD (RTS) LDA PlayerProj_ID,X CMP #$02 BEQ PRG007_A6BD ; If this is a hammer, jump to PRG007_A6BD JSR PlayerProj_ChangeToPoof ; "Poof" goes the fireball JMP PRG007_A6C3 ; Jump to PRG007_A6C3 PRG007_A6BD: ; Hammer hit... LDA <Temp_Var1 ; Object's attributes BMI PRG007_A6FD ; If OAT_HITNOTKILL is set, jump to PRG007_A6FD (RTS) BPL PRG007_A6C9 ; Otherwise, jump to PRG007_A6C9 PRG007_A6C3: ; Fireball only... LDA <Temp_Var1 AND #OAT_FIREIMMUNITY BNE PRG007_A6FE ; If object is immune to fire, jump to PRG007_A6FE PRG007_A6C9: ; Weapon successfully hit! ; Play "kick" sound LDA Sound_QPlayer ORA #SND_PLAYERKICK STA Sound_QPlayer LDA Objects_HitCount,Y BEQ PRG007_A6DD ; If enemy has no hits left, jump to PRG007_A6DD ; Otherwise, just remove a hit... SUB #$01 STA Objects_HitCount,Y RTS ; Return PRG007_A6DD: ; Enemy bounces upward a bit LDA #-$34 STA Objects_YVel,Y ; Set object's velocity based on Player's velocity (sort of works) LDA PlayerProj_XVel,X ASL A LDA #$0C BCC PRG007_A6EC ; If Player's X Velocity is negative, jump to PRG007_A6EC LDA #-$0C PRG007_A6EC: STA Objects_XVel,Y TYA TAX ; object index -> 'X' ; 100 pts! LDA #$05 JSR Score_PopUp LDX <SlotIndexBackup ; X = Player Projectile slot index ; But the enemy is killed... LDA #OBJSTATE_KILLED STA Objects_State,Y PRG007_A6FD: RTS ; Return PRG007_A6FE: JMP PRG007_A637 ; Jump to PRG007_A637 Fireball_PoofPattern: .byte $45, $41, $43, $47 PRG007_A705: ; Fireball poof! LDY <Player_HaltGame BNE PRG007_A719 ; If gameplay halted, jump to PRG007_A719 ; PlayerProj_ID is now the fireball poof counter for the remainder INC PlayerProj_ID,X ; PlayerProj_ID++ LDA PlayerProj_ID,X CMP #$10 BNE PRG007_A719 ; If PlayerProj_ID <> $10, jump to PRG007_A719 PRG007_A713: ; Poof is over; clear it! LDA #$00 STA PlayerProj_ID,X RTS ; Return PRG007_A719: TXA ADD <Counter_1 AND #$01 ; A = 0 or 1 ASL A ASL A ASL A ; A = 0 or 8 ADC #$18 ; A = $18 or $20 TAY ; -> 'Y' ; Set poof left sprite X LDA PlayerProj_X,X SBC #$04 SUB <Horz_Scroll STA Sprite_RAM+$03,Y ; Set poof right sprite X ADD #$08 STA Sprite_RAM+$07,Y LDA PlayerProj_Y,X SUB Level_VertScroll CMP #208 BGE PRG007_A713 ; If poof has fallen too low, jump to PRG007_A713 (remove it) ; Set left and right "poof" sprite Ys STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y LDA PlayerProj_ID,X LSR A LSR A TAX ; X = index into Fireball_PoofPattern LDA Fireball_PoofPattern,X ; Get proper poof pattern ; Set left and right "poof" sprite pattern STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y LDA #SPR_PAL1 LDX Player_Behind BEQ PRG007_A75F ; If Player is not behind the scenes, jump to PRG007_A75F ORA #SPR_BEHINDBG PRG007_A75F: STA Sprite_RAM+$02,Y ; Set left sprite attributes ORA #(SPR_HFLIP | SPR_VFLIP) STA Sprite_RAM+$06,Y ; Set right sprite attributes LDX <SlotIndexBackup ; X = Player Projectile slot index RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Player_WaterOrWaterfallVizFX ; ; Visual effects for standing in a waterfall (splashing on head) ; or the periodic bubbles underwater... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Y offsets for periodic bubble generated by the Player while underwater SwimBubble_YOff: .byte $04, $04 ; Not a frog swimming frame .byte $08, $08 ; Idle or left/right frog swimming .byte $0D, $0D ; Down frog swim .byte $00, $00 ; Up frog swim ; X offsets for periodic bubble generated by the Player while underwater (left is not horizontally flipped, right is h-flipped) SwimBubble_XOff: .byte $00, $0B ; Not a frog swimming frame .byte $00, $0B ; Idle or left/right frog swimming .byte $05, $05 ; Down frog swim .byte $05, $05 ; Up frog swim Player_WaterOrWaterfallVizFX: LDY Player_FlyTime INY BNE PRG007_A783 ; (Will be zero if Player_FlyTime = $FF, i.e. P-Wing) If not using P-Wing, jump to PRG007_A783 ; Otherwise, clear kill tally (P-Wing does not net you 1-ups) STY Kill_Tally PRG007_A783: LDY <Player_HaltGame BNE PRG007_A7F0 ; If gameplay halted, jump to PRG007_A7F0 (RTS) LDA Player_InWater BEQ PRG007_A7F0 ; If Player is not underwater, jump to PRG007_A7F0 (RTS) ; Otherwise, clear kill tally (Being underwater also resets your chain stomping) STY Kill_Tally CMP #$01 BEQ PRG007_A7F1 ; If Player_InWater = 1 (water, not waterfall), jump to PRG007_A7F1 ; Player's in a waterfall! LDA <Player_YVel CMP #$3c BGS PRG007_A7A2 ; If Player's Y velocity >= $3C, jump to PRG007_A7A2 INC <Player_YVel ; Player_YVel++ LDA <Counter_1 LSR A BCC PRG007_A7A2 ; Every other tick, jump to PRG007_A7A2 INC <Player_YVel ; Player_YVel++ PRG007_A7A2: JSR Object_GetRandNearUnusedSpr BEQ PRG007_A7F0 ; If no free sprite, jump to PRG007_A7F0 (RTS) LDA Player_OffScreen BNE PRG007_A7F0 ; If Player is off-screen, jump to PRG007_A7F0 (RTS) ; Patterns for "splashing" effect seen above Player's head LDA #$47 STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y LDA <Counter_1 LSR A AND #$03 ADD #$05 ; Value of 5 to 8 LDX Player_IsDucking BNE PRG007_A7C6 ; If Player is ducking, jump to PRG007_A7C6 LDX Player_Suit BNE PRG007_A7C9 ; If Player is not small, jump to PRG007_A7C9 PRG007_A7C6: ADD #10 ; Small or ducking, +10 (15 to 18) PRG007_A7C9: STA <Temp_Var1 ; -> Temp_Var1 LDX <SlotIndexBackup ; Restore 'X' as slot index ; Sprite "splashing" effect Y LDA <Player_SpriteY ADD <Temp_Var1 SUB #10 STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y ; Sprite "splashing" effect X LDA <Player_SpriteX STA Sprite_RAM+$03,Y ADD #$08 STA Sprite_RAM+$07,Y LDA <Counter_1 AND #$03 SUB #$02 ; A = -2 to 1 (spread value) JSR Draw_SpreadAndColorful ; Spreads out the two sprites and rotates the color palette PRG007_A7F0: RTS ; Return PRG007_A7F1: ; Player's in regular old water LDY #$7f ; Y = $7F ("slow" mask value for idle underwater player) LDA <Pad_Holding AND #(PAD_A | PAD_LEFT | PAD_RIGHT) BEQ PRG007_A7FB ; If Player is not pressing A, LEFT, or RIGHT (swim controls), jump to PRG007_A7FB LDY #$3f ; Y = $3F ("fast" mask value for idle underwater player) PRG007_A7FB: TYA ; Mask -> 'Y' AND <Counter_1 BNE PRG007_A80C ; Periodically jump to PRG007_A80C (RTS) ; SlotIndexBackup = 2 LDX #$02 PRG007_A802: STX <SlotIndexBackup LDA Bubble_Cnt,X BEQ PRG007_A80D ; If this bubble slot is empty, jump to PRG007_A80D DEX ; X-- BPL PRG007_A802 ; While X >= 0, loop! PRG007_A80C: RTS ; Return PRG007_A80D: LDA RandomN ORA #$10 STA Bubble_Cnt,X ; Set random value -> Bubble_Cnt LDY #$00 ; Y = 0 LDA <Player_Frame CMP #PF_FROGSWIM_UPBASE BLT PRG007_A835 ; If Player is not within the low end range of frog suit swim frames, jump to PRG007_A835 LDY #$03 ; Otherwise, Y = 3 (pending this might be the "up" frame) CMP #PF_FROGHOP_BASE BLT PRG007_A835 ; If frame < PF_FROGHOP_BASE (if true, then absolutely the "up" swim frame), jump to PRG007_A835 LDY #$00 ; Otherwise, Y = 0 CMP #PF_FROGSWIM_IDLEBASE BLT PRG007_A835 ; If not possibly just the "idling" frog frames, jump to PRG007_A835 INY ; Otherwise, Y = 1 (idle or left/right frog swim) CMP #PF_FROGSWIM_LRBASE+2 BLT PRG007_A835 ; Not a down swimming frame, jump to PRG007_A835 INY ; Otherwise, Y = 2 (down frog swim) CMP #(PF_FROGSWIM_DOWNBASE+3) ; This is actually 1 passed the end of frog suit swim frames BLT PRG007_A835 ; If within range of the last frog suit swim frame, jump to PRG007_A835 LDY #$00 ; Otherwise, Y = 0 PRG007_A835: ; Y *= 2 TYA ASL A TAY BIT <Player_FlipBits BVC PRG007_A83D ; If Player is not horizontally flipped, jump to PRG007_A83D INY ; Otherwise, Y++ PRG007_A83D: LDA #$00 ; A = 0 LDX <Player_Suit BNE PRG007_A845 ; If Player is not small, jump to PRG007_A845 LDA #$08 ; Otherwise, A = 8 PRG007_A845: LDX <SlotIndexBackup ; X = slot backup ; Set Bubble Y ADD <Player_Y ADC SwimBubble_YOff,Y STA Bubble_Y,X LDA <Player_YHi ADC #$00 STA Bubble_YHi,X ; Set Bubble X LDA <Player_X ADD SwimBubble_XOff,Y STA Bubble_X,X LDA <Player_XHi ADC #$00 STA Bubble_XHi,X RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Bubbles_UpdateAndDraw ; ; Update and draw bubbles that appear underwater ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Bubbles_UpdateAndDraw: LDX #$03 ; X = 3 PRG007_A86A: STX <SlotIndexBackup ; -> Slot index backup LDA Bubble_Cnt,X BEQ PRG007_A874 ; If this bubble slot is not in use, jump to PRG007_A874 JSR Bubble_UpdateAndDraw ; Update and draw this bubble PRG007_A874: DEX ; X-- BPL PRG007_A86A ; While X >= 0, loop! RTS ; Return Bubble_UpdateAndDraw: LDA <Player_HaltGame BEQ PRG007_A87F ; If gameplay is not halted, juimp to PRG007_A89A JMP PRG007_A89A ; Otherwise, jump to PRG007_A89A PRG007_A87F: INC Bubble_Cnt,X ; Bubble counter increment ; Fix bit 7 on bubble counter LDA Bubble_Cnt,X ORA #$80 STA Bubble_Cnt,X AND #%00110000 BEQ PRG007_A89A ; Periodically jump to PRG007_A89A DEC Bubble_Y,X ; Bubble Y -- LDY Bubble_Y,X INY BNE PRG007_A89A ; If no carry, jump to PRG007_A89A DEC Bubble_YHi,X ; Apply carry PRG007_A89A: LDA Level_7Vertical BEQ PRG007_A8BF ; If this level is not vertical, jump to PRG007_A8F0 ; Vertical level... LDA Bubble_Y,X ADD #10 ; Bubble Y + 10 AND #$f0 STA <Temp_Var3 ; Temp_Var3 = bubble row (offset into tile memory) LDA Bubble_YHi,X ADC #HIGH(Tile_Mem) STA <Temp_Var2 ; Temp_Var2 = bubble high offset into tile memory ; Create row/column offset into tile memory for current screen of bubble -> Temp_var1 LDA Bubble_X,X LSR A LSR A LSR A LSR A ORA <Temp_Var3 STA <Temp_Var1 LDY #$00 ; Y = 0 (not using the offset like non-vertical does) BEQ PRG007_A8F0 ; Jump (technically always) to PRG007_A8F0 PRG007_A8BF: LDA Bubble_Y,X ADD #10 ; Bubble Y + 10 AND #$f0 STA <Temp_Var3 ; Temp_Var3 = bubble row (offset into tile memory) LDA Bubble_YHi,X ADC #$00 ; Apply carry PHA ; Save it ; Temp_Var5 = bubble X LDA Bubble_X,X STA <Temp_Var5 LDA Bubble_XHi,X ASL A ; 2 bytes per screen TAY ; Y = offset into Tile_Mem_Addr LDA Tile_Mem_Addr,Y STA <Temp_Var1 ; Temp_Var1 = low byte of this screen's tile memory address PLA ; Restore Bubble's Y Hi AND #$01 ; Only 0/1 valid for non-vertical ADD Tile_Mem_Addr+1,Y ; Add to high byte of address STA <Temp_Var2 ; -> Temp_Var2 ; Create row/column offset -> Temp_Var3 LDA <Temp_Var5 LSR A LSR A LSR A LSR A ORA <Temp_Var3 TAY ; Y = this offset PRG007_A8F0: LDA [Temp_Var1],Y ; Get the tile the bubble detects PHA ; Save it ; Get tile "quadrant" -> Temp_Var1 ASL A ROL A ROL A AND #$03 STA <Temp_Var1 PLA ; Restore specific tile STA <Temp_Var2 ; -> Temp_Var2 LDY <Temp_Var1 ; Y = tile quadrant CMP Tile_AttrTable,Y BGE PRG007_A91E ; If this tile is solid, jump to PRG007_A91E (destroy bubble) LDA Level_TilesetIdx ASL A ASL A ; Tileset index * 4 ADD <Temp_Var1 ; + quadrant TAY ; -> 'Y' (offset into Level_MinTileUWByQuad) LDA <Temp_Var2 CMP #TILE1_WFALLTOP BEQ PRG007_A91E ; If this is the top of a waterfall, jump to PRG007_A915 (indirect to PRG007_A91E) CMP #TILE1_WFALLMID PRG007_A915: BEQ PRG007_A91E ; If this is the top or middle of a waterfall, jump to PRG007_A91E LDA Level_MinTileUWByQuad,Y CMP <Temp_Var2 BLT Bubble_Draw ; If this tile is still considered underwater, jump to Bubble_Draw PRG007_A91E: ; Remove this bubble LDA #$00 STA Bubble_Cnt,X RTS ; Return Bubble_XOff: .byte $00, $01, $00, -$01 Bubble_SprRAMOff: .byte $10, $14, $0C, $FF, $10, $14, $0C Bubble_Draw: LDA Level_NoStopCnt AND #%00001100 LSR A LSR A TAY ; Y = 0 to 3 ; Temp_Var1 = bubble's X offset LDA Bubble_XOff,Y STA <Temp_Var1 LDA <Counter_1 AND #%00000011 ADC <SlotIndexBackup TAY ; Y = (0 to 3) + bubble's index LDA Bubble_SprRAMOff,Y BMI PRG007_A978 ; If we hit the $FF value in Bubble_SprRAMOff, jump to PRG007_A978 (RTS) TAY ; -> 'Y' LDA Sprite_RAM+$00,Y CMP #$f8 BNE PRG007_A978 ; If this sprite is not free, jump to PRG007_A978 (RTS) ; Bubble Y LDA Bubble_Y,X SUB Level_VertScroll STA Sprite_RAM+$00,Y CMP #200 BGE PRG007_A91E ; If this bubble's sprite Y >= 200, jump to PRG007_A91E (destroy bubble) ; Bubble X LDA Bubble_X,X ADD <Temp_Var1 SUB <Horz_Scroll STA Sprite_RAM+$03,Y CMP #248 BCS PRG007_A91E ; If this bubble's X >= 248, jump to PRG007_A91E (destroy bubble) ; Bubble's pattern LDA #$17 STA Sprite_RAM+$01,Y ; Bubble's attributes LDA #SPR_PAL1 STA Sprite_RAM+$02,Y PRG007_A978: RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Splash_UpdateAndDraw ; ; Update and draw water surface splashes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Splash_UpdateAndDraw: LDX #$02 ; X = 2 PRG007_A97B: STX <SlotIndexBackup ; -> Slot Index backup LDA Splash_Counter,X BEQ PRG007_A9A0 ; If no splash is active here, jump to PRG007_A9A0 LDA <Player_HaltGame ; This probably used to skip something if gameplay was halted, i.e. (BNE xxxx) NOP NOP INC Splash_Counter,X ; Splash counter++ LDA <Counter_1 LSR A BCC PRG007_A991 ; Every other tick, jump to PRG007_A991 INC Splash_Counter,X ; Splash counter++ PRG007_A991: LDA Splash_Counter,X CMP #$30 BLT PRG007_A99D ; If splash counter < $30, jump to PRG007_A99D JSR Splash_Remove ; Remove this splash BEQ PRG007_A9A0 ; Jump (technically always) to PRG007_A9A0 PRG007_A99D: JSR Splash_Draw ; Draw this splash PRG007_A9A0: DEX ; X-- BPL PRG007_A97B ; While X >= 0, loop! RTS ; Return Splash_Patterns: .byte $11, $13, $15, $47, $47, $47 Splash_Remove: ; Remove this splash LDA #$00 STA Splash_Counter,X PRG007_A9AF: RTS ; Return Splash_Draw: JSR Object_GetRandNearUnusedSpr BEQ PRG007_A9AF ; If no sprite available, jump to PRG007_A9AF (RTS) STY <Temp_Var1 ; Sprite RAM offset -> Temp_Var1 LDA Splash_X,X SUB <Horz_Scroll ; Make scroll relative X for splash CMP #240 BGE Splash_Remove ; If splash X >= 240, jump to Splash_Remove STA Sprite_RAM+$03,Y ; Set left splash sprite X ADC #$08 ; +8 STA Sprite_RAM+$07,Y ; Set right splash sprite X LDA Splash_Y,X ; Get splash Y LDY Splash_NoScrollY,X BNE PRG007_A9D5 ; If Splash_NoScrollY is set, do not make splash Y scroll relative SUB Level_VertScroll ; Make scroll relative Y for splash PRG007_A9D5: LDY <Temp_Var1 ; Y = sprite RAM offset CMP #$ae BGE Splash_Remove ; If splash sprite RAM offset >= $AE (?), jump to Splash_Remove (remove it!) ; Set splash sprites Y STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y ; Set left splash sprite attributes LDA #SPR_PAL1 STA Sprite_RAM+$02,Y ; Set right splash sprite attributes LDA #(SPR_PAL1 | SPR_HFLIP) STA Sprite_RAM+$06,Y LDA Splash_Counter,X LSR A LSR A LSR A TAX ; X = splash counter / 8 STX <Temp_Var1 ; -> Temp_Var1 ; Set splash sprite patterns LDA Splash_Patterns,X STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y LDX <SlotIndexBackup ; X = splash index LDA <Temp_Var1 CMP #$03 BLT PRG007_AA4C ; If (splash counter / 8) < 3, jump to PRG007_AA4C (RTS) LDA <Counter_1 AND #$01 ORA <Player_HaltGame BNE PRG007_AA10 ; Every other tick or gameplay halted, jump to INC Splash_Y,X ; Splash_Y++ PRG007_AA10: LDA Splash_Counter,X SUB #24 LSR A LSR A LSR A AND #$03 ; A = (splash counter - 24) / 8 Draw_SpreadAndColorful: STA <Temp_Var1 ; Subtract from sprite X LDA Sprite_RAM+$03,Y SUB <Temp_Var1 STA Sprite_RAM+$03,Y ; Add to other sprite X LDA Sprite_RAM+$07,Y ADD <Temp_Var1 STA Sprite_RAM+$07,Y ; Set attributes of two sprites LDA #SPR_PAL1 STA Sprite_RAM+$06,Y ORA #SPR_HFLIP STA Sprite_RAM+$02,Y LDA Level_NoStopCnt AND #$02 BNE PRG007_AA4C ; 2 ticks on, 2 ticks off; jump to PRG007_AA4C (RTS) ; Mess with attributes for a little sparkly fun LDA <Temp_Var1 ORA #SPR_VFLIP STA Sprite_RAM+$02,Y ORA #SPR_HFLIP STA Sprite_RAM+$06,Y PRG007_AA4C: RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Scores_GiveAndDraw ; ; Gives awarded points and draws score sprites. Also caps ; the Kill_Tally variable at a maximum value of 8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Patterns for the left and right sprites of the score sprite ($FF means "don't display") ; 10 20 40 80 100 200 400 800 1000 2000 4000 8000 1-up Score_PatternLeft: .byte $FF, $FF, $FF, $FF, $5B, $63, $6B, $6D, $5B, $63, $6B, $6D, $61 Score_PatternRight: .byte $5B, $63, $6B, $6D, $69, $69, $69, $69, $59, $59, $59, $59, $6F ; Score to add (low byte) ScoreAdd_L: .byte LOW( 1) ; 10 points .byte LOW( 2) ; 20 points .byte LOW( 4) ; 40 points .byte LOW( 8) ; 80 points .byte LOW( 10) ; 100 points .byte LOW( 20) ; 200 points .byte LOW( 40) ; 400 points .byte LOW( 80) ; 800 points .byte LOW(100) ; 1000 points .byte LOW(200) ; 2000 points .byte LOW(400) ; 4000 points .byte LOW(800) ; 8000 points .byte $00 ; 1-up (no score value) ; Score to add (high byte) ScoreAdd_H: .byte HIGH( 1) ; 10 points .byte HIGH( 2) ; 20 points .byte HIGH( 4) ; 40 points .byte HIGH( 8) ; 80 points .byte HIGH( 10) ; 100 points .byte HIGH( 20) ; 200 points .byte HIGH( 40) ; 400 points .byte HIGH( 80) ; 800 points .byte HIGH(100) ; 1000 points .byte HIGH(200) ; 2000 points .byte HIGH(400) ; 4000 points .byte HIGH(800) ; 8000 points .byte $00 ; 1-up (no score value) Scores_GiveAndDraw: LDA Kill_Tally CMP #$08 BLT PRG007_AA8D ; If Kill_Tally < 8, jump to PRG007_AA8D ; Max Kill_Tally at 8 LDA #$08 STA Kill_Tally PRG007_AA8D: LDX #$04 ; X = 4 (all five on-screen "scores") PRG007_AA8F: STX <SlotIndexBackup ; Update SlotIndexBackup LDA Scores_Value,X AND #$7f ; Keep only lower 7 bits BEQ PRG007_AAAD ; If this score's value is $00 or $80, jump to PRG007_AAAD CMP #$0D BLT PRG007_AAA8 ; If score value < $0D (1-up), jump to PRG007_AAA8 LDA Scores_Value,X AND #$80 ; Keep bit 7 ORA #$0d ; Cap at 1-up ($0D) regardless of value STA Scores_Value,X ; Update value AND #$7f ; Keep only lower 7 bits PRG007_AAA8: STA <Temp_Var1 ; Score value -> Temp_Var1 JSR Score_GiveAndDraw ; Give awarded points and draw score sprites PRG007_AAAD: DEX ; X-- BPL PRG007_AA8F ; While X >= 0, loop! RTS ; Return Score_GiveAndDraw: LDA Player_Grow ; If Player is growing up... ORA Player_StarOff ; ... is losing invincibility (?) ... ORA Player_SuitLost ; ... or has lost their power-up ... BNE PRG007_AAC0 ; ... then jump to PRG007_AAC0 LDA <Player_HaltGame BNE PRG007_AB1D ; If gameplay is halted, jump to PRG007_AB1D PRG007_AAC0: LDA Scores_Counter,X BNE PRG007_AACF ; If this score counter hasn't expired, jump to PRG007_AACF PRG007_AAC5: ; Otherwise, this score is finished; clear it out! LDA #$00 STA Scores_Value,X RTS ; Return ; Mask values that control how quickly the score rises Score_RiseCounterMask: .byte $03, $01, $00, $00 PRG007_AACF: DEC Scores_Counter,X ; Decrement the score counter CMP #$2a BNE PRG007_AB04 ; If score counter <> $2A, jump to PRG007_AB04 ; Score counter = $2A... LDY <Temp_Var1 ; Y = score value ; Add Score's value to Score_Earned LDA Score_Earned ADD ScoreAdd_L-1,Y ; -1 because a score value of zero is "empty" STA Score_Earned LDA Score_Earned+1 ADC ScoreAdd_H-1,Y STA Score_Earned+1 CPY #$0d BNE PRG007_AB02 ; If this is not 1-up level score, jump to PRG007_AB02 ; Play 1-up sound! LDA Sound_QLevel1 ORA #SND_LEVEL1UP STA Sound_QLevel1 LDX Player_Current ; X = current Player LDA Player_Lives,X BMI PRG007_AB02 ; If this Player is dead (and how could we be here, hmm?), jump to PRG007_AB02 INC Player_Lives,X ; Otherwise, give them the extra life! PRG007_AB02: LDX <SlotIndexBackup ; X = score slot index PRG007_AB04: LDA Scores_Counter,X LSR A LSR A LSR A LSR A TAY ; Y = score counter / 16 LDA <Counter_1 AND Score_RiseCounterMask,Y BNE PRG007_AB1D ; Periodically jump to PRG007_AB1D LDA Scores_Y,X CMP #$04 BLT PRG007_AB1D ; If this score's Y < 4, jump to PRG007_AB1D DEC Scores_Y,X ; Otherwise, rise up! PRG007_AB1D: ; Scroll score horizontally with screen LDA Scores_X,X SUB Level_ScrollDiffH STA Scores_X,X CMP #248 BGE PRG007_AAC5 ; If score's X >= 248, jump to PRG007_AAC5 (get rid of it!) ; Scroll score vertically with screen LDA Scores_Y,X SUB Level_ScrollDiffV STA Scores_Y,X CMP #248 BGE PRG007_AAC5 ; If score's Y >= 248, jump to PRG007_AAC5 (get rid of it!) LDA Scores_Value,X BMI PRG007_AB53 ; If score value has bit 7 set, jump to PRG007_AB53 ; Otherwise... ; This just takes from object sprite RAM LDA Object_SprRAM,X ADD #16 ; +16 (4 sprites over) TAY ; Y = Sprite RAM offset STY <Temp_Var5 ; -> Temp_Var5 ADD #$04 ; +4 (1 sprite over) STA <Temp_Var6 ; -> Temp_Var6 LDA Sprite_RAM+$00,Y CMP #$f8 BEQ PRG007_AB76 ; If this sprite is free, jump to PRG007_AB76 PRG007_AB53: JSR Object_GetRandNearUnusedSpr ; Sprite is not free; get a nearby one STY <Temp_Var5 ; -> Temp_Var5 BNE PRG007_AB70 ; As long as result wasn't zero, jump to PRG007_AB70 ; No sprites available... ; Temp_Var6 = $FF LDA #$ff STA <Temp_Var6 LDA <Counter_1 LSR A BCC PRG007_AB6D ; Every other tick, jump to PRG007_AB6D ; Basically only one or the other half of the score will actually display LDA <Temp_Var5 PHA LDA <Temp_Var6 STA <Temp_Var5 PLA STA <Temp_Var6 PRG007_AB6D: JMP PRG007_AB76 ; Jump to PRG007_AB76 PRG007_AB70: ; New sprite RAM offset selected... TYA ; -> Y ADD #$04 ; +4 (next sprite over) STA <Temp_Var6 ; -> Temp_Var6 PRG007_AB76: LDY <Temp_Var5 CPY #$ff BEQ PRG007_AB99 ; If this sprite RAM offset is invalid, jump to PRG007_AB99 LDX <Temp_Var1 ; X = score value LDA Score_PatternLeft-1,X ; -1 because a score value of zero is "empty" LDX <SlotIndexBackup ; X = score slot index CMP #$ff BEQ PRG007_AB99 ; If this is the "don't display" marker, jump to PRG007_AB99 ; Otherwise, set the pattern STA Sprite_RAM+$01,Y ; Score Sprite Y LDA Scores_Y,X STA Sprite_RAM+$00,Y ; Score Sprite X LDA Scores_X,X STA Sprite_RAM+$03,Y JSR Score_SetAttribute PRG007_AB99: LDY <Temp_Var6 ; Y = second sprite offset CPY #$ff BEQ PRG007_ABC4 ; If this sprite is marked as "don't display", jump to PRG007_ABC4 ; Score Sprite Y LDA Scores_Y,X STA Sprite_RAM+$00,Y ; Score Sprite X LDA Scores_X,X ADD #$08 STA Sprite_RAM+$03,Y LDX <Temp_Var1 ; X = score value ; Score Sprite pattern LDA Score_PatternRight-1,X STA Sprite_RAM+$01,Y Score_SetAttribute: LDA <Temp_Var1 ; Get score value CMP #$0d LDA #$01 ; A = 1 BGE PRG007_ABBF ; If this is the 1-up, jump to PRG007_ABBF NOP ; Otherwise, do ... nothing! PRG007_ABBF: ; Set attribute STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = score slot index PRG007_ABC4: RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; BrickBusts_DrawAndUpdate ; ; Draws and updates the brick bust debris/poof effects ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BrickBusts_DrawAndUpdate: LDX #$01 ; X = 1 PRG007_ABC7: STX <SlotIndexBackup ; -> SlotIndexBackup JSR BrickBust_DrawAndUpdate ; Draw and update this brick bust DEX ; X-- BPL PRG007_ABC7 ; While X >= 0, loop PRG007_ABCF: RTS ; Return BrickBust_SprRAMOff: .byte $08, $18 ; Four sprites required here BrickPoof_SprRAMOff: .byte $08, $10 ; Only two sprites required here ; Draw and update the specific brick bust BrickBust_DrawAndUpdate: LDA BrickBust_En,X BEQ PRG007_ABCF ; If this brick bust slot is not active, jump to PRG007_ABCF CMP #$02 BEQ PRG007_ABE0 ; If the bust type is 2 (typical), jump to PRG007_ABE0 JMP PRG007_AD27 ; Otherwise, jump to PRG007_AD27 PRG007_ABE0: LDA <Player_HaltGame BNE PRG007_ABED ; If gameplay halted, jump to PRG007_ABED LDA <Counter_1 AND #$03 BNE PRG007_ABED ; 1:4 proceed, otherwise jump to PRG007_ABED INC BrickBust_YVel,X ; BrickBust_YVel++ (gravity) PRG007_ABED: LDA BrickBust_YUpr,X PHA ; Save upper chunk Y CLC ; Clear carry (no point?) SUB Level_ScrollDiffV ; Adjust Y based on vertical screen scroll LDY <Player_HaltGame BNE PRG007_ABFE ; If gameplay is halted, jump to PRG007_ABFE ADD BrickBust_YVel,X ; Apply brick bust Y velocity PRG007_ABFE: STA BrickBust_YUpr,X ; -> upper chunk Y PLA ; Restore original Y EOR BrickBust_YUpr,X BPL PRG007_AC1F ; If the sign hasn't changed, jump to PRG007_AC1F ; Sign changed; need to make sure the block bust debris didn't wrap LDA Level_ScrollDiffV LDY <Player_HaltGame BNE PRG007_AC12 ; If gameplay halted, jump to PRG007_AC12 SUB BrickBust_YVel,X ; Apply velocity in reverse PRG007_AC12: EOR BrickBust_YUpr,X BPL PRG007_AC1F ; If the sign didn't change, jump to PRG007_AC1F ; Otherwise, toggle the upper chunk disable LDA BrickBust_HEn,X EOR #$08 STA BrickBust_HEn,X PRG007_AC1F: LDA BrickBust_YLwr,X PHA ; Save lower chunk Y CLC ; Clear carry (no point?) SUB Level_ScrollDiffV ; Adjust Y based on vertical screens croll LDY <Player_HaltGame BNE PRG007_AC36 ; If gameplay is halted, jump to PRG007_AC36 INC BrickBust_XDist,X ; Increase the chunk separation ADD BrickBust_YVel,X ; Apply Y velocity ADD #$02 ; More impact on lower chunk PRG007_AC36: STA BrickBust_YLwr,X PLA ; Restore lower chunk Y EOR BrickBust_YLwr,X BPL PRG007_AC5A ; If the sign hasn't changed, jump to PRG007_AC5A ; Sign changed; need to make sure the block bust debris didn't wrap LDA Level_ScrollDiffV LDY <Player_HaltGame BNE PRG007_AC4D ; If gameplay halted, jump to PRG007_AC4D SUB BrickBust_YVel,X ; Apply velocity in reverse SUB #$02 ; With the greater impact PRG007_AC4D: EOR BrickBust_YLwr,X BPL PRG007_AC5A ; If sign didn't change, jump to PRG007_AC5A ; Otherwise, toggle the lower chunk disable LDA BrickBust_HEn,X EOR #$04 STA BrickBust_HEn,X PRG007_AC5A: ; Scroll brick bust debris horizontally with screen LDA BrickBust_X,X SUB Level_ScrollDiffH STA BrickBust_X,X TXA ; Keeps things interesting EOR <Counter_1 AND #$01 TAY ; Y = 0 or 1 LDA BrickBust_SprRAMOff,Y TAY ; Y = sprite RAM offset CPY #$08 BNE PRG007_AC7A ; If NOT using the offset $08, jump to PRG007_AC7A LDA Sprite_RAM+$08 CMP #$f8 BEQ PRG007_AC7A ; If this sprite is not in use, jump to PRG007_AC7A RTS ; Return PRG007_AC7A: LDA BrickBust_HEn,X STA <Temp_Var4 ; Horizontal enable flag -> Var4 CMP #$0c BLT PRG007_AC91 ; If at least one of upper or lower are enabled, jump to PRG007_AC91 ; Upper and lower are both disabled! LDA <Player_HaltGame BNE PRG007_AC8E ; If gameplay halted, jump to PRG007_AC8E LDA BrickBust_YVel,X CMP #$08 BLS PRG007_AC91 ; If brick bust Y velocity < $08, jump to PRG007_AC91 PRG007_AC8E: JMP PRG007_AD21 ; Otherwise, jump to PRG007_AD21 (disable this brick bust) PRG007_AC91: LDA <Temp_Var4 AND #$08 BNE PRG007_ACA0 ; If upper bust chunks are disabled, jump to PRG007_ACA0 ; Otherwise set sprite Y for left and right uppers LDA BrickBust_YUpr,X STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y PRG007_ACA0: LDA <Temp_Var4 AND #$04 BNE PRG007_ACAF ; If lower bust chunks are disabled, jump to PRG007_ACAF ; Otherwise set sprite Y for left and right lowers LDA BrickBust_YLwr,X STA Sprite_RAM+$08,Y STA Sprite_RAM+$0C,Y PRG007_ACAF: LSR <Temp_Var4 BCC PRG007_ACBB ; If right bust chunks are NOT disabled, jump to PRG007_ACBB ; Hide right-hand bust chunks LDA #$f8 STA Sprite_RAM+$00,Y STA Sprite_RAM+$08,Y PRG007_ACBB: LSR <Temp_Var4 BCC PRG007_ACC7 ; If left bust chunks are NOT disabled, jump to PRG007_ACC7 ; Hide left-hand bust chunks LDA #$f8 STA Sprite_RAM+$04,Y STA Sprite_RAM+$0C,Y PRG007_ACC7: ; Pattern for bust chunks LDA #$4b STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y STA Sprite_RAM+$09,Y STA Sprite_RAM+$0D,Y LDA BrickBust_X,X PHA ; Save chunk X ADD BrickBust_XDist,X ; Add the distance ADD #$08 ; +8 STA Sprite_RAM+$03,Y ; Set right upper chunk X STA Sprite_RAM+$0B,Y ; Set right lower chunk X CMP #248 BLT PRG007_ACF2 ; If bust chunk X < 248, jump to PRG007_ACF2 ; Otherwise, disable right chunks LDA BrickBust_HEn,X ORA #$01 STA BrickBust_HEn,X PRG007_ACF2: PLA ; Restore chunk X SUB BrickBust_XDist,X ; Subtract the distance STA Sprite_RAM+$07,Y ; Set left upper chunk X STA Sprite_RAM+$0F,Y ; Set left lower chunk X ; Seems like this should be a >= 8 check?? CMP #244 BLT PRG007_AD09 ; If bust chunk X < 244 (??), jump to PRG007_AD09 ; Otherwise, disable left chunks LDA BrickBust_HEn,X ORA #$02 STA BrickBust_HEn,X PRG007_AD09: ; Rotate the horizontal / vertical flips LDA Level_NoStopCnt AND #$06 LSR A LSR A ROR A ROR A ORA #SPR_PAL3 STA Sprite_RAM+$02,Y STA Sprite_RAM+$06,Y STA Sprite_RAM+$0A,Y STA Sprite_RAM+$0E,Y RTS ; Return PRG007_AD21: ; Disable this brick bust LDA #$00 STA BrickBust_En,X RTS ; Return PRG007_AD27: ; Brick bust type non-2 ("poof" away the tile) LDA BrickBust_HEn,X BEQ PRG007_AD21 ; If BrickBust_HEn = 0 (poof expired), jump to PRG007_AD21 (disable this brick bust) LDA <Player_HaltGame BNE PRG007_AD33 ; If gameplay is halted, jump to PRG007_AD33 DEC BrickBust_HEn,X ; BrickBust_HEn-- (used as a counter here) PRG007_AD33: LDA BrickBust_YUpr,X LDY Level_AScrlConfig BNE PRG007_AD42 ; If raster enabled, jump to PRG007_AD42 ; Otherwise, just be screen-scroll relative SUB Level_ScrollDiffV STA BrickBust_YUpr,X PRG007_AD42: CMP #208 BGE PRG007_AD21 ; If the poof effect Y >= 208 (too low), jump to PRG007_AD21 (disable this brick bust) CPY #$00 BNE PRG007_AD54 ; If raster effects enabled, jump to PRG007_AD54 ; Scroll poof horizontally LDA BrickBust_X,X SUB Level_ScrollDiffH STA BrickBust_X,X PRG007_AD54: CMP #240 BGE PRG007_AD21 ; If the poof effect X >= 24, jump to PRG007_AD21 (disable this brick bust) TXA ; Keep it interesting EOR <Counter_1 AND #$01 TAY ; Y = 0 or 1 LDA BrickPoof_SprRAMOff,Y TAY ; Y = Sprite RAM offset LDA Sprite_RAM+$00,Y CMP #$f8 BNE PRG007_ADA7 ; If this sprite is not free, jump to PRG007_ADA7 (RTS) ; Set left sprite X LDA BrickBust_X,X STA Sprite_RAM+$03,Y ; Set right sprite X ADD #$08 ; +8 STA Sprite_RAM+$07,Y ; Set left/right sprite Y LDA BrickBust_YUpr,X STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y LDA Level_NoStopCnt LSR A LSR A LSR A ROR A AND #SPR_VFLIP STA <Temp_Var1 ; Periodically vertically flip ; Form attribute with sprite palette 1 for left half LDA #SPR_PAL1 ORA <Temp_Var1 STA Sprite_RAM+$02,Y ; Right half uses opposite flips EOR #(SPR_HFLIP | SPR_VFLIP) STA Sprite_RAM+$06,Y LDA BrickBust_HEn,X LSR A LSR A LSR A TAX ; X = 0 to 3 LDA Poof_Patterns,X ; Get appropriate "poof" pattern STA Sprite_RAM+$01,Y ; Left STA Sprite_RAM+$05,Y ; Right LDX <SlotIndexBackup ; X = restore slot index PRG007_ADA7: RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CoinPUp_DrawAndUpdate ; ; Draws and updates the coins which have popped out of blocks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CoinPUp_Patterns: .byte $49, $4F, $4D, $4F CoinPUp_Attributes: .byte SPR_PAL3, SPR_PAL3 | SPR_HFLIP, SPR_PAL3, SPR_PAL3 CoinPUps_DrawAndUpdate: LDX #$03 ; X = 3 (all "power up" coin slots) PRG007_ADB2: STX <SlotIndexBackup ; -> slot index backup LDA CoinPUp_State,X BEQ PRG007_ADBC ; If there's no active "powerup coin" here, jump to PRG007_ADBC JSR CoinPUp_UpdateAndDraw ; Update and draw powerup coin PRG007_ADBC: DEX ; X-- BPL PRG007_ADB2 ; While X >= 0, loop! RTS ; Return CoinPUp_UpdateAndDraw: LDA <Player_HaltGame BNE PRG007_ADF0 ; If gameplay is halted, jump to PRG007_ADF0 INC CoinPUp_Counter,X ; counter++ ; Apply coin's Y velocity LDA CoinPUp_Y,X ADD CoinPUp_YVel,X STA CoinPUp_Y,X LDA CoinPUp_Counter,X AND #$03 BNE PRG007_ADE2 ; 1:4 ticks proceed, otherwise jump to PRG007_ADE2 INC CoinPUp_YVel,X ; coin YVel ++ LDA CoinPUp_YVel,X CMP #$05 BEQ PRG007_AE28 ; If coin's Y velocity = 5, jump to PRG007_AE28 PRG007_ADE2: LDA CoinPUp_X,X SUB Level_ScrollDiffH ; Make relative coin X CMP #248 BGE PRG007_AE4A ; If coin X >= 248, jump to PRG007_AE4A (remove coin) STA CoinPUp_X,X ; Update coin X PRG007_ADF0: LDA <Player_HaltGame BEQ PRG007_AE02 ; If gameplay is not halted, jump to PRG007_AE02 ; Move coin Y with vertical scroll LDA CoinPUp_Y,X SUB Level_ScrollDiffV STA CoinPUp_Y,X CMP #197 BGE PRG007_AE4A ; If coin Y >= 197, jump to PRG007_AE4A (remove coin) PRG007_AE02: JSR Object_GetRandNearUnusedSpr ; Set coin Y LDA CoinPUp_Y,X STA Sprite_RAM+$00,Y ; Set coin X LDA CoinPUp_X,X STA Sprite_RAM+$03,Y LDA CoinPUp_Counter,X LSR A LSR A AND #$03 TAX ; X = 0 to 3 by coin counter ; Set pattern LDA CoinPUp_Patterns,X STA Sprite_RAM+$01,Y ; Set attribute LDA CoinPUp_Attributes,X STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = power up coin slot index RTS ; Return PRG007_AE28: JSR Score_FindFreeSlot ; Get 100 pts LDA #$85 STA Scores_Value,Y LDA #$30 STA Scores_Counter,Y LDA CoinPUp_Y,X CMP #192 BLT PRG007_AE3E ; If the coin is not too low, jump to PRG007_AE3E LDA #$05 ; Otherwise use top of screen PRG007_AE3E: STA Scores_Y,Y ; -> Scores_Y ; Center score above coin LDA CoinPUp_X,X SUB #$04 STA Scores_X,Y PRG007_AE4A: ; Remove coin LDA #$00 STA CoinPUp_State,X RTS ; Return ; Sets carry if solid was hit SObj_CheckHitSolid: ; Flag Blooper Kid as out of water until determined otherwise LDA #$01 STA SObjBlooperKid_OutOfWater,X ; Temp_Var6 = special object Y + 12 LDA SpecialObj_YLo,X ADD #12 STA <Temp_Var6 ; Aligned to grid -> Temp_Var3 AND #$f0 STA <Temp_Var3 LDA SpecialObj_YHi,X ADC #$00 ; Apply carry PHA ; Save Y Hi ; Special object X + 4 -> Temp_Var5 LDA SpecialObj_XLo,X ADD #$04 SUB <Horz_Scroll ; - ADD <Horz_Scroll ; + ?? STA <Temp_Var5 LDA <Horz_Scroll_Hi ADC #$00 ; Apply carry ASL A ; 2 bytes per screen (for Tile_Mem_Addr) TAY ; -> 'Y' ; Low byte of Tile_Mem_Addr -> Temp_Var1 LDA Tile_Mem_Addr,Y STA <Temp_Var1 PLA ; Restore Y Hi AND #$01 ; Only use 0 or 1 (only valid Y His in a non-vertical level) ADD Tile_Mem_Addr+1,Y ; Add to the high byte of Tile_Mem_Addr STA <Temp_Var2 ; -> Temp_Var2 ; Form a row/column offset -> 'Y' LDA <Temp_Var5 LSR A LSR A LSR A LSR A ORA <Temp_Var3 TAY LDA [Temp_Var1],Y ; Get the tile here PHA ; Save it ASL A ROL A ROL A AND #$03 TAY ; Y = tile quadrant STY <Temp_Var2 ; -> Temp_Var2 PLA ; Restore the tile value STA <Temp_Var1 ; -> Temp_Var1 CMP Tile_AttrTable,Y BLT PRG007_AEE0 ; If this tile is not solid on top, jump to PRG007_AEE0 CMP Tile_AttrTable+4,Y BLT PRG007_AECF ; If this tile is not solid on the sides/bottom, jump to PRG007_AECF ; Tile is solid all around LDA SpecialObj_ID,X CMP #SOBJ_FIREBROFIREBALL BEQ PRG007_AEB3 ; If this a Fire Bro's fireball (the only one that bounces on the floor), jump to PRG007_AEB3 SEC ; Set carry RTS ; Return PRG007_AEB3: INC SpecialObj_Data,X ; SpecialObj_Data++ LDA SpecialObj_Data,X CMP #$02 BNE PRG007_AEC0 ; If SpecialObj_Data <> 2, jump to PRG007_AEC0 JMP PRG007_AF02 ; Jump to PRG007_AF02 PRG007_AEC0: ; Fireball's Y -= 3 DEC SpecialObj_YLo,X DEC SpecialObj_YLo,X DEC SpecialObj_YLo,X PRG007_AEC9: ; Bounce fireball! LDA #-$2C STA SpecialObj_YVel,X PRG007_AECE: RTS ; Return PRG007_AECF: ; Tile solid only on top LDA SpecialObj_ID,X CMP #SOBJ_FIREBROFIREBALL CLC ; Clear carry BNE PRG007_AECE ; If this is not the Fire Bro's fireball, jump to PRG007_AECE LDA <Temp_Var6 AND #$0f ; Find Y relative to the tile CMP #$05 BLT PRG007_AEC9 ; If it's less than 5 pixels from the top, count as hit the floor, and bounce! RTS ; Return PRG007_AEE0: ; Tile not solid on top (literally, but likely assumes not solid on the side/bottom either) LDA SpecialObj_ID,X CMP #SOBJ_BLOOPERKID CLC ; Clear carry BNE PRG007_AEFC ; If this is not a Blooper Kid, jump to PRG007_AEFC ; Blooper kid only... LDA Level_TilesetIdx ASL A ASL A ; TilesetIdx * 4 ADD <Temp_Var2 ; Add the quadrant TAY ; Y = offset into Level_MinTileUWByQuad LDA Level_MinTileUWByQuad,Y CMP <Temp_Var1 BLT PRG007_AEFB ; If this tile is not considered underwater, jump to PRG007_AEFB (RTS) DEC SObjBlooperKid_OutOfWater,X ; Otherwise, SObjBlooperKid_OutOfWater = 0 (Blooper Kid is still in water!) PRG007_AEFB: RTS ; Return PRG007_AEFC: ; SpecialObj_Data = 0 LDA #$00 STA SpecialObj_Data,X RTS ; Return PRG007_AF02: ; impact sound LDA Sound_QPlayer ORA #SND_PLAYERBUMP STA Sound_QPlayer ; Something removed here... NOP NOP NOP NOP NOP NOP NOP JMP PRG007_B84C ; Jump to PRG007_B84C ("Poof" away the fireball) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SpecialObjs_UpdateAndDraw ; ; Updates Special Objects and they draw as they will ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SpecialObjs_UpdateAndDraw: ; No Microgoomba stuck to Player until we say so... LDA #$00 STA Player_Microgoomba LDX #$07 ; X = 7 PRG007_AF1B: STX <SlotIndexBackup ; Store current checked index -> SlotIndexBackup JSR SpecialObj_UpdateAndDraw ; Does the update and draw routines of Special OBjects DEX ; X-- BPL PRG007_AF1B ; While X >= 0, loop! SObj_DoNothing: PRG007_AF23: RTS ; Return SpecialObj_UpdateAndDraw: LDA SpecialObj_ID,X BEQ PRG007_AF23 ; If this special object slot is not in use, jump to PRG007_AF23 (RTS) LDA AScrlURDiag_WrapState_Copy BEQ PRG007_AF4B ; If diagonal scroller is not wrapping, jump to PRG007_AF4B LDA <Player_HaltGame BNE PRG007_AF4B ; If gameplay is halted, jump to PRG007_AF4B ; Offset special object to compensate for the diagonal autoscroller's wrap LDA SpecialObj_XLo,X ADD AScrlURDiag_OffsetX STA SpecialObj_XLo,X LDA SpecialObj_YLo,X ADD AScrlURDiag_OffsetY STA SpecialObj_YLo,X BCC PRG007_AF4B ; If no carry, jump to PRG007_AF4B INC SpecialObj_YHi,X ; Apply carry PRG007_AF4B: LDY <Player_HaltGame BNE PRG007_AF57 ; If gameplay halted, jump to PRG007_AF57 LDY SpecialObj_Timer,X BEQ PRG007_AF57 ; If SpecialObj_Timer = 0, jump to PRG007_AF57 DEC SpecialObj_Timer,X ; SpecialObj_Timer-- PRG007_AF57: LDA SpecialObj_XLo,X SUB <Horz_Scroll CMP #248 BGE SpecialObj_RemoveInd ; If special object X >= 248, jump to SpecialObj_RemoveInd (remove special object) LDA SpecialObj_YLo,X ADD #16 PHA ; Save Special object Y + 16 LDA SpecialObj_YHi,X ADC #$00 ; Apply carry STA <Temp_Var1 ; -> Temp_Var1 PLA ; Restore special object Y + 16 CMP Level_VertScroll LDA <Temp_Var1 SBC Level_VertScrollH STA <Temp_Var14 ; Temp_Var14 = 0 if special object is on same screen... BEQ PRG007_AF9E ; If Temp_Var14 = 0 (special object on same screen), jump to PRG007_AF9E ; A few select special objects can deal with existing on a different screen, ; otherwise the object will be deleted immediately LDA SpecialObj_ID,X CMP #SOBJ_BUBBLE BEQ PRG007_AF97 CMP #SOBJ_MICROGOOMBA BEQ PRG007_AF97 CMP #SOBJ_RECOVEREDWAND BEQ PRG007_AF97 CMP #SOBJ_BRICKDEBRIS BEQ PRG007_AF97 CMP #SOBJ_SPIKEBALL BEQ PRG007_AF97 CMP #SOBJ_HAMMER BNE SpecialObj_RemoveInd PRG007_AF97: LDA <Temp_Var14 BMI PRG007_AF9E ; If this select special object is above, keep it alive, jump to PRG007_AF9E SpecialObj_RemoveInd: JMP SpecialObj_Remove ; Jump to SpecialObj_Remove PRG007_AF9E: LDA SpecialObj_ID,X JSR DynJump ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! .word SObj_DoNothing ; 00: EMPTY / NOT USED (should never get here anyway) .word SObj_Hammer ; 01: Hammer Bro hammer .word SObj_Boomerang ; 02: Boomerangs .word SObj_UNKNOWN ; 03: .word SObj_Fireball ; 04: Nipper fireball .word SObj_Fireball ; 05: Piranha fireball .word SObj_Microgoomba ; 06: Micro goombas .word SObj_Spikeball ; 07: Spike/Patooie's spike ball .word SObj_WandBlast ; 08: Koopaling wand blast .word SObj_KuriboShoe ; 09: Lost Kuribo shoe .word SObj_Wrench ; 0A: Rocky's Wrench .word SObj_Cannonball ; 0B: Cannonball .word SObj_Fireball ; 0C: Fire bro bouncing fireball .word SObj_ExplodeStar ; 0D: Explosion star .word SObj_Bubble ; 0E: Bubble .word SObj_LavaLotusFire; 0F: Lava Lotus fire .word SObj_Wand ; 10: Recovered wand .word SObj_CoinOrDebris ; 11: Popped out coin .word SObj_Fireball ; 12: Fire Chomp's fire .word SObj_CoinOrDebris ; 13: Brick debris (e.g. from Piledriver Microgoomba) .word SObj_BlooperKid ; 14: Blooper kid .word SObj_Laser ; 15: Laser .word SObj_Poof ; 16: Poof PUpCoin_Patterns: .byte $49, $4F, $4D, $4F PUpCoin_Attributes: .byte SPR_PAL3, SPR_PAL3 | SPR_HFLIP, SPR_PAL3, SPR_PAL3 SObj_Laser: ; Load patterns for laser LDA #$12 STA PatTable_BankSel+4 JSR Laser_PrepSpritesAndHit ; Prepare the laser sprites and hurt Player LDA <Player_HaltGame BNE PRG007_B01F ; If gameplay is halted, jump to PRG007_B01F (RTS) ; Y += 8 LDA SpecialObj_YLo,X ADD #$08 STA SpecialObj_YLo,X ; X += 8 LDA SpecialObj_XLo,X SUB #$08 STA SpecialObj_XLo,X JSR SObj_CheckHitSolid BCC PRG007_B01F ; If laser didn't hit solid, jump to PRG007_B01F (RTS) ; Laser hit floor! ; Align Y LDA SpecialObj_YLo,X AND #$f0 ADD #$05 STA SpecialObj_YLo,X ; Align X LDA SpecialObj_XLo,X AND #$f0 ADC #$0b STA SpecialObj_XLo,X JSR SpecialObj_Remove ; Remove laser ; Generate puff via "brick bust" puff (atypical, but whatever) LDY #$01 ; Y = 1 PRG007_B017: LDA BrickBust_En,Y BEQ PRG007_B020 ; If this brick bust slot is free, jump to PRG007_B020 DEY ; Y-- BPL PRG007_B017 ; While Y >= 0, loop! PRG007_B01F: RTS ; Return PRG007_B020: ; Enable this brick bust slot (poof style) LDA #$01 STA BrickBust_En,Y ; Brick bust (poof) X LDA SpecialObj_XLo,X SUB #$08 SUB <Horz_Scroll STA BrickBust_X,Y ; Brick bust (poof) Y LDA SpecialObj_YLo,X ADD #$04 SBC Level_VertScroll STA BrickBust_YUpr,Y ; Poof counter LDA #$17 STA BrickBust_HEn,Y RTS ; Return Laser_PrepSpritesAndHit: JSR SObj_GetSprRAMOffChkVScreen JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Set laser pattern LDA #$b7 STA Sprite_RAM+$01,Y ; Use rotating color attributes LDA <Counter_1 LSR A LSR A AND #$03 STA Sprite_RAM+$02,Y JMP SObj_PlayerCollide ; Do Player to laser collision and don't come back! PRG007_B058: RTS ; Return BlooperKid_VelAccel: .byte $01, -$01 BlooperKid_VelLimit: .byte $10, -$10 BlooperKid_SpriteYOff: .byte $00, $01, $02, $03, $04, $05, $06, $07, $08, $07, $06, $05, $04, $03, $02, $01 SObj_BlooperKid: LDA <Player_HaltGame BNE PRG007_B0BC ; If gameplay halted, jump to PRG007_B0BC LDA <Counter_1 AND #$07 BNE PRG007_B0A9 ; 1:8 ticks proceed, otherwise jump to PRG007_B0A9 LDA SpecialObj_Data,X AND #$01 TAY ; Y = 0 or 1 ; Accelerate Blooper Kid Y LDA SpecialObj_YVel,X ADD BlooperKid_VelAccel,Y STA SpecialObj_YVel,X CMP BlooperKid_VelLimit,Y BNE PRG007_B091 ; If Blooper Kid has not hit Y velocity limit, jump to PRG007_B091 INC SpecialObj_Data,X ; Otherwise change direction PRG007_B091: LDA SpecialObj_Var1,X AND #$01 TAY ; Y = 0 or 1 ; Accelerate Blooper Kid X LDA SpecialObj_XVel,X ADD BlooperKid_VelAccel,Y STA SpecialObj_XVel,X CMP BlooperKid_VelLimit,Y BNE PRG007_B0A9 ; If Blooper Kid has not hit X velocity limit, jump to PRG007_B0A9 INC SpecialObj_Var1,X ; Otherwise change direction PRG007_B0A9: JSR SObj_AddXVelFrac ; Apply X Velocity LDA SpecialObj_YVel,X BPL PRG007_B0B9 ; If Blooper Kid is moving downward, jump to PRG007_B0B9 JSR SObj_CheckHitSolid ; Check if hit solid LDA SObjBlooperKid_OutOfWater,X BEQ PRG007_B0BC ; If Blooper Kid is still in water, jump to PRG007_B0BC PRG007_B0B9: JSR SObj_AddYVelFrac ; Apply Y velocity PRG007_B0BC: LDA SpecialObj_Timer,X BEQ PRG007_B0F7 ; If timer expired, jump to PRG007_B0F7 CMP #$30 BGE PRG007_B0C9 ; If timer >= $30, jump to PRG007_B0C9 ; Blooper Kid flickering away.. AND #$02 BNE PRG007_B0F6 ; 2 ticks on, 2 ticks off; jump to PRG007_B0F6 (RTS) PRG007_B0C9: JSR SObj_GetSprRAMOffChkVScreen JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative LDA Level_NoStopCnt LSR A AND #$0f TAX ; X = 0 to 15 ; Set Sprite Y LDA Sprite_RAM+$00,Y ADD BlooperKid_SpriteYOff,X STA Sprite_RAM+$00,Y TXA LDX <SlotIndexBackup ; X = special object slot index CMP #$08 LDA #$b5 ; A = $B5 BLT PRG007_B0EB ; If only halfway through the animation cycle, jump to PRG007_B0EB LDA #$b7 ; A = $B7 PRG007_B0EB: ; Set Blooper Kid pattern STA Sprite_RAM+$01,Y ; Set Blooper Kid attributes LDA #SPR_PAL1 STA Sprite_RAM+$02,Y JMP SObj_PlayerCollide ; Do Player to Blooper Kid collision and don't come back! PRG007_B0F6: RTS ; Return PRG007_B0F7: JMP SpecialObj_Remove ; Remove Blooper kid SObj_CoinOrDebris: LDA <Player_HaltGame BNE PRG007_B11F ; If gameplay halted, jump to PRG007_B11F INC SpecialObj_Var1,X ; Var1++ JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity LDA SpecialObj_ID,X CMP #SOBJ_BRICKDEBRIS BNE PRG007_B11F ; If this is not brick debris, jump to PRG007_B11F ; Brick debris only... LDA SpecialObj_YVel,X BMI PRG007_B114 ; If brick debris is moving upward, jump to PRG007_B114 CMP #$70 BGE PRG007_B11F ; If brick debris is falling >= $70, jump to PRG007_B11F PRG007_B114: LDA SpecialObj_Data,X BNE PRG007_B11C ; If data <> 0, jump to PRG007_B11C (fall slower) INC SpecialObj_YVel,X ; YVel++ PRG007_B11C: INC SpecialObj_YVel,X ; YVel++ PRG007_B11F: JSR SObj_GetSprRAMOffChkVScreen LDA SpecialObj_ID,X CMP #SOBJ_BRICKDEBRIS BNE PRG007_B169 ; If this is not brick debris, jump to PRG007_B169 ; Brick debris only... LDA SpecialObj_Data,X BEQ PRG007_B153 ; If data = 0 (full giant world style brick rather than chunks), jump to PRG007_B153 JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Brick debris chunk pattern LDA #$4b STA Sprite_RAM+$01,Y ; Temp_Var1 = SPR_PAL3 LDA #SPR_PAL3 STA <Temp_Var1 LDA SpecialObj_Timer,X BEQ PRG007_B144 ; If timer expired, jump to PRG007_B144 ; Rotating colors for Ice Brick debris LSR A AND #$03 STA <Temp_Var1 PRG007_B144: ; Rotating effect LDA Level_NoStopCnt ASL A ASL A ASL A ASL A AND #(SPR_HFLIP | SPR_VFLIP) ; Set attributes ORA <Temp_Var1 ; OR'd with palette STA Sprite_RAM+$02,Y RTS ; Return PRG007_B153: JSR SObj_Draw16x16 ; Draw full brick ; Set petterns LDA #$75 STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y ; Set attributes on left sprite LDA #SPR_PAL3 STA Sprite_RAM+$02,Y ; Set attributes on right sprite LDA #(SPR_PAL3 | SPR_HFLIP) STA Sprite_RAM+$06,Y RTS ; Return PRG007_B169: ; Popped out coin only LDA SpecialObj_YVel,X CMP #$20 BMI PRG007_B17E ; If Y Velocity < $20, jump to PRG007_B17E ; Coin fell far enough.. JSR SpecialObj_Remove ; Remove it INC Coins_Earned ; You get a coin JSR Score_FindFreeSlot LDA #$89 ; Get 1000 pts; $80 just mixes up what sprite it uses JMP PRG007_B44B ; Jump to PRG007_B44B PRG007_B17E: JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Set coin sprite Y LDA Sprite_RAM+$03,Y ADD #$04 STA Sprite_RAM+$03,Y LDA SpecialObj_Var1,X LSR A LSR A AND #$03 TAX ; X = 0 to 3 ; Set pattern LDA PUpCoin_Patterns,X STA Sprite_RAM+$01,Y ; Set attributes LDA PUpCoin_Attributes,X STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = special object slot index RTS ; Return ; Velocity gets applied at different rates (slower as timer decreases) ExplodeStar_VelMask: .byte $07, $03, $01, $00 SObj_ExplodeStar: LDA SpecialObj_Data,X BNE PRG007_B1DD ; If star's data <> 0, jump to PRG007_B1DD (RTS) LDA SpecialObj_Timer,X BEQ PRG007_B1DE ; If timer expired, jump to PRG007_B1DE (RTS) LSR A LSR A LSR A LSR A AND #$03 TAY ; Y = 0 to 3, by timer ; Apply velocities at lower rates as timer decreases LDA <Counter_1 AND ExplodeStar_VelMask,Y BNE PRG007_B1C3 JSR SObj_AddXVelFrac ; Apply X velocity JSR SObj_AddYVelFrac ; Apply Y velocity PRG007_B1C3: JSR SObj_GetSprRAMOffChkVScreen JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Set Explosion Star pattern LDA #$73 STA Sprite_RAM+$01,Y ; Apply cycling palette attribute LDA Level_NoStopCnt LSR A LSR A NOP ADD <SlotIndexBackup AND #$03 ; A = 0 to 3 (palette select) STA Sprite_RAM+$02,Y RTS ; Return PRG007_B1DD: RTS ; Return PRG007_B1DE: JMP SpecialObj_Remove ; Remove special object and don't come back! Wand_Pattern1: .byte $99, $B9, $BD, $B9, $99, $BB, $BF, $BB Wand_Pattern2: .byte $99, $BB, $BB, $BB, $99, $B9, $BD, $B9 Wand_Attributes: .byte SPR_PAL2, SPR_PAL2, SPR_PAL2, SPR_PAL2 | SPR_VFLIP, SPR_PAL2 | SPR_VFLIP, SPR_PAL2 | SPR_VFLIP, SPR_PAL2, SPR_PAL2 SObj_Wand: ; Load wand graphics LDA #$48 STA PatTable_BankSel+4 LDA <Player_HaltGame BNE PRG007_B254 ; If gameplay is halted, jump to PRG007_B254 JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity DEC SpecialObj_YVel,X ; Wand_FrameCnt += Var1 (spin rate) LDA Wand_FrameCnt ADD SpecialObj_Var1,X STA Wand_FrameCnt BCC PRG007_B217 ; If no carry, jump to PRG007_B217 INC Wand_Frame ; Next wand frame PRG007_B217: JSR SObj_CheckHitSolid BCC PRG007_B254 ; If wand has not hit solid surface, jump to PRG007_B254 LDA SpecialObj_YVel,X BMI PRG007_B254 ; If wand is moving upward, jump to PRG007_B254 CMP #$20 BLT PRG007_B241 ; If wand Y Vel < $20, jump to PRG007_B241 ; Wand bounces! LSR A ; Divide by 2 JSR Negate ; Negate STA SpecialObj_YVel,X ; Wand Y -= 2 DEC SpecialObj_YLo,X DEC SpecialObj_YLo,X INC Wand_BounceFlag ; Wand_BounceFlag++ ; Var1 += $80 (rapid spin rate!) LDA SpecialObj_Var1,X ADD #$80 STA SpecialObj_Var1,X JMP PRG007_B254 ; Jump to PRG007_B254 PRG007_B241: ; Wand has landed! LDA #$00 STA SpecialObj_YVel,X STA Wand_Frame ; Wand_Frame = 0 ; Align wand Y to grid + 5 LDA SpecialObj_YLo,X AND #$f0 ADD #$05 STA SpecialObj_YLo,X PRG007_B254: JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_B291 ; If wand is not on vertical screen, jump to PRG007_B291 (RTS) JSR SObj_Draw16x16 ; Prepare wand sprite ; Subtract 4 from sprite Ys LDA Sprite_RAM+$00,Y SBC #$04 STA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y LDA Wand_BounceFlag LSR A ; Sets carry on odd bounces LDA Wand_Frame AND #$07 ; A = 0 to 7 by Wand_Frame BCC PRG007_B274 ; If wand is not on an odd bounce, jump to PRG007_B274 EOR #$07 ; Invert result (wand spin) PRG007_B274: TAX ; Frame -> 'X' ; Set wand sprites patterns LDA Wand_Pattern1,X STA Sprite_RAM+$01,Y LDA Wand_Pattern2,X STA Sprite_RAM+$05,Y ; Set wand sprite attributes LDA Wand_Attributes,X STA Sprite_RAM+$02,Y ORA #SPR_HFLIP STA Sprite_RAM+$06,Y LDX <SlotIndexBackup ; X = special object slot index JMP SObj_PlayerCollide ; Do Player-to-wand collision and don't come back! PRG007_B291: RTS ; Return SObj_LavaLotusFire: ; Load Lava Lotus fire patterns LDA #$1b STA PatTable_BankSel+5 LDA <Player_HaltGame BNE PRG007_B2EE ; If gameplay halted, jump to PRG007_B2EE LDA SpecialObj_Var2,X BEQ PRG007_B2A8 ; If Var2 (Lava Lotus fire "life" counter) = 0, jump to PRG007_B2A8 LDA <Counter_1 LSR A BCC PRG007_B2A8 ; Every other tick, jump to PRG007_B2A8 DEC SpecialObj_Var2,X ; Var2-- PRG007_B2A8: LDA SpecialObj_Data,X BEQ PRG007_B2E2 ; If SpecialObj_Data = 0, jump to PRG007_B2E2 LDY SpecialObj_Var1,X ; Y = Var1 (the parent Lava Lotus index) LDA Objects_State,Y CMP #OBJSTATE_NORMAL BNE PRG007_B2D8 ; If Lava Lotus is no longer in normal state, jump to PRG007_B2D8 LDA Level_ObjectID,Y CMP #OBJ_LAVALOTUS BNE PRG007_B2D8 ; If this is no longer a Lava Lotus, jump to PRG007_B2D8 LDA Objects_Var5,Y CMP #$4f BLT PRG007_B2D8 ; If Lava Lotus' Var5 < $4F, jump to PRG007_B2D8 LDA Level_NoStopCnt INC SpecialObj_XLo,X ; X++ AND #$02 BNE PRG007_B2D5 ; 2 ticks on, 2 ticks off; jump to PRG007_B2D5 ; X -= 2 DEC SpecialObj_XLo,X DEC SpecialObj_XLo,X PRG007_B2D5: JMP PRG007_B2EE ; Jump to PRG007_B2EE PRG007_B2D8: ; SpecialObj_Data = 0 LDA #$00 STA SpecialObj_Data,X ; Var2 = $C0 LDA #$c0 STA SpecialObj_Var2,X PRG007_B2E2: LDA <Counter_1 AND #$03 BNE PRG007_B2EE ; 1:4 ticks proceed, otherwise jump to PRG007_B2EE JSR SObj_AddXVelFrac ; Apply X Velocity JSR SObj_AddYVelFrac ; Apply Y Velocity PRG007_B2EE: LDA SpecialObj_Var2,X BNE PRG007_B2F6 ; If Var2 <> 0 (fire still has life), jump to PRG007_B2F6 JMP SpecialObj_Remove ; Otherwise, remove it and don't come back! PRG007_B2F6: CMP #$30 BGE PRG007_B303 ; If Var2 >= 30, jump to PRG007_B303 TXA ; A = special object slot index ASL A ; * 2 ADC SpecialObj_Var2,X ; Add life counter AND #$02 ; 0 or 2 BNE PRG007_B320 ; 2 ticks on, 2 ticks off; jump to PRG007_B320 (fire flickers away) (RTS) PRG007_B303: JSR SObj_GetSprRAMOffChkVScreen JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative LDA Level_NoStopCnt LSR A LSR A LSR A ; 8 ticks on/off LDA #$d9 ; A = $D9 BCC PRG007_B315 ; 8 ticks on, 8 ticks off; jump to PRG007_B315 LDA #$db ; A = $DB PRG007_B315: ; Store pattern STA Sprite_RAM+$01,Y ; Set attribute LDA #SPR_PAL1 STA Sprite_RAM+$02,Y JMP SObj_PlayerCollide ; Do Player-to-fire collision and don't come back! PRG007_B320: RTS ; Return SObj_Bubble: LDA <Player_HaltGame BNE PRG007_B364 ; If gameplay is halted, jump to PRG007_B364 LDA SpecialObj_Timer,X BNE PRG007_B32D ; If timer not expired, jump to PRG007_B32D JMP SpecialObj_Remove ; Otherwise, remove the bubble PRG007_B32D LDA SpecialObj_Data,X BNE PRG007_B352 ; If data <> 0, jump to PRG007_B352 JSR SObj_AddYVelFrac ; Apply Y velocity LDA SpecialObj_YVel,X BMI PRG007_B344 ; If bubble is moving upward, jump to PRG007_B344 SUB #$07 ; Slow down (downward bubble) STA SpecialObj_YVel,X BPL PRG007_B34F ; If bubble is still moving downward, jump to PRG007_B34F BMI PRG007_B34C ; Otherwise, jump to PRG007_B34C PRG007_B344: ADD #$07 ; Slow down (upward bubble) STA SpecialObj_YVel,X BMI PRG007_B34F ; If bubble is still moving upward, jump to PRG007_B34F PRG007_B34C: INC SpecialObj_Data,X ; Otherwise, set SpecialObj_Data PRG007_B34F: JMP PRG007_B364 ; Jump to PRG007_B364 PRG007_B352: INC SpecialObj_Var1,X ; SpecialObj_Var1++ LDA SpecialObj_Var1,X AND #%00110000 BEQ PRG007_B364 ; 48 ticks on, 48 ticks off; jump to PRG007_B364 DEC SpecialObj_YLo,X ; Bubble Y -- BNE PRG007_B364 DEC SpecialObj_YHi,X ; Apply carry PRG007_B364: LDA Level_NoStopCnt AND #%00001100 LSR A LSR A TAY ; Y = 0 or 3 ; Bubble_XOff -> Temp_Var1 LDA Bubble_XOff,Y STA <Temp_Var1 JSR SObj_GetSprRAMOffChkVScreen JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Set bubble X LDA SpecialObj_XLo,X ADD <Temp_Var1 SUB <Horz_Scroll STA Sprite_RAM+$03,Y ; Set bubble pattern LDA #$17 STA Sprite_RAM+$01,Y ; Set bubble attributes LDA #SPR_PAL1 STA Sprite_RAM+$02,Y RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SObj_ApplyXYVelsWithGravity ; ; Apply the special object X and Y velocity with gravity ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SObj_ApplyXYVelsWithGravity: JSR SObj_AddXVelFrac ; Apply X velocity JSR SObj_AddYVelFrac ; Apply Y velocity LDA SpecialObj_YVel,X BMI PRG007_B39D ; If special object is moving upward, jump to PRG007_B39D CMP #$6e BGE PRG007_B3A3 ; If special object Y velocity >= $6E, jump to PRG007_B3A3 (RTS) PRG007_B39D: ; Apply gravity INC SpecialObj_YVel,X INC SpecialObj_YVel,X PRG007_B3A3: RTS ; Return Cannonball_YOffset: .byte 16, $00 Cannonball_YDiffLimit: .byte 16, 32 SObj_Cannonball: ; Load cannonball graphics LDA #$36 STA PatTable_BankSel+4 LDA <Player_HaltGame BNE PRG007_B3C2 ; If gameplay halted, jump to PRG007_B3C2 JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity JSR SObj_OffsetYForRaster ; Offset the Y by raster effects, if any LDA SpecialObj_Data,X BNE PRG007_B3C2 ; If data <> 0 (cannonball is stomped), jump to PRG007_B3C2 ; Otherwise, Y Vel -= 2 (??) DEC SpecialObj_YVel,X DEC SpecialObj_YVel,X PRG007_B3C2: JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_B3A3 ; If cannonball is vertically off-screen, jump to PRG007_B3A3 (RTS) JSR SObj_Draw16x16 ; Prep cannonball sprites ; Set cannon ball sprite attributes LDA #SPR_PAL3 STA Sprite_RAM+$02,Y STA Sprite_RAM+$06,Y ; Set left and right cannonball patterns LDA #$af STA Sprite_RAM+$05,Y LDA #$ad STA Sprite_RAM+$01,Y LDA SpecialObj_Data,X ORA Player_IsDying ORA Player_OffScreen BNE PRG007_B445 ; If cannonon ball is already stomped, Player is dying, or Player is off-screen, jump to PRG007_B445 (RTS) LDY #$00 ; Y = 0 (Player is small or ducking) LDA <Player_Suit BEQ PRG007_B3F3 ; If Player is small, jump to PRG007_B3F3 LDA Player_IsDucking BNE PRG007_B3F3 ; If Player is ducking, jump to PRG007_B3F3 INY ; Y = 1 (Player not small/ducking) PRG007_B3F3: LDA SpecialObj_YLo,X ; Cannonball Y SUB <Player_Y ; Player Y SUB Cannonball_YOffset,Y ; Offset CMP Cannonball_YDiffLimit,Y BGE PRG007_B445 ; If Player is not close enough to top of cannonball, jump to PRG007_B445 (RTS) LDA SpecialObj_XLo,X ADD #$08 ; Cannonball X + 8 SUB <Player_X ; Diff against Player X CMP #20 BGE PRG007_B445 ; If Player is not close enough horizontally to cannonball, jump to PRG007_B445 (RTS) LDA Player_StarInv BNE PRG007_B426 ; If Player is invincible by Star Man, jump to PRG007_B426 LDA <Player_YVel BMI PRG007_B442 ; If Player is moving upward, jump to PRG007_B442 LDA SpecialObj_YLo,X SUB Level_VertScroll SUB #19 CMP <Player_SpriteY BLT PRG007_B442 ; If Player is close enough to bottom of cannonball, jump to PRG007_B442 PRG007_B426: ; Flag cannonball as stomped! LDA #$01 STA SpecialObj_Data,X ; Halt its movements LDA #$00 STA SpecialObj_XVel,X STA SpecialObj_YVel,X ; Player bounces off cannonball LDA #-$30 STA <Player_YVel ; Cannonball kick sound LDA Sound_QPlayer ORA #SND_PLAYERKICK STA Sound_QPlayer JMP PRG007_B446 ; Jump to PRG007_B446 PRG007_B442: JMP PRG007_B805 ; Jump to PRG007_B805 (remainder of Player hit checks) PRG007_B445: RTS ; Return PRG007_B446: JSR Score_FindFreeSlot ; Set base score and add Kill_Tally LDA #$85 ; Base 100 points; $80 just mixes up what sprite it uses PRG007_B44B: ADD Kill_Tally STA Scores_Value,Y INC Kill_Tally ; Kill_Tally++ ; Set the score counter LDA #$30 STA Scores_Counter,Y LDA SpecialObj_YLo,X SUB Level_VertScroll SBC #$06 CMP #192 BLT PRG007_B469 ; If score Y < 192, jump to PRG007_B469 LDA #$05 ; Otherwise, use Y = 5 PRG007_B469: STA Scores_Y,Y ; Set score Y ; Set score X LDA SpecialObj_XLo,X SUB <Horz_Scroll STA Scores_X,Y RTS ; Return SObj_OffsetYForRaster: LDA Level_AScrlConfig BEQ PRG007_B491 ; If there's no raster effect going on, jump to PRG007_B491 (RTS) LDY #$00 ; Y = $00 (16-bit sign extension) LDA Level_ScrollDiffV BPL PRG007_B483 ; If vertical scroll difference is not negative, jump to PRG007_B483 DEY ; Otherwise, Y = $FF (16-bit sign extension) PRG007_B483: ADD SpecialObj_YLo,X STA SpecialObj_YLo,X ; Apply raster offset to Special Object Y TYA ADC SpecialObj_YHi,X STA SpecialObj_YHi,X ; Apply sign extension/carry PRG007_B491: RTS ; Return Wrench_Patterns: .byte $A1, $95, $9F, $95 Wrench_Attributes: .byte SPR_PAL2, SPR_PAL2 | SPR_VFLIP, SPR_PAL2, SPR_PAL2 SObj_Wrench: LDA <Player_HaltGame BNE PRG007_B4AF ; If gameplay halted, jump to PRG007_B4AF JSR SObj_OffsetYForRaster ; Offset Y with raster effects (if any) JSR SObj_AddXVelFrac ; Apply X velocity LDA SpecialObj_YVel,X BEQ PRG007_B4AC ; If wrench Y velocity = 0, jump to PRG007_B4AC INC SpecialObj_YVel,X ; Otherwise, Y Vel++ (fall?) PRG007_B4AC: JSR SObj_AddYVelFrac ; Apply Y velocity PRG007_B4AF: JSR SObj_PlayerCollide ; Do Player-to-wrench collision JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_B4EB ; If wrench is not vertically on-screen, jump to PRG007_B4EB (RTS) ; Set Temp_Var1 = $00 or $80, depending on sign bit of X velocity LDA SpecialObj_XVel,X AND #$80 STA <Temp_Var1 LDA Level_NoStopCnt LSR A ADD <SlotIndexBackup AND #$03 TAX ; X = 0 to 3 ; Set wrench pattern LDA Wrench_Patterns,X STA Sprite_RAM+$01,Y ; Set wrench attributes LDA Wrench_Attributes,X EOR <Temp_Var1 STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = special object slot index SObj_SetSpriteXYRelative: LDA SpecialObj_YLo,X SUB Level_VertScroll STA Sprite_RAM+$00,Y LDA SpecialObj_XLo,X SUB <Horz_Scroll STA Sprite_RAM+$03,Y PRG007_B4EB: RTS ; Return ; In the Japanese original, there were other power ups that "flew off" ; when you lost them, and those are the additional values. None of ; them display correctly anymore, however, because: ; ; The graphics for the fly-off sprite only exist with small Mario, ; meaning when they added the "American" rule of returning to "super" ; state, it didn't have the suit sprite graphics available! LostShoe_Pattern: .byte $A9, $AB ; 0 .byte $39, $39 ; 1 .byte $3B, $3B ; 2 .byte $3D, $3D ; 3 LostShoe_Attribute: .byte $02, $01, $01, $01 SObj_WandBlast: LDA <Player_HaltGame BNE PRG007_B502 ; If gameplay is halted, jump to PRG007_B502 JSR SObj_AddXVelFrac ; Apply X Velocity JSR SObj_AddYVelFrac ; Apply Y Velocity PRG007_B502: JSR SObj_GetSprRAMOffChkVScreen LDA SpecialObj_Timer,X TAX ; Timer -> 'X' ; Select which pattern to use by timer LDA #$fd ; A = $FD CPX #$e0 BGE PRG007_B517 ; If timer >= $E0, jump to PRG007_B517 LDA #$f9 ; A = $F9 CPX #$c0 BGE PRG007_B517 ; If timer >= $C0, jump to PRG007_B517 LDA #$fb ; A = $FB PRG007_B517: ; Set the wand blast pattern STA Sprite_RAM+$01,Y LDX <SlotIndexBackup ; X = special object slot index JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative TXA ; Special object slot index -> 'A' LSR A ; Shift bit 0 into carry ROR A ; Rotate it around to bit 7 AND #SPR_VFLIP STA <Temp_Var1 ; Temp_Var1 = VFlip attribute or not LDA <Counter_1 LSR A LSR A LSR A ROR A AND #SPR_VFLIP ORA #SPR_PAL1 EOR <Temp_Var1 ; Invert VFlip by Temp_Var1 ; Set wand blast attribute STA Sprite_RAM+$02,Y JMP SObj_PlayerCollide ; Do Player-to-wand blast collision and don't come back! RTS ; Return SObj_KuriboShoe: JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity JSR SObj_GetSprRAMOffChkVScreen LDA SpecialObj_Data,X TAX ; SpecialObj_Data -> 'X' (NOTE: Will always be zero in US version, see notes at LostShoe_Pattern) ; Set left sprite attribute LDA LostShoe_Attribute,X STA Sprite_RAM+$02,Y CPX #$00 BEQ PRG007_B54F ; For the lost Kuribo's shoe only: Do not mirror sprite, jump to PRG007_B54F ORA #SPR_HFLIP ; Mirror sprite (NOTE: Used only in Japanese version for the "fly off" super suits!) PRG007_B54F: STA Sprite_RAM+$06,Y ; Set attributes on right sprite ; X *= 2 (two patterns per suit, again generally unused in US version) TXA ASL A TAX ; Pattern for left fly off sprite LDA LostShoe_Pattern,X STA Sprite_RAM+$01,Y ; Pattern for right fly off sprite LDA LostShoe_Pattern+1,X STA Sprite_RAM+$05,Y LDX <SlotIndexBackup ; X = special object slot index SObj_Draw16x16: JSR SObj_SetSpriteXYRelative ; Copy sprite Y into right sprite LDA Sprite_RAM+$00,Y STA Sprite_RAM+$04,Y ; Right sprite is X + 8 LDA Sprite_RAM+$03,Y ADD #$08 STA Sprite_RAM+$07,Y RTS ; Return SObj_Spikeball: LDA <Player_HaltGame BNE PRG007_B588 ; If gameplay is halted, jump to PRG007_B588 LDA SpecialObj_Data,X BEQ PRG007_B585 ; If SpecialObj_Data = 0 (no gravity version, specifically Spike's spike ball), jump to PRG007_B585 JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity JMP PRG007_B588 ; Jump to PRG007_B588 PRG007_B585: JSR SObj_AddXVelFrac ; Apply X velocity only PRG007_B588: JSR SObj_GetSprRAMOffChkVScreen ; Spike ball pattern LDA #$95 STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y JSR SObj_Draw16x16 ; Draw spike ball ; Set spike ball left attributes LDA Level_NoStopCnt LSR A LSR A LSR A ROR A AND #SPR_VFLIP ; Toggles which side is going to be vertically flipped ORA #SPR_PAL2 STA Sprite_RAM+$02,Y ; Set opposite flips on right sprite EOR #(SPR_HFLIP | SPR_VFLIP) STA Sprite_RAM+$06,Y LDA SpecialObj_Data,X BNE PRG007_B5B1 ; If SpecialObj_Data <> 0 (Gravity version, specifically Patooie's spike ball), jump to PRG007_B5B1 (RTS) JMP SObj_PlayerCollide ; Do Player to spike ball collision and don't come back! PRG007_B5B1: RTS ; Return Microgoomba_XAccel: .byte $01, -$01 Microgoomba_XLimit: .byte $10, -$10 Microgoomba_SprRAMAlt: .byte $00, $04, $08, $0C, $10, $14, $18, $1C, $20, $24 SObj_Microgoomba: ; Load Microgoomba's graphics LDA #$4f STA PatTable_BankSel+5 LDA <Player_HaltGame BEQ PRG007_B5CC ; If gameplay is not halted, jump to PRG007_B5CC JMP Microgoomba_Draw ; Draw Microgoomba and don't come back! PRG007_B5CC: LDA SpecialObj_Data,X BNE PRG007_B5D4 ; If SpecialObj_Data <> 0, jump to PRG007_B5D4 JMP PRG007_B660 ; Otherwise, jump to PRG007_B660 PRG007_B5D4: BPL PRG007_B5DC ; If SpecialObj_Data > 0, jump to PRG007_B5DC JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity JMP Microgoomba_Draw ; Draw Microgoomba and don't come back PRG007_B5DC: LDY Player_StarInv BNE PRG007_B601 ; If Player is invincible by Star Man, jump to PRG007_B601 LDY Player_InWater BNE PRG007_B601 ; If Player is in water, jump to PRG007_B601 INC Player_UphillSpeedIdx ; Player_UphillSpeedIdx = 1 (Microgoomba stuck to Player) CMP #$05 BGE PRG007_B5F6 ; If Microgoomba is already at his maximum stickiness, jump to PRG007_B5F6 ; Player is trying to shake him... LDA <Counter_1 AND #$0f BNE PRG007_B5F6 ; 1:16 ticks proceed, otherwise, jump to PRG007_B5F6 INC SpecialObj_Data,X ; SpecialObj_Data++ (Increase "stickiness", up to 5) PRG007_B5F6: LDA <Pad_Input AND #$ff ; This probably was intended to be a specific button rather than "everything" BEQ PRG007_B617 ; If Player is not pressing anything, jump to PRG007_B617 DEC SpecialObj_Data,X ; SpecialObj_Data-- BNE PRG007_B617 ; If SpecialObj_Data > 0, jump to PRG007_B617 PRG007_B601: ; Otherwise, SpecialObj_Data = $FF (Microgoomba's "death" value) LDA #$ff STA SpecialObj_Data,X ; Microgoomba flops off LDA #-$20 STA SpecialObj_YVel,X LDA #$08 ; A = $08 LDY RandomN,X BPL PRG007_B614 ; 50/50 chance we jump to PRG007_B614 LDA #-$08 ; A = -$08 PRG007_B614: STA SpecialObj_XVel,X ; Random X velocity PRG007_B617: INC SpecialObj_Var1,X ; SpecialObj_Var1++ ; Set Microgoomba's Y... LDA SpecialObj_Var1,X LSR A LSR A AND #%00011111 CMP #%00010000 AND #%00001111 BCC PRG007_B62B ; 16 ticks on, 16 ticks off; jump to PRG007_B62B EOR #%00001111 ADC #$00 PRG007_B62B: CLC ; Clear carry LDY Player_IsDucking BNE PRG007_B635 ; If Player is ducking, jump to PRG007_B635 LDY <Player_Suit BNE PRG007_B639 ; If Player is small, jump to PRG007_B639 PRG007_B635: LSR A ADD #$08 PRG007_B639: ADC <Player_Y STA SpecialObj_YLo,X LDA <Player_YHi ADC #$00 STA SpecialObj_YHi,X ; Set Microgoomba's X... LDA SpecialObj_Var1,X AND #%00011111 CMP #%00010000 AND #%00001111 BLT PRG007_B654 ; 16 ticks on, 16 ticks off; jump to PRG007_B62B EOR #%00001111 ADC #$00 PRG007_B654: SUB #$03 ADD <Player_X STA SpecialObj_XLo,X JMP Microgoomba_Draw ; Draw Microgoomba and don't come back PRG007_B660: ; SpecialObj_Data = 0... JSR SObj_AddXVelFrac ; Apply X Velocity JSR SObj_AddYVelFrac ; Apply Y Velocity LDA SpecialObj_YVel,X CMP #$10 BGS PRG007_B670 ; If Microgoomba's Y velocity >= 16, jump to PRG007_B670 INC SpecialObj_YVel,X ; Otherwise, Y Vel++ PRG007_B670: LDA <Counter_1 AND #$00 BNE Microgoomba_Draw ; Technically NEVER jump to Microgoomba_Draw (??) LDA SpecialObj_Var1,X AND #$01 TAY ; Y = 0 or 1 ; Accelerate Microgoomba LDA SpecialObj_XVel,X ADD Microgoomba_XAccel,Y STA SpecialObj_XVel,X CMP Microgoomba_XLimit,Y BNE Microgoomba_Draw ; If Microgoomba hasn't his X velocity limit, jump to Microgoomba_Draw INC SpecialObj_Var1,X ; Otherwise, SpecialObj_Var1++ (switch direction) Microgoomba_Draw: JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_B6CE ; If Microgoomba is not on this vertical screen, jump to PRG007_B6CE (RTS) LDA SpecialObj_Data,X BEQ PRG007_B6A9 BMI PRG007_B6A9 ; If SpecialObj_Data <= 0, jump to PRG007_B6A9 TXA ASL A ASL A ASL A ASL A EOR SpecialObj_Var1,X AND #%00010000 BEQ PRG007_B6A9 ; Every 2 direction changes, jump to PRG007_B6A9 ; Use alternate Sprite RAM offset periodically LDY Microgoomba_SprRAMAlt,X ; Y = Microgoomba sprite RAM offset PRG007_B6A9: JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative ; Microgoomba pattern LDA #$ff STA Sprite_RAM+$01,Y LDX #SPR_PAL3 LDA Level_NoStopCnt AND #$08 BEQ PRG007_B6BC ; 8 ticks on, 8 ticks off; jump to PRG007_B6BC LDX #(SPR_PAL3 | SPR_HFLIP) PRG007_B6BC: ; Store selected attributes TXA STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = special object slot LDA SpecialObj_Data,X BEQ PRG007_B6CF ; If SpecialObj_Data = 0, jump to PRG007_B6CF (Player to Microgoomba collision) BPL PRG007_B6CE ; If SpecialObj_Data > 0 (Microgoomba still alive), jump to PRG007_B6CE (RTS) ; Microgoomba is dead; vertically flip LDA #(SPR_PAL3 | SPR_VFLIP) STA Sprite_RAM+$02,Y PRG007_B6CE: RTS ; Return PRG007_B6CF: JMP SObj_PlayerCollide ; Handle Player to Microgoomba collision and don't come back! ; The hammer starting X is offset Hammer_XOff: ; Not-HF HF (HF = Horizontally flipped) .byte 8, -8 ; Non-Heavy Hammer hold offset .byte 8, -8 ; Non-Heavy Boomerang hold offset .byte 16, -8 ; Heavy Bro hold offset ; The hammer starting Y is offset Hammer_YOff: ; Not-HF HF (HF = Horizontally flipped) .byte 3, 3 ; Non-Heavy Hammer hold offset .byte 3, 3 ; Non-Heavy Boomerang hold offset .byte -6, -6 ; Heavy Bro hold offset SObjYOff_PlayerSize: .byte 18, 10 ; Small vs not small SObj_VLimit: .byte $10, $16 PRG007_B6E2: .byte $00, $10 SObj_Hammer: LDA <Player_HaltGame BEQ PRG007_B6EB ; If gameplay is not halted, jump to PRG007_B6EB JMP PRG007_B773 ; Otherwise, jump to PRG007_B773 PRG007_B6EB: ; SpecialObj_Data special purposes: ; Bits 0-3: Decrement to zero ; Bits 4-7: While lower 4 bits not zero, references an object which, if not in normal state or off-screen, destroys this object LDA SpecialObj_Data,X AND #%00001111 ; Consider lowest 4 bits of SpecialObj_Data BEQ PRG007_B76D ; If zero, jump to PRG007_B76D PRG007_B6F2: ; Lowest 4 bits of SpecialObj_Data is non-zero DEC SpecialObj_Data,X ; SpecialObj_Data-- (mainly to effect the lowest 4 bits) LDA SpecialObj_Data,X LSR A LSR A LSR A LSR A TAY ; Y = the upper 4 bits (an object slot index) STY <Temp_Var2 ; -> Temp_Var2 LDA Objects_State,Y CMP #OBJSTATE_NORMAL BNE PRG007_B70D ; If this object is not in normal state, jump to PRG007_B70D LDA Objects_SprHVis,Y AND #%11000000 BEQ PRG007_B710 ; If this sprite does not have its two left sprites off-screen, jump to PRG007_B710 PRG007_B70D: ; Referenced object is not in normal state or it is off-screen; destroy special object JMP SpecialObj_Remove PRG007_B710: LDA Objects_FlipBits,Y AND #SPR_HFLIP STA <Temp_Var3 ; Catch the horizontal flip bit of the referenced object -> Temp_Var3 ; Temp_Var1 = 0 to 1, based on whether object is horizontally flipped ASL A ASL A ROL A AND #$01 STA <Temp_Var1 LDA SpecialObj_ID,X CMP #SOBJ_HAMMER BEQ PRG007_B729 ; If this is a hammer, jump to PRG007_B729 ; Otherwise, Temp_Var1 += 2 INC <Temp_Var1 INC <Temp_Var1 PRG007_B729: LDA Level_ObjectID,Y CMP #OBJ_HEAVYBRO BNE PRG007_B737 ; If this not a Heavy Bro, jump to PRG007_B737 ; Otherwise, Temp_Var1 += 4 LDA <Temp_Var1 ADD #$04 STA <Temp_Var1 PRG007_B737: ; Set hammer starting X LDA Objects_X,Y LDY <Temp_Var1 ADD Hammer_XOff,Y STA SpecialObj_XLo,X LDY <Temp_Var2 ; Y = referenced object slot index ; Set hammer starting Y LDA Objects_Y,Y CLC LDY <Temp_Var1 ADC Hammer_YOff,Y STA SpecialObj_YLo,X LDA #$00 ; A = 0 LDY SpecialObj_XVel,X BMI PRG007_B75A ; If hammer is traveling to the left, jump to PRG007_B75A LDA #SPR_HFLIP ; A = SPR_HFLIP PRG007_B75A: CMP <Temp_Var3 BEQ PRG007_B76A ; If hammer is flipped the same way as object, jump to PRG007_B76A ; Reverse X velocity LDA SpecialObj_XVel,X JSR Negate STA SpecialObj_XVel,X INC SpecialObj_Var2,X PRG007_B76A: JMP PRG007_B773 ; Jump to PRG007_B773 PRG007_B76D: INC SpecialObj_Var1,X ; SpecialObj_Var1++ JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity PRG007_B773: JSR SObj_GetSprRAMOffChkVScreen ; Get a sprite RAM offset BEQ PRG007_B779 ; If object is on the same vertical screen (see Temp_Var14 calculation), jump to PRG007_B779 RTS ; Return PRG007_B779: STY <Temp_Var2 ; Sprite RAM offset -> 'Y' LDA SpecialObj_XVel,X LDY SpecialObj_ID,X CPY #SOBJ_HAMMER BEQ PRG007_B787 ; If this is a hammer, jump to PRG007_B787 EOR #$80 ; Invert sign on X velocity PRG007_B787: LSR A ; Shift down the bit AND #SPR_HFLIP ; Horizontal flip bit STA <Temp_Var1 ; -> Temp_Var1 CPY #SOBJ_HAMMER BNE PRG007_B798 ; If this is not a hammer, jump to PRG007_B798 LDY <Temp_Var2 ; Y = Sprite RAM Offset JSR Hammer_Draw ; Draw hammer JMP PRG007_B7C5 ; Jump to PRG007_B7C5 PRG007_B798: LDY <Temp_Var2 ; Y = Sprite RAM Offset LDA SpecialObj_Var1,X AND #%00001100 LSR A LSR A TAX ; X = 0 to 3 ; Set boomerang sprites attributes LDA <Temp_Var1 EOR Boomerang_Attributes,X ORA #SPR_PAL1 STA Sprite_RAM+$02,Y STA Sprite_RAM+$06,Y LDA <Temp_Var1 BEQ PRG007_B7B5 ; If Temp_Var1 = 0, jump to PRG007_B7B5 INX INX PRG007_B7B5: TXA AND #$03 TAX ; Set boomerang sprites patterns LDA Boomerang_Patterns,X STA Sprite_RAM+$01,Y LDA Boomerang_Patterns+2,X STA Sprite_RAM+$05,Y PRG007_B7C5: LDX <SlotIndexBackup ; X = special object slot index JSR SObj_Draw16x16 ; Draw Boomerang LDA SpecialObj_Data,X AND #%00001111 BNE PRG007_B826 ; If lower 4 bits are not zero, jump to PRG007_B826 (RTS) SObj_PlayerCollide: ; Player to Special Object collision logic... TXA ; object slot index -> 'A' ADD <Counter_1 ; Keep it interesting LSR A BCC PRG007_B826 ; Every other tick, jump to PRG007_B826 (RTS) LDY #$00 ; Y = 0 (small/ducking) LDA <Player_Suit BEQ PRG007_B7E4 ; If Player is small, jump to PRG007_B7E4 LDA Player_IsDucking BNE PRG007_B7E4 ; If Player is ducking, jump to PRG007_B7E4 INY ; Y = 1 (otherwise) PRG007_B7E4: LDA SpecialObj_YLo,X ; Special object Y ADD #$08 ; +8 SUB <Player_Y ; Subtract Player Y SUB SObjYOff_PlayerSize,Y ; Subtract Player height offset CMP SObj_VLimit,Y BGE PRG007_B843 ; If result >= SObj_VLimit, jump to PRG007_B843 (RTS) LDA SpecialObj_XLo,X ; Special object X ADD #$06 ; +6 SUB <Player_X ; Subtract Player X SBC #$00 ; Carry? CMP #16 BGE PRG007_B843 ; If result >= 16, jump to PRG007_B843 (RTS) PRG007_B805: LDA Player_FlashInv ; If Player is flashing from being hit ... ORA Player_Statue ; ... if Player is a statue ... ORA <Player_HaltGame ; ... if gameplay is halted ... ORA Player_IsDying ; ... Player is dying ... ORA Player_OffScreen ; ... Player is off-screen ... ORA Player_Behind_En ; ... Player is legitimately hidden behind the scenes ... ORA <Temp_Var14 ; ... or special object is not vertically on-screen ... BNE PRG007_B843 ; ... jump to Player_Behind_En (RTS) LDA SpecialObj_ID,X CMP #SOBJ_MICROGOOMBA BNE PRG007_B827 ; If this is not a microgoomba, jump to PRG007_B827 ; Microgooma sets to 5 LDA #$05 STA SpecialObj_Data,X PRG007_B826: RTS ; Return PRG007_B827: CMP #$10 BNE PRG007_B836 ; If this is not the recovered wand, jump to PRG007_B836 ; Wand grabbed! INC Level_GetWandState ; Level_GetWandState++ ; Play victory music! LDA #MUS1_BOSSVICTORY STA Sound_QMusic1 JMP SpecialObj_Remove ; Remove the wand and don't come back! PRG007_B836: LDA Player_StarInv BNE PRG007_B844 ; If Player is Star Man invincible, jump to PRG007_B844 JMP Player_GetHurt ; Hurt Player and don't come back! SpecialObj_Remove: ; Remove special object LDA #$00 STA SpecialObj_ID,X PRG007_B843: RTS ; Return PRG007_B844: ; Player is invincible; destroy the special object! ; Play "kick" sound LDA Sound_QPlayer ORA #SND_PLAYERKICK STA Sound_QPlayer PRG007_B84C: ; Change to a "poof" LDA #SOBJ_POOF STA SpecialObj_ID,X ; SpecialObj_Data = $1F LDA #$1f STA SpecialObj_Data,X RTS ; Return Hammer_Attributes: .byte $00, SPR_HFLIP, SPR_HFLIP, SPR_HFLIP | SPR_VFLIP, SPR_HFLIP | SPR_VFLIP, SPR_VFLIP, SPR_VFLIP, $00 Hammer_Patterns: .byte $A1, $A3, $B9, $B9, $A3, $A1 .byte $AF, $AF, $A1, $A3, $B9, $B9 Hammer_Draw: LDA SpecialObj_Var1,X AND #%00011100 LSR A LSR A TAX ; X = 0 to 7 (hammer's current frame) ; Set upper and lower sprite attributes LDA <Temp_Var1 EOR Hammer_Attributes,X ORA #SPR_PAL1 STA Sprite_RAM+$02,Y STA Sprite_RAM+$06,Y LDA <Temp_Var1 BEQ PRG007_B888 ; If no flip, jump to PRG007_B888 ; Otherwise, X += 4 (4 "frames" ahead on the hammer for the flip) INX INX INX INX PRG007_B888: ; Cap X 0 to 7 TXA AND #$07 TAX ; Set upper sprite pattern LDA Hammer_Patterns,X STA Sprite_RAM+$01,Y ; Set bottom sprite pattern LDA Hammer_Patterns+4,X STA Sprite_RAM+$05,Y RTS ; Return Boomerang_XVelDelta: .byte $01, -$01 Boomerang_XVelLimit: .byte $20, $E0 Boomerang_YVelAccel: .byte $01, -$01 Boomerang_YVelLimit: .byte $12, -$12 Boomerang_Attributes: .byte SPR_HFLIP | SPR_VFLIP, SPR_HFLIP | SPR_VFLIP, $00, $00 Boomerang_Patterns: .byte $8B, $8F, $89, $8D, $8B, $8F SObj_Boomerang: ; Load Boomerang's graphics LDA #$4e STA PatTable_BankSel+4 LDA <Player_HaltGame BEQ PRG007_B8B7 ; If gameplay is not halted, jump to PRG007_B8B7 JMP PRG007_B773 ; Jump to PRG007_B773 (Draw Boomerang) PRG007_B8B7: LDA SpecialObj_Data,X AND #%00001111 BEQ PRG007_B8C1 ; If lower 4 bits of SpecialObj_Data = 0, jump to PRG007_B8C1 JMP PRG007_B6F2 ; Jump to PRG007_B6F2 PRG007_B8C1: INC SpecialObj_Var1,X ; Var1 ++ LDA SndCur_Level2 AND #SND_BOOMERANG BNE PRG007_B8D3 ; If boomerang sound is currently playing, jump to PRG007_B8D3 ; Player boomerang sound LDA Sound_QLevel2 ORA #SND_BOOMERANG STA Sound_QLevel2 PRG007_B8D3: LDA SpecialObj_Var2,X BMI PRG007_B904 LDA SpecialObj_Timer,X BNE PRG007_B904 ; If timer not expired, jump to PRG007_B904 LDA SpecialObj_Var2,X AND #$01 TAY ; Y = 0 or 1 (Boomerang Direction) ; Accelerate Boomerang LDA SpecialObj_XVel,X ADD Boomerang_XVelDelta,Y STA SpecialObj_XVel,X CMP Boomerang_XVelLimit,Y BNE PRG007_B904 ; If boomerang has not hit limit, jump to PRG007_B904 ; Set boomerang timer LDA #$30 STA SpecialObj_Timer,X INC SpecialObj_Var2,X ; SpecialObj_Var2++ (change direction) LDA SpecialObj_Var3,X BEQ PRG007_B904 ; If SpecialObj_Var3 = 0, jump to PRG007_B904 ; Boomerang is on the return LDA #$ff STA SpecialObj_Var2,X PRG007_B904: LDA <Counter_1 LSR A BCS PRG007_B92A ; Every other tick, jump to PRG007_B92A LDA SpecialObj_Var3,X CMP #$01 BLT PRG007_B915 LDY SpecialObj_YVel,X BEQ PRG007_B92A ; If Boomerang Y Vel = 0, jump to PRG007_B92A PRG007_B915: AND #$01 TAY ; Y = 0 or 1 ; Accelerate Boomerang Y Velocity LDA SpecialObj_YVel,X ADD Boomerang_YVelAccel,Y STA SpecialObj_YVel,X CMP Boomerang_YVelLimit,Y BNE PRG007_B92A ; If Boomerang Y Velocity is at limit, jump to PRG007_B92A INC SpecialObj_Var3,X ; SpecialObj_Var3++ PRG007_B92A: JSR SObj_AddXVelFrac ; Apply X Velocity JSR SObj_AddYVelFrac ; Apply Y Velocity JSR PRG007_B773 ; Draw Boomerang LDA SpecialObj_Var2,X BPL PRG007_B979 ; If SpecialObj_Var2 <> $FF, jump to PRG007_B979 TXA ; Keep things interesting ADD <Counter_1 LSR A BCS PRG007_B979 ; Every other tick, jump to PRG007_B979 (RTS) LDA SpecialObj_Data,X LSR A LSR A LSR A LSR A TAY ; Y = object slot index of boomerang thrower LDA Objects_State,Y CMP #OBJSTATE_NORMAL BNE PRG007_B979 ; If thrower's state <> Normal, jump to PRG007_B979 (RTS) LDA Level_ObjectID,Y CMP #OBJ_BOOMERANGBRO BNE PRG007_B979 ; If thrower's slot is not a boomerang brother (Anymore), jump to PRG007_B979 (RTS) ; This is for the Boomerang brother to "catch" LDA SpecialObj_YLo,X ADD #8 SUB Objects_Y,Y SUB #8 CMP #16 BGE PRG007_B979 ; If boomerang Y diff >= 16, jump to PRG007_B979 (RTS) LDA SpecialObj_XLo,X ADD #8 SUB Objects_X,Y SBC #0 CMP #16 BGE PRG007_B979 ; If boomerang X diff >= 16, jump to PRGO007_B979 (RTS) JMP SpecialObj_Remove ; Boomerang Bro caught boomerang PRG007_B979: RTS ; Return SObj_UNKNOWN_XAccel: .byte $01, -$01 SObj_UNKNOWN_XLimit: .byte $20, $E0 SObj_UNKNOWN_YAccel: .byte $04, -$01 SObj_UNKNOWN_YLimit: .byte $0F, -$12 SObj_UNKNOWN: LDA <Player_HaltGame BEQ PRG007_B989 ; If gameplay not halted, jump to PRG007_B989 JMP PRG007_B773 ; Otherwise, jump to PRG007_B773 (Hammer/Boomerang draw routines??) PRG007_B989: LDA SpecialObj_Data,X AND #$0f BEQ PRG007_B993 ; 1:16 ticks jump to PRG007_B993 JMP PRG007_B6F2 ; Jump to PRG007_B6F2 PRG007_B993: DEC SpecialObj_Var1,X ; Var1-- LDY SpecialObj_Timer,X BEQ PRG007_B9A1 ; If timer not expired, jump to PRG007_B9A1 DEY ; Y-- BNE PRG007_B9C4 ; If timer still has at least 1 tick left, jump to PRG007_B9C4 INC SpecialObj_Var3,X ; SpecialObj_Var3++ PRG007_B9A1: LDA <Counter_1 AND #$00 ; ?? BNE PRG007_B9C4 ; Jump technically NEVER to PRG007_B9C4 LDA SpecialObj_Var2,X AND #$01 TAY ; Y = 0 or 1 ; Accelerate X LDA SpecialObj_XVel,X ADD SObj_UNKNOWN_XAccel,Y STA SpecialObj_XVel,X CMP SObj_UNKNOWN_XLimit,Y BNE PRG007_B9C4 ; If it hasn't hit its X velocity limit, jump to PRG007_B9C4 ; Timer = $50 LDA #$50 STA SpecialObj_Timer,X INC SpecialObj_Var2,X ; Var2++ PRG007_B9C4: LDA <Counter_1 AND #$03 BNE PRG007_B9ED ; 1:4 ticks proceed, otherwise jump to PRG007_B9ED LDA SpecialObj_Var3,X BEQ PRG007_B9ED ; If SpecialObj_Var3 = 0, jump to PRG007_B9ED CMP #$03 BLT PRG007_B9D8 ; If SpecialObj_Var3 < 3, jump to PRG007_B9D8 LDY SpecialObj_YVel,X BEQ PRG007_B9ED ; If it is not moving vertically, jump to PRG007_B9ED PRG007_B9D8: AND #$01 TAY ; Y = 0 or 1 ; Accelerate Y LDA SpecialObj_YVel,X ADD SObj_UNKNOWN_YAccel,Y STA SpecialObj_YVel,X CMP SObj_UNKNOWN_YLimit,Y BNE PRG007_B9ED ; If it hasn't hit its Y velocity limit, jump to PRG007_B9ED INC SpecialObj_Var3,X ; SpecialObj_Var3++ PRG007_B9ED: JMP PRG007_B92A ; Jump to PRG007_B92A (uses more Boomerang behavior) Fireball_Patterns: .byte $65, $67, $65, $67 Fireball_Attributes: .byte SPR_PAL1, SPR_PAL1, SPR_PAL1 | SPR_HFLIP | SPR_VFLIP, SPR_PAL1 | SPR_HFLIP | SPR_VFLIP SObj_Fireball: LDA <Player_HaltGame BNE PRG007_BA33 ; If gameplay halted, jump to PRG007_BA33 ; Gameplay not halted... INC SpecialObj_Var1,X ; SpecialObj_Var1++ LDA SpecialObj_ID,X CMP #SOBJ_PIRANHAFIREBALL BEQ PRG007_BA2D ; If this is a piranha's fireball, jump to PRG007_BA2D CMP #SOBJ_FIRECHOMPFIRE BEQ PRG007_BA2D ; If this is a Fire Chomp's fireball, jump to PRG007_BA2D ; Not a piranha's or Fire Chomp's fireball JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity LDA SpecialObj_YVel,X CMP #$30 BPL PRG007_BA1A ; If fireball Y vel < $30, jump to PRG007_BA1A ; Heavier gravity INC SpecialObj_YVel,X INC SpecialObj_YVel,X PRG007_BA1A: LDA SpecialObj_ID,X CMP #SOBJ_FIREBROFIREBALL BNE PRG007_BA24 ; If this is not Fire Bro's fireball, jump to PRG007_BA24 JSR SObj_CheckHitSolid ; Bounce fireball off surfaces PRG007_BA24: JMP PRG007_BA33 ; Jump to PRG007_BA33 JSR SObj_ApplyXYVelsWithGravity ; Apply X and Y velocities with gravity JMP PRG007_BA33 ; Jump to PRG007_BA33 PRG007_BA2D: JSR SObj_AddXVelFrac ; Apply X velocity JSR SObj_AddYVelFrac ; Apply Y velocity PRG007_BA33: JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_BA92 ; If fireball isn't vertically on-screen, jump to PRG007_BA92 JSR SObj_SetSpriteXYRelative ; Special Object X/Y put to sprite, scroll-relative LDA SpecialObj_ID,X CMP #SOBJ_FIRECHOMPFIRE BNE PRG007_BA55 ; If this is not a Fire Chomp's fireball, jump to PRG007_BA55 ; Fire Chomp's fireball only... LDA Level_NoStopCnt LSR A LSR A LDA #$89 ; A = $89 (first fireball pattern) BCC PRG007_BA4D ; 4 ticks on, 4 ticks off; jump to PRG007_BA4D LDA #$8b ; A = $8B (second fireball pattern) PRG007_BA4D: STA Sprite_RAM+$01,Y ; Set fireball pattern LDA #$01 ; A = 1 JMP PRG007_BA6E ; Jump to PRG007_BA6E PRG007_BA55: LDA SpecialObj_XVel,X LSR A AND #SPR_HFLIP ; Flip based on X velocity PHA ; Save flip LDA SpecialObj_Var1,X LSR A LSR A AND #$03 TAX ; X = 0 to 3 ; Set fireball pattern LDA Fireball_Patterns,X STA Sprite_RAM+$01,Y PLA ; Restore flip EOR Fireball_Attributes,X PRG007_BA6E: ; Set fireball attributes STA Sprite_RAM+$02,Y LDX <SlotIndexBackup ; X = special object slot index LDA <Player_Suit CMP #$06 BNE PRG007_BA8F ; If Player is not wearing the Hammer Suit, jump to PRG007_BA8F LDA Player_IsDucking BEQ PRG007_BA8F ; If Player is NOT ducking (immunity to fireballs), jump to PRG007_BA8F LDA Player_StarInv PHA ; Save Player's Star Man invincibility status ; Collide with it like Player were invincible! (Visually the shell protects him) LDA #$10 STA Player_StarInv JSR SObj_PlayerCollide ; Restore actual Star Man invincibility PLA STA Player_StarInv RTS ; Return PRG007_BA8F: JMP SObj_PlayerCollide ; Do Player-to-Fireball collision and don't come back! PRG007_BA92: RTS ; Return Poof_Patterns: .byte $47, $45, $43, $41 SObj_Poof: LDA SpecialObj_Data,X BNE PRG007_BA9F ; If data > 0, jump to PRG007_BA9F JMP SpecialObj_Remove ; Otherwise, remove the puff PRG007_BA9F: LDA <Player_HaltGame BNE PRG007_BAA6 ; If gameplay halted, jump to PRG007_BAA6 DEC SpecialObj_Data,X ; Data-- PRG007_BAA6: JSR SObj_GetSprRAMOffChkVScreen BNE PRG007_BAD6 ; If puff is vertically off-screen, jump to PRG007_BAD6 JSR SObj_Draw16x16 ; Prep puff sprite ; Set puff attributes on left sprite LDA Level_NoStopCnt LSR A LSR A LSR A ROR A AND #SPR_VFLIP STA <Temp_Var1 LDA #SPR_PAL1 ORA <Temp_Var1 STA Sprite_RAM+$02,Y ; Set puff attributes on right sprite EOR #(SPR_HFLIP | SPR_VFLIP) STA Sprite_RAM+$06,Y LDA SpecialObj_Data,X LSR A LSR A LSR A TAX ; Set poof patterns LDA Poof_Patterns,X STA Sprite_RAM+$01,Y STA Sprite_RAM+$05,Y LDX <SlotIndexBackup ; X = special object slot index PRG007_BAD6: RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SObj_GetSprRAMOffChkVScreen ; ; Gets an appropriate sprite RAM offset and also returns zero if ; the object is on the same vertical screen as the Player ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SObj_SprRAMBase: .byte $08, $10, $00, $08, $10, $04, $0C, $14, $0C SObj_GetSprRAMOffChkVScreen: LDY #$07 ; Y = 7 CPX #$09 BEQ PRG007_BAED ; If special object slot = 9, jump to PRG007_BAED CPX #$03 BLT PRG007_BAED ; If special object slot < 3, jump to PRG007_BAED LDY #$08 ; Y = 8 PRG007_BAED: LDA SObj_SprRAMBase-1,X ADD Object_SprRAM-1,Y TAY ; Y = Sprite RAM offset CPX #$00 BNE PRG007_BB1A ; If special object slot 0, jump to PRG007_BB1A JSR Object_GetRandNearUnusedSpr BNE PRG007_BB1A ; If sprite available, jump to PRG007_BB1A LDA SpecialObj_ID,X ; If this special object is empty, or is a Nipper fireball/Piranha Fireball/Microgoomba, jump to PRG007_BB1A CMP #SOBJ_NIPPERFIREBALL BEQ PRG007_BB1A CMP #SOBJ_PIRANHAFIREBALL BEQ PRG007_BB1A CMP #SOBJ_MICROGOOMBA BEQ PRG007_BB1A CMP #$00 BEQ PRG007_BB1A LDA RandomN,X AND #$03 ; 0 to 3 ASL A ASL A ASL A ; Multiply by 8 TAY ; Y = 0, 8, 16, 24 PRG007_BB1A: LDA <Temp_Var14 ; Return the relative Y Hi value RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SObj_AddXVelFrac ; ; Adds the 4.4FP X velocity to X of special object ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SObj_AddXVelFrac: LDA SpecialObj_XVel,X ; Get X Velocity ASL A ASL A ASL A ASL A ; Fractional part shifted up ADD SpecialObj_XVelFrac,X STA SpecialObj_XVelFrac,X ; Add to special object's X vel fractional accumulator PHP ; Save CPU status ; Basically amounts to an arithmetic shift right 4 places LDA SpecialObj_XVel,X ; Get X Velocity LSR A LSR A LSR A LSR A ; Whole part shifted down (integer) CMP #%00001000 ; Check the sign bit BLT PRG007_BB39 ; If the value was not negatively signed, jump to PRG007_BB39 ORA #%11110000 ; Otherwise, apply a sign extension PRG007_BB39: PLP ; Restore CPU status ADC SpecialObj_XLo,X STA SpecialObj_XLo,X ; Add with carry RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SObj_AddYVelFrac ; ; Adds the 4.4FP Y velocity to Y of special object ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SObj_AddYVelFrac: LDA SpecialObj_YVel,X ; Get Y Velocity ASL A ASL A ASL A ASL A ; Fractional part shifted up ADD SpecialObj_YVelFrac,X STA SpecialObj_YVelFrac,X ; Add to special object's X vel fractional accumulator PHP ; Save CPU status ; Basically amounts to an arithmetic shift right 4 places LDA SpecialObj_YVel,X ; Get Y Velocity LSR A LSR A LSR A LSR A ; Whole part shifted down (integer) CMP #%00001000 ; Check the sign bit LDY #$00 ; Y = $00 (16-bit sign extension) BLT PRG007_BB60 ; If the value was not negatively signed, jump to PRG007_BB60 ORA #%11110000 ; Otherwise, apply a sign extension DEY ; Y = $FF (16-bit sign extension) PRG007_BB60: PLP ; Restore CPU status ADC SpecialObj_YLo,X STA SpecialObj_YLo,X ; Add with carry TYA ; Sign extension ; Apply sign extension ADC SpecialObj_YHi,X STA SpecialObj_YHi,X RTS ; Return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CannonFire_UpdateAndDraw ; ; Updates and draws the Cannon Fires ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CannonFire_UpdateAndDraw: LDA <Player_HaltGame ORA EndCard_Flag BNE PRG007_BB80 ; If gameplay halted or end level card grabbed, jump to PRG007_BB80 (RTS) LDX #$07 ; X = 7 PRG007_BB78: STX <SlotIndexBackup ; Update index backup JSR CannonFire_DrawAndUpdate ; Draw and Update Cannon Fire DEX ; X-- BPL PRG007_BB78 ; While X >= 0, loop! PRG007_BB80: RTS ; Return CannonFire_DrawAndUpdate: LDA CannonFire_ID,X BEQ PRG007_BB80 ; If this slot is unused/empty, jump to PRG007_BB80 (RTS) PHA ; Save ID ; Update CannonFire_Timer LDA CannonFire_Timer,X BEQ PRG007_BB8F ; If CannonFire_Timer = 0, jump to CannonFire_Timer DEC CannonFire_Timer,X ; CannonFire_Timer-- PRG007_BB8F: ; Update CannonFire_Timer2 LDA CannonFire_Timer2,X BEQ PRG007_BB97 DEC CannonFire_Timer2,X PRG007_BB97: PLA ; Restore ID JSR DynJump ; THESE MUST FOLLOW DynJump FOR THE DYNAMIC JUMP TO WORK!! .word PRG007_BB80 ; 00: Unused (would never get here anyway) .word CFire_BulletBill ; 01: Bullet Bill cannon .word CFire_BulletBill ; 02: Missile Bill (homing Bullet Bill) .word CFire_RockyWrench ; 03: Creates Rocky Wrench .word CFire_4Way ; 04: 4-way cannon .word CFire_GoombaPipe ; 05: Goomba pipe (left output) .word CFire_GoombaPipe ; 06: Goomba pipe (right output) .word CFire_Cannonball ; 07: Fires cannonballs horizontally left .word CFire_Cannonball ; 08: Fires BIG cannonballs horizontally left .word CFire_Cannonball ; 09: Fires cannonballs diagonally, upper left .word CFire_Cannonball ; 0A: Fires cannonballs diagonally, upper right .word CFire_Cannonball ; 0B: Fires cannonballs diagonally, lower left .word CFire_Cannonball ; 0C: Fires cannonballs diagonally, lower right .word CFire_Cannonball ; 0D: .word CFire_Cannonball ; 0E: .word CFire_Cannonball ; 0F: .word CFire_Cannonball ; 10: .word CFire_Cannonball ; 11: Fires cannonballs horizontally right .word CFire_Cannonball ; 12: Fires BIG cannonballs horizontally right .word CFire_Cannonball ; 13: Launches fused Bob-ombs to the left .word CFire_Cannonball ; 14: Launches fused Bob-ombs to the right .word CFire_Laser ; 15: Laser fire CFire_Laser: LDA CannonFire_X,X CMP <Horz_Scroll LDA CannonFire_XHi,X SBC <Horz_Scroll_Hi BNE PRG007_BBEB ; If the Cannon Fire laser is horizontally off-screen, jump to PRG007_BBEB (RTS) LDA CannonFire_X,X SUB <Player_X CMP #$38 BLT PRG007_BBEB ; If Player is too far left, jump to PRG007_BBEB (RTS) CMP #$4c BGE PRG007_BBEB ; If Player is too far right, jump to PRG007_BBEB (RTS) LDY #$07 ; Y = 7 PRG007_BBE3: LDA SpecialObj_ID,Y BEQ PRG007_BBEC ; If this special object slot is not in use, jump to PRG007_BBEC DEY ; Y-- BPL PRG007_BBE3 ; While Y >= 0, loop! PRG007_BBEB: RTS ; Return PRG007_BBEC: LDA SndCur_Player ORA Sound_QPlayer AND #SND_PLAYERPIPE BNE PRG007_BBFB ; If the pipe/shrink sound is queued or currently playing, jump to PRG007_BBFB ; Otherwise play the "bump" sound (which played rapidly makes the laser sound) LDA #SND_PLAYERBUMP STA Sound_QPlayer PRG007_BBFB: ; This is a laser! LDA #SOBJ_LASER STA SpecialObj_ID,Y ; Set laser X LDA CannonFire_X,X SUB #$08 STA SpecialObj_XLo,Y ; Set laser Y LDA CannonFire_Y,X ADD #$08 STA SpecialObj_YLo,Y LDA CannonFire_YHi,X STA SpecialObj_YHi,Y RTS ; Return CFire_Cannonball: ; Load cannonball graphics LDA #$36 STA PatTable_BankSel+4 LDA CannonFire_Timer,X BNE PRG007_BC5B ; If timer not expired, jump to PRG007_BC5B (RTS) LDA CannonFire_X,X CMP <Horz_Scroll LDA CannonFire_XHi,X SBC <Horz_Scroll_Hi BNE PRG007_BC5B ; If Cannon Fire is off-screen left, jump to PRG007_BC5B (RTS) LDA CannonFire_X,X SUB <Horz_Scroll CMP #240 BGE PRG007_BC5B ; If Cannon Fire is off-screen right, jump to PRG007_BC5B (RTS) ; Reload timer = $87 LDA #$87 STA CannonFire_Timer,X ; Temp_Var1 = this particular Cannon Fire ID LDA CannonFire_ID,X STA <Temp_Var1 CMP #CFIRE_HRBIGCANNON BEQ PRG007_BC4B ; If this is the right-shooting BIG Cannon, jump to PRG007_BC4B CMP #CFIRE_HLBIGCANNON BNE PRG007_BC4E ; If this is NOT the left-shooting BIG Cannon, jump to PRG007_BC4E PRG007_BC4B: JMP PRG007_BC5C ; For all BIG Cannons, jump to PRG007_BC5C PRG007_BC4E: CMP #CFIRE_LBOBOMBS BLT PRG007_BC55 ; If this is not one of the Bob-omb cannons, jump to PRG007_BC55 JMP PRG007_BCB4 ; For all Bob-omb cannons, jump to PRG007_BCB4 PRG007_BC55: ADD #(Cannons_CPXOff - CannonPoof_XOffs - CFIRE_HLCANNON) ; Offset to proper array index for this Cannon Fire JMP PRG007_BE59 ; Jump to PRG007_BE59 (fire cannonball!) PRG007_BC5B: RTS ; Return PRG007_BC5C: ; Left/right BIG Cannons JSR PrepareNewObjectOrAbort ; Get me an object slot or don't come back! ; This is a BIG Cannon Ball! LDA #OBJ_BIGCANNONBALL STA Level_ObjectID,X ; Big Cannon Ball is BIG INC Objects_IsGiant,X LDY <SlotIndexBackup ; Y = Cannon Fire slot index ; Set BIG Cannon Ball Y LDA CannonFire_Y,Y STA <Objects_Y,X LDA CannonFire_YHi,Y STA <Objects_YHi,X LDA <Temp_Var1 CMP #CFIRE_HRCANNON LDA #$30 ; A = $30 LDY #$12 ; Y = $12 BGE PRG007_BC81 ; Basically if this is the right-shooting BIG Cannon, jump to PRG007_BC81 LDY #$09 ; Y = $09 LDA #-$30 ; A = -$30 PRG007_BC81: STY <Temp_Var1 ; Temp_Var1 = $12 (if right-shooting) or $09 (if left-shooting) STA <Objects_XVel,X ; X velocity = -$30 or $30, depending on direction EOR #$80 ; Invert the sign bit LDY <SlotIndexBackup ; Y = Cannon Fire slot index ASL A ; Inverted sign bit -> carry ; Set BIG Cannon Ball X LDA CannonFire_X,Y BCS PRG007_BC92 ; If right-shooting, jump to PRG007_BC92 SUB #16 ; -16 for left-shooting PRG007_BC92: STA <Objects_X,X LDA CannonFire_XHi,Y SBC #$00 STA <Objects_XHi,X JSR PRG007_BD09 ; Set attribute and make noise and smoke! JSR CannonFire_NoiseAndSmoke ; make more smoke!! ; +4 to this smoke though LDA CannonFire_Y,X SUB Level_VertScroll ADD #$04 STA BrickBust_YUpr ; +8 to the other smoke ADC #$08 STA BrickBust_YUpr+1 RTS ; Return PRG007_BCB4: ; Bob-omb cannons! JSR PrepareNewObjectOrAbort ; It's a Bob-omb!! LDA #OBJ_BOBOMBEXPLODE STA Level_ObjectID,X ; Bobomb's Timer3 = $80 LDA #$80 STA Objects_Timer3,X INC Objects_Var7,X ; Bob-omb's Var7++ INC Objects_Var1,X ; Bob-omb's Var1++ LDY <SlotIndexBackup ; Y = Cannon Fire slot index ; Set Bob-omb's Y LDA CannonFire_Y,Y SUB #$08 STA <Objects_Y,X LDA CannonFire_YHi,Y SBC #$00 STA <Objects_YHi,X ; Set Bob-omb's Y velocity LDA #-$30 STA <Objects_YVel,X LDA <Temp_Var1 CMP #CFIRE_RBOBOMBS LDA #$10 ; A = $10 LDY #$0b ; Y = $0B BCS PRG007_BCE9 ; If this is a right-shot Bob-omb, jump to PRG007_BCE9 DEY ; Y = $0A LDA #-$10 ; A = -$10 PRG007_BCE9: STY <Temp_Var1 ; Temp_Var1 = $0A or $0B STA <Objects_XVel,X ; Set Bob-omb's X velocity (-$10 or $10) ASL A ; Shift sign bit into carry ; Temp_Var2 = $00 (16-bit sign extension) LDA #$00 STA <Temp_Var2 LDY <SlotIndexBackup ; Y = Cannon Fire slot index ; Set Bob-omb's X LDA #$08 ; A = $08 BCC PRG007_BCFC ; If this is a right-shot Bob-omb, jump to PRG007_BCFC LDA #-$08 ; A = -$08 DEC <Temp_Var2 ; Temp_Var2 = $FF (16-bit sign extension) PRG007_BCFC: ADD CannonFire_X,Y STA <Objects_X,X LDA CannonFire_XHi,Y ADC <Temp_Var2 STA <Objects_XHi,X PRG007_BD09: ; Set Cannon Ball / Bob-omb attributes LDA #SPR_PAL3 STA Objects_SprAttr,X LDX <SlotIndexBackup ; X = Cannon Fire slot index JMP CannonFire_NoiseAndSmoke ; Play cannon fire noise and make smoke Goomba_InitFlipBits: .byte SPR_HFLIP, $00 CFire_GoombaPipe: LDA CannonFire_Timer,X BNE PRG007_BD7A ; If timer not expired, jump to PRG007_BD7A (RTS) TXA TAY ; Cannon Fire index -> 'Y' (this isn't really used) ; Set timer to $70 LDA #$70 STA CannonFire_Timer,Y ; (only used here, then it goes back to 'X' anyway) INC CannonFire_Var,X ; CannonFire_Var++ LDA CannonFire_Var,X AND #$03 BEQ PRG007_BD7A ; 1:4 ticks proceed, otherwise jump to PRG007_BD7A (RTS) JSR PrepareNewObjectOrAbort ; Prepare me a Goomba! ; Set Goomba X LDA CannonFire_X,Y STA <Objects_X,X LDA CannonFire_XHi,Y STA <Objects_XHi,X JSR Level_ObjCalcXDiffs STY <Temp_Var2 ; Store directional flag -> Temp_Var2 LDY <SlotIndexBackup ; Y = Cannon Fire index LDA CannonFire_ID,Y LDY #$00 ; Y = 0 (right output Goomba pipe) CMP #CFIRE_GOOMBAPIPE_L BNE PRG007_BD49 ; If this is not a left output Goomba pipe, jump to CFIRE_GOOMBAPIPE INY ; Y = 1 (left output Goomba pipe) PRG007_BD49: CPY <Temp_Var2 BNE PRG007_BD7B ; If Player is on the wrong side of the Goomba pipe, jump to PRG007_BD7B ; Set Goomba's initial flip bits LDA Goomba_InitFlipBits,Y STA Objects_FlipBits,X LDY <SlotIndexBackup ; Y = Cannon Fire slot index ; Set Goomba's Y LDA CannonFire_Y,Y SUB #$03 STA <Objects_Y,X LDA CannonFire_YHi,Y SBC #$00 STA <Objects_YHi,X ; It's a Goomba LDA #OBJ_GOOMBA STA Level_ObjectID,X ; Set Goomba's color LDA #SPR_PAL3 STA Objects_SprAttr,X ; Set Goomba's Var1 = $28 LDA #$28 STA Objects_Var1,X LDA #$ff STA Objects_SprHVis,X PRG007_BD78: LDX <SlotIndexBackup ; X = Cannon Fire slot index PRG007_BD7A: RTS ; Return PRG007_BD7B: ; Player's on the wrong side of the goomba pipe; kill goomba! :( LDA #OBJSTATE_DEADEMPTY STA Objects_State,X BEQ PRG007_BD78 ; Jump (technically always) to PRG007_BD78 PRG007_BD82: .byte $00, $08, $10, $18, $20, $28, $30, $38 FourWay_CannonballXVel: .byte $00, $0B, $10, $0B, $00, -$0B, -$10, -$0B .byte $F0, $F0, $F5, $0B, $F5, $0B, $F5, $0B, $F5, $0B, $10, $10 FourWay_CannonballYVel: .byte -$10, -$0B, $00, $0B, $10, $0B, $00, -$0B .byte $00, $00, $F5, $F5, $0B, $0B, $F5, $F5, $0B, $0B, $00, $00 CannonPoof_XOffs: FourWay_CPXOff: .byte $08, $18, $1C, $18, $08, $F8, $F4, $F8 Cannons_CPXOff: .byte -$0C ; CFIRE_ULCANNON .byte -$0C ; CFIRE_URCANNON .byte -$08 ; CFIRE_LLCANNON .byte $08 ; CFIRE_LRCANNON .byte -$08 ; CFIRE_HLCANNON2 .byte $08 ; CFIRE_ULCANNON2 .byte $00 ; CFIRE_URCANNON2 .byte $00 ; CFIRE_LLCANNON2 .byte $00 ; CFIRE_HRCANNON .byte $00 ; Not used? .byte $0C ; CFIRE_LBOBOMBS .byte $0C ; CFIRE_RBOBOMBS Bill_CPXOff: .byte $0C, -$0C ; Bullet/Missile Bill CannonPoof_YOffs: FourWay_CPYOff: .byte $F3, $F7, $07, $17, $1B, $17, $07, $F7 Cannons_CPYOff: .byte $00 ; CFIRE_ULCANNON .byte $08 ; CFIRE_URCANNON .byte -$08 ; CFIRE_LLCANNON .byte -$08 ; CFIRE_LRCANNON .byte $08 ; CFIRE_HLCANNON2 .byte $08 ; CFIRE_ULCANNON2 .byte $00 ; CFIRE_URCANNON2 .byte $00 ; CFIRE_LLCANNON2 .byte $00 ; CFIRE_HRCANNON .byte $00 ; Not used? .byte $00 ; CFIRE_LBOBOMBS .byte $00 ; CFIRE_RBOBOMBS Bill_CPYOff: .byte $00, $00 ; Bullet/Missile Bill CFire_4Way: ; Load graphics for 4-Way cannon LDA #$36 STA PatTable_BankSel+4 LDA CannonFire_Timer2,X BNE PRG007_BE1C ; If timer2 has not expired, jump to PRG007_BE1C (RTS) ; Reset timer2 = $3D LDA #$3d STA CannonFire_Timer2,X LDA CannonFire_Y,X CMP Level_VertScroll LDA CannonFire_YHi,X SBC Level_VertScrollH BNE PRG007_BE42 ; If the 4-Way cannon is vertically off-screen, jump to PRG007_BE42 (RTS) LDA CannonFire_X,X CMP <Horz_Scroll LDA CannonFire_XHi,X SBC <Horz_Scroll_Hi BNE PRG007_BE42 ; If the 4-Way cannon is horizontally off-screen, jump to PRG007_BE42 (RTS) LDA CannonFire_X,X SUB <Horz_Scroll ADD #32 CMP #40 BLT PRG007_BE42 ; If the 4-Way cannon is too far left off-screen, jump to PRG007_BE42 (RTS) ; Reset cannon timer to $20 LDA #$20 STA CannonFire_Timer,X INC CannonFire_Var,X ; CannonFire_Var++ PRG007_BE1C: LDA CannonFire_Timer,X BEQ PRG007_BE42 ; If timer expired, jump to PRG007_BE42 (RTS) CMP #$1d BNE PRG007_BE43 ; If timer <> $1D, jump to PRG007_BE43 LDA #CHNGTILE_4WAYCANNON STA Level_ChgTileEvent ; Set coordinates of change LDA CannonFire_Y,X STA Level_BlockChgYLo LDA CannonFire_YHi,X STA Level_BlockChgYHi LDA CannonFire_X,X STA Level_BlockChgXLo LDA CannonFire_XHi,X STA Level_BlockChgXHi PRG007_BE42: RTS ; Return PRG007_BE43: CMP #$01 BNE PRG007_BEAA ; If timer <> 1, jump to PRG007_BEAA LDA CannonFire_Var,X AND #$07 STA <Temp_Var1 ; Temp_Var1 = 0 to 7 JSR FireCannonBall ; Fire cannon ball LDA CannonFire_Var,X ADD #$04 AND #$07 ; +4 wrap around (fire the cannonball on the opposite side) PRG007_BE59: STA <Temp_Var1 JMP FireCannonBall ; Fire the cannonball! FireCannonBall: LDY #$05 ; Y = 5 PRG007_BE60: LDA SpecialObj_ID,Y BEQ PRG007_BE69 ; If this special object slot is free, jump to PRG007_BE69 DEY ; Y-- BPL PRG007_BE60 ; While Y >= 0, loop! RTS ; Return PRG007_BE69: ; Set this as a cannon ball! LDA #SOBJ_CANNONBALL STA SpecialObj_ID,Y ; Set cannonball X LDA CannonFire_X,X CLC LDX <Temp_Var1 ; X = 0 to 7 ADC CannonPoof_XOffs,X STA SpecialObj_XLo,Y ; Set cannonball Y velocity LDA FourWay_CannonballYVel,X STA SpecialObj_YVel,Y ; Set cannonball X velocity LDA FourWay_CannonballXVel,X STA SpecialObj_XVel,Y ; Temp_Var3 = 0 (16-bit sign extension) LDA #$00 STA <Temp_Var3 LDA CannonPoof_YOffs,X BPL PRG007_BE91 ; If Y offset is not negative, jump to PRG007_BE91 DEC <Temp_Var3 ; Temp_Var3 = $FF (16-bit sign extension) PRG007_BE91: CLC LDX <SlotIndexBackup ; X = Cannon Fire slot index ADC CannonFire_Y,X STA SpecialObj_YLo,Y LDA CannonFire_YHi,X ADC <Temp_Var3 ; 16-bit sign extension STA SpecialObj_YHi,Y ; Data = 0 LDA #$00 STA SpecialObj_Data,Y JMP CannonFire_NoiseAndSmoke ; Play cannon fire noise and make smoke PRG007_BEAA: RTS ; Return ; Produces the smoke resulting from cannon fire; specify X/Y offset ; from Cannon Fire's position by Temp_Var1 which indexes CannonPoof_X/YOffs CannonFire_NoiseAndSmoke: ; Cannon firing noise LDA Sound_QLevel1 ORA #SND_LEVELBABOOM STA Sound_QLevel1 JSR BrickBust_MoveOver ; Make room in first "brick bust" slot for poof ; Brick bust, poof style LDA #$01 STA BrickBust_En ; Set poof X LDA CannonFire_X,X ; Get Cannon Fire X CLC LDX <Temp_Var1 ; X = Temp_Var1 holds the index into CannonPoof_XOffs ADC CannonPoof_XOffs,X ; + CannonPoof_XOffs[Temp_Var1] SUB <Horz_Scroll ; Make relative to horizontal scroll STA BrickBust_X ; Set X LDA CannonPoof_YOffs,X ; A = CannonPoof_YOffs[Temp_Var1] LDX <SlotIndexBackup ; X = Cannon Fire slot index ADD CannonFire_Y,X ; + Cannon Fire Y SUB Level_VertScroll ; Make relative to vertical scroll STA BrickBust_YUpr ; Set Y ; Set poof counter LDA #$1f STA BrickBust_HEn RTS ; Return Rocky_InitAttr: .byte SPR_HFLIP | SPR_BEHINDBG, SPR_BEHINDBG CFire_RockyWrench: LDA CannonFire_Timer,X BNE PRG007_BF28 ; If timer not expired, jump to PRG007_BF28 (RTS) ; Reset cannon timer to $C0 LDA #$c0 STA CannonFire_Timer,X JSR PrepareNewObjectOrAbort ; Get me a slot for Rocky Wrench or don't come back! LDY <SlotIndexBackup ; Y = Cannon Fire slot index ; This is a Rocky Wrench LDA #OBJ_ROCKYWRENCH STA Level_ObjectID,X ; Start at Cannon Fire Y - 6 LDA CannonFire_Y,Y SUB #$06 STA <Objects_Y,X LDA CannonFire_YHi,Y SBC #$00 STA <Objects_YHi,X ; Set Rocky's X to Cannon Fire's X LDA CannonFire_XHi,Y STA <Objects_XHi,X LDA CannonFire_X,Y STA <Objects_X,X ; Var5 = 0 LDA #$00 STA <Objects_Var5,X ; Set Rocky's timer to $28 LDA #$28 STA Objects_Timer,X ; Set Rocky's attributes LDA #SPR_PAL3 STA Objects_SprAttr,X ; Set Rocky's initial attributes towards Player JSR Level_ObjCalcXDiffs LDA Rocky_InitAttr,Y STA Objects_FlipBits,X LDX <SlotIndexBackup ; X = Cannon Fire slot index PRG007_BF28: RTS ; Return Bill_XVelTowardsPlayer: .byte $18, -$18 Bill_FlipTowardsPlayer: .byte SPR_HFLIP, $00 Bill_Var4TowardsPlayer: .byte $01, $00 CFire_BulletBill: LDA CannonFire_Timer,X BNE PRG007_BF28 ; If timer not expired, jump to PRG007_BF28 (RTS) LDA CannonFire_Y,X CMP Level_VertScroll LDA CannonFire_YHi,X SBC Level_VertScrollH BNE PRG007_BF28 ; If Cannon Fire has fallen off screen vertically, jump to PRG007_BF28 (RTS) LDA CannonFire_X,X CMP <Horz_Scroll LDA CannonFire_XHi,X SBC <Horz_Scroll_Hi BNE PRG007_BF28 ; If Cannon Fire has fallen off screen horizontally, jump to PRG007_BF28 (RTS) ; Reset Cannon Fire timer to $80-$9F, random LDA RandomN,X AND #$1f ORA #$80 STA CannonFire_Timer,X LDA CannonFire_X,X SUB <Horz_Scroll ADD #16 CMP #32 BLT PRG007_BF28 ; If Cannon Fire X + 16 is less than 32 pixels from screen edge, jump to PRG007_BF28 (RTS) LDA <Player_X SBC CannonFire_X,X ADD #17 CMP #34 BLT PRG007_BF28 ; If Player is standing on Bullet Bill cannon, jump to PRG007_BF28 (RTS) JSR PrepareNewObjectOrAbort LDY <SlotIndexBackup ; Y = Cannon Fire object slot LDA CannonFire_ID,Y LSR A ; Selects which Bill type LDA #OBJ_BULLETBILL BCS PRG007_BF80 ; If carry set, jump to PRG007_BF80 LDA #OBJ_BULLETBILLHOMING PRG007_BF80: STA Level_ObjectID,X ; Store Bill's ID ; Set Bill's palette LDA #SPR_PAL3 STA Objects_SprAttr,X ; Set Bill's Y LDA CannonFire_Y,Y SUB #$01 STA <Objects_Y,X LDA CannonFire_YHi,Y SBC #$00 STA <Objects_YHi,X ; Set Bill's X LDA CannonFire_XHi,Y STA <Objects_XHi,X LDA CannonFire_X,Y STA <Objects_X,X STA Objects_Var13,X ; original X hold ; Bill's timer = $0C LDA #$0c STA Objects_Timer,X ; Bill's Var3 = $20 LDA #$20 STA Objects_Var3,X JSR Level_ObjCalcXDiffs ; Bill fires towards Player LDA Bill_XVelTowardsPlayer,Y STA <Objects_XVel,X ; Bill faces Player LDA Bill_FlipTowardsPlayer,Y STA Objects_FlipBits,X ; Set Bill's direction flag LDA Bill_Var4TowardsPlayer,Y STA <Objects_Var4,X LDX <SlotIndexBackup ; X = Cannon Fire slot index TYA ; 0 or 1 ADD #(Bill_CPXOff - CannonPoof_XOffs) STA <Temp_Var1 ; -> Temp_Var1 JSR CannonFire_NoiseAndSmoke ; Play cannon fire noise and make smoke RTS ; Return ; Provides a newly prepared object or does not return to caller! PrepareNewObjectOrAbort: LDX #$04 ; X = 4 PRG007_BFCF: LDA Objects_State,X BEQ PRG007_BFDC ; If this object state = 0 (Dead/Empty), jump to PRG007_BFDC DEX ; X-- BPL PRG007_BFCF ; While X >= 0, loop! ; No object slots available; do not return to caller!! PLA PLA LDX <SlotIndexBackup ; Restore 'X' to its slot index value RTS ; Return PRG007_BFDC: JSR Level_PrepareNewObject ; Prepare this new object ; Set to normal state LDA #OBJSTATE_NORMAL STA Objects_State,X RTS ; Return ; Rest of ROM bank was empty
programs/oeis/204/A204877.asm
neoneye/loda
22
91493
<reponame>neoneye/loda ; A204877: Continued fraction expansion of 3*tanh(1/3). ; 0,1,27,5,63,9,99,13,135,17,171,21,207,25,243,29,279,33,315,37,351,41,387,45,423,49,459,53,495,57,531,61,567,65,603,69,639,73,675,77,711,81,747,85,783,89,819,93,855,97,891,101,927,105,963,109,999,113,1035,117,1071,121,1107,125,1143,129,1179,133,1215,137,1251,141,1287,145,1323,149,1359,153,1395,157,1431,161,1467,165,1503,169,1539,173,1575,177,1611,181,1647,185,1683,189,1719,193,1755,197 mul $0,2 mov $2,$0 sub $2,1 mov $1,$2 mod $1,4 mul $2,$1 mul $1,$2 add $1,5 trn $1,5 mov $0,$1
Assignment/obj/b__main.ads
vivianjia123/Password-Manager
0
1093
<gh_stars>0 pragma Warnings (Off); pragma Ada_95; with System; with System.Parameters; with System.Secondary_Stack; package ada_main is gnat_argc : Integer; gnat_argv : System.Address; gnat_envp : System.Address; pragma Import (C, gnat_argc); pragma Import (C, gnat_argv); pragma Import (C, gnat_envp); gnat_exit_status : Integer; pragma Import (C, gnat_exit_status); GNAT_Version : constant String := "GNAT Version: Community 2019 (20190517-83)" & ASCII.NUL; pragma Export (C, GNAT_Version, "__gnat_version"); Ada_Main_Program_Name : constant String := "_ada_main" & ASCII.NUL; pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name"); procedure adainit; pragma Export (C, adainit, "adainit"); procedure adafinal; pragma Export (C, adafinal, "adafinal"); function main (argc : Integer; argv : System.Address; envp : System.Address) return Integer; pragma Export (C, main, "main"); type Version_32 is mod 2 ** 32; u00001 : constant Version_32 := 16#edf25caa#; pragma Export (C, u00001, "mainB"); u00002 : constant Version_32 := 16#050ff2f0#; pragma Export (C, u00002, "system__standard_libraryB"); u00003 : constant Version_32 := 16#0f7d71d4#; pragma Export (C, u00003, "system__standard_libraryS"); u00004 : constant Version_32 := 16#76789da1#; pragma Export (C, u00004, "adaS"); u00005 : constant Version_32 := 16#5b4659fa#; pragma Export (C, u00005, "ada__charactersS"); u00006 : constant Version_32 := 16#8f637df8#; pragma Export (C, u00006, "ada__characters__handlingB"); u00007 : constant Version_32 := 16#3b3f6154#; pragma Export (C, u00007, "ada__characters__handlingS"); u00008 : constant Version_32 := 16#4b7bb96a#; pragma Export (C, u00008, "ada__characters__latin_1S"); u00009 : constant Version_32 := 16#e6d4fa36#; pragma Export (C, u00009, "ada__stringsS"); u00010 : constant Version_32 := 16#085b6ffb#; pragma Export (C, u00010, "systemS"); u00011 : constant Version_32 := 16#34742901#; pragma Export (C, u00011, "system__exception_tableB"); u00012 : constant Version_32 := 16#55f506b9#; pragma Export (C, u00012, "system__exception_tableS"); u00013 : constant Version_32 := 16#ae860117#; pragma Export (C, u00013, "system__soft_linksB"); u00014 : constant Version_32 := 16#4d58644d#; pragma Export (C, u00014, "system__soft_linksS"); u00015 : constant Version_32 := 16#bd45c2cc#; pragma Export (C, u00015, "system__secondary_stackB"); u00016 : constant Version_32 := 16#4dcf97e2#; pragma Export (C, u00016, "system__secondary_stackS"); u00017 : constant Version_32 := 16#d90c4a0d#; pragma Export (C, u00017, "ada__exceptionsB"); u00018 : constant Version_32 := 16#16307b94#; pragma Export (C, u00018, "ada__exceptionsS"); u00019 : constant Version_32 := 16#5726abed#; pragma Export (C, u00019, "ada__exceptions__last_chance_handlerB"); u00020 : constant Version_32 := 16#41e5552e#; pragma Export (C, u00020, "ada__exceptions__last_chance_handlerS"); u00021 : constant Version_32 := 16#ce4af020#; pragma Export (C, u00021, "system__exceptionsB"); u00022 : constant Version_32 := 16#6038020d#; pragma Export (C, u00022, "system__exceptionsS"); u00023 : constant Version_32 := 16#69416224#; pragma Export (C, u00023, "system__exceptions__machineB"); u00024 : constant Version_32 := 16#d27d9682#; pragma Export (C, u00024, "system__exceptions__machineS"); u00025 : constant Version_32 := 16#aa0563fc#; pragma Export (C, u00025, "system__exceptions_debugB"); u00026 : constant Version_32 := 16#76d1963f#; pragma Export (C, u00026, "system__exceptions_debugS"); u00027 : constant Version_32 := 16#6c2f8802#; pragma Export (C, u00027, "system__img_intB"); u00028 : constant Version_32 := 16#0a808f39#; pragma Export (C, u00028, "system__img_intS"); u00029 : constant Version_32 := 16#ced09590#; pragma Export (C, u00029, "system__storage_elementsB"); u00030 : constant Version_32 := 16#259825ff#; pragma Export (C, u00030, "system__storage_elementsS"); u00031 : constant Version_32 := 16#39df8c17#; pragma Export (C, u00031, "system__tracebackB"); u00032 : constant Version_32 := 16#5679b13f#; pragma Export (C, u00032, "system__tracebackS"); u00033 : constant Version_32 := 16#9ed49525#; pragma Export (C, u00033, "system__traceback_entriesB"); u00034 : constant Version_32 := 16#0800998b#; pragma Export (C, u00034, "system__traceback_entriesS"); u00035 : constant Version_32 := 16#bb296fbb#; pragma Export (C, u00035, "system__traceback__symbolicB"); u00036 : constant Version_32 := 16#c84061d1#; pragma Export (C, u00036, "system__traceback__symbolicS"); u00037 : constant Version_32 := 16#701f9d88#; pragma Export (C, u00037, "ada__exceptions__tracebackB"); u00038 : constant Version_32 := 16#20245e75#; pragma Export (C, u00038, "ada__exceptions__tracebackS"); u00039 : constant Version_32 := 16#a0d3d22b#; pragma Export (C, u00039, "system__address_imageB"); u00040 : constant Version_32 := 16#a9b7f2c1#; pragma Export (C, u00040, "system__address_imageS"); u00041 : constant Version_32 := 16#8c33a517#; pragma Export (C, u00041, "system__wch_conB"); u00042 : constant Version_32 := 16#13264d29#; pragma Export (C, u00042, "system__wch_conS"); u00043 : constant Version_32 := 16#9721e840#; pragma Export (C, u00043, "system__wch_stwB"); u00044 : constant Version_32 := 16#3e376128#; pragma Export (C, u00044, "system__wch_stwS"); u00045 : constant Version_32 := 16#a831679c#; pragma Export (C, u00045, "system__wch_cnvB"); u00046 : constant Version_32 := 16#1c91f7da#; pragma Export (C, u00046, "system__wch_cnvS"); u00047 : constant Version_32 := 16#5ab55268#; pragma Export (C, u00047, "interfacesS"); u00048 : constant Version_32 := 16#ece6fdb6#; pragma Export (C, u00048, "system__wch_jisB"); u00049 : constant Version_32 := 16#9ce1eefb#; pragma Export (C, u00049, "system__wch_jisS"); u00050 : constant Version_32 := 16#86dbf443#; pragma Export (C, u00050, "system__parametersB"); u00051 : constant Version_32 := 16#40b73bd0#; pragma Export (C, u00051, "system__parametersS"); u00052 : constant Version_32 := 16#75bf515c#; pragma Export (C, u00052, "system__soft_links__initializeB"); u00053 : constant Version_32 := 16#5697fc2b#; pragma Export (C, u00053, "system__soft_links__initializeS"); u00054 : constant Version_32 := 16#41837d1e#; pragma Export (C, u00054, "system__stack_checkingB"); u00055 : constant Version_32 := 16#86e40413#; pragma Export (C, u00055, "system__stack_checkingS"); u00056 : constant Version_32 := 16#96df1a3f#; pragma Export (C, u00056, "ada__strings__mapsB"); u00057 : constant Version_32 := 16#1e526bec#; pragma Export (C, u00057, "ada__strings__mapsS"); u00058 : constant Version_32 := 16#98e13b0e#; pragma Export (C, u00058, "system__bit_opsB"); u00059 : constant Version_32 := 16#0765e3a3#; pragma Export (C, u00059, "system__bit_opsS"); u00060 : constant Version_32 := 16#3cdd1378#; pragma Export (C, u00060, "system__unsigned_typesS"); u00061 : constant Version_32 := 16#92f05f13#; pragma Export (C, u00061, "ada__strings__maps__constantsS"); u00062 : constant Version_32 := 16#f64b89a4#; pragma Export (C, u00062, "ada__integer_text_ioB"); u00063 : constant Version_32 := 16#2ec7c168#; pragma Export (C, u00063, "ada__integer_text_ioS"); u00064 : constant Version_32 := 16#f4e097a7#; pragma Export (C, u00064, "ada__text_ioB"); u00065 : constant Version_32 := 16#3913d0d6#; pragma Export (C, u00065, "ada__text_ioS"); u00066 : constant Version_32 := 16#10558b11#; pragma Export (C, u00066, "ada__streamsB"); u00067 : constant Version_32 := 16#67e31212#; pragma Export (C, u00067, "ada__streamsS"); u00068 : constant Version_32 := 16#92d882c5#; pragma Export (C, u00068, "ada__io_exceptionsS"); u00069 : constant Version_32 := 16#d398a95f#; pragma Export (C, u00069, "ada__tagsB"); u00070 : constant Version_32 := 16#12a0afb8#; pragma Export (C, u00070, "ada__tagsS"); u00071 : constant Version_32 := 16#796f31f1#; pragma Export (C, u00071, "system__htableB"); u00072 : constant Version_32 := 16#8c99dc11#; pragma Export (C, u00072, "system__htableS"); u00073 : constant Version_32 := 16#089f5cd0#; pragma Export (C, u00073, "system__string_hashB"); u00074 : constant Version_32 := 16#2ec7b76f#; pragma Export (C, u00074, "system__string_hashS"); u00075 : constant Version_32 := 16#b8e72903#; pragma Export (C, u00075, "system__val_lluB"); u00076 : constant Version_32 := 16#51139e9a#; pragma Export (C, u00076, "system__val_lluS"); u00077 : constant Version_32 := 16#269742a9#; pragma Export (C, u00077, "system__val_utilB"); u00078 : constant Version_32 := 16#a4fbd905#; pragma Export (C, u00078, "system__val_utilS"); u00079 : constant Version_32 := 16#ec4d5631#; pragma Export (C, u00079, "system__case_utilB"); u00080 : constant Version_32 := 16#378ed9af#; pragma Export (C, u00080, "system__case_utilS"); u00081 : constant Version_32 := 16#73d2d764#; pragma Export (C, u00081, "interfaces__c_streamsB"); u00082 : constant Version_32 := 16#b1330297#; pragma Export (C, u00082, "interfaces__c_streamsS"); u00083 : constant Version_32 := 16#4e0ce0a1#; pragma Export (C, u00083, "system__crtlS"); u00084 : constant Version_32 := 16#ec083f01#; pragma Export (C, u00084, "system__file_ioB"); u00085 : constant Version_32 := 16#af2a8e9e#; pragma Export (C, u00085, "system__file_ioS"); u00086 : constant Version_32 := 16#86c56e5a#; pragma Export (C, u00086, "ada__finalizationS"); u00087 : constant Version_32 := 16#95817ed8#; pragma Export (C, u00087, "system__finalization_rootB"); u00088 : constant Version_32 := 16#47a91c6b#; pragma Export (C, u00088, "system__finalization_rootS"); u00089 : constant Version_32 := 16#e4774a28#; pragma Export (C, u00089, "system__os_libB"); u00090 : constant Version_32 := 16#d8e681fb#; pragma Export (C, u00090, "system__os_libS"); u00091 : constant Version_32 := 16#2a8e89ad#; pragma Export (C, u00091, "system__stringsB"); u00092 : constant Version_32 := 16#684d436e#; pragma Export (C, u00092, "system__stringsS"); u00093 : constant Version_32 := 16#f5c4f553#; pragma Export (C, u00093, "system__file_control_blockS"); u00094 : constant Version_32 := 16#fdedfd10#; pragma Export (C, u00094, "ada__text_io__integer_auxB"); u00095 : constant Version_32 := 16#2fe01d89#; pragma Export (C, u00095, "ada__text_io__integer_auxS"); u00096 : constant Version_32 := 16#181dc502#; pragma Export (C, u00096, "ada__text_io__generic_auxB"); u00097 : constant Version_32 := 16#305a076a#; pragma Export (C, u00097, "ada__text_io__generic_auxS"); u00098 : constant Version_32 := 16#b10ba0c7#; pragma Export (C, u00098, "system__img_biuB"); u00099 : constant Version_32 := 16#faff9b35#; pragma Export (C, u00099, "system__img_biuS"); u00100 : constant Version_32 := 16#4e06ab0c#; pragma Export (C, u00100, "system__img_llbB"); u00101 : constant Version_32 := 16#bb388bcb#; pragma Export (C, u00101, "system__img_llbS"); u00102 : constant Version_32 := 16#9dca6636#; pragma Export (C, u00102, "system__img_lliB"); u00103 : constant Version_32 := 16#19143a2a#; pragma Export (C, u00103, "system__img_lliS"); u00104 : constant Version_32 := 16#a756d097#; pragma Export (C, u00104, "system__img_llwB"); u00105 : constant Version_32 := 16#1254a85d#; pragma Export (C, u00105, "system__img_llwS"); u00106 : constant Version_32 := 16#eb55dfbb#; pragma Export (C, u00106, "system__img_wiuB"); u00107 : constant Version_32 := 16#94be1ca7#; pragma Export (C, u00107, "system__img_wiuS"); u00108 : constant Version_32 := 16#0f9783a4#; pragma Export (C, u00108, "system__val_intB"); u00109 : constant Version_32 := 16#bda40698#; pragma Export (C, u00109, "system__val_intS"); u00110 : constant Version_32 := 16#383fd226#; pragma Export (C, u00110, "system__val_unsB"); u00111 : constant Version_32 := 16#09db6ec1#; pragma Export (C, u00111, "system__val_unsS"); u00112 : constant Version_32 := 16#fb020d94#; pragma Export (C, u00112, "system__val_lliB"); u00113 : constant Version_32 := 16#6435fd0b#; pragma Export (C, u00113, "system__val_lliS"); u00114 : constant Version_32 := 16#8ba6725a#; pragma Export (C, u00114, "mycommandlineB"); u00115 : constant Version_32 := 16#dbf720e9#; pragma Export (C, u00115, "mycommandlineS"); u00116 : constant Version_32 := 16#01a73f89#; pragma Export (C, u00116, "ada__command_lineB"); u00117 : constant Version_32 := 16#3cdef8c9#; pragma Export (C, u00117, "ada__command_lineS"); u00118 : constant Version_32 := 16#e1642826#; pragma Export (C, u00118, "mystringB"); u00119 : constant Version_32 := 16#ce083c8f#; pragma Export (C, u00119, "mystringS"); u00120 : constant Version_32 := 16#72d5fbb0#; pragma Export (C, u00120, "mystringtokeniserB"); u00121 : constant Version_32 := 16#fd8d8b9c#; pragma Export (C, u00121, "mystringtokeniserS"); u00122 : constant Version_32 := 16#1d2481c9#; pragma Export (C, u00122, "passworddatabaseB"); u00123 : constant Version_32 := 16#2cee8423#; pragma Export (C, u00123, "passworddatabaseS"); u00124 : constant Version_32 := 16#179d7d28#; pragma Export (C, u00124, "ada__containersS"); u00125 : constant Version_32 := 16#8225628b#; pragma Export (C, u00125, "ada__containers__red_black_treesS"); u00126 : constant Version_32 := 16#bcec81df#; pragma Export (C, u00126, "ada__containers__helpersB"); u00127 : constant Version_32 := 16#4adfc5eb#; pragma Export (C, u00127, "ada__containers__helpersS"); u00128 : constant Version_32 := 16#020a3f4d#; pragma Export (C, u00128, "system__atomic_countersB"); u00129 : constant Version_32 := 16#bc074276#; pragma Export (C, u00129, "system__atomic_countersS"); u00130 : constant Version_32 := 16#2e260032#; pragma Export (C, u00130, "system__storage_pools__subpoolsB"); u00131 : constant Version_32 := 16#cc5a1856#; pragma Export (C, u00131, "system__storage_pools__subpoolsS"); u00132 : constant Version_32 := 16#d96e3c40#; pragma Export (C, u00132, "system__finalization_mastersB"); u00133 : constant Version_32 := 16#53a75631#; pragma Export (C, u00133, "system__finalization_mastersS"); u00134 : constant Version_32 := 16#7268f812#; pragma Export (C, u00134, "system__img_boolB"); u00135 : constant Version_32 := 16#fd821e10#; pragma Export (C, u00135, "system__img_boolS"); u00136 : constant Version_32 := 16#d7aac20c#; pragma Export (C, u00136, "system__ioB"); u00137 : constant Version_32 := 16#961998b4#; pragma Export (C, u00137, "system__ioS"); u00138 : constant Version_32 := 16#6d4d969a#; pragma Export (C, u00138, "system__storage_poolsB"); u00139 : constant Version_32 := 16#2bb6f156#; pragma Export (C, u00139, "system__storage_poolsS"); u00140 : constant Version_32 := 16#84042202#; pragma Export (C, u00140, "system__storage_pools__subpools__finalizationB"); u00141 : constant Version_32 := 16#fe2f4b3a#; pragma Export (C, u00141, "system__storage_pools__subpools__finalizationS"); u00142 : constant Version_32 := 16#039168f8#; pragma Export (C, u00142, "system__stream_attributesB"); u00143 : constant Version_32 := 16#8bc30a4e#; pragma Export (C, u00143, "system__stream_attributesS"); u00144 : constant Version_32 := 16#d33519d1#; pragma Export (C, u00144, "passwordmanagerB"); u00145 : constant Version_32 := 16#3c6cb760#; pragma Export (C, u00145, "passwordmanagerS"); u00146 : constant Version_32 := 16#0c5e1d96#; pragma Export (C, u00146, "pinB"); u00147 : constant Version_32 := 16#553c8633#; pragma Export (C, u00147, "pinS"); u00148 : constant Version_32 := 16#dde34de3#; pragma Export (C, u00148, "system__exp_intB"); u00149 : constant Version_32 := 16#11785907#; pragma Export (C, u00149, "system__exp_intS"); u00150 : constant Version_32 := 16#c9ad0aeb#; pragma Export (C, u00150, "utilityS"); u00151 : constant Version_32 := 16#e31b7c4e#; pragma Export (C, u00151, "system__memoryB"); u00152 : constant Version_32 := 16#512609cf#; pragma Export (C, u00152, "system__memoryS"); -- BEGIN ELABORATION ORDER -- ada%s -- ada.characters%s -- ada.characters.latin_1%s -- interfaces%s -- system%s -- system.atomic_counters%s -- system.atomic_counters%b -- system.exp_int%s -- system.exp_int%b -- system.img_bool%s -- system.img_bool%b -- system.img_int%s -- system.img_int%b -- system.img_lli%s -- system.img_lli%b -- system.io%s -- system.io%b -- system.parameters%s -- system.parameters%b -- system.crtl%s -- interfaces.c_streams%s -- interfaces.c_streams%b -- system.storage_elements%s -- system.storage_elements%b -- system.stack_checking%s -- system.stack_checking%b -- system.string_hash%s -- system.string_hash%b -- system.htable%s -- system.htable%b -- system.strings%s -- system.strings%b -- system.traceback_entries%s -- system.traceback_entries%b -- system.unsigned_types%s -- system.img_biu%s -- system.img_biu%b -- system.img_llb%s -- system.img_llb%b -- system.img_llw%s -- system.img_llw%b -- system.img_wiu%s -- system.img_wiu%b -- system.wch_con%s -- system.wch_con%b -- system.wch_jis%s -- system.wch_jis%b -- system.wch_cnv%s -- system.wch_cnv%b -- system.traceback%s -- system.traceback%b -- system.secondary_stack%s -- system.standard_library%s -- ada.exceptions%s -- system.exceptions_debug%s -- system.exceptions_debug%b -- system.soft_links%s -- system.wch_stw%s -- system.wch_stw%b -- ada.exceptions.last_chance_handler%s -- ada.exceptions.last_chance_handler%b -- ada.exceptions.traceback%s -- ada.exceptions.traceback%b -- system.address_image%s -- system.address_image%b -- system.exception_table%s -- system.exception_table%b -- system.exceptions%s -- system.exceptions%b -- system.exceptions.machine%s -- system.exceptions.machine%b -- system.memory%s -- system.memory%b -- system.secondary_stack%b -- system.soft_links.initialize%s -- system.soft_links.initialize%b -- system.soft_links%b -- system.standard_library%b -- system.traceback.symbolic%s -- system.traceback.symbolic%b -- ada.exceptions%b -- ada.command_line%s -- ada.command_line%b -- ada.containers%s -- ada.io_exceptions%s -- ada.strings%s -- system.case_util%s -- system.case_util%b -- system.os_lib%s -- system.os_lib%b -- system.val_util%s -- system.val_util%b -- system.val_llu%s -- system.val_llu%b -- ada.tags%s -- ada.tags%b -- ada.streams%s -- ada.streams%b -- system.file_control_block%s -- system.finalization_root%s -- system.finalization_root%b -- ada.finalization%s -- ada.containers.helpers%s -- ada.containers.helpers%b -- ada.containers.red_black_trees%s -- system.file_io%s -- system.file_io%b -- system.storage_pools%s -- system.storage_pools%b -- system.finalization_masters%s -- system.finalization_masters%b -- system.storage_pools.subpools%s -- system.storage_pools.subpools.finalization%s -- system.storage_pools.subpools.finalization%b -- system.storage_pools.subpools%b -- system.stream_attributes%s -- system.stream_attributes%b -- system.val_lli%s -- system.val_lli%b -- system.val_uns%s -- system.val_uns%b -- system.val_int%s -- system.val_int%b -- ada.text_io%s -- ada.text_io%b -- ada.text_io.generic_aux%s -- ada.text_io.generic_aux%b -- ada.text_io.integer_aux%s -- ada.text_io.integer_aux%b -- ada.integer_text_io%s -- ada.integer_text_io%b -- system.bit_ops%s -- system.bit_ops%b -- ada.strings.maps%s -- ada.strings.maps%b -- ada.strings.maps.constants%s -- ada.characters.handling%s -- ada.characters.handling%b -- mycommandline%s -- mycommandline%b -- mystring%s -- mystring%b -- mystringtokeniser%s -- mystringtokeniser%b -- passworddatabase%s -- passworddatabase%b -- pin%s -- pin%b -- passwordmanager%s -- passwordmanager%b -- utility%s -- main%b -- END ELABORATION ORDER end ada_main;
Lab 10/lab10.asm
AndrewDichabeng/Computer-Systems-Foundations
0
167381
<reponame>AndrewDichabeng/Computer-Systems-Foundations ; Program to accept a signed decimal number in the format +/-xxxx ; Calculate the 8-bit "quarter precision" IEEE-754 encoding and print it to screen. ; Format -/+xxxx in decimal, entered as ASCII. ; 1) Get sign ; 2) Get number ; 3) Normalize number to get exponent ; 3) Compute bias-** representation of exponent ; 4) Create final IEEE-754 representation ; Constant definitions DISPLAY .EQU 04E9h ; address of Libra display ; Global variables .ORG 0000 SIGN: .DB 0 ; Sign of entered number (0=positive, 1=negative) SUM: .DB 0 ; Unsigned binary representation of entered number EXP: .DB 0 ; Excess/bias representation of exponent (only uses lower 3 bits) FP: .DB 0 ; 8-bit quarter-precision IEEE-754 representation of number .ORG 1000h ; ------------------------------------------------------------------- ; Insert Sub-routines getChar, printStr, and newLine from Lab 8 here ; ------------------------------------------------------------------- printStr: ; Save registers modified by this subroutine push AX ; FIXED push SI ; FIXED push DX ; FIXED mov DX, DISPLAY LoopPS: mov AL, [SI] ; Load the next char to be printed - USING INPUT PARAMETER SI cmp AL, '$' ; Compare the char to '$' je quitPS ; If it is equal, then quit subroutine and return to calling code out DX,AL ; If it is not equal to '$', then print it inc SI ; Point to the next char to be printed jmp LoopPS ; Jump back to the top of the loop quitPS: ; Restore registers pop DX ; FIXED pop SI ; FIXED pop AX ; FIXED RET s_CR .EQU 0Dh ; ASCII value for Carriage return s_LF .EQU 0Ah ; ASCII value for NewLine newLine: ; Save registers modified by this subroutine push AX ; FIXED push DX ; FIXED mov DX, DISPLAY ; Initialize the output port number in DX mov AL, s_LF ; Load line feed (LF) into AL out DX,AL ; print the char mov AL, s_CR ; Load carriage return (CR) into AL out DX,AL ; print the char ; Restore registers pop DX ; FIXED pop AX ; FIXED RET ; --------------------------------------------------------------- ; getChar: waits for a keypress and returns pressed key in AL ; Input parameters: ; none. ; Output parameters: ; AL: ASCII Value of key pressed by user ; --------------------------------------------------------------- ; Constants used by this subroutine KBSTATUS .EQU 0064h ; FIXED port number of keyboard STATUS reg KBBUFFER .EQU 0060h ; FIXED port number of keyboard BUFFER reg getChar: push DX ; save reg used GCWait: mov DX, KBSTATUS ; load addr of keybrd STATUS in AL,DX ; Read contents of keyboard STATUS register cmp AL,0 ; key pressed? je GCWait ; no, go back and check again for keypress mov DX, KBBUFFER ; load port number of kbrd BUFFER register in AL,DX ; get key into AL from BUFFER GCDone: pop DX ; restore regs ret ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; END OF SUBROUTINES FROM lab8.asm ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; --------------------------------------------------------------- ; getSign: waits for user to press '+' or '-'. Ignores other chars. ; Valid input sign character is echoed to screen. ; Input parameters: ; none. ; Output parameters: ; AL: Returns a zero for '+' and one for '-' ; --------------------------------------------------------------- getSign: call getChar mov DX, DISPLAY out DX, AL cmp AL, '-' je getpos cmp AL, '+' je getneg jmp getSign getpos: mov AL, 0 RET getneg: mov AL,1 RET ; ------------------------------------------------------------------------------- ; getDigit: waits for user to press 0-9 digit. Ignores other chars except RETURN ; Input parameters: ; none. ; Output parameters: ; AL: Returns binary value of digit in AL. Returns 99 if user presses ENTER ; ------------------------------------------------------------------------------ ; Constants used by this subroutine ENTERK .EQU 0Ah getDigit: call getChar cmp AL, ENTERK ; Check for ENTER Key (ENTERK) jne skipGD mov AL, DONE ; if yes, return 99 in AL RET skipGD: cmp AL, '0' ; check for '0' jb getDigit ; if below '0', get another char cmp AL, '9' ; check for '9' ja getDigit ; if above '9', get another char call printStr ; Echo digit back to screen (remember to save/restore any used registers) ; Shift ASCII --> binary RET ; ----------------------------------------------------------------------------------------- ; getNumber: Accepts a series of decimal digits and builds a binary number using shift-add ; Input parameters: ; none. ; Output parameters: ; AL: Returns binary value of number in AL. ; ----------------------------------------------------------------------------------------- ; Constants used by this subroutine DONE .EQU 99 getNumber: ; FIXED -- complete entire subroutine push CX ; Save CX register mov CH, 0 ; Use CH for running sum mov CL, 10 ; Use CL for multiplier=10 loopGN: call getDigit ; get a digit cmp AL, ENTERK ; Check if user pressed ENTER je doneGN ; If so, we are done this subroutine push AX ; Save entered character onto stack mov AL,CH ; Copy running sum into AL mul CL ; Compute AX=sum*10 (then ignore AH) mov CH, AL ; Move running sum back into CH pop AX ; Restore saved character add CH,AL ; Add entered digit to shifted running sum jmp loopGN doneGN: mov AL, CH ; Put final sum into AL pop CX ; Restore CX RET ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Lab 10 code section ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; print: push SI push DX push CX mov CX, 8 mov DX, DISPLAY ploop: shl BL, 1 jnc zero mov AL, 31h jmp printnumber zero: mov AL, 30h printnumber: out DX, AL dec CX cmp CX, 0 jne ploop pop CX pop DX pop SI RET normalize: push AX looop: rcl CL, 1 inc BX jnc looop mov AL, 8 sub AL, BL add AL, 3 mov [EXP], AL mov [SUM], CL pop AX RET quarterprecisionform: mov AL, 0 mov CL, [SIGN] add AL, CL shl AL, 3 mov CL, [EXP] add AL, CL shl AL, 4 mov CL, [SUM] shr CL, 4 add AL, CL RET Message1: .DB 'Enter a number BW -33 to +33.$' ; FIXED -- Message to be printed on screen Message2: .DB 'Your normalized number is...$' ; --------------------------------------------------------------------------- ; Main function: Asks the user to enter a signed number between -MAX to +MAX ; Computes quarter-precision 8-bit IEEE-754 representation ; Uses printStr, newline, and getChar subroutines. ; --------------------------------------------------------------------------- main: mov SI, Message1 ; FIXED Print prompt call printStr ; FIXED call newLine ; FIXED part1: call getSign ; FIXED - call getSign to get +/- sign from keyboard mov [SIGN], AL ; FIXED - Save sign to global variable SIGN call getNumber ; FIXED - call getNumber to get the unsigned number mov [SUM], AL ; FIXED - Save number to global variable SUM part2: call normalize call quarterprecisionform mov BL, AL mov SI, Message2 call printStr call print HLT ; Quit .END main ; Entry point of program is main()
tests/src/xdg_home_paths.adb
darkestkhan/xdg
2
9297
<reponame>darkestkhan/xdg pragma License (GPL); ------------------------------------------------------------------------------ -- EMAIL: <<EMAIL>> -- -- License: GNU GPLv3 or any later as published by Free Software Foundation -- -- (see README file) -- -- Copyright © 2013 darkestkhan -- ------------------------------------------------------------------------------ -- This Program is Free Software: You can redistribute it and/or modify -- -- it under the terms of The GNU General Public License as published by -- -- the Free Software Foundation, either version 3 of the license, or -- -- (at Your option) any later version. -- -- -- -- This Program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the -- -- GNU General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this program. If not, see <http://www.gnu.org/licenses/>. -- ------------------------------------------------------------------------------ -------------------------------------------------------------------------- -- Test parameterized Data_Home, Config_Home and Cache_Home functions. -- -------------------------------------------------------------------------- with Ada.Environment_Variables; with Ada.Command_Line; with Ada.Text_IO; with XDG; procedure XDG_Home_Paths is package EV renames Ada.Environment_Variables; package CLI renames Ada.Command_Line; package TIO renames Ada.Text_IO; type String_Access is access String; type XDG_Paths is (Data_Home, Config_Home, Cache_Home); -- Error count; Errors: Natural := 0; Home_Path: constant String := EV.Value ("HOME"); -- NOTE: '/' at the end of Dir is added in order to ease up testing. Dir: constant String := "XDG?/"; function Get_Path (To: in XDG_Paths) return String is begin case To is when Data_Home => return XDG.Data_Home (Dir); when Config_Home => return XDG.Config_Home (Dir); when Cache_Home => return XDG.Cache_Home (Dir); end case; end Get_Path; Var_Names: constant array (XDG_Paths) of String_Access := ( new String'("XDG_DATA_HOME"), new String'("XDG_CONFIG_HOME"), new String'("XDG_CACHE_HOME") ); Paths: constant array (XDG_Paths) of String_Access := ( new String'(Home_Path & "data/"), new String'(Home_Path & "config/"), new String'(Home_Path & "cache/") ); Error_Message: constant String := "Test error when testing: "; Error_Message_At_Exit: constant String := "xdg_home_paths: Total number of unexpected failures triggered: "; begin for I in XDG_Paths loop EV.Clear (Var_Names (I).all); EV.Set (Var_Names (I).all, Paths (I).all); if Get_Path (I) /= Paths (I).all & Dir then Errors := Errors + 1; TIO.Put_Line ( File => TIO.Standard_Error, Item => Error_Message & " " & XDG_Paths'Image (I) ); TIO.Put_Line ( File => TIO.Standard_Error, Item => " Expected value: " & Paths (I).all & Dir ); TIO.Put_Line ( File => TIO.Standard_Error, Item => " Received value: " & Get_Path (I) ); end if; end loop; if Errors /= 0 then TIO.Put_Line ( File => TIO.Standard_Error, Item => Error_Message_At_Exit & Natural'Image (Errors) ); CLI.Set_Exit_Status (CLI.Failure); end if; end XDG_Home_Paths;
user/usertests.asm
noyaviv/try
0
91856
user/_usertests: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <copyinstr1>: } // what if you pass ridiculous string pointers to system calls? void copyinstr1(char *s) { 0: 1141 addi sp,sp,-16 2: e406 sd ra,8(sp) 4: e022 sd s0,0(sp) 6: 0800 addi s0,sp,16 uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff }; for(int ai = 0; ai < 2; ai++){ uint64 addr = addrs[ai]; int fd = open((char *)addr, O_CREATE|O_WRONLY); 8: 20100593 li a1,513 c: 4505 li a0,1 e: 057e slli a0,a0,0x1f 10: 00005097 auipc ra,0x5 14: 72c080e7 jalr 1836(ra) # 573c <open> if(fd >= 0){ 18: 02055063 bgez a0,38 <copyinstr1+0x38> int fd = open((char *)addr, O_CREATE|O_WRONLY); 1c: 20100593 li a1,513 20: 557d li a0,-1 22: 00005097 auipc ra,0x5 26: 71a080e7 jalr 1818(ra) # 573c <open> uint64 addr = addrs[ai]; 2a: 55fd li a1,-1 if(fd >= 0){ 2c: 00055863 bgez a0,3c <copyinstr1+0x3c> printf("open(%p) returned %d, not -1\n", addr, fd); exit(1); } } } 30: 60a2 ld ra,8(sp) 32: 6402 ld s0,0(sp) 34: 0141 addi sp,sp,16 36: 8082 ret uint64 addr = addrs[ai]; 38: 4585 li a1,1 3a: 05fe slli a1,a1,0x1f printf("open(%p) returned %d, not -1\n", addr, fd); 3c: 862a mv a2,a0 3e: 00006517 auipc a0,0x6 42: f1a50513 addi a0,a0,-230 # 5f58 <malloc+0x416> 46: 00006097 auipc ra,0x6 4a: a3e080e7 jalr -1474(ra) # 5a84 <printf> exit(1); 4e: 4505 li a0,1 50: 00005097 auipc ra,0x5 54: 6ac080e7 jalr 1708(ra) # 56fc <exit> 0000000000000058 <bsstest>: void bsstest(char *s) { int i; for(i = 0; i < sizeof(uninit); i++){ 58: 00009797 auipc a5,0x9 5c: 47078793 addi a5,a5,1136 # 94c8 <uninit> 60: 0000c697 auipc a3,0xc 64: b7868693 addi a3,a3,-1160 # bbd8 <buf> if(uninit[i] != '\0'){ 68: 0007c703 lbu a4,0(a5) 6c: e709 bnez a4,76 <bsstest+0x1e> for(i = 0; i < sizeof(uninit); i++){ 6e: 0785 addi a5,a5,1 70: fed79ce3 bne a5,a3,68 <bsstest+0x10> 74: 8082 ret { 76: 1141 addi sp,sp,-16 78: e406 sd ra,8(sp) 7a: e022 sd s0,0(sp) 7c: 0800 addi s0,sp,16 printf("%s: bss test failed\n", s); 7e: 85aa mv a1,a0 80: 00006517 auipc a0,0x6 84: ef850513 addi a0,a0,-264 # 5f78 <malloc+0x436> 88: 00006097 auipc ra,0x6 8c: 9fc080e7 jalr -1540(ra) # 5a84 <printf> exit(1); 90: 4505 li a0,1 92: 00005097 auipc ra,0x5 96: 66a080e7 jalr 1642(ra) # 56fc <exit> 000000000000009a <opentest>: { 9a: 1101 addi sp,sp,-32 9c: ec06 sd ra,24(sp) 9e: e822 sd s0,16(sp) a0: e426 sd s1,8(sp) a2: 1000 addi s0,sp,32 a4: 84aa mv s1,a0 fd = open("echo", 0); a6: 4581 li a1,0 a8: 00006517 auipc a0,0x6 ac: ee850513 addi a0,a0,-280 # 5f90 <malloc+0x44e> b0: 00005097 auipc ra,0x5 b4: 68c080e7 jalr 1676(ra) # 573c <open> if(fd < 0){ b8: 02054663 bltz a0,e4 <opentest+0x4a> close(fd); bc: 00005097 auipc ra,0x5 c0: 668080e7 jalr 1640(ra) # 5724 <close> fd = open("doesnotexist", 0); c4: 4581 li a1,0 c6: 00006517 auipc a0,0x6 ca: eea50513 addi a0,a0,-278 # 5fb0 <malloc+0x46e> ce: 00005097 auipc ra,0x5 d2: 66e080e7 jalr 1646(ra) # 573c <open> if(fd >= 0){ d6: 02055563 bgez a0,100 <opentest+0x66> } da: 60e2 ld ra,24(sp) dc: 6442 ld s0,16(sp) de: 64a2 ld s1,8(sp) e0: 6105 addi sp,sp,32 e2: 8082 ret printf("%s: open echo failed!\n", s); e4: 85a6 mv a1,s1 e6: 00006517 auipc a0,0x6 ea: eb250513 addi a0,a0,-334 # 5f98 <malloc+0x456> ee: 00006097 auipc ra,0x6 f2: 996080e7 jalr -1642(ra) # 5a84 <printf> exit(1); f6: 4505 li a0,1 f8: 00005097 auipc ra,0x5 fc: 604080e7 jalr 1540(ra) # 56fc <exit> printf("%s: open doesnotexist succeeded!\n", s); 100: 85a6 mv a1,s1 102: 00006517 auipc a0,0x6 106: ebe50513 addi a0,a0,-322 # 5fc0 <malloc+0x47e> 10a: 00006097 auipc ra,0x6 10e: 97a080e7 jalr -1670(ra) # 5a84 <printf> exit(1); 112: 4505 li a0,1 114: 00005097 auipc ra,0x5 118: 5e8080e7 jalr 1512(ra) # 56fc <exit> 000000000000011c <truncate2>: { 11c: 7179 addi sp,sp,-48 11e: f406 sd ra,40(sp) 120: f022 sd s0,32(sp) 122: ec26 sd s1,24(sp) 124: e84a sd s2,16(sp) 126: e44e sd s3,8(sp) 128: 1800 addi s0,sp,48 12a: 89aa mv s3,a0 unlink("truncfile"); 12c: 00006517 auipc a0,0x6 130: ebc50513 addi a0,a0,-324 # 5fe8 <malloc+0x4a6> 134: 00005097 auipc ra,0x5 138: 618080e7 jalr 1560(ra) # 574c <unlink> int fd1 = open("truncfile", O_CREATE|O_TRUNC|O_WRONLY); 13c: 60100593 li a1,1537 140: 00006517 auipc a0,0x6 144: ea850513 addi a0,a0,-344 # 5fe8 <malloc+0x4a6> 148: 00005097 auipc ra,0x5 14c: 5f4080e7 jalr 1524(ra) # 573c <open> 150: 84aa mv s1,a0 write(fd1, "abcd", 4); 152: 4611 li a2,4 154: 00006597 auipc a1,0x6 158: ea458593 addi a1,a1,-348 # 5ff8 <malloc+0x4b6> 15c: 00005097 auipc ra,0x5 160: 5c0080e7 jalr 1472(ra) # 571c <write> int fd2 = open("truncfile", O_TRUNC|O_WRONLY); 164: 40100593 li a1,1025 168: 00006517 auipc a0,0x6 16c: e8050513 addi a0,a0,-384 # 5fe8 <malloc+0x4a6> 170: 00005097 auipc ra,0x5 174: 5cc080e7 jalr 1484(ra) # 573c <open> 178: 892a mv s2,a0 int n = write(fd1, "x", 1); 17a: 4605 li a2,1 17c: 00006597 auipc a1,0x6 180: e8458593 addi a1,a1,-380 # 6000 <malloc+0x4be> 184: 8526 mv a0,s1 186: 00005097 auipc ra,0x5 18a: 596080e7 jalr 1430(ra) # 571c <write> if(n != -1){ 18e: 57fd li a5,-1 190: 02f51b63 bne a0,a5,1c6 <truncate2+0xaa> unlink("truncfile"); 194: 00006517 auipc a0,0x6 198: e5450513 addi a0,a0,-428 # 5fe8 <malloc+0x4a6> 19c: 00005097 auipc ra,0x5 1a0: 5b0080e7 jalr 1456(ra) # 574c <unlink> close(fd1); 1a4: 8526 mv a0,s1 1a6: 00005097 auipc ra,0x5 1aa: 57e080e7 jalr 1406(ra) # 5724 <close> close(fd2); 1ae: 854a mv a0,s2 1b0: 00005097 auipc ra,0x5 1b4: 574080e7 jalr 1396(ra) # 5724 <close> } 1b8: 70a2 ld ra,40(sp) 1ba: 7402 ld s0,32(sp) 1bc: 64e2 ld s1,24(sp) 1be: 6942 ld s2,16(sp) 1c0: 69a2 ld s3,8(sp) 1c2: 6145 addi sp,sp,48 1c4: 8082 ret printf("%s: write returned %d, expected -1\n", s, n); 1c6: 862a mv a2,a0 1c8: 85ce mv a1,s3 1ca: 00006517 auipc a0,0x6 1ce: e3e50513 addi a0,a0,-450 # 6008 <malloc+0x4c6> 1d2: 00006097 auipc ra,0x6 1d6: 8b2080e7 jalr -1870(ra) # 5a84 <printf> exit(1); 1da: 4505 li a0,1 1dc: 00005097 auipc ra,0x5 1e0: 520080e7 jalr 1312(ra) # 56fc <exit> 00000000000001e4 <createtest>: { 1e4: 7179 addi sp,sp,-48 1e6: f406 sd ra,40(sp) 1e8: f022 sd s0,32(sp) 1ea: ec26 sd s1,24(sp) 1ec: e84a sd s2,16(sp) 1ee: 1800 addi s0,sp,48 name[0] = 'a'; 1f0: 06100793 li a5,97 1f4: fcf40c23 sb a5,-40(s0) name[2] = '\0'; 1f8: fc040d23 sb zero,-38(s0) 1fc: 03000493 li s1,48 for(i = 0; i < N; i++){ 200: 06400913 li s2,100 name[1] = '0' + i; 204: fc940ca3 sb s1,-39(s0) fd = open(name, O_CREATE|O_RDWR); 208: 20200593 li a1,514 20c: fd840513 addi a0,s0,-40 210: 00005097 auipc ra,0x5 214: 52c080e7 jalr 1324(ra) # 573c <open> close(fd); 218: 00005097 auipc ra,0x5 21c: 50c080e7 jalr 1292(ra) # 5724 <close> for(i = 0; i < N; i++){ 220: 2485 addiw s1,s1,1 222: 0ff4f493 andi s1,s1,255 226: fd249fe3 bne s1,s2,204 <createtest+0x20> name[0] = 'a'; 22a: 06100793 li a5,97 22e: fcf40c23 sb a5,-40(s0) name[2] = '\0'; 232: fc040d23 sb zero,-38(s0) 236: 03000493 li s1,48 for(i = 0; i < N; i++){ 23a: 06400913 li s2,100 name[1] = '0' + i; 23e: fc940ca3 sb s1,-39(s0) unlink(name); 242: fd840513 addi a0,s0,-40 246: 00005097 auipc ra,0x5 24a: 506080e7 jalr 1286(ra) # 574c <unlink> for(i = 0; i < N; i++){ 24e: 2485 addiw s1,s1,1 250: 0ff4f493 andi s1,s1,255 254: ff2495e3 bne s1,s2,23e <createtest+0x5a> } 258: 70a2 ld ra,40(sp) 25a: 7402 ld s0,32(sp) 25c: 64e2 ld s1,24(sp) 25e: 6942 ld s2,16(sp) 260: 6145 addi sp,sp,48 262: 8082 ret 0000000000000264 <bigwrite>: { 264: 715d addi sp,sp,-80 266: e486 sd ra,72(sp) 268: e0a2 sd s0,64(sp) 26a: fc26 sd s1,56(sp) 26c: f84a sd s2,48(sp) 26e: f44e sd s3,40(sp) 270: f052 sd s4,32(sp) 272: ec56 sd s5,24(sp) 274: e85a sd s6,16(sp) 276: e45e sd s7,8(sp) 278: 0880 addi s0,sp,80 27a: 8baa mv s7,a0 unlink("bigwrite"); 27c: 00006517 auipc a0,0x6 280: b7c50513 addi a0,a0,-1156 # 5df8 <malloc+0x2b6> 284: 00005097 auipc ra,0x5 288: 4c8080e7 jalr 1224(ra) # 574c <unlink> for(sz = 499; sz < (MAXOPBLOCKS+2)*BSIZE; sz += 471){ 28c: 1f300493 li s1,499 fd = open("bigwrite", O_CREATE | O_RDWR); 290: 00006a97 auipc s5,0x6 294: b68a8a93 addi s5,s5,-1176 # 5df8 <malloc+0x2b6> int cc = write(fd, buf, sz); 298: 0000ca17 auipc s4,0xc 29c: 940a0a13 addi s4,s4,-1728 # bbd8 <buf> for(sz = 499; sz < (MAXOPBLOCKS+2)*BSIZE; sz += 471){ 2a0: 6b0d lui s6,0x3 2a2: 1c9b0b13 addi s6,s6,457 # 31c9 <subdir+0x173> fd = open("bigwrite", O_CREATE | O_RDWR); 2a6: 20200593 li a1,514 2aa: 8556 mv a0,s5 2ac: 00005097 auipc ra,0x5 2b0: 490080e7 jalr 1168(ra) # 573c <open> 2b4: 892a mv s2,a0 if(fd < 0){ 2b6: 04054d63 bltz a0,310 <bigwrite+0xac> int cc = write(fd, buf, sz); 2ba: 8626 mv a2,s1 2bc: 85d2 mv a1,s4 2be: 00005097 auipc ra,0x5 2c2: 45e080e7 jalr 1118(ra) # 571c <write> 2c6: 89aa mv s3,a0 if(cc != sz){ 2c8: 06a49463 bne s1,a0,330 <bigwrite+0xcc> int cc = write(fd, buf, sz); 2cc: 8626 mv a2,s1 2ce: 85d2 mv a1,s4 2d0: 854a mv a0,s2 2d2: 00005097 auipc ra,0x5 2d6: 44a080e7 jalr 1098(ra) # 571c <write> if(cc != sz){ 2da: 04951963 bne a0,s1,32c <bigwrite+0xc8> close(fd); 2de: 854a mv a0,s2 2e0: 00005097 auipc ra,0x5 2e4: 444080e7 jalr 1092(ra) # 5724 <close> unlink("bigwrite"); 2e8: 8556 mv a0,s5 2ea: 00005097 auipc ra,0x5 2ee: 462080e7 jalr 1122(ra) # 574c <unlink> for(sz = 499; sz < (MAXOPBLOCKS+2)*BSIZE; sz += 471){ 2f2: 1d74849b addiw s1,s1,471 2f6: fb6498e3 bne s1,s6,2a6 <bigwrite+0x42> } 2fa: 60a6 ld ra,72(sp) 2fc: 6406 ld s0,64(sp) 2fe: 74e2 ld s1,56(sp) 300: 7942 ld s2,48(sp) 302: 79a2 ld s3,40(sp) 304: 7a02 ld s4,32(sp) 306: 6ae2 ld s5,24(sp) 308: 6b42 ld s6,16(sp) 30a: 6ba2 ld s7,8(sp) 30c: 6161 addi sp,sp,80 30e: 8082 ret printf("%s: cannot create bigwrite\n", s); 310: 85de mv a1,s7 312: 00006517 auipc a0,0x6 316: d1e50513 addi a0,a0,-738 # 6030 <malloc+0x4ee> 31a: 00005097 auipc ra,0x5 31e: 76a080e7 jalr 1898(ra) # 5a84 <printf> exit(1); 322: 4505 li a0,1 324: 00005097 auipc ra,0x5 328: 3d8080e7 jalr 984(ra) # 56fc <exit> 32c: 84ce mv s1,s3 int cc = write(fd, buf, sz); 32e: 89aa mv s3,a0 printf("%s: write(%d) ret %d\n", s, sz, cc); 330: 86ce mv a3,s3 332: 8626 mv a2,s1 334: 85de mv a1,s7 336: 00006517 auipc a0,0x6 33a: d1a50513 addi a0,a0,-742 # 6050 <malloc+0x50e> 33e: 00005097 auipc ra,0x5 342: 746080e7 jalr 1862(ra) # 5a84 <printf> exit(1); 346: 4505 li a0,1 348: 00005097 auipc ra,0x5 34c: 3b4080e7 jalr 948(ra) # 56fc <exit> 0000000000000350 <copyin>: { 350: 715d addi sp,sp,-80 352: e486 sd ra,72(sp) 354: e0a2 sd s0,64(sp) 356: fc26 sd s1,56(sp) 358: f84a sd s2,48(sp) 35a: f44e sd s3,40(sp) 35c: f052 sd s4,32(sp) 35e: 0880 addi s0,sp,80 uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff }; 360: 4785 li a5,1 362: 07fe slli a5,a5,0x1f 364: fcf43023 sd a5,-64(s0) 368: 57fd li a5,-1 36a: fcf43423 sd a5,-56(s0) for(int ai = 0; ai < 2; ai++){ 36e: fc040913 addi s2,s0,-64 int fd = open("copyin1", O_CREATE|O_WRONLY); 372: 00006a17 auipc s4,0x6 376: cf6a0a13 addi s4,s4,-778 # 6068 <malloc+0x526> uint64 addr = addrs[ai]; 37a: 00093983 ld s3,0(s2) int fd = open("copyin1", O_CREATE|O_WRONLY); 37e: 20100593 li a1,513 382: 8552 mv a0,s4 384: 00005097 auipc ra,0x5 388: 3b8080e7 jalr 952(ra) # 573c <open> 38c: 84aa mv s1,a0 if(fd < 0){ 38e: 08054863 bltz a0,41e <copyin+0xce> int n = write(fd, (void*)addr, 8192); 392: 6609 lui a2,0x2 394: 85ce mv a1,s3 396: 00005097 auipc ra,0x5 39a: 386080e7 jalr 902(ra) # 571c <write> if(n >= 0){ 39e: 08055d63 bgez a0,438 <copyin+0xe8> close(fd); 3a2: 8526 mv a0,s1 3a4: 00005097 auipc ra,0x5 3a8: 380080e7 jalr 896(ra) # 5724 <close> unlink("copyin1"); 3ac: 8552 mv a0,s4 3ae: 00005097 auipc ra,0x5 3b2: 39e080e7 jalr 926(ra) # 574c <unlink> n = write(1, (char*)addr, 8192); 3b6: 6609 lui a2,0x2 3b8: 85ce mv a1,s3 3ba: 4505 li a0,1 3bc: 00005097 auipc ra,0x5 3c0: 360080e7 jalr 864(ra) # 571c <write> if(n > 0){ 3c4: 08a04963 bgtz a0,456 <copyin+0x106> if(pipe(fds) < 0){ 3c8: fb840513 addi a0,s0,-72 3cc: 00005097 auipc ra,0x5 3d0: 340080e7 jalr 832(ra) # 570c <pipe> 3d4: 0a054063 bltz a0,474 <copyin+0x124> n = write(fds[1], (char*)addr, 8192); 3d8: 6609 lui a2,0x2 3da: 85ce mv a1,s3 3dc: fbc42503 lw a0,-68(s0) 3e0: 00005097 auipc ra,0x5 3e4: 33c080e7 jalr 828(ra) # 571c <write> if(n > 0){ 3e8: 0aa04363 bgtz a0,48e <copyin+0x13e> close(fds[0]); 3ec: fb842503 lw a0,-72(s0) 3f0: 00005097 auipc ra,0x5 3f4: 334080e7 jalr 820(ra) # 5724 <close> close(fds[1]); 3f8: fbc42503 lw a0,-68(s0) 3fc: 00005097 auipc ra,0x5 400: 328080e7 jalr 808(ra) # 5724 <close> for(int ai = 0; ai < 2; ai++){ 404: 0921 addi s2,s2,8 406: fd040793 addi a5,s0,-48 40a: f6f918e3 bne s2,a5,37a <copyin+0x2a> } 40e: 60a6 ld ra,72(sp) 410: 6406 ld s0,64(sp) 412: 74e2 ld s1,56(sp) 414: 7942 ld s2,48(sp) 416: 79a2 ld s3,40(sp) 418: 7a02 ld s4,32(sp) 41a: 6161 addi sp,sp,80 41c: 8082 ret printf("open(copyin1) failed\n"); 41e: 00006517 auipc a0,0x6 422: c5250513 addi a0,a0,-942 # 6070 <malloc+0x52e> 426: 00005097 auipc ra,0x5 42a: 65e080e7 jalr 1630(ra) # 5a84 <printf> exit(1); 42e: 4505 li a0,1 430: 00005097 auipc ra,0x5 434: 2cc080e7 jalr 716(ra) # 56fc <exit> printf("write(fd, %p, 8192) returned %d, not -1\n", addr, n); 438: 862a mv a2,a0 43a: 85ce mv a1,s3 43c: 00006517 auipc a0,0x6 440: c4c50513 addi a0,a0,-948 # 6088 <malloc+0x546> 444: 00005097 auipc ra,0x5 448: 640080e7 jalr 1600(ra) # 5a84 <printf> exit(1); 44c: 4505 li a0,1 44e: 00005097 auipc ra,0x5 452: 2ae080e7 jalr 686(ra) # 56fc <exit> printf("write(1, %p, 8192) returned %d, not -1 or 0\n", addr, n); 456: 862a mv a2,a0 458: 85ce mv a1,s3 45a: 00006517 auipc a0,0x6 45e: c5e50513 addi a0,a0,-930 # 60b8 <malloc+0x576> 462: 00005097 auipc ra,0x5 466: 622080e7 jalr 1570(ra) # 5a84 <printf> exit(1); 46a: 4505 li a0,1 46c: 00005097 auipc ra,0x5 470: 290080e7 jalr 656(ra) # 56fc <exit> printf("pipe() failed\n"); 474: 00006517 auipc a0,0x6 478: c7450513 addi a0,a0,-908 # 60e8 <malloc+0x5a6> 47c: 00005097 auipc ra,0x5 480: 608080e7 jalr 1544(ra) # 5a84 <printf> exit(1); 484: 4505 li a0,1 486: 00005097 auipc ra,0x5 48a: 276080e7 jalr 630(ra) # 56fc <exit> printf("write(pipe, %p, 8192) returned %d, not -1 or 0\n", addr, n); 48e: 862a mv a2,a0 490: 85ce mv a1,s3 492: 00006517 auipc a0,0x6 496: c6650513 addi a0,a0,-922 # 60f8 <malloc+0x5b6> 49a: 00005097 auipc ra,0x5 49e: 5ea080e7 jalr 1514(ra) # 5a84 <printf> exit(1); 4a2: 4505 li a0,1 4a4: 00005097 auipc ra,0x5 4a8: 258080e7 jalr 600(ra) # 56fc <exit> 00000000000004ac <copyout>: { 4ac: 711d addi sp,sp,-96 4ae: ec86 sd ra,88(sp) 4b0: e8a2 sd s0,80(sp) 4b2: e4a6 sd s1,72(sp) 4b4: e0ca sd s2,64(sp) 4b6: fc4e sd s3,56(sp) 4b8: f852 sd s4,48(sp) 4ba: f456 sd s5,40(sp) 4bc: 1080 addi s0,sp,96 uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff }; 4be: 4785 li a5,1 4c0: 07fe slli a5,a5,0x1f 4c2: faf43823 sd a5,-80(s0) 4c6: 57fd li a5,-1 4c8: faf43c23 sd a5,-72(s0) for(int ai = 0; ai < 2; ai++){ 4cc: fb040913 addi s2,s0,-80 int fd = open("README", 0); 4d0: 00006a17 auipc s4,0x6 4d4: c58a0a13 addi s4,s4,-936 # 6128 <malloc+0x5e6> n = write(fds[1], "x", 1); 4d8: 00006a97 auipc s5,0x6 4dc: b28a8a93 addi s5,s5,-1240 # 6000 <malloc+0x4be> uint64 addr = addrs[ai]; 4e0: 00093983 ld s3,0(s2) int fd = open("README", 0); 4e4: 4581 li a1,0 4e6: 8552 mv a0,s4 4e8: 00005097 auipc ra,0x5 4ec: 254080e7 jalr 596(ra) # 573c <open> 4f0: 84aa mv s1,a0 if(fd < 0){ 4f2: 08054663 bltz a0,57e <copyout+0xd2> int n = read(fd, (void*)addr, 8192); 4f6: 6609 lui a2,0x2 4f8: 85ce mv a1,s3 4fa: 00005097 auipc ra,0x5 4fe: 21a080e7 jalr 538(ra) # 5714 <read> if(n > 0){ 502: 08a04b63 bgtz a0,598 <copyout+0xec> close(fd); 506: 8526 mv a0,s1 508: 00005097 auipc ra,0x5 50c: 21c080e7 jalr 540(ra) # 5724 <close> if(pipe(fds) < 0){ 510: fa840513 addi a0,s0,-88 514: 00005097 auipc ra,0x5 518: 1f8080e7 jalr 504(ra) # 570c <pipe> 51c: 08054d63 bltz a0,5b6 <copyout+0x10a> n = write(fds[1], "x", 1); 520: 4605 li a2,1 522: 85d6 mv a1,s5 524: fac42503 lw a0,-84(s0) 528: 00005097 auipc ra,0x5 52c: 1f4080e7 jalr 500(ra) # 571c <write> if(n != 1){ 530: 4785 li a5,1 532: 08f51f63 bne a0,a5,5d0 <copyout+0x124> n = read(fds[0], (void*)addr, 8192); 536: 6609 lui a2,0x2 538: 85ce mv a1,s3 53a: fa842503 lw a0,-88(s0) 53e: 00005097 auipc ra,0x5 542: 1d6080e7 jalr 470(ra) # 5714 <read> if(n > 0){ 546: 0aa04263 bgtz a0,5ea <copyout+0x13e> close(fds[0]); 54a: fa842503 lw a0,-88(s0) 54e: 00005097 auipc ra,0x5 552: 1d6080e7 jalr 470(ra) # 5724 <close> close(fds[1]); 556: fac42503 lw a0,-84(s0) 55a: 00005097 auipc ra,0x5 55e: 1ca080e7 jalr 458(ra) # 5724 <close> for(int ai = 0; ai < 2; ai++){ 562: 0921 addi s2,s2,8 564: fc040793 addi a5,s0,-64 568: f6f91ce3 bne s2,a5,4e0 <copyout+0x34> } 56c: 60e6 ld ra,88(sp) 56e: 6446 ld s0,80(sp) 570: 64a6 ld s1,72(sp) 572: 6906 ld s2,64(sp) 574: 79e2 ld s3,56(sp) 576: 7a42 ld s4,48(sp) 578: 7aa2 ld s5,40(sp) 57a: 6125 addi sp,sp,96 57c: 8082 ret printf("open(README) failed\n"); 57e: 00006517 auipc a0,0x6 582: bb250513 addi a0,a0,-1102 # 6130 <malloc+0x5ee> 586: 00005097 auipc ra,0x5 58a: 4fe080e7 jalr 1278(ra) # 5a84 <printf> exit(1); 58e: 4505 li a0,1 590: 00005097 auipc ra,0x5 594: 16c080e7 jalr 364(ra) # 56fc <exit> printf("read(fd, %p, 8192) returned %d, not -1 or 0\n", addr, n); 598: 862a mv a2,a0 59a: 85ce mv a1,s3 59c: 00006517 auipc a0,0x6 5a0: bac50513 addi a0,a0,-1108 # 6148 <malloc+0x606> 5a4: 00005097 auipc ra,0x5 5a8: 4e0080e7 jalr 1248(ra) # 5a84 <printf> exit(1); 5ac: 4505 li a0,1 5ae: 00005097 auipc ra,0x5 5b2: 14e080e7 jalr 334(ra) # 56fc <exit> printf("pipe() failed\n"); 5b6: 00006517 auipc a0,0x6 5ba: b3250513 addi a0,a0,-1230 # 60e8 <malloc+0x5a6> 5be: 00005097 auipc ra,0x5 5c2: 4c6080e7 jalr 1222(ra) # 5a84 <printf> exit(1); 5c6: 4505 li a0,1 5c8: 00005097 auipc ra,0x5 5cc: 134080e7 jalr 308(ra) # 56fc <exit> printf("pipe write failed\n"); 5d0: 00006517 auipc a0,0x6 5d4: ba850513 addi a0,a0,-1112 # 6178 <malloc+0x636> 5d8: 00005097 auipc ra,0x5 5dc: 4ac080e7 jalr 1196(ra) # 5a84 <printf> exit(1); 5e0: 4505 li a0,1 5e2: 00005097 auipc ra,0x5 5e6: 11a080e7 jalr 282(ra) # 56fc <exit> printf("read(pipe, %p, 8192) returned %d, not -1 or 0\n", addr, n); 5ea: 862a mv a2,a0 5ec: 85ce mv a1,s3 5ee: 00006517 auipc a0,0x6 5f2: ba250513 addi a0,a0,-1118 # 6190 <malloc+0x64e> 5f6: 00005097 auipc ra,0x5 5fa: 48e080e7 jalr 1166(ra) # 5a84 <printf> exit(1); 5fe: 4505 li a0,1 600: 00005097 auipc ra,0x5 604: 0fc080e7 jalr 252(ra) # 56fc <exit> 0000000000000608 <truncate1>: { 608: 711d addi sp,sp,-96 60a: ec86 sd ra,88(sp) 60c: e8a2 sd s0,80(sp) 60e: e4a6 sd s1,72(sp) 610: e0ca sd s2,64(sp) 612: fc4e sd s3,56(sp) 614: f852 sd s4,48(sp) 616: f456 sd s5,40(sp) 618: 1080 addi s0,sp,96 61a: 8aaa mv s5,a0 unlink("truncfile"); 61c: 00006517 auipc a0,0x6 620: 9cc50513 addi a0,a0,-1588 # 5fe8 <malloc+0x4a6> 624: 00005097 auipc ra,0x5 628: 128080e7 jalr 296(ra) # 574c <unlink> int fd1 = open("truncfile", O_CREATE|O_WRONLY|O_TRUNC); 62c: 60100593 li a1,1537 630: 00006517 auipc a0,0x6 634: 9b850513 addi a0,a0,-1608 # 5fe8 <malloc+0x4a6> 638: 00005097 auipc ra,0x5 63c: 104080e7 jalr 260(ra) # 573c <open> 640: 84aa mv s1,a0 write(fd1, "abcd", 4); 642: 4611 li a2,4 644: 00006597 auipc a1,0x6 648: 9b458593 addi a1,a1,-1612 # 5ff8 <malloc+0x4b6> 64c: 00005097 auipc ra,0x5 650: 0d0080e7 jalr 208(ra) # 571c <write> close(fd1); 654: 8526 mv a0,s1 656: 00005097 auipc ra,0x5 65a: 0ce080e7 jalr 206(ra) # 5724 <close> int fd2 = open("truncfile", O_RDONLY); 65e: 4581 li a1,0 660: 00006517 auipc a0,0x6 664: 98850513 addi a0,a0,-1656 # 5fe8 <malloc+0x4a6> 668: 00005097 auipc ra,0x5 66c: 0d4080e7 jalr 212(ra) # 573c <open> 670: 84aa mv s1,a0 int n = read(fd2, buf, sizeof(buf)); 672: 02000613 li a2,32 676: fa040593 addi a1,s0,-96 67a: 00005097 auipc ra,0x5 67e: 09a080e7 jalr 154(ra) # 5714 <read> if(n != 4){ 682: 4791 li a5,4 684: 0cf51e63 bne a0,a5,760 <truncate1+0x158> fd1 = open("truncfile", O_WRONLY|O_TRUNC); 688: 40100593 li a1,1025 68c: 00006517 auipc a0,0x6 690: 95c50513 addi a0,a0,-1700 # 5fe8 <malloc+0x4a6> 694: 00005097 auipc ra,0x5 698: 0a8080e7 jalr 168(ra) # 573c <open> 69c: 89aa mv s3,a0 int fd3 = open("truncfile", O_RDONLY); 69e: 4581 li a1,0 6a0: 00006517 auipc a0,0x6 6a4: 94850513 addi a0,a0,-1720 # 5fe8 <malloc+0x4a6> 6a8: 00005097 auipc ra,0x5 6ac: 094080e7 jalr 148(ra) # 573c <open> 6b0: 892a mv s2,a0 n = read(fd3, buf, sizeof(buf)); 6b2: 02000613 li a2,32 6b6: fa040593 addi a1,s0,-96 6ba: 00005097 auipc ra,0x5 6be: 05a080e7 jalr 90(ra) # 5714 <read> 6c2: 8a2a mv s4,a0 if(n != 0){ 6c4: ed4d bnez a0,77e <truncate1+0x176> n = read(fd2, buf, sizeof(buf)); 6c6: 02000613 li a2,32 6ca: fa040593 addi a1,s0,-96 6ce: 8526 mv a0,s1 6d0: 00005097 auipc ra,0x5 6d4: 044080e7 jalr 68(ra) # 5714 <read> 6d8: 8a2a mv s4,a0 if(n != 0){ 6da: e971 bnez a0,7ae <truncate1+0x1a6> write(fd1, "abcdef", 6); 6dc: 4619 li a2,6 6de: 00006597 auipc a1,0x6 6e2: b4258593 addi a1,a1,-1214 # 6220 <malloc+0x6de> 6e6: 854e mv a0,s3 6e8: 00005097 auipc ra,0x5 6ec: 034080e7 jalr 52(ra) # 571c <write> n = read(fd3, buf, sizeof(buf)); 6f0: 02000613 li a2,32 6f4: fa040593 addi a1,s0,-96 6f8: 854a mv a0,s2 6fa: 00005097 auipc ra,0x5 6fe: 01a080e7 jalr 26(ra) # 5714 <read> if(n != 6){ 702: 4799 li a5,6 704: 0cf51d63 bne a0,a5,7de <truncate1+0x1d6> n = read(fd2, buf, sizeof(buf)); 708: 02000613 li a2,32 70c: fa040593 addi a1,s0,-96 710: 8526 mv a0,s1 712: 00005097 auipc ra,0x5 716: 002080e7 jalr 2(ra) # 5714 <read> if(n != 2){ 71a: 4789 li a5,2 71c: 0ef51063 bne a0,a5,7fc <truncate1+0x1f4> unlink("truncfile"); 720: 00006517 auipc a0,0x6 724: 8c850513 addi a0,a0,-1848 # 5fe8 <malloc+0x4a6> 728: 00005097 auipc ra,0x5 72c: 024080e7 jalr 36(ra) # 574c <unlink> close(fd1); 730: 854e mv a0,s3 732: 00005097 auipc ra,0x5 736: ff2080e7 jalr -14(ra) # 5724 <close> close(fd2); 73a: 8526 mv a0,s1 73c: 00005097 auipc ra,0x5 740: fe8080e7 jalr -24(ra) # 5724 <close> close(fd3); 744: 854a mv a0,s2 746: 00005097 auipc ra,0x5 74a: fde080e7 jalr -34(ra) # 5724 <close> } 74e: 60e6 ld ra,88(sp) 750: 6446 ld s0,80(sp) 752: 64a6 ld s1,72(sp) 754: 6906 ld s2,64(sp) 756: 79e2 ld s3,56(sp) 758: 7a42 ld s4,48(sp) 75a: 7aa2 ld s5,40(sp) 75c: 6125 addi sp,sp,96 75e: 8082 ret printf("%s: read %d bytes, wanted 4\n", s, n); 760: 862a mv a2,a0 762: 85d6 mv a1,s5 764: 00006517 auipc a0,0x6 768: a5c50513 addi a0,a0,-1444 # 61c0 <malloc+0x67e> 76c: 00005097 auipc ra,0x5 770: 318080e7 jalr 792(ra) # 5a84 <printf> exit(1); 774: 4505 li a0,1 776: 00005097 auipc ra,0x5 77a: f86080e7 jalr -122(ra) # 56fc <exit> printf("aaa fd3=%d\n", fd3); 77e: 85ca mv a1,s2 780: 00006517 auipc a0,0x6 784: a6050513 addi a0,a0,-1440 # 61e0 <malloc+0x69e> 788: 00005097 auipc ra,0x5 78c: 2fc080e7 jalr 764(ra) # 5a84 <printf> printf("%s: read %d bytes, wanted 0\n", s, n); 790: 8652 mv a2,s4 792: 85d6 mv a1,s5 794: 00006517 auipc a0,0x6 798: a5c50513 addi a0,a0,-1444 # 61f0 <malloc+0x6ae> 79c: 00005097 auipc ra,0x5 7a0: 2e8080e7 jalr 744(ra) # 5a84 <printf> exit(1); 7a4: 4505 li a0,1 7a6: 00005097 auipc ra,0x5 7aa: f56080e7 jalr -170(ra) # 56fc <exit> printf("bbb fd2=%d\n", fd2); 7ae: 85a6 mv a1,s1 7b0: 00006517 auipc a0,0x6 7b4: a6050513 addi a0,a0,-1440 # 6210 <malloc+0x6ce> 7b8: 00005097 auipc ra,0x5 7bc: 2cc080e7 jalr 716(ra) # 5a84 <printf> printf("%s: read %d bytes, wanted 0\n", s, n); 7c0: 8652 mv a2,s4 7c2: 85d6 mv a1,s5 7c4: 00006517 auipc a0,0x6 7c8: a2c50513 addi a0,a0,-1492 # 61f0 <malloc+0x6ae> 7cc: 00005097 auipc ra,0x5 7d0: 2b8080e7 jalr 696(ra) # 5a84 <printf> exit(1); 7d4: 4505 li a0,1 7d6: 00005097 auipc ra,0x5 7da: f26080e7 jalr -218(ra) # 56fc <exit> printf("%s: read %d bytes, wanted 6\n", s, n); 7de: 862a mv a2,a0 7e0: 85d6 mv a1,s5 7e2: 00006517 auipc a0,0x6 7e6: a4650513 addi a0,a0,-1466 # 6228 <malloc+0x6e6> 7ea: 00005097 auipc ra,0x5 7ee: 29a080e7 jalr 666(ra) # 5a84 <printf> exit(1); 7f2: 4505 li a0,1 7f4: 00005097 auipc ra,0x5 7f8: f08080e7 jalr -248(ra) # 56fc <exit> printf("%s: read %d bytes, wanted 2\n", s, n); 7fc: 862a mv a2,a0 7fe: 85d6 mv a1,s5 800: 00006517 auipc a0,0x6 804: a4850513 addi a0,a0,-1464 # 6248 <malloc+0x706> 808: 00005097 auipc ra,0x5 80c: 27c080e7 jalr 636(ra) # 5a84 <printf> exit(1); 810: 4505 li a0,1 812: 00005097 auipc ra,0x5 816: eea080e7 jalr -278(ra) # 56fc <exit> 000000000000081a <writetest>: { 81a: 7139 addi sp,sp,-64 81c: fc06 sd ra,56(sp) 81e: f822 sd s0,48(sp) 820: f426 sd s1,40(sp) 822: f04a sd s2,32(sp) 824: ec4e sd s3,24(sp) 826: e852 sd s4,16(sp) 828: e456 sd s5,8(sp) 82a: e05a sd s6,0(sp) 82c: 0080 addi s0,sp,64 82e: 8b2a mv s6,a0 fd = open("small", O_CREATE|O_RDWR); 830: 20200593 li a1,514 834: 00006517 auipc a0,0x6 838: a3450513 addi a0,a0,-1484 # 6268 <malloc+0x726> 83c: 00005097 auipc ra,0x5 840: f00080e7 jalr -256(ra) # 573c <open> if(fd < 0){ 844: 0a054d63 bltz a0,8fe <writetest+0xe4> 848: 892a mv s2,a0 84a: 4481 li s1,0 if(write(fd, "aaaaaaaaaa", SZ) != SZ){ 84c: 00006997 auipc s3,0x6 850: a4498993 addi s3,s3,-1468 # 6290 <malloc+0x74e> if(write(fd, "bbbbbbbbbb", SZ) != SZ){ 854: 00006a97 auipc s5,0x6 858: a74a8a93 addi s5,s5,-1420 # 62c8 <malloc+0x786> for(i = 0; i < N; i++){ 85c: 06400a13 li s4,100 if(write(fd, "aaaaaaaaaa", SZ) != SZ){ 860: 4629 li a2,10 862: 85ce mv a1,s3 864: 854a mv a0,s2 866: 00005097 auipc ra,0x5 86a: eb6080e7 jalr -330(ra) # 571c <write> 86e: 47a9 li a5,10 870: 0af51563 bne a0,a5,91a <writetest+0x100> if(write(fd, "bbbbbbbbbb", SZ) != SZ){ 874: 4629 li a2,10 876: 85d6 mv a1,s5 878: 854a mv a0,s2 87a: 00005097 auipc ra,0x5 87e: ea2080e7 jalr -350(ra) # 571c <write> 882: 47a9 li a5,10 884: 0af51a63 bne a0,a5,938 <writetest+0x11e> for(i = 0; i < N; i++){ 888: 2485 addiw s1,s1,1 88a: fd449be3 bne s1,s4,860 <writetest+0x46> close(fd); 88e: 854a mv a0,s2 890: 00005097 auipc ra,0x5 894: e94080e7 jalr -364(ra) # 5724 <close> fd = open("small", O_RDONLY); 898: 4581 li a1,0 89a: 00006517 auipc a0,0x6 89e: 9ce50513 addi a0,a0,-1586 # 6268 <malloc+0x726> 8a2: 00005097 auipc ra,0x5 8a6: e9a080e7 jalr -358(ra) # 573c <open> 8aa: 84aa mv s1,a0 if(fd < 0){ 8ac: 0a054563 bltz a0,956 <writetest+0x13c> i = read(fd, buf, N*SZ*2); 8b0: 7d000613 li a2,2000 8b4: 0000b597 auipc a1,0xb 8b8: 32458593 addi a1,a1,804 # bbd8 <buf> 8bc: 00005097 auipc ra,0x5 8c0: e58080e7 jalr -424(ra) # 5714 <read> if(i != N*SZ*2){ 8c4: 7d000793 li a5,2000 8c8: 0af51563 bne a0,a5,972 <writetest+0x158> close(fd); 8cc: 8526 mv a0,s1 8ce: 00005097 auipc ra,0x5 8d2: e56080e7 jalr -426(ra) # 5724 <close> if(unlink("small") < 0){ 8d6: 00006517 auipc a0,0x6 8da: 99250513 addi a0,a0,-1646 # 6268 <malloc+0x726> 8de: 00005097 auipc ra,0x5 8e2: e6e080e7 jalr -402(ra) # 574c <unlink> 8e6: 0a054463 bltz a0,98e <writetest+0x174> } 8ea: 70e2 ld ra,56(sp) 8ec: 7442 ld s0,48(sp) 8ee: 74a2 ld s1,40(sp) 8f0: 7902 ld s2,32(sp) 8f2: 69e2 ld s3,24(sp) 8f4: 6a42 ld s4,16(sp) 8f6: 6aa2 ld s5,8(sp) 8f8: 6b02 ld s6,0(sp) 8fa: 6121 addi sp,sp,64 8fc: 8082 ret printf("%s: error: creat small failed!\n", s); 8fe: 85da mv a1,s6 900: 00006517 auipc a0,0x6 904: 97050513 addi a0,a0,-1680 # 6270 <malloc+0x72e> 908: 00005097 auipc ra,0x5 90c: 17c080e7 jalr 380(ra) # 5a84 <printf> exit(1); 910: 4505 li a0,1 912: 00005097 auipc ra,0x5 916: dea080e7 jalr -534(ra) # 56fc <exit> printf("%s: error: write aa %d new file failed\n", s, i); 91a: 8626 mv a2,s1 91c: 85da mv a1,s6 91e: 00006517 auipc a0,0x6 922: 98250513 addi a0,a0,-1662 # 62a0 <malloc+0x75e> 926: 00005097 auipc ra,0x5 92a: 15e080e7 jalr 350(ra) # 5a84 <printf> exit(1); 92e: 4505 li a0,1 930: 00005097 auipc ra,0x5 934: dcc080e7 jalr -564(ra) # 56fc <exit> printf("%s: error: write bb %d new file failed\n", s, i); 938: 8626 mv a2,s1 93a: 85da mv a1,s6 93c: 00006517 auipc a0,0x6 940: 99c50513 addi a0,a0,-1636 # 62d8 <malloc+0x796> 944: 00005097 auipc ra,0x5 948: 140080e7 jalr 320(ra) # 5a84 <printf> exit(1); 94c: 4505 li a0,1 94e: 00005097 auipc ra,0x5 952: dae080e7 jalr -594(ra) # 56fc <exit> printf("%s: error: open small failed!\n", s); 956: 85da mv a1,s6 958: 00006517 auipc a0,0x6 95c: 9a850513 addi a0,a0,-1624 # 6300 <malloc+0x7be> 960: 00005097 auipc ra,0x5 964: 124080e7 jalr 292(ra) # 5a84 <printf> exit(1); 968: 4505 li a0,1 96a: 00005097 auipc ra,0x5 96e: d92080e7 jalr -622(ra) # 56fc <exit> printf("%s: read failed\n", s); 972: 85da mv a1,s6 974: 00006517 auipc a0,0x6 978: 9ac50513 addi a0,a0,-1620 # 6320 <malloc+0x7de> 97c: 00005097 auipc ra,0x5 980: 108080e7 jalr 264(ra) # 5a84 <printf> exit(1); 984: 4505 li a0,1 986: 00005097 auipc ra,0x5 98a: d76080e7 jalr -650(ra) # 56fc <exit> printf("%s: unlink small failed\n", s); 98e: 85da mv a1,s6 990: 00006517 auipc a0,0x6 994: 9a850513 addi a0,a0,-1624 # 6338 <malloc+0x7f6> 998: 00005097 auipc ra,0x5 99c: 0ec080e7 jalr 236(ra) # 5a84 <printf> exit(1); 9a0: 4505 li a0,1 9a2: 00005097 auipc ra,0x5 9a6: d5a080e7 jalr -678(ra) # 56fc <exit> 00000000000009aa <writebig>: { 9aa: 7139 addi sp,sp,-64 9ac: fc06 sd ra,56(sp) 9ae: f822 sd s0,48(sp) 9b0: f426 sd s1,40(sp) 9b2: f04a sd s2,32(sp) 9b4: ec4e sd s3,24(sp) 9b6: e852 sd s4,16(sp) 9b8: e456 sd s5,8(sp) 9ba: 0080 addi s0,sp,64 9bc: 8aaa mv s5,a0 fd = open("big", O_CREATE|O_RDWR); 9be: 20200593 li a1,514 9c2: 00006517 auipc a0,0x6 9c6: 99650513 addi a0,a0,-1642 # 6358 <malloc+0x816> 9ca: 00005097 auipc ra,0x5 9ce: d72080e7 jalr -654(ra) # 573c <open> 9d2: 89aa mv s3,a0 for(i = 0; i < MAXFILE; i++){ 9d4: 4481 li s1,0 ((int*)buf)[0] = i; 9d6: 0000b917 auipc s2,0xb 9da: 20290913 addi s2,s2,514 # bbd8 <buf> for(i = 0; i < MAXFILE; i++){ 9de: 10c00a13 li s4,268 if(fd < 0){ 9e2: 06054c63 bltz a0,a5a <writebig+0xb0> ((int*)buf)[0] = i; 9e6: 00992023 sw s1,0(s2) if(write(fd, buf, BSIZE) != BSIZE){ 9ea: 40000613 li a2,1024 9ee: 85ca mv a1,s2 9f0: 854e mv a0,s3 9f2: 00005097 auipc ra,0x5 9f6: d2a080e7 jalr -726(ra) # 571c <write> 9fa: 40000793 li a5,1024 9fe: 06f51c63 bne a0,a5,a76 <writebig+0xcc> for(i = 0; i < MAXFILE; i++){ a02: 2485 addiw s1,s1,1 a04: ff4491e3 bne s1,s4,9e6 <writebig+0x3c> close(fd); a08: 854e mv a0,s3 a0a: 00005097 auipc ra,0x5 a0e: d1a080e7 jalr -742(ra) # 5724 <close> fd = open("big", O_RDONLY); a12: 4581 li a1,0 a14: 00006517 auipc a0,0x6 a18: 94450513 addi a0,a0,-1724 # 6358 <malloc+0x816> a1c: 00005097 auipc ra,0x5 a20: d20080e7 jalr -736(ra) # 573c <open> a24: 89aa mv s3,a0 n = 0; a26: 4481 li s1,0 i = read(fd, buf, BSIZE); a28: 0000b917 auipc s2,0xb a2c: 1b090913 addi s2,s2,432 # bbd8 <buf> if(fd < 0){ a30: 06054263 bltz a0,a94 <writebig+0xea> i = read(fd, buf, BSIZE); a34: 40000613 li a2,1024 a38: 85ca mv a1,s2 a3a: 854e mv a0,s3 a3c: 00005097 auipc ra,0x5 a40: cd8080e7 jalr -808(ra) # 5714 <read> if(i == 0){ a44: c535 beqz a0,ab0 <writebig+0x106> } else if(i != BSIZE){ a46: 40000793 li a5,1024 a4a: 0af51f63 bne a0,a5,b08 <writebig+0x15e> if(((int*)buf)[0] != n){ a4e: 00092683 lw a3,0(s2) a52: 0c969a63 bne a3,s1,b26 <writebig+0x17c> n++; a56: 2485 addiw s1,s1,1 i = read(fd, buf, BSIZE); a58: bff1 j a34 <writebig+0x8a> printf("%s: error: creat big failed!\n", s); a5a: 85d6 mv a1,s5 a5c: 00006517 auipc a0,0x6 a60: 90450513 addi a0,a0,-1788 # 6360 <malloc+0x81e> a64: 00005097 auipc ra,0x5 a68: 020080e7 jalr 32(ra) # 5a84 <printf> exit(1); a6c: 4505 li a0,1 a6e: 00005097 auipc ra,0x5 a72: c8e080e7 jalr -882(ra) # 56fc <exit> printf("%s: error: write big file failed\n", s, i); a76: 8626 mv a2,s1 a78: 85d6 mv a1,s5 a7a: 00006517 auipc a0,0x6 a7e: 90650513 addi a0,a0,-1786 # 6380 <malloc+0x83e> a82: 00005097 auipc ra,0x5 a86: 002080e7 jalr 2(ra) # 5a84 <printf> exit(1); a8a: 4505 li a0,1 a8c: 00005097 auipc ra,0x5 a90: c70080e7 jalr -912(ra) # 56fc <exit> printf("%s: error: open big failed!\n", s); a94: 85d6 mv a1,s5 a96: 00006517 auipc a0,0x6 a9a: 91250513 addi a0,a0,-1774 # 63a8 <malloc+0x866> a9e: 00005097 auipc ra,0x5 aa2: fe6080e7 jalr -26(ra) # 5a84 <printf> exit(1); aa6: 4505 li a0,1 aa8: 00005097 auipc ra,0x5 aac: c54080e7 jalr -940(ra) # 56fc <exit> if(n == MAXFILE - 1){ ab0: 10b00793 li a5,267 ab4: 02f48a63 beq s1,a5,ae8 <writebig+0x13e> close(fd); ab8: 854e mv a0,s3 aba: 00005097 auipc ra,0x5 abe: c6a080e7 jalr -918(ra) # 5724 <close> if(unlink("big") < 0){ ac2: 00006517 auipc a0,0x6 ac6: 89650513 addi a0,a0,-1898 # 6358 <malloc+0x816> aca: 00005097 auipc ra,0x5 ace: c82080e7 jalr -894(ra) # 574c <unlink> ad2: 06054963 bltz a0,b44 <writebig+0x19a> } ad6: 70e2 ld ra,56(sp) ad8: 7442 ld s0,48(sp) ada: 74a2 ld s1,40(sp) adc: 7902 ld s2,32(sp) ade: 69e2 ld s3,24(sp) ae0: 6a42 ld s4,16(sp) ae2: 6aa2 ld s5,8(sp) ae4: 6121 addi sp,sp,64 ae6: 8082 ret printf("%s: read only %d blocks from big", s, n); ae8: 10b00613 li a2,267 aec: 85d6 mv a1,s5 aee: 00006517 auipc a0,0x6 af2: 8da50513 addi a0,a0,-1830 # 63c8 <malloc+0x886> af6: 00005097 auipc ra,0x5 afa: f8e080e7 jalr -114(ra) # 5a84 <printf> exit(1); afe: 4505 li a0,1 b00: 00005097 auipc ra,0x5 b04: bfc080e7 jalr -1028(ra) # 56fc <exit> printf("%s: read failed %d\n", s, i); b08: 862a mv a2,a0 b0a: 85d6 mv a1,s5 b0c: 00006517 auipc a0,0x6 b10: 8e450513 addi a0,a0,-1820 # 63f0 <malloc+0x8ae> b14: 00005097 auipc ra,0x5 b18: f70080e7 jalr -144(ra) # 5a84 <printf> exit(1); b1c: 4505 li a0,1 b1e: 00005097 auipc ra,0x5 b22: bde080e7 jalr -1058(ra) # 56fc <exit> printf("%s: read content of block %d is %d\n", s, b26: 8626 mv a2,s1 b28: 85d6 mv a1,s5 b2a: 00006517 auipc a0,0x6 b2e: 8de50513 addi a0,a0,-1826 # 6408 <malloc+0x8c6> b32: 00005097 auipc ra,0x5 b36: f52080e7 jalr -174(ra) # 5a84 <printf> exit(1); b3a: 4505 li a0,1 b3c: 00005097 auipc ra,0x5 b40: bc0080e7 jalr -1088(ra) # 56fc <exit> printf("%s: unlink big failed\n", s); b44: 85d6 mv a1,s5 b46: 00006517 auipc a0,0x6 b4a: 8ea50513 addi a0,a0,-1814 # 6430 <malloc+0x8ee> b4e: 00005097 auipc ra,0x5 b52: f36080e7 jalr -202(ra) # 5a84 <printf> exit(1); b56: 4505 li a0,1 b58: 00005097 auipc ra,0x5 b5c: ba4080e7 jalr -1116(ra) # 56fc <exit> 0000000000000b60 <unlinkread>: { b60: 7179 addi sp,sp,-48 b62: f406 sd ra,40(sp) b64: f022 sd s0,32(sp) b66: ec26 sd s1,24(sp) b68: e84a sd s2,16(sp) b6a: e44e sd s3,8(sp) b6c: 1800 addi s0,sp,48 b6e: 89aa mv s3,a0 fd = open("unlinkread", O_CREATE | O_RDWR); b70: 20200593 li a1,514 b74: 00005517 auipc a0,0x5 b78: 21450513 addi a0,a0,532 # 5d88 <malloc+0x246> b7c: 00005097 auipc ra,0x5 b80: bc0080e7 jalr -1088(ra) # 573c <open> if(fd < 0){ b84: 0e054563 bltz a0,c6e <unlinkread+0x10e> b88: 84aa mv s1,a0 write(fd, "hello", SZ); b8a: 4615 li a2,5 b8c: 00006597 auipc a1,0x6 b90: 8dc58593 addi a1,a1,-1828 # 6468 <malloc+0x926> b94: 00005097 auipc ra,0x5 b98: b88080e7 jalr -1144(ra) # 571c <write> close(fd); b9c: 8526 mv a0,s1 b9e: 00005097 auipc ra,0x5 ba2: b86080e7 jalr -1146(ra) # 5724 <close> fd = open("unlinkread", O_RDWR); ba6: 4589 li a1,2 ba8: 00005517 auipc a0,0x5 bac: 1e050513 addi a0,a0,480 # 5d88 <malloc+0x246> bb0: 00005097 auipc ra,0x5 bb4: b8c080e7 jalr -1140(ra) # 573c <open> bb8: 84aa mv s1,a0 if(fd < 0){ bba: 0c054863 bltz a0,c8a <unlinkread+0x12a> if(unlink("unlinkread") != 0){ bbe: 00005517 auipc a0,0x5 bc2: 1ca50513 addi a0,a0,458 # 5d88 <malloc+0x246> bc6: 00005097 auipc ra,0x5 bca: b86080e7 jalr -1146(ra) # 574c <unlink> bce: ed61 bnez a0,ca6 <unlinkread+0x146> fd1 = open("unlinkread", O_CREATE | O_RDWR); bd0: 20200593 li a1,514 bd4: 00005517 auipc a0,0x5 bd8: 1b450513 addi a0,a0,436 # 5d88 <malloc+0x246> bdc: 00005097 auipc ra,0x5 be0: b60080e7 jalr -1184(ra) # 573c <open> be4: 892a mv s2,a0 write(fd1, "yyy", 3); be6: 460d li a2,3 be8: 00006597 auipc a1,0x6 bec: 8c858593 addi a1,a1,-1848 # 64b0 <malloc+0x96e> bf0: 00005097 auipc ra,0x5 bf4: b2c080e7 jalr -1236(ra) # 571c <write> close(fd1); bf8: 854a mv a0,s2 bfa: 00005097 auipc ra,0x5 bfe: b2a080e7 jalr -1238(ra) # 5724 <close> if(read(fd, buf, sizeof(buf)) != SZ){ c02: 660d lui a2,0x3 c04: 0000b597 auipc a1,0xb c08: fd458593 addi a1,a1,-44 # bbd8 <buf> c0c: 8526 mv a0,s1 c0e: 00005097 auipc ra,0x5 c12: b06080e7 jalr -1274(ra) # 5714 <read> c16: 4795 li a5,5 c18: 0af51563 bne a0,a5,cc2 <unlinkread+0x162> if(buf[0] != 'h'){ c1c: 0000b717 auipc a4,0xb c20: fbc74703 lbu a4,-68(a4) # bbd8 <buf> c24: 06800793 li a5,104 c28: 0af71b63 bne a4,a5,cde <unlinkread+0x17e> if(write(fd, buf, 10) != 10){ c2c: 4629 li a2,10 c2e: 0000b597 auipc a1,0xb c32: faa58593 addi a1,a1,-86 # bbd8 <buf> c36: 8526 mv a0,s1 c38: 00005097 auipc ra,0x5 c3c: ae4080e7 jalr -1308(ra) # 571c <write> c40: 47a9 li a5,10 c42: 0af51c63 bne a0,a5,cfa <unlinkread+0x19a> close(fd); c46: 8526 mv a0,s1 c48: 00005097 auipc ra,0x5 c4c: adc080e7 jalr -1316(ra) # 5724 <close> unlink("unlinkread"); c50: 00005517 auipc a0,0x5 c54: 13850513 addi a0,a0,312 # 5d88 <malloc+0x246> c58: 00005097 auipc ra,0x5 c5c: af4080e7 jalr -1292(ra) # 574c <unlink> } c60: 70a2 ld ra,40(sp) c62: 7402 ld s0,32(sp) c64: 64e2 ld s1,24(sp) c66: 6942 ld s2,16(sp) c68: 69a2 ld s3,8(sp) c6a: 6145 addi sp,sp,48 c6c: 8082 ret printf("%s: create unlinkread failed\n", s); c6e: 85ce mv a1,s3 c70: 00005517 auipc a0,0x5 c74: 7d850513 addi a0,a0,2008 # 6448 <malloc+0x906> c78: 00005097 auipc ra,0x5 c7c: e0c080e7 jalr -500(ra) # 5a84 <printf> exit(1); c80: 4505 li a0,1 c82: 00005097 auipc ra,0x5 c86: a7a080e7 jalr -1414(ra) # 56fc <exit> printf("%s: open unlinkread failed\n", s); c8a: 85ce mv a1,s3 c8c: 00005517 auipc a0,0x5 c90: 7e450513 addi a0,a0,2020 # 6470 <malloc+0x92e> c94: 00005097 auipc ra,0x5 c98: df0080e7 jalr -528(ra) # 5a84 <printf> exit(1); c9c: 4505 li a0,1 c9e: 00005097 auipc ra,0x5 ca2: a5e080e7 jalr -1442(ra) # 56fc <exit> printf("%s: unlink unlinkread failed\n", s); ca6: 85ce mv a1,s3 ca8: 00005517 auipc a0,0x5 cac: 7e850513 addi a0,a0,2024 # 6490 <malloc+0x94e> cb0: 00005097 auipc ra,0x5 cb4: dd4080e7 jalr -556(ra) # 5a84 <printf> exit(1); cb8: 4505 li a0,1 cba: 00005097 auipc ra,0x5 cbe: a42080e7 jalr -1470(ra) # 56fc <exit> printf("%s: unlinkread read failed", s); cc2: 85ce mv a1,s3 cc4: 00005517 auipc a0,0x5 cc8: 7f450513 addi a0,a0,2036 # 64b8 <malloc+0x976> ccc: 00005097 auipc ra,0x5 cd0: db8080e7 jalr -584(ra) # 5a84 <printf> exit(1); cd4: 4505 li a0,1 cd6: 00005097 auipc ra,0x5 cda: a26080e7 jalr -1498(ra) # 56fc <exit> printf("%s: unlinkread wrong data\n", s); cde: 85ce mv a1,s3 ce0: 00005517 auipc a0,0x5 ce4: 7f850513 addi a0,a0,2040 # 64d8 <malloc+0x996> ce8: 00005097 auipc ra,0x5 cec: d9c080e7 jalr -612(ra) # 5a84 <printf> exit(1); cf0: 4505 li a0,1 cf2: 00005097 auipc ra,0x5 cf6: a0a080e7 jalr -1526(ra) # 56fc <exit> printf("%s: unlinkread write failed\n", s); cfa: 85ce mv a1,s3 cfc: 00005517 auipc a0,0x5 d00: 7fc50513 addi a0,a0,2044 # 64f8 <malloc+0x9b6> d04: 00005097 auipc ra,0x5 d08: d80080e7 jalr -640(ra) # 5a84 <printf> exit(1); d0c: 4505 li a0,1 d0e: 00005097 auipc ra,0x5 d12: 9ee080e7 jalr -1554(ra) # 56fc <exit> 0000000000000d16 <linktest>: { d16: 1101 addi sp,sp,-32 d18: ec06 sd ra,24(sp) d1a: e822 sd s0,16(sp) d1c: e426 sd s1,8(sp) d1e: e04a sd s2,0(sp) d20: 1000 addi s0,sp,32 d22: 892a mv s2,a0 unlink("lf1"); d24: 00005517 auipc a0,0x5 d28: 7f450513 addi a0,a0,2036 # 6518 <malloc+0x9d6> d2c: 00005097 auipc ra,0x5 d30: a20080e7 jalr -1504(ra) # 574c <unlink> unlink("lf2"); d34: 00005517 auipc a0,0x5 d38: 7ec50513 addi a0,a0,2028 # 6520 <malloc+0x9de> d3c: 00005097 auipc ra,0x5 d40: a10080e7 jalr -1520(ra) # 574c <unlink> fd = open("lf1", O_CREATE|O_RDWR); d44: 20200593 li a1,514 d48: 00005517 auipc a0,0x5 d4c: 7d050513 addi a0,a0,2000 # 6518 <malloc+0x9d6> d50: 00005097 auipc ra,0x5 d54: 9ec080e7 jalr -1556(ra) # 573c <open> if(fd < 0){ d58: 10054763 bltz a0,e66 <linktest+0x150> d5c: 84aa mv s1,a0 if(write(fd, "hello", SZ) != SZ){ d5e: 4615 li a2,5 d60: 00005597 auipc a1,0x5 d64: 70858593 addi a1,a1,1800 # 6468 <malloc+0x926> d68: 00005097 auipc ra,0x5 d6c: 9b4080e7 jalr -1612(ra) # 571c <write> d70: 4795 li a5,5 d72: 10f51863 bne a0,a5,e82 <linktest+0x16c> close(fd); d76: 8526 mv a0,s1 d78: 00005097 auipc ra,0x5 d7c: 9ac080e7 jalr -1620(ra) # 5724 <close> if(link("lf1", "lf2") < 0){ d80: 00005597 auipc a1,0x5 d84: 7a058593 addi a1,a1,1952 # 6520 <malloc+0x9de> d88: 00005517 auipc a0,0x5 d8c: 79050513 addi a0,a0,1936 # 6518 <malloc+0x9d6> d90: 00005097 auipc ra,0x5 d94: 9cc080e7 jalr -1588(ra) # 575c <link> d98: 10054363 bltz a0,e9e <linktest+0x188> unlink("lf1"); d9c: 00005517 auipc a0,0x5 da0: 77c50513 addi a0,a0,1916 # 6518 <malloc+0x9d6> da4: 00005097 auipc ra,0x5 da8: 9a8080e7 jalr -1624(ra) # 574c <unlink> if(open("lf1", 0) >= 0){ dac: 4581 li a1,0 dae: 00005517 auipc a0,0x5 db2: 76a50513 addi a0,a0,1898 # 6518 <malloc+0x9d6> db6: 00005097 auipc ra,0x5 dba: 986080e7 jalr -1658(ra) # 573c <open> dbe: 0e055e63 bgez a0,eba <linktest+0x1a4> fd = open("lf2", 0); dc2: 4581 li a1,0 dc4: 00005517 auipc a0,0x5 dc8: 75c50513 addi a0,a0,1884 # 6520 <malloc+0x9de> dcc: 00005097 auipc ra,0x5 dd0: 970080e7 jalr -1680(ra) # 573c <open> dd4: 84aa mv s1,a0 if(fd < 0){ dd6: 10054063 bltz a0,ed6 <linktest+0x1c0> if(read(fd, buf, sizeof(buf)) != SZ){ dda: 660d lui a2,0x3 ddc: 0000b597 auipc a1,0xb de0: dfc58593 addi a1,a1,-516 # bbd8 <buf> de4: 00005097 auipc ra,0x5 de8: 930080e7 jalr -1744(ra) # 5714 <read> dec: 4795 li a5,5 dee: 10f51263 bne a0,a5,ef2 <linktest+0x1dc> close(fd); df2: 8526 mv a0,s1 df4: 00005097 auipc ra,0x5 df8: 930080e7 jalr -1744(ra) # 5724 <close> if(link("lf2", "lf2") >= 0){ dfc: 00005597 auipc a1,0x5 e00: 72458593 addi a1,a1,1828 # 6520 <malloc+0x9de> e04: 852e mv a0,a1 e06: 00005097 auipc ra,0x5 e0a: 956080e7 jalr -1706(ra) # 575c <link> e0e: 10055063 bgez a0,f0e <linktest+0x1f8> unlink("lf2"); e12: 00005517 auipc a0,0x5 e16: 70e50513 addi a0,a0,1806 # 6520 <malloc+0x9de> e1a: 00005097 auipc ra,0x5 e1e: 932080e7 jalr -1742(ra) # 574c <unlink> if(link("lf2", "lf1") >= 0){ e22: 00005597 auipc a1,0x5 e26: 6f658593 addi a1,a1,1782 # 6518 <malloc+0x9d6> e2a: 00005517 auipc a0,0x5 e2e: 6f650513 addi a0,a0,1782 # 6520 <malloc+0x9de> e32: 00005097 auipc ra,0x5 e36: 92a080e7 jalr -1750(ra) # 575c <link> e3a: 0e055863 bgez a0,f2a <linktest+0x214> if(link(".", "lf1") >= 0){ e3e: 00005597 auipc a1,0x5 e42: 6da58593 addi a1,a1,1754 # 6518 <malloc+0x9d6> e46: 00005517 auipc a0,0x5 e4a: 7e250513 addi a0,a0,2018 # 6628 <malloc+0xae6> e4e: 00005097 auipc ra,0x5 e52: 90e080e7 jalr -1778(ra) # 575c <link> e56: 0e055863 bgez a0,f46 <linktest+0x230> } e5a: 60e2 ld ra,24(sp) e5c: 6442 ld s0,16(sp) e5e: 64a2 ld s1,8(sp) e60: 6902 ld s2,0(sp) e62: 6105 addi sp,sp,32 e64: 8082 ret printf("%s: create lf1 failed\n", s); e66: 85ca mv a1,s2 e68: 00005517 auipc a0,0x5 e6c: 6c050513 addi a0,a0,1728 # 6528 <malloc+0x9e6> e70: 00005097 auipc ra,0x5 e74: c14080e7 jalr -1004(ra) # 5a84 <printf> exit(1); e78: 4505 li a0,1 e7a: 00005097 auipc ra,0x5 e7e: 882080e7 jalr -1918(ra) # 56fc <exit> printf("%s: write lf1 failed\n", s); e82: 85ca mv a1,s2 e84: 00005517 auipc a0,0x5 e88: 6bc50513 addi a0,a0,1724 # 6540 <malloc+0x9fe> e8c: 00005097 auipc ra,0x5 e90: bf8080e7 jalr -1032(ra) # 5a84 <printf> exit(1); e94: 4505 li a0,1 e96: 00005097 auipc ra,0x5 e9a: 866080e7 jalr -1946(ra) # 56fc <exit> printf("%s: link lf1 lf2 failed\n", s); e9e: 85ca mv a1,s2 ea0: 00005517 auipc a0,0x5 ea4: 6b850513 addi a0,a0,1720 # 6558 <malloc+0xa16> ea8: 00005097 auipc ra,0x5 eac: bdc080e7 jalr -1060(ra) # 5a84 <printf> exit(1); eb0: 4505 li a0,1 eb2: 00005097 auipc ra,0x5 eb6: 84a080e7 jalr -1974(ra) # 56fc <exit> printf("%s: unlinked lf1 but it is still there!\n", s); eba: 85ca mv a1,s2 ebc: 00005517 auipc a0,0x5 ec0: 6bc50513 addi a0,a0,1724 # 6578 <malloc+0xa36> ec4: 00005097 auipc ra,0x5 ec8: bc0080e7 jalr -1088(ra) # 5a84 <printf> exit(1); ecc: 4505 li a0,1 ece: 00005097 auipc ra,0x5 ed2: 82e080e7 jalr -2002(ra) # 56fc <exit> printf("%s: open lf2 failed\n", s); ed6: 85ca mv a1,s2 ed8: 00005517 auipc a0,0x5 edc: 6d050513 addi a0,a0,1744 # 65a8 <malloc+0xa66> ee0: 00005097 auipc ra,0x5 ee4: ba4080e7 jalr -1116(ra) # 5a84 <printf> exit(1); ee8: 4505 li a0,1 eea: 00005097 auipc ra,0x5 eee: 812080e7 jalr -2030(ra) # 56fc <exit> printf("%s: read lf2 failed\n", s); ef2: 85ca mv a1,s2 ef4: 00005517 auipc a0,0x5 ef8: 6cc50513 addi a0,a0,1740 # 65c0 <malloc+0xa7e> efc: 00005097 auipc ra,0x5 f00: b88080e7 jalr -1144(ra) # 5a84 <printf> exit(1); f04: 4505 li a0,1 f06: 00004097 auipc ra,0x4 f0a: 7f6080e7 jalr 2038(ra) # 56fc <exit> printf("%s: link lf2 lf2 succeeded! oops\n", s); f0e: 85ca mv a1,s2 f10: 00005517 auipc a0,0x5 f14: 6c850513 addi a0,a0,1736 # 65d8 <malloc+0xa96> f18: 00005097 auipc ra,0x5 f1c: b6c080e7 jalr -1172(ra) # 5a84 <printf> exit(1); f20: 4505 li a0,1 f22: 00004097 auipc ra,0x4 f26: 7da080e7 jalr 2010(ra) # 56fc <exit> printf("%s: link non-existant succeeded! oops\n", s); f2a: 85ca mv a1,s2 f2c: 00005517 auipc a0,0x5 f30: 6d450513 addi a0,a0,1748 # 6600 <malloc+0xabe> f34: 00005097 auipc ra,0x5 f38: b50080e7 jalr -1200(ra) # 5a84 <printf> exit(1); f3c: 4505 li a0,1 f3e: 00004097 auipc ra,0x4 f42: 7be080e7 jalr 1982(ra) # 56fc <exit> printf("%s: link . lf1 succeeded! oops\n", s); f46: 85ca mv a1,s2 f48: 00005517 auipc a0,0x5 f4c: 6e850513 addi a0,a0,1768 # 6630 <malloc+0xaee> f50: 00005097 auipc ra,0x5 f54: b34080e7 jalr -1228(ra) # 5a84 <printf> exit(1); f58: 4505 li a0,1 f5a: 00004097 auipc ra,0x4 f5e: 7a2080e7 jalr 1954(ra) # 56fc <exit> 0000000000000f62 <bigdir>: { f62: 715d addi sp,sp,-80 f64: e486 sd ra,72(sp) f66: e0a2 sd s0,64(sp) f68: fc26 sd s1,56(sp) f6a: f84a sd s2,48(sp) f6c: f44e sd s3,40(sp) f6e: f052 sd s4,32(sp) f70: ec56 sd s5,24(sp) f72: e85a sd s6,16(sp) f74: 0880 addi s0,sp,80 f76: 89aa mv s3,a0 unlink("bd"); f78: 00005517 auipc a0,0x5 f7c: 6d850513 addi a0,a0,1752 # 6650 <malloc+0xb0e> f80: 00004097 auipc ra,0x4 f84: 7cc080e7 jalr 1996(ra) # 574c <unlink> fd = open("bd", O_CREATE); f88: 20000593 li a1,512 f8c: 00005517 auipc a0,0x5 f90: 6c450513 addi a0,a0,1732 # 6650 <malloc+0xb0e> f94: 00004097 auipc ra,0x4 f98: 7a8080e7 jalr 1960(ra) # 573c <open> if(fd < 0){ f9c: 0c054963 bltz a0,106e <bigdir+0x10c> close(fd); fa0: 00004097 auipc ra,0x4 fa4: 784080e7 jalr 1924(ra) # 5724 <close> for(i = 0; i < N; i++){ fa8: 4901 li s2,0 name[0] = 'x'; faa: 07800a93 li s5,120 if(link("bd", name) != 0){ fae: 00005a17 auipc s4,0x5 fb2: 6a2a0a13 addi s4,s4,1698 # 6650 <malloc+0xb0e> for(i = 0; i < N; i++){ fb6: 1f400b13 li s6,500 name[0] = 'x'; fba: fb540823 sb s5,-80(s0) name[1] = '0' + (i / 64); fbe: 41f9579b sraiw a5,s2,0x1f fc2: 01a7d71b srliw a4,a5,0x1a fc6: 012707bb addw a5,a4,s2 fca: 4067d69b sraiw a3,a5,0x6 fce: 0306869b addiw a3,a3,48 fd2: fad408a3 sb a3,-79(s0) name[2] = '0' + (i % 64); fd6: 03f7f793 andi a5,a5,63 fda: 9f99 subw a5,a5,a4 fdc: 0307879b addiw a5,a5,48 fe0: faf40923 sb a5,-78(s0) name[3] = '\0'; fe4: fa0409a3 sb zero,-77(s0) if(link("bd", name) != 0){ fe8: fb040593 addi a1,s0,-80 fec: 8552 mv a0,s4 fee: 00004097 auipc ra,0x4 ff2: 76e080e7 jalr 1902(ra) # 575c <link> ff6: 84aa mv s1,a0 ff8: e949 bnez a0,108a <bigdir+0x128> for(i = 0; i < N; i++){ ffa: 2905 addiw s2,s2,1 ffc: fb691fe3 bne s2,s6,fba <bigdir+0x58> unlink("bd"); 1000: 00005517 auipc a0,0x5 1004: 65050513 addi a0,a0,1616 # 6650 <malloc+0xb0e> 1008: 00004097 auipc ra,0x4 100c: 744080e7 jalr 1860(ra) # 574c <unlink> name[0] = 'x'; 1010: 07800913 li s2,120 for(i = 0; i < N; i++){ 1014: 1f400a13 li s4,500 name[0] = 'x'; 1018: fb240823 sb s2,-80(s0) name[1] = '0' + (i / 64); 101c: 41f4d79b sraiw a5,s1,0x1f 1020: 01a7d71b srliw a4,a5,0x1a 1024: 009707bb addw a5,a4,s1 1028: 4067d69b sraiw a3,a5,0x6 102c: 0306869b addiw a3,a3,48 1030: fad408a3 sb a3,-79(s0) name[2] = '0' + (i % 64); 1034: 03f7f793 andi a5,a5,63 1038: 9f99 subw a5,a5,a4 103a: 0307879b addiw a5,a5,48 103e: faf40923 sb a5,-78(s0) name[3] = '\0'; 1042: fa0409a3 sb zero,-77(s0) if(unlink(name) != 0){ 1046: fb040513 addi a0,s0,-80 104a: 00004097 auipc ra,0x4 104e: 702080e7 jalr 1794(ra) # 574c <unlink> 1052: ed21 bnez a0,10aa <bigdir+0x148> for(i = 0; i < N; i++){ 1054: 2485 addiw s1,s1,1 1056: fd4491e3 bne s1,s4,1018 <bigdir+0xb6> } 105a: 60a6 ld ra,72(sp) 105c: 6406 ld s0,64(sp) 105e: 74e2 ld s1,56(sp) 1060: 7942 ld s2,48(sp) 1062: 79a2 ld s3,40(sp) 1064: 7a02 ld s4,32(sp) 1066: 6ae2 ld s5,24(sp) 1068: 6b42 ld s6,16(sp) 106a: 6161 addi sp,sp,80 106c: 8082 ret printf("%s: bigdir create failed\n", s); 106e: 85ce mv a1,s3 1070: 00005517 auipc a0,0x5 1074: 5e850513 addi a0,a0,1512 # 6658 <malloc+0xb16> 1078: 00005097 auipc ra,0x5 107c: a0c080e7 jalr -1524(ra) # 5a84 <printf> exit(1); 1080: 4505 li a0,1 1082: 00004097 auipc ra,0x4 1086: 67a080e7 jalr 1658(ra) # 56fc <exit> printf("%s: bigdir link(bd, %s) failed\n", s, name); 108a: fb040613 addi a2,s0,-80 108e: 85ce mv a1,s3 1090: 00005517 auipc a0,0x5 1094: 5e850513 addi a0,a0,1512 # 6678 <malloc+0xb36> 1098: 00005097 auipc ra,0x5 109c: 9ec080e7 jalr -1556(ra) # 5a84 <printf> exit(1); 10a0: 4505 li a0,1 10a2: 00004097 auipc ra,0x4 10a6: 65a080e7 jalr 1626(ra) # 56fc <exit> printf("%s: bigdir unlink failed", s); 10aa: 85ce mv a1,s3 10ac: 00005517 auipc a0,0x5 10b0: 5ec50513 addi a0,a0,1516 # 6698 <malloc+0xb56> 10b4: 00005097 auipc ra,0x5 10b8: 9d0080e7 jalr -1584(ra) # 5a84 <printf> exit(1); 10bc: 4505 li a0,1 10be: 00004097 auipc ra,0x4 10c2: 63e080e7 jalr 1598(ra) # 56fc <exit> 00000000000010c6 <validatetest>: { 10c6: 7139 addi sp,sp,-64 10c8: fc06 sd ra,56(sp) 10ca: f822 sd s0,48(sp) 10cc: f426 sd s1,40(sp) 10ce: f04a sd s2,32(sp) 10d0: ec4e sd s3,24(sp) 10d2: e852 sd s4,16(sp) 10d4: e456 sd s5,8(sp) 10d6: e05a sd s6,0(sp) 10d8: 0080 addi s0,sp,64 10da: 8b2a mv s6,a0 for(p = 0; p <= (uint)hi; p += PGSIZE){ 10dc: 4481 li s1,0 if(link("nosuchfile", (char*)p) != -1){ 10de: 00005997 auipc s3,0x5 10e2: 5da98993 addi s3,s3,1498 # 66b8 <malloc+0xb76> 10e6: 597d li s2,-1 for(p = 0; p <= (uint)hi; p += PGSIZE){ 10e8: 6a85 lui s5,0x1 10ea: 00114a37 lui s4,0x114 if(link("nosuchfile", (char*)p) != -1){ 10ee: 85a6 mv a1,s1 10f0: 854e mv a0,s3 10f2: 00004097 auipc ra,0x4 10f6: 66a080e7 jalr 1642(ra) # 575c <link> 10fa: 01251f63 bne a0,s2,1118 <validatetest+0x52> for(p = 0; p <= (uint)hi; p += PGSIZE){ 10fe: 94d6 add s1,s1,s5 1100: ff4497e3 bne s1,s4,10ee <validatetest+0x28> } 1104: 70e2 ld ra,56(sp) 1106: 7442 ld s0,48(sp) 1108: 74a2 ld s1,40(sp) 110a: 7902 ld s2,32(sp) 110c: 69e2 ld s3,24(sp) 110e: 6a42 ld s4,16(sp) 1110: 6aa2 ld s5,8(sp) 1112: 6b02 ld s6,0(sp) 1114: 6121 addi sp,sp,64 1116: 8082 ret printf("%s: link should not succeed\n", s); 1118: 85da mv a1,s6 111a: 00005517 auipc a0,0x5 111e: 5ae50513 addi a0,a0,1454 # 66c8 <malloc+0xb86> 1122: 00005097 auipc ra,0x5 1126: 962080e7 jalr -1694(ra) # 5a84 <printf> exit(1); 112a: 4505 li a0,1 112c: 00004097 auipc ra,0x4 1130: 5d0080e7 jalr 1488(ra) # 56fc <exit> 0000000000001134 <pgbug>: // regression test. copyin(), copyout(), and copyinstr() used to cast // the virtual page address to uint, which (with certain wild system // call arguments) resulted in a kernel page faults. void pgbug(char *s) { 1134: 7179 addi sp,sp,-48 1136: f406 sd ra,40(sp) 1138: f022 sd s0,32(sp) 113a: ec26 sd s1,24(sp) 113c: 1800 addi s0,sp,48 char *argv[1]; argv[0] = 0; 113e: fc043c23 sd zero,-40(s0) exec((char*)0xeaeb0b5b00002f5e, argv); 1142: 00007497 auipc s1,0x7 1146: 2664b483 ld s1,614(s1) # 83a8 <__SDATA_BEGIN__> 114a: fd840593 addi a1,s0,-40 114e: 8526 mv a0,s1 1150: 00004097 auipc ra,0x4 1154: 5e4080e7 jalr 1508(ra) # 5734 <exec> pipe((int*)0xeaeb0b5b00002f5e); 1158: 8526 mv a0,s1 115a: 00004097 auipc ra,0x4 115e: 5b2080e7 jalr 1458(ra) # 570c <pipe> exit(0); 1162: 4501 li a0,0 1164: 00004097 auipc ra,0x4 1168: 598080e7 jalr 1432(ra) # 56fc <exit> 000000000000116c <badarg>: // regression test. test whether exec() leaks memory if one of the // arguments is invalid. the test passes if the kernel doesn't panic. void badarg(char *s) { 116c: 7139 addi sp,sp,-64 116e: fc06 sd ra,56(sp) 1170: f822 sd s0,48(sp) 1172: f426 sd s1,40(sp) 1174: f04a sd s2,32(sp) 1176: ec4e sd s3,24(sp) 1178: 0080 addi s0,sp,64 117a: 64b1 lui s1,0xc 117c: 35048493 addi s1,s1,848 # c350 <buf+0x778> for(int i = 0; i < 50000; i++){ char *argv[2]; argv[0] = (char*)0xffffffff; 1180: 597d li s2,-1 1182: 02095913 srli s2,s2,0x20 argv[1] = 0; exec("echo", argv); 1186: 00005997 auipc s3,0x5 118a: e0a98993 addi s3,s3,-502 # 5f90 <malloc+0x44e> argv[0] = (char*)0xffffffff; 118e: fd243023 sd s2,-64(s0) argv[1] = 0; 1192: fc043423 sd zero,-56(s0) exec("echo", argv); 1196: fc040593 addi a1,s0,-64 119a: 854e mv a0,s3 119c: 00004097 auipc ra,0x4 11a0: 598080e7 jalr 1432(ra) # 5734 <exec> for(int i = 0; i < 50000; i++){ 11a4: 34fd addiw s1,s1,-1 11a6: f4e5 bnez s1,118e <badarg+0x22> } exit(0); 11a8: 4501 li a0,0 11aa: 00004097 auipc ra,0x4 11ae: 552080e7 jalr 1362(ra) # 56fc <exit> 00000000000011b2 <copyinstr2>: { 11b2: 7155 addi sp,sp,-208 11b4: e586 sd ra,200(sp) 11b6: e1a2 sd s0,192(sp) 11b8: 0980 addi s0,sp,208 for(int i = 0; i < MAXPATH; i++) 11ba: f6840793 addi a5,s0,-152 11be: fe840693 addi a3,s0,-24 b[i] = 'x'; 11c2: 07800713 li a4,120 11c6: 00e78023 sb a4,0(a5) for(int i = 0; i < MAXPATH; i++) 11ca: 0785 addi a5,a5,1 11cc: fed79de3 bne a5,a3,11c6 <copyinstr2+0x14> b[MAXPATH] = '\0'; 11d0: fe040423 sb zero,-24(s0) int ret = unlink(b); 11d4: f6840513 addi a0,s0,-152 11d8: 00004097 auipc ra,0x4 11dc: 574080e7 jalr 1396(ra) # 574c <unlink> if(ret != -1){ 11e0: 57fd li a5,-1 11e2: 0ef51063 bne a0,a5,12c2 <copyinstr2+0x110> int fd = open(b, O_CREATE | O_WRONLY); 11e6: 20100593 li a1,513 11ea: f6840513 addi a0,s0,-152 11ee: 00004097 auipc ra,0x4 11f2: 54e080e7 jalr 1358(ra) # 573c <open> if(fd != -1){ 11f6: 57fd li a5,-1 11f8: 0ef51563 bne a0,a5,12e2 <copyinstr2+0x130> ret = link(b, b); 11fc: f6840593 addi a1,s0,-152 1200: 852e mv a0,a1 1202: 00004097 auipc ra,0x4 1206: 55a080e7 jalr 1370(ra) # 575c <link> if(ret != -1){ 120a: 57fd li a5,-1 120c: 0ef51b63 bne a0,a5,1302 <copyinstr2+0x150> char *args[] = { "xx", 0 }; 1210: 00006797 auipc a5,0x6 1214: 68878793 addi a5,a5,1672 # 7898 <malloc+0x1d56> 1218: f4f43c23 sd a5,-168(s0) 121c: f6043023 sd zero,-160(s0) ret = exec(b, args); 1220: f5840593 addi a1,s0,-168 1224: f6840513 addi a0,s0,-152 1228: 00004097 auipc ra,0x4 122c: 50c080e7 jalr 1292(ra) # 5734 <exec> if(ret != -1){ 1230: 57fd li a5,-1 1232: 0ef51963 bne a0,a5,1324 <copyinstr2+0x172> int pid = fork(); 1236: 00004097 auipc ra,0x4 123a: 4be080e7 jalr 1214(ra) # 56f4 <fork> if(pid < 0){ 123e: 10054363 bltz a0,1344 <copyinstr2+0x192> if(pid == 0){ 1242: 12051463 bnez a0,136a <copyinstr2+0x1b8> 1246: 00007797 auipc a5,0x7 124a: 27a78793 addi a5,a5,634 # 84c0 <big.0> 124e: 00008697 auipc a3,0x8 1252: 27268693 addi a3,a3,626 # 94c0 <__global_pointer$+0x918> big[i] = 'x'; 1256: 07800713 li a4,120 125a: 00e78023 sb a4,0(a5) for(int i = 0; i < PGSIZE; i++) 125e: 0785 addi a5,a5,1 1260: fed79de3 bne a5,a3,125a <copyinstr2+0xa8> big[PGSIZE] = '\0'; 1264: 00008797 auipc a5,0x8 1268: 24078e23 sb zero,604(a5) # 94c0 <__global_pointer$+0x918> char *args2[] = { big, big, big, 0 }; 126c: 00007797 auipc a5,0x7 1270: d3c78793 addi a5,a5,-708 # 7fa8 <malloc+0x2466> 1274: 6390 ld a2,0(a5) 1276: 6794 ld a3,8(a5) 1278: 6b98 ld a4,16(a5) 127a: 6f9c ld a5,24(a5) 127c: f2c43823 sd a2,-208(s0) 1280: f2d43c23 sd a3,-200(s0) 1284: f4e43023 sd a4,-192(s0) 1288: f4f43423 sd a5,-184(s0) ret = exec("echo", args2); 128c: f3040593 addi a1,s0,-208 1290: 00005517 auipc a0,0x5 1294: d0050513 addi a0,a0,-768 # 5f90 <malloc+0x44e> 1298: 00004097 auipc ra,0x4 129c: 49c080e7 jalr 1180(ra) # 5734 <exec> if(ret != -1){ 12a0: 57fd li a5,-1 12a2: 0af50e63 beq a0,a5,135e <copyinstr2+0x1ac> printf("exec(echo, BIG) returned %d, not -1\n", fd); 12a6: 55fd li a1,-1 12a8: 00005517 auipc a0,0x5 12ac: 4c850513 addi a0,a0,1224 # 6770 <malloc+0xc2e> 12b0: 00004097 auipc ra,0x4 12b4: 7d4080e7 jalr 2004(ra) # 5a84 <printf> exit(1); 12b8: 4505 li a0,1 12ba: 00004097 auipc ra,0x4 12be: 442080e7 jalr 1090(ra) # 56fc <exit> printf("unlink(%s) returned %d, not -1\n", b, ret); 12c2: 862a mv a2,a0 12c4: f6840593 addi a1,s0,-152 12c8: 00005517 auipc a0,0x5 12cc: 42050513 addi a0,a0,1056 # 66e8 <malloc+0xba6> 12d0: 00004097 auipc ra,0x4 12d4: 7b4080e7 jalr 1972(ra) # 5a84 <printf> exit(1); 12d8: 4505 li a0,1 12da: 00004097 auipc ra,0x4 12de: 422080e7 jalr 1058(ra) # 56fc <exit> printf("open(%s) returned %d, not -1\n", b, fd); 12e2: 862a mv a2,a0 12e4: f6840593 addi a1,s0,-152 12e8: 00005517 auipc a0,0x5 12ec: 42050513 addi a0,a0,1056 # 6708 <malloc+0xbc6> 12f0: 00004097 auipc ra,0x4 12f4: 794080e7 jalr 1940(ra) # 5a84 <printf> exit(1); 12f8: 4505 li a0,1 12fa: 00004097 auipc ra,0x4 12fe: 402080e7 jalr 1026(ra) # 56fc <exit> printf("link(%s, %s) returned %d, not -1\n", b, b, ret); 1302: 86aa mv a3,a0 1304: f6840613 addi a2,s0,-152 1308: 85b2 mv a1,a2 130a: 00005517 auipc a0,0x5 130e: 41e50513 addi a0,a0,1054 # 6728 <malloc+0xbe6> 1312: 00004097 auipc ra,0x4 1316: 772080e7 jalr 1906(ra) # 5a84 <printf> exit(1); 131a: 4505 li a0,1 131c: 00004097 auipc ra,0x4 1320: 3e0080e7 jalr 992(ra) # 56fc <exit> printf("exec(%s) returned %d, not -1\n", b, fd); 1324: 567d li a2,-1 1326: f6840593 addi a1,s0,-152 132a: 00005517 auipc a0,0x5 132e: 42650513 addi a0,a0,1062 # 6750 <malloc+0xc0e> 1332: 00004097 auipc ra,0x4 1336: 752080e7 jalr 1874(ra) # 5a84 <printf> exit(1); 133a: 4505 li a0,1 133c: 00004097 auipc ra,0x4 1340: 3c0080e7 jalr 960(ra) # 56fc <exit> printf("fork failed\n"); 1344: 00006517 auipc a0,0x6 1348: 88c50513 addi a0,a0,-1908 # 6bd0 <malloc+0x108e> 134c: 00004097 auipc ra,0x4 1350: 738080e7 jalr 1848(ra) # 5a84 <printf> exit(1); 1354: 4505 li a0,1 1356: 00004097 auipc ra,0x4 135a: 3a6080e7 jalr 934(ra) # 56fc <exit> exit(747); // OK 135e: 2eb00513 li a0,747 1362: 00004097 auipc ra,0x4 1366: 39a080e7 jalr 922(ra) # 56fc <exit> int st = 0; 136a: f4042a23 sw zero,-172(s0) wait(&st); 136e: f5440513 addi a0,s0,-172 1372: 00004097 auipc ra,0x4 1376: 392080e7 jalr 914(ra) # 5704 <wait> if(st != 747){ 137a: f5442703 lw a4,-172(s0) 137e: 2eb00793 li a5,747 1382: 00f71663 bne a4,a5,138e <copyinstr2+0x1dc> } 1386: 60ae ld ra,200(sp) 1388: 640e ld s0,192(sp) 138a: 6169 addi sp,sp,208 138c: 8082 ret printf("exec(echo, BIG) succeeded, should have failed\n"); 138e: 00005517 auipc a0,0x5 1392: 40a50513 addi a0,a0,1034 # 6798 <malloc+0xc56> 1396: 00004097 auipc ra,0x4 139a: 6ee080e7 jalr 1774(ra) # 5a84 <printf> exit(1); 139e: 4505 li a0,1 13a0: 00004097 auipc ra,0x4 13a4: 35c080e7 jalr 860(ra) # 56fc <exit> 00000000000013a8 <truncate3>: { 13a8: 7159 addi sp,sp,-112 13aa: f486 sd ra,104(sp) 13ac: f0a2 sd s0,96(sp) 13ae: eca6 sd s1,88(sp) 13b0: e8ca sd s2,80(sp) 13b2: e4ce sd s3,72(sp) 13b4: e0d2 sd s4,64(sp) 13b6: fc56 sd s5,56(sp) 13b8: 1880 addi s0,sp,112 13ba: 892a mv s2,a0 close(open("truncfile", O_CREATE|O_TRUNC|O_WRONLY)); 13bc: 60100593 li a1,1537 13c0: 00005517 auipc a0,0x5 13c4: c2850513 addi a0,a0,-984 # 5fe8 <malloc+0x4a6> 13c8: 00004097 auipc ra,0x4 13cc: 374080e7 jalr 884(ra) # 573c <open> 13d0: 00004097 auipc ra,0x4 13d4: 354080e7 jalr 852(ra) # 5724 <close> pid = fork(); 13d8: 00004097 auipc ra,0x4 13dc: 31c080e7 jalr 796(ra) # 56f4 <fork> if(pid < 0){ 13e0: 08054063 bltz a0,1460 <truncate3+0xb8> if(pid == 0){ 13e4: e969 bnez a0,14b6 <truncate3+0x10e> 13e6: 06400993 li s3,100 int fd = open("truncfile", O_WRONLY); 13ea: 00005a17 auipc s4,0x5 13ee: bfea0a13 addi s4,s4,-1026 # 5fe8 <malloc+0x4a6> int n = write(fd, "1234567890", 10); 13f2: 00005a97 auipc s5,0x5 13f6: 406a8a93 addi s5,s5,1030 # 67f8 <malloc+0xcb6> int fd = open("truncfile", O_WRONLY); 13fa: 4585 li a1,1 13fc: 8552 mv a0,s4 13fe: 00004097 auipc ra,0x4 1402: 33e080e7 jalr 830(ra) # 573c <open> 1406: 84aa mv s1,a0 if(fd < 0){ 1408: 06054a63 bltz a0,147c <truncate3+0xd4> int n = write(fd, "1234567890", 10); 140c: 4629 li a2,10 140e: 85d6 mv a1,s5 1410: 00004097 auipc ra,0x4 1414: 30c080e7 jalr 780(ra) # 571c <write> if(n != 10){ 1418: 47a9 li a5,10 141a: 06f51f63 bne a0,a5,1498 <truncate3+0xf0> close(fd); 141e: 8526 mv a0,s1 1420: 00004097 auipc ra,0x4 1424: 304080e7 jalr 772(ra) # 5724 <close> fd = open("truncfile", O_RDONLY); 1428: 4581 li a1,0 142a: 8552 mv a0,s4 142c: 00004097 auipc ra,0x4 1430: 310080e7 jalr 784(ra) # 573c <open> 1434: 84aa mv s1,a0 read(fd, buf, sizeof(buf)); 1436: 02000613 li a2,32 143a: f9840593 addi a1,s0,-104 143e: 00004097 auipc ra,0x4 1442: 2d6080e7 jalr 726(ra) # 5714 <read> close(fd); 1446: 8526 mv a0,s1 1448: 00004097 auipc ra,0x4 144c: 2dc080e7 jalr 732(ra) # 5724 <close> for(int i = 0; i < 100; i++){ 1450: 39fd addiw s3,s3,-1 1452: fa0994e3 bnez s3,13fa <truncate3+0x52> exit(0); 1456: 4501 li a0,0 1458: 00004097 auipc ra,0x4 145c: 2a4080e7 jalr 676(ra) # 56fc <exit> printf("%s: fork failed\n", s); 1460: 85ca mv a1,s2 1462: 00005517 auipc a0,0x5 1466: 36650513 addi a0,a0,870 # 67c8 <malloc+0xc86> 146a: 00004097 auipc ra,0x4 146e: 61a080e7 jalr 1562(ra) # 5a84 <printf> exit(1); 1472: 4505 li a0,1 1474: 00004097 auipc ra,0x4 1478: 288080e7 jalr 648(ra) # 56fc <exit> printf("%s: open failed\n", s); 147c: 85ca mv a1,s2 147e: 00005517 auipc a0,0x5 1482: 36250513 addi a0,a0,866 # 67e0 <malloc+0xc9e> 1486: 00004097 auipc ra,0x4 148a: 5fe080e7 jalr 1534(ra) # 5a84 <printf> exit(1); 148e: 4505 li a0,1 1490: 00004097 auipc ra,0x4 1494: 26c080e7 jalr 620(ra) # 56fc <exit> printf("%s: write got %d, expected 10\n", s, n); 1498: 862a mv a2,a0 149a: 85ca mv a1,s2 149c: 00005517 auipc a0,0x5 14a0: 36c50513 addi a0,a0,876 # 6808 <malloc+0xcc6> 14a4: 00004097 auipc ra,0x4 14a8: 5e0080e7 jalr 1504(ra) # 5a84 <printf> exit(1); 14ac: 4505 li a0,1 14ae: 00004097 auipc ra,0x4 14b2: 24e080e7 jalr 590(ra) # 56fc <exit> 14b6: 09600993 li s3,150 int fd = open("truncfile", O_CREATE|O_WRONLY|O_TRUNC); 14ba: 00005a17 auipc s4,0x5 14be: b2ea0a13 addi s4,s4,-1234 # 5fe8 <malloc+0x4a6> int n = write(fd, "xxx", 3); 14c2: 00005a97 auipc s5,0x5 14c6: 366a8a93 addi s5,s5,870 # 6828 <malloc+0xce6> int fd = open("truncfile", O_CREATE|O_WRONLY|O_TRUNC); 14ca: 60100593 li a1,1537 14ce: 8552 mv a0,s4 14d0: 00004097 auipc ra,0x4 14d4: 26c080e7 jalr 620(ra) # 573c <open> 14d8: 84aa mv s1,a0 if(fd < 0){ 14da: 04054763 bltz a0,1528 <truncate3+0x180> int n = write(fd, "xxx", 3); 14de: 460d li a2,3 14e0: 85d6 mv a1,s5 14e2: 00004097 auipc ra,0x4 14e6: 23a080e7 jalr 570(ra) # 571c <write> if(n != 3){ 14ea: 478d li a5,3 14ec: 04f51c63 bne a0,a5,1544 <truncate3+0x19c> close(fd); 14f0: 8526 mv a0,s1 14f2: 00004097 auipc ra,0x4 14f6: 232080e7 jalr 562(ra) # 5724 <close> for(int i = 0; i < 150; i++){ 14fa: 39fd addiw s3,s3,-1 14fc: fc0997e3 bnez s3,14ca <truncate3+0x122> wait(&xstatus); 1500: fbc40513 addi a0,s0,-68 1504: 00004097 auipc ra,0x4 1508: 200080e7 jalr 512(ra) # 5704 <wait> unlink("truncfile"); 150c: 00005517 auipc a0,0x5 1510: adc50513 addi a0,a0,-1316 # 5fe8 <malloc+0x4a6> 1514: 00004097 auipc ra,0x4 1518: 238080e7 jalr 568(ra) # 574c <unlink> exit(xstatus); 151c: fbc42503 lw a0,-68(s0) 1520: 00004097 auipc ra,0x4 1524: 1dc080e7 jalr 476(ra) # 56fc <exit> printf("%s: open failed\n", s); 1528: 85ca mv a1,s2 152a: 00005517 auipc a0,0x5 152e: 2b650513 addi a0,a0,694 # 67e0 <malloc+0xc9e> 1532: 00004097 auipc ra,0x4 1536: 552080e7 jalr 1362(ra) # 5a84 <printf> exit(1); 153a: 4505 li a0,1 153c: 00004097 auipc ra,0x4 1540: 1c0080e7 jalr 448(ra) # 56fc <exit> printf("%s: write got %d, expected 3\n", s, n); 1544: 862a mv a2,a0 1546: 85ca mv a1,s2 1548: 00005517 auipc a0,0x5 154c: 2e850513 addi a0,a0,744 # 6830 <malloc+0xcee> 1550: 00004097 auipc ra,0x4 1554: 534080e7 jalr 1332(ra) # 5a84 <printf> exit(1); 1558: 4505 li a0,1 155a: 00004097 auipc ra,0x4 155e: 1a2080e7 jalr 418(ra) # 56fc <exit> 0000000000001562 <exectest>: { 1562: 715d addi sp,sp,-80 1564: e486 sd ra,72(sp) 1566: e0a2 sd s0,64(sp) 1568: fc26 sd s1,56(sp) 156a: f84a sd s2,48(sp) 156c: 0880 addi s0,sp,80 156e: 892a mv s2,a0 char *echoargv[] = { "echo", "OK", 0 }; 1570: 00005797 auipc a5,0x5 1574: a2078793 addi a5,a5,-1504 # 5f90 <malloc+0x44e> 1578: fcf43023 sd a5,-64(s0) 157c: 00005797 auipc a5,0x5 1580: 2d478793 addi a5,a5,724 # 6850 <malloc+0xd0e> 1584: fcf43423 sd a5,-56(s0) 1588: fc043823 sd zero,-48(s0) unlink("echo-ok"); 158c: 00005517 auipc a0,0x5 1590: 2cc50513 addi a0,a0,716 # 6858 <malloc+0xd16> 1594: 00004097 auipc ra,0x4 1598: 1b8080e7 jalr 440(ra) # 574c <unlink> pid = fork(); 159c: 00004097 auipc ra,0x4 15a0: 158080e7 jalr 344(ra) # 56f4 <fork> if(pid < 0) { 15a4: 04054663 bltz a0,15f0 <exectest+0x8e> 15a8: 84aa mv s1,a0 if(pid == 0) { 15aa: e959 bnez a0,1640 <exectest+0xde> close(1); 15ac: 4505 li a0,1 15ae: 00004097 auipc ra,0x4 15b2: 176080e7 jalr 374(ra) # 5724 <close> fd = open("echo-ok", O_CREATE|O_WRONLY); 15b6: 20100593 li a1,513 15ba: 00005517 auipc a0,0x5 15be: 29e50513 addi a0,a0,670 # 6858 <malloc+0xd16> 15c2: 00004097 auipc ra,0x4 15c6: 17a080e7 jalr 378(ra) # 573c <open> if(fd < 0) { 15ca: 04054163 bltz a0,160c <exectest+0xaa> if(fd != 1) { 15ce: 4785 li a5,1 15d0: 04f50c63 beq a0,a5,1628 <exectest+0xc6> printf("%s: wrong fd\n", s); 15d4: 85ca mv a1,s2 15d6: 00005517 auipc a0,0x5 15da: 2a250513 addi a0,a0,674 # 6878 <malloc+0xd36> 15de: 00004097 auipc ra,0x4 15e2: 4a6080e7 jalr 1190(ra) # 5a84 <printf> exit(1); 15e6: 4505 li a0,1 15e8: 00004097 auipc ra,0x4 15ec: 114080e7 jalr 276(ra) # 56fc <exit> printf("%s: fork failed\n", s); 15f0: 85ca mv a1,s2 15f2: 00005517 auipc a0,0x5 15f6: 1d650513 addi a0,a0,470 # 67c8 <malloc+0xc86> 15fa: 00004097 auipc ra,0x4 15fe: 48a080e7 jalr 1162(ra) # 5a84 <printf> exit(1); 1602: 4505 li a0,1 1604: 00004097 auipc ra,0x4 1608: 0f8080e7 jalr 248(ra) # 56fc <exit> printf("%s: create failed\n", s); 160c: 85ca mv a1,s2 160e: 00005517 auipc a0,0x5 1612: 25250513 addi a0,a0,594 # 6860 <malloc+0xd1e> 1616: 00004097 auipc ra,0x4 161a: 46e080e7 jalr 1134(ra) # 5a84 <printf> exit(1); 161e: 4505 li a0,1 1620: 00004097 auipc ra,0x4 1624: 0dc080e7 jalr 220(ra) # 56fc <exit> if(exec("echo", echoargv) < 0){ 1628: fc040593 addi a1,s0,-64 162c: 00005517 auipc a0,0x5 1630: 96450513 addi a0,a0,-1692 # 5f90 <malloc+0x44e> 1634: 00004097 auipc ra,0x4 1638: 100080e7 jalr 256(ra) # 5734 <exec> 163c: 02054163 bltz a0,165e <exectest+0xfc> if (wait(&xstatus) != pid) { 1640: fdc40513 addi a0,s0,-36 1644: 00004097 auipc ra,0x4 1648: 0c0080e7 jalr 192(ra) # 5704 <wait> 164c: 02951763 bne a0,s1,167a <exectest+0x118> if(xstatus != 0) 1650: fdc42503 lw a0,-36(s0) 1654: cd0d beqz a0,168e <exectest+0x12c> exit(xstatus); 1656: 00004097 auipc ra,0x4 165a: 0a6080e7 jalr 166(ra) # 56fc <exit> printf("%s: exec echo failed\n", s); 165e: 85ca mv a1,s2 1660: 00005517 auipc a0,0x5 1664: 22850513 addi a0,a0,552 # 6888 <malloc+0xd46> 1668: 00004097 auipc ra,0x4 166c: 41c080e7 jalr 1052(ra) # 5a84 <printf> exit(1); 1670: 4505 li a0,1 1672: 00004097 auipc ra,0x4 1676: 08a080e7 jalr 138(ra) # 56fc <exit> printf("%s: wait failed!\n", s); 167a: 85ca mv a1,s2 167c: 00005517 auipc a0,0x5 1680: 22450513 addi a0,a0,548 # 68a0 <malloc+0xd5e> 1684: 00004097 auipc ra,0x4 1688: 400080e7 jalr 1024(ra) # 5a84 <printf> 168c: b7d1 j 1650 <exectest+0xee> fd = open("echo-ok", O_RDONLY); 168e: 4581 li a1,0 1690: 00005517 auipc a0,0x5 1694: 1c850513 addi a0,a0,456 # 6858 <malloc+0xd16> 1698: 00004097 auipc ra,0x4 169c: 0a4080e7 jalr 164(ra) # 573c <open> if(fd < 0) { 16a0: 02054a63 bltz a0,16d4 <exectest+0x172> if (read(fd, buf, 2) != 2) { 16a4: 4609 li a2,2 16a6: fb840593 addi a1,s0,-72 16aa: 00004097 auipc ra,0x4 16ae: 06a080e7 jalr 106(ra) # 5714 <read> 16b2: 4789 li a5,2 16b4: 02f50e63 beq a0,a5,16f0 <exectest+0x18e> printf("%s: read failed\n", s); 16b8: 85ca mv a1,s2 16ba: 00005517 auipc a0,0x5 16be: c6650513 addi a0,a0,-922 # 6320 <malloc+0x7de> 16c2: 00004097 auipc ra,0x4 16c6: 3c2080e7 jalr 962(ra) # 5a84 <printf> exit(1); 16ca: 4505 li a0,1 16cc: 00004097 auipc ra,0x4 16d0: 030080e7 jalr 48(ra) # 56fc <exit> printf("%s: open failed\n", s); 16d4: 85ca mv a1,s2 16d6: 00005517 auipc a0,0x5 16da: 10a50513 addi a0,a0,266 # 67e0 <malloc+0xc9e> 16de: 00004097 auipc ra,0x4 16e2: 3a6080e7 jalr 934(ra) # 5a84 <printf> exit(1); 16e6: 4505 li a0,1 16e8: 00004097 auipc ra,0x4 16ec: 014080e7 jalr 20(ra) # 56fc <exit> unlink("echo-ok"); 16f0: 00005517 auipc a0,0x5 16f4: 16850513 addi a0,a0,360 # 6858 <malloc+0xd16> 16f8: 00004097 auipc ra,0x4 16fc: 054080e7 jalr 84(ra) # 574c <unlink> if(buf[0] == 'O' && buf[1] == 'K') 1700: fb844703 lbu a4,-72(s0) 1704: 04f00793 li a5,79 1708: 00f71863 bne a4,a5,1718 <exectest+0x1b6> 170c: fb944703 lbu a4,-71(s0) 1710: 04b00793 li a5,75 1714: 02f70063 beq a4,a5,1734 <exectest+0x1d2> printf("%s: wrong output\n", s); 1718: 85ca mv a1,s2 171a: 00005517 auipc a0,0x5 171e: 19e50513 addi a0,a0,414 # 68b8 <malloc+0xd76> 1722: 00004097 auipc ra,0x4 1726: 362080e7 jalr 866(ra) # 5a84 <printf> exit(1); 172a: 4505 li a0,1 172c: 00004097 auipc ra,0x4 1730: fd0080e7 jalr -48(ra) # 56fc <exit> exit(0); 1734: 4501 li a0,0 1736: 00004097 auipc ra,0x4 173a: fc6080e7 jalr -58(ra) # 56fc <exit> 000000000000173e <pipe1>: { 173e: 711d addi sp,sp,-96 1740: ec86 sd ra,88(sp) 1742: e8a2 sd s0,80(sp) 1744: e4a6 sd s1,72(sp) 1746: e0ca sd s2,64(sp) 1748: fc4e sd s3,56(sp) 174a: f852 sd s4,48(sp) 174c: f456 sd s5,40(sp) 174e: f05a sd s6,32(sp) 1750: ec5e sd s7,24(sp) 1752: 1080 addi s0,sp,96 1754: 892a mv s2,a0 if(pipe(fds) != 0){ 1756: fa840513 addi a0,s0,-88 175a: 00004097 auipc ra,0x4 175e: fb2080e7 jalr -78(ra) # 570c <pipe> 1762: ed25 bnez a0,17da <pipe1+0x9c> 1764: 84aa mv s1,a0 pid = fork(); 1766: 00004097 auipc ra,0x4 176a: f8e080e7 jalr -114(ra) # 56f4 <fork> 176e: 8a2a mv s4,a0 if(pid == 0){ 1770: c159 beqz a0,17f6 <pipe1+0xb8> } else if(pid > 0){ 1772: 16a05e63 blez a0,18ee <pipe1+0x1b0> close(fds[1]); 1776: fac42503 lw a0,-84(s0) 177a: 00004097 auipc ra,0x4 177e: faa080e7 jalr -86(ra) # 5724 <close> total = 0; 1782: 8a26 mv s4,s1 cc = 1; 1784: 4985 li s3,1 while((n = read(fds[0], buf, cc)) > 0){ 1786: 0000aa97 auipc s5,0xa 178a: 452a8a93 addi s5,s5,1106 # bbd8 <buf> if(cc > sizeof(buf)) 178e: 6b0d lui s6,0x3 while((n = read(fds[0], buf, cc)) > 0){ 1790: 864e mv a2,s3 1792: 85d6 mv a1,s5 1794: fa842503 lw a0,-88(s0) 1798: 00004097 auipc ra,0x4 179c: f7c080e7 jalr -132(ra) # 5714 <read> 17a0: 10a05263 blez a0,18a4 <pipe1+0x166> for(i = 0; i < n; i++){ 17a4: 0000a717 auipc a4,0xa 17a8: 43470713 addi a4,a4,1076 # bbd8 <buf> 17ac: 00a4863b addw a2,s1,a0 if((buf[i] & 0xff) != (seq++ & 0xff)){ 17b0: 00074683 lbu a3,0(a4) 17b4: 0ff4f793 andi a5,s1,255 17b8: 2485 addiw s1,s1,1 17ba: 0cf69163 bne a3,a5,187c <pipe1+0x13e> for(i = 0; i < n; i++){ 17be: 0705 addi a4,a4,1 17c0: fec498e3 bne s1,a2,17b0 <pipe1+0x72> total += n; 17c4: 00aa0a3b addw s4,s4,a0 cc = cc * 2; 17c8: 0019979b slliw a5,s3,0x1 17cc: 0007899b sext.w s3,a5 if(cc > sizeof(buf)) 17d0: 013b7363 bgeu s6,s3,17d6 <pipe1+0x98> cc = sizeof(buf); 17d4: 89da mv s3,s6 if((buf[i] & 0xff) != (seq++ & 0xff)){ 17d6: 84b2 mv s1,a2 17d8: bf65 j 1790 <pipe1+0x52> printf("%s: pipe() failed\n", s); 17da: 85ca mv a1,s2 17dc: 00005517 auipc a0,0x5 17e0: 0f450513 addi a0,a0,244 # 68d0 <malloc+0xd8e> 17e4: 00004097 auipc ra,0x4 17e8: 2a0080e7 jalr 672(ra) # 5a84 <printf> exit(1); 17ec: 4505 li a0,1 17ee: 00004097 auipc ra,0x4 17f2: f0e080e7 jalr -242(ra) # 56fc <exit> close(fds[0]); 17f6: fa842503 lw a0,-88(s0) 17fa: 00004097 auipc ra,0x4 17fe: f2a080e7 jalr -214(ra) # 5724 <close> for(n = 0; n < N; n++){ 1802: 0000ab17 auipc s6,0xa 1806: 3d6b0b13 addi s6,s6,982 # bbd8 <buf> 180a: 416004bb negw s1,s6 180e: 0ff4f493 andi s1,s1,255 1812: 409b0993 addi s3,s6,1033 if(write(fds[1], buf, SZ) != SZ){ 1816: 8bda mv s7,s6 for(n = 0; n < N; n++){ 1818: 6a85 lui s5,0x1 181a: 42da8a93 addi s5,s5,1069 # 142d <truncate3+0x85> { 181e: 87da mv a5,s6 buf[i] = seq++; 1820: 0097873b addw a4,a5,s1 1824: 00e78023 sb a4,0(a5) for(i = 0; i < SZ; i++) 1828: 0785 addi a5,a5,1 182a: fef99be3 bne s3,a5,1820 <pipe1+0xe2> buf[i] = seq++; 182e: 409a0a1b addiw s4,s4,1033 if(write(fds[1], buf, SZ) != SZ){ 1832: 40900613 li a2,1033 1836: 85de mv a1,s7 1838: fac42503 lw a0,-84(s0) 183c: 00004097 auipc ra,0x4 1840: ee0080e7 jalr -288(ra) # 571c <write> 1844: 40900793 li a5,1033 1848: 00f51c63 bne a0,a5,1860 <pipe1+0x122> for(n = 0; n < N; n++){ 184c: 24a5 addiw s1,s1,9 184e: 0ff4f493 andi s1,s1,255 1852: fd5a16e3 bne s4,s5,181e <pipe1+0xe0> exit(0); 1856: 4501 li a0,0 1858: 00004097 auipc ra,0x4 185c: ea4080e7 jalr -348(ra) # 56fc <exit> printf("%s: pipe1 oops 1\n", s); 1860: 85ca mv a1,s2 1862: 00005517 auipc a0,0x5 1866: 08650513 addi a0,a0,134 # 68e8 <malloc+0xda6> 186a: 00004097 auipc ra,0x4 186e: 21a080e7 jalr 538(ra) # 5a84 <printf> exit(1); 1872: 4505 li a0,1 1874: 00004097 auipc ra,0x4 1878: e88080e7 jalr -376(ra) # 56fc <exit> printf("%s: pipe1 oops 2\n", s); 187c: 85ca mv a1,s2 187e: 00005517 auipc a0,0x5 1882: 08250513 addi a0,a0,130 # 6900 <malloc+0xdbe> 1886: 00004097 auipc ra,0x4 188a: 1fe080e7 jalr 510(ra) # 5a84 <printf> } 188e: 60e6 ld ra,88(sp) 1890: 6446 ld s0,80(sp) 1892: 64a6 ld s1,72(sp) 1894: 6906 ld s2,64(sp) 1896: 79e2 ld s3,56(sp) 1898: 7a42 ld s4,48(sp) 189a: 7aa2 ld s5,40(sp) 189c: 7b02 ld s6,32(sp) 189e: 6be2 ld s7,24(sp) 18a0: 6125 addi sp,sp,96 18a2: 8082 ret if(total != N * SZ){ 18a4: 6785 lui a5,0x1 18a6: 42d78793 addi a5,a5,1069 # 142d <truncate3+0x85> 18aa: 02fa0063 beq s4,a5,18ca <pipe1+0x18c> printf("%s: pipe1 oops 3 total %d\n", total); 18ae: 85d2 mv a1,s4 18b0: 00005517 auipc a0,0x5 18b4: 06850513 addi a0,a0,104 # 6918 <malloc+0xdd6> 18b8: 00004097 auipc ra,0x4 18bc: 1cc080e7 jalr 460(ra) # 5a84 <printf> exit(1); 18c0: 4505 li a0,1 18c2: 00004097 auipc ra,0x4 18c6: e3a080e7 jalr -454(ra) # 56fc <exit> close(fds[0]); 18ca: fa842503 lw a0,-88(s0) 18ce: 00004097 auipc ra,0x4 18d2: e56080e7 jalr -426(ra) # 5724 <close> wait(&xstatus); 18d6: fa440513 addi a0,s0,-92 18da: 00004097 auipc ra,0x4 18de: e2a080e7 jalr -470(ra) # 5704 <wait> exit(xstatus); 18e2: fa442503 lw a0,-92(s0) 18e6: 00004097 auipc ra,0x4 18ea: e16080e7 jalr -490(ra) # 56fc <exit> printf("%s: fork() failed\n", s); 18ee: 85ca mv a1,s2 18f0: 00005517 auipc a0,0x5 18f4: 04850513 addi a0,a0,72 # 6938 <malloc+0xdf6> 18f8: 00004097 auipc ra,0x4 18fc: 18c080e7 jalr 396(ra) # 5a84 <printf> exit(1); 1900: 4505 li a0,1 1902: 00004097 auipc ra,0x4 1906: dfa080e7 jalr -518(ra) # 56fc <exit> 000000000000190a <exitwait>: { 190a: 7139 addi sp,sp,-64 190c: fc06 sd ra,56(sp) 190e: f822 sd s0,48(sp) 1910: f426 sd s1,40(sp) 1912: f04a sd s2,32(sp) 1914: ec4e sd s3,24(sp) 1916: e852 sd s4,16(sp) 1918: 0080 addi s0,sp,64 191a: 8a2a mv s4,a0 for(i = 0; i < 100; i++){ 191c: 4901 li s2,0 191e: 06400993 li s3,100 pid = fork(); 1922: 00004097 auipc ra,0x4 1926: dd2080e7 jalr -558(ra) # 56f4 <fork> 192a: 84aa mv s1,a0 if(pid < 0){ 192c: 02054a63 bltz a0,1960 <exitwait+0x56> if(pid){ 1930: c151 beqz a0,19b4 <exitwait+0xaa> if(wait(&xstate) != pid){ 1932: fcc40513 addi a0,s0,-52 1936: 00004097 auipc ra,0x4 193a: dce080e7 jalr -562(ra) # 5704 <wait> 193e: 02951f63 bne a0,s1,197c <exitwait+0x72> if(i != xstate) { 1942: fcc42783 lw a5,-52(s0) 1946: 05279963 bne a5,s2,1998 <exitwait+0x8e> for(i = 0; i < 100; i++){ 194a: 2905 addiw s2,s2,1 194c: fd391be3 bne s2,s3,1922 <exitwait+0x18> } 1950: 70e2 ld ra,56(sp) 1952: 7442 ld s0,48(sp) 1954: 74a2 ld s1,40(sp) 1956: 7902 ld s2,32(sp) 1958: 69e2 ld s3,24(sp) 195a: 6a42 ld s4,16(sp) 195c: 6121 addi sp,sp,64 195e: 8082 ret printf("%s: fork failed\n", s); 1960: 85d2 mv a1,s4 1962: 00005517 auipc a0,0x5 1966: e6650513 addi a0,a0,-410 # 67c8 <malloc+0xc86> 196a: 00004097 auipc ra,0x4 196e: 11a080e7 jalr 282(ra) # 5a84 <printf> exit(1); 1972: 4505 li a0,1 1974: 00004097 auipc ra,0x4 1978: d88080e7 jalr -632(ra) # 56fc <exit> printf("%s: wait wrong pid\n", s); 197c: 85d2 mv a1,s4 197e: 00005517 auipc a0,0x5 1982: fd250513 addi a0,a0,-46 # 6950 <malloc+0xe0e> 1986: 00004097 auipc ra,0x4 198a: 0fe080e7 jalr 254(ra) # 5a84 <printf> exit(1); 198e: 4505 li a0,1 1990: 00004097 auipc ra,0x4 1994: d6c080e7 jalr -660(ra) # 56fc <exit> printf("%s: wait wrong exit status\n", s); 1998: 85d2 mv a1,s4 199a: 00005517 auipc a0,0x5 199e: fce50513 addi a0,a0,-50 # 6968 <malloc+0xe26> 19a2: 00004097 auipc ra,0x4 19a6: 0e2080e7 jalr 226(ra) # 5a84 <printf> exit(1); 19aa: 4505 li a0,1 19ac: 00004097 auipc ra,0x4 19b0: d50080e7 jalr -688(ra) # 56fc <exit> exit(i); 19b4: 854a mv a0,s2 19b6: 00004097 auipc ra,0x4 19ba: d46080e7 jalr -698(ra) # 56fc <exit> 00000000000019be <twochildren>: { 19be: 1101 addi sp,sp,-32 19c0: ec06 sd ra,24(sp) 19c2: e822 sd s0,16(sp) 19c4: e426 sd s1,8(sp) 19c6: e04a sd s2,0(sp) 19c8: 1000 addi s0,sp,32 19ca: 892a mv s2,a0 19cc: 3e800493 li s1,1000 int pid1 = fork(); 19d0: 00004097 auipc ra,0x4 19d4: d24080e7 jalr -732(ra) # 56f4 <fork> if(pid1 < 0){ 19d8: 02054c63 bltz a0,1a10 <twochildren+0x52> if(pid1 == 0){ 19dc: c921 beqz a0,1a2c <twochildren+0x6e> int pid2 = fork(); 19de: 00004097 auipc ra,0x4 19e2: d16080e7 jalr -746(ra) # 56f4 <fork> if(pid2 < 0){ 19e6: 04054763 bltz a0,1a34 <twochildren+0x76> if(pid2 == 0){ 19ea: c13d beqz a0,1a50 <twochildren+0x92> wait(0); 19ec: 4501 li a0,0 19ee: 00004097 auipc ra,0x4 19f2: d16080e7 jalr -746(ra) # 5704 <wait> wait(0); 19f6: 4501 li a0,0 19f8: 00004097 auipc ra,0x4 19fc: d0c080e7 jalr -756(ra) # 5704 <wait> for(int i = 0; i < 1000; i++){ 1a00: 34fd addiw s1,s1,-1 1a02: f4f9 bnez s1,19d0 <twochildren+0x12> } 1a04: 60e2 ld ra,24(sp) 1a06: 6442 ld s0,16(sp) 1a08: 64a2 ld s1,8(sp) 1a0a: 6902 ld s2,0(sp) 1a0c: 6105 addi sp,sp,32 1a0e: 8082 ret printf("%s: fork failed\n", s); 1a10: 85ca mv a1,s2 1a12: 00005517 auipc a0,0x5 1a16: db650513 addi a0,a0,-586 # 67c8 <malloc+0xc86> 1a1a: 00004097 auipc ra,0x4 1a1e: 06a080e7 jalr 106(ra) # 5a84 <printf> exit(1); 1a22: 4505 li a0,1 1a24: 00004097 auipc ra,0x4 1a28: cd8080e7 jalr -808(ra) # 56fc <exit> exit(0); 1a2c: 00004097 auipc ra,0x4 1a30: cd0080e7 jalr -816(ra) # 56fc <exit> printf("%s: fork failed\n", s); 1a34: 85ca mv a1,s2 1a36: 00005517 auipc a0,0x5 1a3a: d9250513 addi a0,a0,-622 # 67c8 <malloc+0xc86> 1a3e: 00004097 auipc ra,0x4 1a42: 046080e7 jalr 70(ra) # 5a84 <printf> exit(1); 1a46: 4505 li a0,1 1a48: 00004097 auipc ra,0x4 1a4c: cb4080e7 jalr -844(ra) # 56fc <exit> exit(0); 1a50: 00004097 auipc ra,0x4 1a54: cac080e7 jalr -852(ra) # 56fc <exit> 0000000000001a58 <forkfork>: { 1a58: 7179 addi sp,sp,-48 1a5a: f406 sd ra,40(sp) 1a5c: f022 sd s0,32(sp) 1a5e: ec26 sd s1,24(sp) 1a60: 1800 addi s0,sp,48 1a62: 84aa mv s1,a0 int pid = fork(); 1a64: 00004097 auipc ra,0x4 1a68: c90080e7 jalr -880(ra) # 56f4 <fork> if(pid < 0){ 1a6c: 04054163 bltz a0,1aae <forkfork+0x56> if(pid == 0){ 1a70: cd29 beqz a0,1aca <forkfork+0x72> int pid = fork(); 1a72: 00004097 auipc ra,0x4 1a76: c82080e7 jalr -894(ra) # 56f4 <fork> if(pid < 0){ 1a7a: 02054a63 bltz a0,1aae <forkfork+0x56> if(pid == 0){ 1a7e: c531 beqz a0,1aca <forkfork+0x72> wait(&xstatus); 1a80: fdc40513 addi a0,s0,-36 1a84: 00004097 auipc ra,0x4 1a88: c80080e7 jalr -896(ra) # 5704 <wait> if(xstatus != 0) { 1a8c: fdc42783 lw a5,-36(s0) 1a90: ebbd bnez a5,1b06 <forkfork+0xae> wait(&xstatus); 1a92: fdc40513 addi a0,s0,-36 1a96: 00004097 auipc ra,0x4 1a9a: c6e080e7 jalr -914(ra) # 5704 <wait> if(xstatus != 0) { 1a9e: fdc42783 lw a5,-36(s0) 1aa2: e3b5 bnez a5,1b06 <forkfork+0xae> } 1aa4: 70a2 ld ra,40(sp) 1aa6: 7402 ld s0,32(sp) 1aa8: 64e2 ld s1,24(sp) 1aaa: 6145 addi sp,sp,48 1aac: 8082 ret printf("%s: fork failed", s); 1aae: 85a6 mv a1,s1 1ab0: 00005517 auipc a0,0x5 1ab4: ed850513 addi a0,a0,-296 # 6988 <malloc+0xe46> 1ab8: 00004097 auipc ra,0x4 1abc: fcc080e7 jalr -52(ra) # 5a84 <printf> exit(1); 1ac0: 4505 li a0,1 1ac2: 00004097 auipc ra,0x4 1ac6: c3a080e7 jalr -966(ra) # 56fc <exit> { 1aca: 0c800493 li s1,200 int pid1 = fork(); 1ace: 00004097 auipc ra,0x4 1ad2: c26080e7 jalr -986(ra) # 56f4 <fork> if(pid1 < 0){ 1ad6: 00054f63 bltz a0,1af4 <forkfork+0x9c> if(pid1 == 0){ 1ada: c115 beqz a0,1afe <forkfork+0xa6> wait(0); 1adc: 4501 li a0,0 1ade: 00004097 auipc ra,0x4 1ae2: c26080e7 jalr -986(ra) # 5704 <wait> for(int j = 0; j < 200; j++){ 1ae6: 34fd addiw s1,s1,-1 1ae8: f0fd bnez s1,1ace <forkfork+0x76> exit(0); 1aea: 4501 li a0,0 1aec: 00004097 auipc ra,0x4 1af0: c10080e7 jalr -1008(ra) # 56fc <exit> exit(1); 1af4: 4505 li a0,1 1af6: 00004097 auipc ra,0x4 1afa: c06080e7 jalr -1018(ra) # 56fc <exit> exit(0); 1afe: 00004097 auipc ra,0x4 1b02: bfe080e7 jalr -1026(ra) # 56fc <exit> printf("%s: fork in child failed", s); 1b06: 85a6 mv a1,s1 1b08: 00005517 auipc a0,0x5 1b0c: e9050513 addi a0,a0,-368 # 6998 <malloc+0xe56> 1b10: 00004097 auipc ra,0x4 1b14: f74080e7 jalr -140(ra) # 5a84 <printf> exit(1); 1b18: 4505 li a0,1 1b1a: 00004097 auipc ra,0x4 1b1e: be2080e7 jalr -1054(ra) # 56fc <exit> 0000000000001b22 <reparent2>: { 1b22: 1101 addi sp,sp,-32 1b24: ec06 sd ra,24(sp) 1b26: e822 sd s0,16(sp) 1b28: e426 sd s1,8(sp) 1b2a: 1000 addi s0,sp,32 1b2c: 32000493 li s1,800 int pid1 = fork(); 1b30: 00004097 auipc ra,0x4 1b34: bc4080e7 jalr -1084(ra) # 56f4 <fork> if(pid1 < 0){ 1b38: 00054f63 bltz a0,1b56 <reparent2+0x34> if(pid1 == 0){ 1b3c: c915 beqz a0,1b70 <reparent2+0x4e> wait(0); 1b3e: 4501 li a0,0 1b40: 00004097 auipc ra,0x4 1b44: bc4080e7 jalr -1084(ra) # 5704 <wait> for(int i = 0; i < 800; i++){ 1b48: 34fd addiw s1,s1,-1 1b4a: f0fd bnez s1,1b30 <reparent2+0xe> exit(0); 1b4c: 4501 li a0,0 1b4e: 00004097 auipc ra,0x4 1b52: bae080e7 jalr -1106(ra) # 56fc <exit> printf("fork failed\n"); 1b56: 00005517 auipc a0,0x5 1b5a: 07a50513 addi a0,a0,122 # 6bd0 <malloc+0x108e> 1b5e: 00004097 auipc ra,0x4 1b62: f26080e7 jalr -218(ra) # 5a84 <printf> exit(1); 1b66: 4505 li a0,1 1b68: 00004097 auipc ra,0x4 1b6c: b94080e7 jalr -1132(ra) # 56fc <exit> fork(); 1b70: 00004097 auipc ra,0x4 1b74: b84080e7 jalr -1148(ra) # 56f4 <fork> fork(); 1b78: 00004097 auipc ra,0x4 1b7c: b7c080e7 jalr -1156(ra) # 56f4 <fork> exit(0); 1b80: 4501 li a0,0 1b82: 00004097 auipc ra,0x4 1b86: b7a080e7 jalr -1158(ra) # 56fc <exit> 0000000000001b8a <createdelete>: { 1b8a: 7175 addi sp,sp,-144 1b8c: e506 sd ra,136(sp) 1b8e: e122 sd s0,128(sp) 1b90: fca6 sd s1,120(sp) 1b92: f8ca sd s2,112(sp) 1b94: f4ce sd s3,104(sp) 1b96: f0d2 sd s4,96(sp) 1b98: ecd6 sd s5,88(sp) 1b9a: e8da sd s6,80(sp) 1b9c: e4de sd s7,72(sp) 1b9e: e0e2 sd s8,64(sp) 1ba0: fc66 sd s9,56(sp) 1ba2: 0900 addi s0,sp,144 1ba4: 8caa mv s9,a0 for(pi = 0; pi < NCHILD; pi++){ 1ba6: 4901 li s2,0 1ba8: 4991 li s3,4 pid = fork(); 1baa: 00004097 auipc ra,0x4 1bae: b4a080e7 jalr -1206(ra) # 56f4 <fork> 1bb2: 84aa mv s1,a0 if(pid < 0){ 1bb4: 02054f63 bltz a0,1bf2 <createdelete+0x68> if(pid == 0){ 1bb8: c939 beqz a0,1c0e <createdelete+0x84> for(pi = 0; pi < NCHILD; pi++){ 1bba: 2905 addiw s2,s2,1 1bbc: ff3917e3 bne s2,s3,1baa <createdelete+0x20> 1bc0: 4491 li s1,4 wait(&xstatus); 1bc2: f7c40513 addi a0,s0,-132 1bc6: 00004097 auipc ra,0x4 1bca: b3e080e7 jalr -1218(ra) # 5704 <wait> if(xstatus != 0) 1bce: f7c42903 lw s2,-132(s0) 1bd2: 0e091263 bnez s2,1cb6 <createdelete+0x12c> for(pi = 0; pi < NCHILD; pi++){ 1bd6: 34fd addiw s1,s1,-1 1bd8: f4ed bnez s1,1bc2 <createdelete+0x38> name[0] = name[1] = name[2] = 0; 1bda: f8040123 sb zero,-126(s0) 1bde: 03000993 li s3,48 1be2: 5a7d li s4,-1 1be4: 07000c13 li s8,112 } else if((i >= 1 && i < N/2) && fd >= 0){ 1be8: 4b21 li s6,8 if((i == 0 || i >= N/2) && fd < 0){ 1bea: 4ba5 li s7,9 for(pi = 0; pi < NCHILD; pi++){ 1bec: 07400a93 li s5,116 1bf0: a29d j 1d56 <createdelete+0x1cc> printf("fork failed\n", s); 1bf2: 85e6 mv a1,s9 1bf4: 00005517 auipc a0,0x5 1bf8: fdc50513 addi a0,a0,-36 # 6bd0 <malloc+0x108e> 1bfc: 00004097 auipc ra,0x4 1c00: e88080e7 jalr -376(ra) # 5a84 <printf> exit(1); 1c04: 4505 li a0,1 1c06: 00004097 auipc ra,0x4 1c0a: af6080e7 jalr -1290(ra) # 56fc <exit> name[0] = 'p' + pi; 1c0e: 0709091b addiw s2,s2,112 1c12: f9240023 sb s2,-128(s0) name[2] = '\0'; 1c16: f8040123 sb zero,-126(s0) for(i = 0; i < N; i++){ 1c1a: 4951 li s2,20 1c1c: a015 j 1c40 <createdelete+0xb6> printf("%s: create failed\n", s); 1c1e: 85e6 mv a1,s9 1c20: 00005517 auipc a0,0x5 1c24: c4050513 addi a0,a0,-960 # 6860 <malloc+0xd1e> 1c28: 00004097 auipc ra,0x4 1c2c: e5c080e7 jalr -420(ra) # 5a84 <printf> exit(1); 1c30: 4505 li a0,1 1c32: 00004097 auipc ra,0x4 1c36: aca080e7 jalr -1334(ra) # 56fc <exit> for(i = 0; i < N; i++){ 1c3a: 2485 addiw s1,s1,1 1c3c: 07248863 beq s1,s2,1cac <createdelete+0x122> name[1] = '0' + i; 1c40: 0304879b addiw a5,s1,48 1c44: f8f400a3 sb a5,-127(s0) fd = open(name, O_CREATE | O_RDWR); 1c48: 20200593 li a1,514 1c4c: f8040513 addi a0,s0,-128 1c50: 00004097 auipc ra,0x4 1c54: aec080e7 jalr -1300(ra) # 573c <open> if(fd < 0){ 1c58: fc0543e3 bltz a0,1c1e <createdelete+0x94> close(fd); 1c5c: 00004097 auipc ra,0x4 1c60: ac8080e7 jalr -1336(ra) # 5724 <close> if(i > 0 && (i % 2 ) == 0){ 1c64: fc905be3 blez s1,1c3a <createdelete+0xb0> 1c68: 0014f793 andi a5,s1,1 1c6c: f7f9 bnez a5,1c3a <createdelete+0xb0> name[1] = '0' + (i / 2); 1c6e: 01f4d79b srliw a5,s1,0x1f 1c72: 9fa5 addw a5,a5,s1 1c74: 4017d79b sraiw a5,a5,0x1 1c78: 0307879b addiw a5,a5,48 1c7c: f8f400a3 sb a5,-127(s0) if(unlink(name) < 0){ 1c80: f8040513 addi a0,s0,-128 1c84: 00004097 auipc ra,0x4 1c88: ac8080e7 jalr -1336(ra) # 574c <unlink> 1c8c: fa0557e3 bgez a0,1c3a <createdelete+0xb0> printf("%s: unlink failed\n", s); 1c90: 85e6 mv a1,s9 1c92: 00005517 auipc a0,0x5 1c96: d2650513 addi a0,a0,-730 # 69b8 <malloc+0xe76> 1c9a: 00004097 auipc ra,0x4 1c9e: dea080e7 jalr -534(ra) # 5a84 <printf> exit(1); 1ca2: 4505 li a0,1 1ca4: 00004097 auipc ra,0x4 1ca8: a58080e7 jalr -1448(ra) # 56fc <exit> exit(0); 1cac: 4501 li a0,0 1cae: 00004097 auipc ra,0x4 1cb2: a4e080e7 jalr -1458(ra) # 56fc <exit> exit(1); 1cb6: 4505 li a0,1 1cb8: 00004097 auipc ra,0x4 1cbc: a44080e7 jalr -1468(ra) # 56fc <exit> printf("%s: oops createdelete %s didn't exist\n", s, name); 1cc0: f8040613 addi a2,s0,-128 1cc4: 85e6 mv a1,s9 1cc6: 00005517 auipc a0,0x5 1cca: d0a50513 addi a0,a0,-758 # 69d0 <malloc+0xe8e> 1cce: 00004097 auipc ra,0x4 1cd2: db6080e7 jalr -586(ra) # 5a84 <printf> exit(1); 1cd6: 4505 li a0,1 1cd8: 00004097 auipc ra,0x4 1cdc: a24080e7 jalr -1500(ra) # 56fc <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 1ce0: 054b7163 bgeu s6,s4,1d22 <createdelete+0x198> if(fd >= 0) 1ce4: 02055a63 bgez a0,1d18 <createdelete+0x18e> for(pi = 0; pi < NCHILD; pi++){ 1ce8: 2485 addiw s1,s1,1 1cea: 0ff4f493 andi s1,s1,255 1cee: 05548c63 beq s1,s5,1d46 <createdelete+0x1bc> name[0] = 'p' + pi; 1cf2: f8940023 sb s1,-128(s0) name[1] = '0' + i; 1cf6: f93400a3 sb s3,-127(s0) fd = open(name, 0); 1cfa: 4581 li a1,0 1cfc: f8040513 addi a0,s0,-128 1d00: 00004097 auipc ra,0x4 1d04: a3c080e7 jalr -1476(ra) # 573c <open> if((i == 0 || i >= N/2) && fd < 0){ 1d08: 00090463 beqz s2,1d10 <createdelete+0x186> 1d0c: fd2bdae3 bge s7,s2,1ce0 <createdelete+0x156> 1d10: fa0548e3 bltz a0,1cc0 <createdelete+0x136> } else if((i >= 1 && i < N/2) && fd >= 0){ 1d14: 014b7963 bgeu s6,s4,1d26 <createdelete+0x19c> close(fd); 1d18: 00004097 auipc ra,0x4 1d1c: a0c080e7 jalr -1524(ra) # 5724 <close> 1d20: b7e1 j 1ce8 <createdelete+0x15e> } else if((i >= 1 && i < N/2) && fd >= 0){ 1d22: fc0543e3 bltz a0,1ce8 <createdelete+0x15e> printf("%s: oops createdelete %s did exist\n", s, name); 1d26: f8040613 addi a2,s0,-128 1d2a: 85e6 mv a1,s9 1d2c: 00005517 auipc a0,0x5 1d30: ccc50513 addi a0,a0,-820 # 69f8 <malloc+0xeb6> 1d34: 00004097 auipc ra,0x4 1d38: d50080e7 jalr -688(ra) # 5a84 <printf> exit(1); 1d3c: 4505 li a0,1 1d3e: 00004097 auipc ra,0x4 1d42: 9be080e7 jalr -1602(ra) # 56fc <exit> for(i = 0; i < N; i++){ 1d46: 2905 addiw s2,s2,1 1d48: 2a05 addiw s4,s4,1 1d4a: 2985 addiw s3,s3,1 1d4c: 0ff9f993 andi s3,s3,255 1d50: 47d1 li a5,20 1d52: 02f90a63 beq s2,a5,1d86 <createdelete+0x1fc> for(pi = 0; pi < NCHILD; pi++){ 1d56: 84e2 mv s1,s8 1d58: bf69 j 1cf2 <createdelete+0x168> for(i = 0; i < N; i++){ 1d5a: 2905 addiw s2,s2,1 1d5c: 0ff97913 andi s2,s2,255 1d60: 2985 addiw s3,s3,1 1d62: 0ff9f993 andi s3,s3,255 1d66: 03490863 beq s2,s4,1d96 <createdelete+0x20c> name[0] = name[1] = name[2] = 0; 1d6a: 84d6 mv s1,s5 name[0] = 'p' + i; 1d6c: f9240023 sb s2,-128(s0) name[1] = '0' + i; 1d70: f93400a3 sb s3,-127(s0) unlink(name); 1d74: f8040513 addi a0,s0,-128 1d78: 00004097 auipc ra,0x4 1d7c: 9d4080e7 jalr -1580(ra) # 574c <unlink> for(pi = 0; pi < NCHILD; pi++){ 1d80: 34fd addiw s1,s1,-1 1d82: f4ed bnez s1,1d6c <createdelete+0x1e2> 1d84: bfd9 j 1d5a <createdelete+0x1d0> 1d86: 03000993 li s3,48 1d8a: 07000913 li s2,112 name[0] = name[1] = name[2] = 0; 1d8e: 4a91 li s5,4 for(i = 0; i < N; i++){ 1d90: 08400a13 li s4,132 1d94: bfd9 j 1d6a <createdelete+0x1e0> } 1d96: 60aa ld ra,136(sp) 1d98: 640a ld s0,128(sp) 1d9a: 74e6 ld s1,120(sp) 1d9c: 7946 ld s2,112(sp) 1d9e: 79a6 ld s3,104(sp) 1da0: 7a06 ld s4,96(sp) 1da2: 6ae6 ld s5,88(sp) 1da4: 6b46 ld s6,80(sp) 1da6: 6ba6 ld s7,72(sp) 1da8: 6c06 ld s8,64(sp) 1daa: 7ce2 ld s9,56(sp) 1dac: 6149 addi sp,sp,144 1dae: 8082 ret 0000000000001db0 <linkunlink>: { 1db0: 711d addi sp,sp,-96 1db2: ec86 sd ra,88(sp) 1db4: e8a2 sd s0,80(sp) 1db6: e4a6 sd s1,72(sp) 1db8: e0ca sd s2,64(sp) 1dba: fc4e sd s3,56(sp) 1dbc: f852 sd s4,48(sp) 1dbe: f456 sd s5,40(sp) 1dc0: f05a sd s6,32(sp) 1dc2: ec5e sd s7,24(sp) 1dc4: e862 sd s8,16(sp) 1dc6: e466 sd s9,8(sp) 1dc8: 1080 addi s0,sp,96 1dca: 84aa mv s1,a0 unlink("x"); 1dcc: 00004517 auipc a0,0x4 1dd0: 23450513 addi a0,a0,564 # 6000 <malloc+0x4be> 1dd4: 00004097 auipc ra,0x4 1dd8: 978080e7 jalr -1672(ra) # 574c <unlink> pid = fork(); 1ddc: 00004097 auipc ra,0x4 1de0: 918080e7 jalr -1768(ra) # 56f4 <fork> if(pid < 0){ 1de4: 02054b63 bltz a0,1e1a <linkunlink+0x6a> 1de8: 8c2a mv s8,a0 unsigned int x = (pid ? 1 : 97); 1dea: 4c85 li s9,1 1dec: e119 bnez a0,1df2 <linkunlink+0x42> 1dee: 06100c93 li s9,97 1df2: 06400493 li s1,100 x = x * 1103515245 + 12345; 1df6: 41c659b7 lui s3,0x41c65 1dfa: e6d9899b addiw s3,s3,-403 1dfe: 690d lui s2,0x3 1e00: 0399091b addiw s2,s2,57 if((x % 3) == 0){ 1e04: 4a0d li s4,3 } else if((x % 3) == 1){ 1e06: 4b05 li s6,1 unlink("x"); 1e08: 00004a97 auipc s5,0x4 1e0c: 1f8a8a93 addi s5,s5,504 # 6000 <malloc+0x4be> link("cat", "x"); 1e10: 00005b97 auipc s7,0x5 1e14: c10b8b93 addi s7,s7,-1008 # 6a20 <malloc+0xede> 1e18: a825 j 1e50 <linkunlink+0xa0> printf("%s: fork failed\n", s); 1e1a: 85a6 mv a1,s1 1e1c: 00005517 auipc a0,0x5 1e20: 9ac50513 addi a0,a0,-1620 # 67c8 <malloc+0xc86> 1e24: 00004097 auipc ra,0x4 1e28: c60080e7 jalr -928(ra) # 5a84 <printf> exit(1); 1e2c: 4505 li a0,1 1e2e: 00004097 auipc ra,0x4 1e32: 8ce080e7 jalr -1842(ra) # 56fc <exit> close(open("x", O_RDWR | O_CREATE)); 1e36: 20200593 li a1,514 1e3a: 8556 mv a0,s5 1e3c: 00004097 auipc ra,0x4 1e40: 900080e7 jalr -1792(ra) # 573c <open> 1e44: 00004097 auipc ra,0x4 1e48: 8e0080e7 jalr -1824(ra) # 5724 <close> for(i = 0; i < 100; i++){ 1e4c: 34fd addiw s1,s1,-1 1e4e: c88d beqz s1,1e80 <linkunlink+0xd0> x = x * 1103515245 + 12345; 1e50: 033c87bb mulw a5,s9,s3 1e54: 012787bb addw a5,a5,s2 1e58: 00078c9b sext.w s9,a5 if((x % 3) == 0){ 1e5c: 0347f7bb remuw a5,a5,s4 1e60: dbf9 beqz a5,1e36 <linkunlink+0x86> } else if((x % 3) == 1){ 1e62: 01678863 beq a5,s6,1e72 <linkunlink+0xc2> unlink("x"); 1e66: 8556 mv a0,s5 1e68: 00004097 auipc ra,0x4 1e6c: 8e4080e7 jalr -1820(ra) # 574c <unlink> 1e70: bff1 j 1e4c <linkunlink+0x9c> link("cat", "x"); 1e72: 85d6 mv a1,s5 1e74: 855e mv a0,s7 1e76: 00004097 auipc ra,0x4 1e7a: 8e6080e7 jalr -1818(ra) # 575c <link> 1e7e: b7f9 j 1e4c <linkunlink+0x9c> if(pid) 1e80: 020c0463 beqz s8,1ea8 <linkunlink+0xf8> wait(0); 1e84: 4501 li a0,0 1e86: 00004097 auipc ra,0x4 1e8a: 87e080e7 jalr -1922(ra) # 5704 <wait> } 1e8e: 60e6 ld ra,88(sp) 1e90: 6446 ld s0,80(sp) 1e92: 64a6 ld s1,72(sp) 1e94: 6906 ld s2,64(sp) 1e96: 79e2 ld s3,56(sp) 1e98: 7a42 ld s4,48(sp) 1e9a: 7aa2 ld s5,40(sp) 1e9c: 7b02 ld s6,32(sp) 1e9e: 6be2 ld s7,24(sp) 1ea0: 6c42 ld s8,16(sp) 1ea2: 6ca2 ld s9,8(sp) 1ea4: 6125 addi sp,sp,96 1ea6: 8082 ret exit(0); 1ea8: 4501 li a0,0 1eaa: 00004097 auipc ra,0x4 1eae: 852080e7 jalr -1966(ra) # 56fc <exit> 0000000000001eb2 <manywrites>: { 1eb2: 711d addi sp,sp,-96 1eb4: ec86 sd ra,88(sp) 1eb6: e8a2 sd s0,80(sp) 1eb8: e4a6 sd s1,72(sp) 1eba: e0ca sd s2,64(sp) 1ebc: fc4e sd s3,56(sp) 1ebe: f852 sd s4,48(sp) 1ec0: f456 sd s5,40(sp) 1ec2: f05a sd s6,32(sp) 1ec4: ec5e sd s7,24(sp) 1ec6: 1080 addi s0,sp,96 1ec8: 8aaa mv s5,a0 for(int ci = 0; ci < nchildren; ci++){ 1eca: 4981 li s3,0 1ecc: 4911 li s2,4 int pid = fork(); 1ece: 00004097 auipc ra,0x4 1ed2: 826080e7 jalr -2010(ra) # 56f4 <fork> 1ed6: 84aa mv s1,a0 if(pid < 0){ 1ed8: 02054963 bltz a0,1f0a <manywrites+0x58> if(pid == 0){ 1edc: c521 beqz a0,1f24 <manywrites+0x72> for(int ci = 0; ci < nchildren; ci++){ 1ede: 2985 addiw s3,s3,1 1ee0: ff2997e3 bne s3,s2,1ece <manywrites+0x1c> 1ee4: 4491 li s1,4 int st = 0; 1ee6: fa042423 sw zero,-88(s0) wait(&st); 1eea: fa840513 addi a0,s0,-88 1eee: 00004097 auipc ra,0x4 1ef2: 816080e7 jalr -2026(ra) # 5704 <wait> if(st != 0) 1ef6: fa842503 lw a0,-88(s0) 1efa: ed6d bnez a0,1ff4 <manywrites+0x142> for(int ci = 0; ci < nchildren; ci++){ 1efc: 34fd addiw s1,s1,-1 1efe: f4e5 bnez s1,1ee6 <manywrites+0x34> exit(0); 1f00: 4501 li a0,0 1f02: 00003097 auipc ra,0x3 1f06: 7fa080e7 jalr 2042(ra) # 56fc <exit> printf("fork failed\n"); 1f0a: 00005517 auipc a0,0x5 1f0e: cc650513 addi a0,a0,-826 # 6bd0 <malloc+0x108e> 1f12: 00004097 auipc ra,0x4 1f16: b72080e7 jalr -1166(ra) # 5a84 <printf> exit(1); 1f1a: 4505 li a0,1 1f1c: 00003097 auipc ra,0x3 1f20: 7e0080e7 jalr 2016(ra) # 56fc <exit> name[0] = 'b'; 1f24: 06200793 li a5,98 1f28: faf40423 sb a5,-88(s0) name[1] = 'a' + ci; 1f2c: 0619879b addiw a5,s3,97 1f30: faf404a3 sb a5,-87(s0) name[2] = '\0'; 1f34: fa040523 sb zero,-86(s0) unlink(name); 1f38: fa840513 addi a0,s0,-88 1f3c: 00004097 auipc ra,0x4 1f40: 810080e7 jalr -2032(ra) # 574c <unlink> 1f44: 4bf9 li s7,30 int cc = write(fd, buf, sz); 1f46: 0000ab17 auipc s6,0xa 1f4a: c92b0b13 addi s6,s6,-878 # bbd8 <buf> for(int i = 0; i < ci+1; i++){ 1f4e: 8a26 mv s4,s1 1f50: 0209ce63 bltz s3,1f8c <manywrites+0xda> int fd = open(name, O_CREATE | O_RDWR); 1f54: 20200593 li a1,514 1f58: fa840513 addi a0,s0,-88 1f5c: 00003097 auipc ra,0x3 1f60: 7e0080e7 jalr 2016(ra) # 573c <open> 1f64: 892a mv s2,a0 if(fd < 0){ 1f66: 04054763 bltz a0,1fb4 <manywrites+0x102> int cc = write(fd, buf, sz); 1f6a: 660d lui a2,0x3 1f6c: 85da mv a1,s6 1f6e: 00003097 auipc ra,0x3 1f72: 7ae080e7 jalr 1966(ra) # 571c <write> if(cc != sz){ 1f76: 678d lui a5,0x3 1f78: 04f51e63 bne a0,a5,1fd4 <manywrites+0x122> close(fd); 1f7c: 854a mv a0,s2 1f7e: 00003097 auipc ra,0x3 1f82: 7a6080e7 jalr 1958(ra) # 5724 <close> for(int i = 0; i < ci+1; i++){ 1f86: 2a05 addiw s4,s4,1 1f88: fd49d6e3 bge s3,s4,1f54 <manywrites+0xa2> unlink(name); 1f8c: fa840513 addi a0,s0,-88 1f90: 00003097 auipc ra,0x3 1f94: 7bc080e7 jalr 1980(ra) # 574c <unlink> for(int iters = 0; iters < howmany; iters++){ 1f98: 3bfd addiw s7,s7,-1 1f9a: fa0b9ae3 bnez s7,1f4e <manywrites+0x9c> unlink(name); 1f9e: fa840513 addi a0,s0,-88 1fa2: 00003097 auipc ra,0x3 1fa6: 7aa080e7 jalr 1962(ra) # 574c <unlink> exit(0); 1faa: 4501 li a0,0 1fac: 00003097 auipc ra,0x3 1fb0: 750080e7 jalr 1872(ra) # 56fc <exit> printf("%s: cannot create %s\n", s, name); 1fb4: fa840613 addi a2,s0,-88 1fb8: 85d6 mv a1,s5 1fba: 00005517 auipc a0,0x5 1fbe: a6e50513 addi a0,a0,-1426 # 6a28 <malloc+0xee6> 1fc2: 00004097 auipc ra,0x4 1fc6: ac2080e7 jalr -1342(ra) # 5a84 <printf> exit(1); 1fca: 4505 li a0,1 1fcc: 00003097 auipc ra,0x3 1fd0: 730080e7 jalr 1840(ra) # 56fc <exit> printf("%s: write(%d) ret %d\n", s, sz, cc); 1fd4: 86aa mv a3,a0 1fd6: 660d lui a2,0x3 1fd8: 85d6 mv a1,s5 1fda: 00004517 auipc a0,0x4 1fde: 07650513 addi a0,a0,118 # 6050 <malloc+0x50e> 1fe2: 00004097 auipc ra,0x4 1fe6: aa2080e7 jalr -1374(ra) # 5a84 <printf> exit(1); 1fea: 4505 li a0,1 1fec: 00003097 auipc ra,0x3 1ff0: 710080e7 jalr 1808(ra) # 56fc <exit> exit(st); 1ff4: 00003097 auipc ra,0x3 1ff8: 708080e7 jalr 1800(ra) # 56fc <exit> 0000000000001ffc <forktest>: { 1ffc: 7179 addi sp,sp,-48 1ffe: f406 sd ra,40(sp) 2000: f022 sd s0,32(sp) 2002: ec26 sd s1,24(sp) 2004: e84a sd s2,16(sp) 2006: e44e sd s3,8(sp) 2008: 1800 addi s0,sp,48 200a: 89aa mv s3,a0 for(n=0; n<N; n++){ 200c: 4481 li s1,0 200e: 3e800913 li s2,1000 pid = fork(); 2012: 00003097 auipc ra,0x3 2016: 6e2080e7 jalr 1762(ra) # 56f4 <fork> if(pid < 0) 201a: 02054863 bltz a0,204a <forktest+0x4e> if(pid == 0) 201e: c115 beqz a0,2042 <forktest+0x46> for(n=0; n<N; n++){ 2020: 2485 addiw s1,s1,1 2022: ff2498e3 bne s1,s2,2012 <forktest+0x16> printf("%s: fork claimed to work 1000 times!\n", s); 2026: 85ce mv a1,s3 2028: 00005517 auipc a0,0x5 202c: a3050513 addi a0,a0,-1488 # 6a58 <malloc+0xf16> 2030: 00004097 auipc ra,0x4 2034: a54080e7 jalr -1452(ra) # 5a84 <printf> exit(1); 2038: 4505 li a0,1 203a: 00003097 auipc ra,0x3 203e: 6c2080e7 jalr 1730(ra) # 56fc <exit> exit(0); 2042: 00003097 auipc ra,0x3 2046: 6ba080e7 jalr 1722(ra) # 56fc <exit> if (n == 0) { 204a: cc9d beqz s1,2088 <forktest+0x8c> if(n == N){ 204c: 3e800793 li a5,1000 2050: fcf48be3 beq s1,a5,2026 <forktest+0x2a> for(; n > 0; n--){ 2054: 00905b63 blez s1,206a <forktest+0x6e> if(wait(0) < 0){ 2058: 4501 li a0,0 205a: 00003097 auipc ra,0x3 205e: 6aa080e7 jalr 1706(ra) # 5704 <wait> 2062: 04054163 bltz a0,20a4 <forktest+0xa8> for(; n > 0; n--){ 2066: 34fd addiw s1,s1,-1 2068: f8e5 bnez s1,2058 <forktest+0x5c> if(wait(0) != -1){ 206a: 4501 li a0,0 206c: 00003097 auipc ra,0x3 2070: 698080e7 jalr 1688(ra) # 5704 <wait> 2074: 57fd li a5,-1 2076: 04f51563 bne a0,a5,20c0 <forktest+0xc4> } 207a: 70a2 ld ra,40(sp) 207c: 7402 ld s0,32(sp) 207e: 64e2 ld s1,24(sp) 2080: 6942 ld s2,16(sp) 2082: 69a2 ld s3,8(sp) 2084: 6145 addi sp,sp,48 2086: 8082 ret printf("%s: no fork at all!\n", s); 2088: 85ce mv a1,s3 208a: 00005517 auipc a0,0x5 208e: 9b650513 addi a0,a0,-1610 # 6a40 <malloc+0xefe> 2092: 00004097 auipc ra,0x4 2096: 9f2080e7 jalr -1550(ra) # 5a84 <printf> exit(1); 209a: 4505 li a0,1 209c: 00003097 auipc ra,0x3 20a0: 660080e7 jalr 1632(ra) # 56fc <exit> printf("%s: wait stopped early\n", s); 20a4: 85ce mv a1,s3 20a6: 00005517 auipc a0,0x5 20aa: 9da50513 addi a0,a0,-1574 # 6a80 <malloc+0xf3e> 20ae: 00004097 auipc ra,0x4 20b2: 9d6080e7 jalr -1578(ra) # 5a84 <printf> exit(1); 20b6: 4505 li a0,1 20b8: 00003097 auipc ra,0x3 20bc: 644080e7 jalr 1604(ra) # 56fc <exit> printf("%s: wait got too many\n", s); 20c0: 85ce mv a1,s3 20c2: 00005517 auipc a0,0x5 20c6: 9d650513 addi a0,a0,-1578 # 6a98 <malloc+0xf56> 20ca: 00004097 auipc ra,0x4 20ce: 9ba080e7 jalr -1606(ra) # 5a84 <printf> exit(1); 20d2: 4505 li a0,1 20d4: 00003097 auipc ra,0x3 20d8: 628080e7 jalr 1576(ra) # 56fc <exit> 00000000000020dc <kernmem>: { 20dc: 715d addi sp,sp,-80 20de: e486 sd ra,72(sp) 20e0: e0a2 sd s0,64(sp) 20e2: fc26 sd s1,56(sp) 20e4: f84a sd s2,48(sp) 20e6: f44e sd s3,40(sp) 20e8: f052 sd s4,32(sp) 20ea: ec56 sd s5,24(sp) 20ec: 0880 addi s0,sp,80 20ee: 8a2a mv s4,a0 for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 20f0: 4485 li s1,1 20f2: 04fe slli s1,s1,0x1f if(xstatus != -1) // did kernel kill child? 20f4: 5afd li s5,-1 for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 20f6: 69b1 lui s3,0xc 20f8: 35098993 addi s3,s3,848 # c350 <buf+0x778> 20fc: 1003d937 lui s2,0x1003d 2100: 090e slli s2,s2,0x3 2102: 48090913 addi s2,s2,1152 # 1003d480 <__BSS_END__+0x1002e898> pid = fork(); 2106: 00003097 auipc ra,0x3 210a: 5ee080e7 jalr 1518(ra) # 56f4 <fork> if(pid < 0){ 210e: 02054963 bltz a0,2140 <kernmem+0x64> if(pid == 0){ 2112: c529 beqz a0,215c <kernmem+0x80> wait(&xstatus); 2114: fbc40513 addi a0,s0,-68 2118: 00003097 auipc ra,0x3 211c: 5ec080e7 jalr 1516(ra) # 5704 <wait> if(xstatus != -1) // did kernel kill child? 2120: fbc42783 lw a5,-68(s0) 2124: 05579d63 bne a5,s5,217e <kernmem+0xa2> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2128: 94ce add s1,s1,s3 212a: fd249ee3 bne s1,s2,2106 <kernmem+0x2a> } 212e: 60a6 ld ra,72(sp) 2130: 6406 ld s0,64(sp) 2132: 74e2 ld s1,56(sp) 2134: 7942 ld s2,48(sp) 2136: 79a2 ld s3,40(sp) 2138: 7a02 ld s4,32(sp) 213a: 6ae2 ld s5,24(sp) 213c: 6161 addi sp,sp,80 213e: 8082 ret printf("%s: fork failed\n", s); 2140: 85d2 mv a1,s4 2142: 00004517 auipc a0,0x4 2146: 68650513 addi a0,a0,1670 # 67c8 <malloc+0xc86> 214a: 00004097 auipc ra,0x4 214e: 93a080e7 jalr -1734(ra) # 5a84 <printf> exit(1); 2152: 4505 li a0,1 2154: 00003097 auipc ra,0x3 2158: 5a8080e7 jalr 1448(ra) # 56fc <exit> printf("%s: oops could read %x = %x\n", s, a, *a); 215c: 0004c683 lbu a3,0(s1) 2160: 8626 mv a2,s1 2162: 85d2 mv a1,s4 2164: 00005517 auipc a0,0x5 2168: 94c50513 addi a0,a0,-1716 # 6ab0 <malloc+0xf6e> 216c: 00004097 auipc ra,0x4 2170: 918080e7 jalr -1768(ra) # 5a84 <printf> exit(1); 2174: 4505 li a0,1 2176: 00003097 auipc ra,0x3 217a: 586080e7 jalr 1414(ra) # 56fc <exit> exit(1); 217e: 4505 li a0,1 2180: 00003097 auipc ra,0x3 2184: 57c080e7 jalr 1404(ra) # 56fc <exit> 0000000000002188 <bigargtest>: { 2188: 7179 addi sp,sp,-48 218a: f406 sd ra,40(sp) 218c: f022 sd s0,32(sp) 218e: ec26 sd s1,24(sp) 2190: 1800 addi s0,sp,48 2192: 84aa mv s1,a0 unlink("bigarg-ok"); 2194: 00005517 auipc a0,0x5 2198: 93c50513 addi a0,a0,-1732 # 6ad0 <malloc+0xf8e> 219c: 00003097 auipc ra,0x3 21a0: 5b0080e7 jalr 1456(ra) # 574c <unlink> pid = fork(); 21a4: 00003097 auipc ra,0x3 21a8: 550080e7 jalr 1360(ra) # 56f4 <fork> if(pid == 0){ 21ac: c121 beqz a0,21ec <bigargtest+0x64> } else if(pid < 0){ 21ae: 0a054063 bltz a0,224e <bigargtest+0xc6> wait(&xstatus); 21b2: fdc40513 addi a0,s0,-36 21b6: 00003097 auipc ra,0x3 21ba: 54e080e7 jalr 1358(ra) # 5704 <wait> if(xstatus != 0) 21be: fdc42503 lw a0,-36(s0) 21c2: e545 bnez a0,226a <bigargtest+0xe2> fd = open("bigarg-ok", 0); 21c4: 4581 li a1,0 21c6: 00005517 auipc a0,0x5 21ca: 90a50513 addi a0,a0,-1782 # 6ad0 <malloc+0xf8e> 21ce: 00003097 auipc ra,0x3 21d2: 56e080e7 jalr 1390(ra) # 573c <open> if(fd < 0){ 21d6: 08054e63 bltz a0,2272 <bigargtest+0xea> close(fd); 21da: 00003097 auipc ra,0x3 21de: 54a080e7 jalr 1354(ra) # 5724 <close> } 21e2: 70a2 ld ra,40(sp) 21e4: 7402 ld s0,32(sp) 21e6: 64e2 ld s1,24(sp) 21e8: 6145 addi sp,sp,48 21ea: 8082 ret 21ec: 00006797 auipc a5,0x6 21f0: 1d478793 addi a5,a5,468 # 83c0 <args.1> 21f4: 00006697 auipc a3,0x6 21f8: 2c468693 addi a3,a3,708 # 84b8 <args.1+0xf8> args[i] = "bigargs test: failed\n "; 21fc: 00005717 auipc a4,0x5 2200: 8e470713 addi a4,a4,-1820 # 6ae0 <malloc+0xf9e> 2204: e398 sd a4,0(a5) for(i = 0; i < MAXARG-1; i++) 2206: 07a1 addi a5,a5,8 2208: fed79ee3 bne a5,a3,2204 <bigargtest+0x7c> args[MAXARG-1] = 0; 220c: 00006597 auipc a1,0x6 2210: 1b458593 addi a1,a1,436 # 83c0 <args.1> 2214: 0e05bc23 sd zero,248(a1) exec("echo", args); 2218: 00004517 auipc a0,0x4 221c: d7850513 addi a0,a0,-648 # 5f90 <malloc+0x44e> 2220: 00003097 auipc ra,0x3 2224: 514080e7 jalr 1300(ra) # 5734 <exec> fd = open("bigarg-ok", O_CREATE); 2228: 20000593 li a1,512 222c: 00005517 auipc a0,0x5 2230: 8a450513 addi a0,a0,-1884 # 6ad0 <malloc+0xf8e> 2234: 00003097 auipc ra,0x3 2238: 508080e7 jalr 1288(ra) # 573c <open> close(fd); 223c: 00003097 auipc ra,0x3 2240: 4e8080e7 jalr 1256(ra) # 5724 <close> exit(0); 2244: 4501 li a0,0 2246: 00003097 auipc ra,0x3 224a: 4b6080e7 jalr 1206(ra) # 56fc <exit> printf("%s: bigargtest: fork failed\n", s); 224e: 85a6 mv a1,s1 2250: 00005517 auipc a0,0x5 2254: 97050513 addi a0,a0,-1680 # 6bc0 <malloc+0x107e> 2258: 00004097 auipc ra,0x4 225c: 82c080e7 jalr -2004(ra) # 5a84 <printf> exit(1); 2260: 4505 li a0,1 2262: 00003097 auipc ra,0x3 2266: 49a080e7 jalr 1178(ra) # 56fc <exit> exit(xstatus); 226a: 00003097 auipc ra,0x3 226e: 492080e7 jalr 1170(ra) # 56fc <exit> printf("%s: bigarg test failed!\n", s); 2272: 85a6 mv a1,s1 2274: 00005517 auipc a0,0x5 2278: 96c50513 addi a0,a0,-1684 # 6be0 <malloc+0x109e> 227c: 00004097 auipc ra,0x4 2280: 808080e7 jalr -2040(ra) # 5a84 <printf> exit(1); 2284: 4505 li a0,1 2286: 00003097 auipc ra,0x3 228a: 476080e7 jalr 1142(ra) # 56fc <exit> 000000000000228e <stacktest>: { 228e: 7179 addi sp,sp,-48 2290: f406 sd ra,40(sp) 2292: f022 sd s0,32(sp) 2294: ec26 sd s1,24(sp) 2296: 1800 addi s0,sp,48 2298: 84aa mv s1,a0 pid = fork(); 229a: 00003097 auipc ra,0x3 229e: 45a080e7 jalr 1114(ra) # 56f4 <fork> if(pid == 0) { 22a2: c115 beqz a0,22c6 <stacktest+0x38> } else if(pid < 0){ 22a4: 04054463 bltz a0,22ec <stacktest+0x5e> wait(&xstatus); 22a8: fdc40513 addi a0,s0,-36 22ac: 00003097 auipc ra,0x3 22b0: 458080e7 jalr 1112(ra) # 5704 <wait> if(xstatus == -1) // kernel killed child? 22b4: fdc42503 lw a0,-36(s0) 22b8: 57fd li a5,-1 22ba: 04f50763 beq a0,a5,2308 <stacktest+0x7a> exit(xstatus); 22be: 00003097 auipc ra,0x3 22c2: 43e080e7 jalr 1086(ra) # 56fc <exit> static inline uint64 r_sp() { uint64 x; asm volatile("mv %0, sp" : "=r" (x) ); 22c6: 870a mv a4,sp printf("%s: stacktest: read below stack %p\n", s, *sp); 22c8: 77fd lui a5,0xfffff 22ca: 97ba add a5,a5,a4 22cc: 0007c603 lbu a2,0(a5) # fffffffffffff000 <__BSS_END__+0xffffffffffff0418> 22d0: 85a6 mv a1,s1 22d2: 00005517 auipc a0,0x5 22d6: 92e50513 addi a0,a0,-1746 # 6c00 <malloc+0x10be> 22da: 00003097 auipc ra,0x3 22de: 7aa080e7 jalr 1962(ra) # 5a84 <printf> exit(1); 22e2: 4505 li a0,1 22e4: 00003097 auipc ra,0x3 22e8: 418080e7 jalr 1048(ra) # 56fc <exit> printf("%s: fork failed\n", s); 22ec: 85a6 mv a1,s1 22ee: 00004517 auipc a0,0x4 22f2: 4da50513 addi a0,a0,1242 # 67c8 <malloc+0xc86> 22f6: 00003097 auipc ra,0x3 22fa: 78e080e7 jalr 1934(ra) # 5a84 <printf> exit(1); 22fe: 4505 li a0,1 2300: 00003097 auipc ra,0x3 2304: 3fc080e7 jalr 1020(ra) # 56fc <exit> exit(0); 2308: 4501 li a0,0 230a: 00003097 auipc ra,0x3 230e: 3f2080e7 jalr 1010(ra) # 56fc <exit> 0000000000002312 <copyinstr3>: { 2312: 7179 addi sp,sp,-48 2314: f406 sd ra,40(sp) 2316: f022 sd s0,32(sp) 2318: ec26 sd s1,24(sp) 231a: 1800 addi s0,sp,48 sbrk(8192); 231c: 6509 lui a0,0x2 231e: 00003097 auipc ra,0x3 2322: 466080e7 jalr 1126(ra) # 5784 <sbrk> uint64 top = (uint64) sbrk(0); 2326: 4501 li a0,0 2328: 00003097 auipc ra,0x3 232c: 45c080e7 jalr 1116(ra) # 5784 <sbrk> if((top % PGSIZE) != 0){ 2330: 03451793 slli a5,a0,0x34 2334: e3c9 bnez a5,23b6 <copyinstr3+0xa4> top = (uint64) sbrk(0); 2336: 4501 li a0,0 2338: 00003097 auipc ra,0x3 233c: 44c080e7 jalr 1100(ra) # 5784 <sbrk> if(top % PGSIZE){ 2340: 03451793 slli a5,a0,0x34 2344: e3d9 bnez a5,23ca <copyinstr3+0xb8> char *b = (char *) (top - 1); 2346: fff50493 addi s1,a0,-1 # 1fff <forktest+0x3> *b = 'x'; 234a: 07800793 li a5,120 234e: fef50fa3 sb a5,-1(a0) int ret = unlink(b); 2352: 8526 mv a0,s1 2354: 00003097 auipc ra,0x3 2358: 3f8080e7 jalr 1016(ra) # 574c <unlink> if(ret != -1){ 235c: 57fd li a5,-1 235e: 08f51363 bne a0,a5,23e4 <copyinstr3+0xd2> int fd = open(b, O_CREATE | O_WRONLY); 2362: 20100593 li a1,513 2366: 8526 mv a0,s1 2368: 00003097 auipc ra,0x3 236c: 3d4080e7 jalr 980(ra) # 573c <open> if(fd != -1){ 2370: 57fd li a5,-1 2372: 08f51863 bne a0,a5,2402 <copyinstr3+0xf0> ret = link(b, b); 2376: 85a6 mv a1,s1 2378: 8526 mv a0,s1 237a: 00003097 auipc ra,0x3 237e: 3e2080e7 jalr 994(ra) # 575c <link> if(ret != -1){ 2382: 57fd li a5,-1 2384: 08f51e63 bne a0,a5,2420 <copyinstr3+0x10e> char *args[] = { "xx", 0 }; 2388: 00005797 auipc a5,0x5 238c: 51078793 addi a5,a5,1296 # 7898 <malloc+0x1d56> 2390: fcf43823 sd a5,-48(s0) 2394: fc043c23 sd zero,-40(s0) ret = exec(b, args); 2398: fd040593 addi a1,s0,-48 239c: 8526 mv a0,s1 239e: 00003097 auipc ra,0x3 23a2: 396080e7 jalr 918(ra) # 5734 <exec> if(ret != -1){ 23a6: 57fd li a5,-1 23a8: 08f51c63 bne a0,a5,2440 <copyinstr3+0x12e> } 23ac: 70a2 ld ra,40(sp) 23ae: 7402 ld s0,32(sp) 23b0: 64e2 ld s1,24(sp) 23b2: 6145 addi sp,sp,48 23b4: 8082 ret sbrk(PGSIZE - (top % PGSIZE)); 23b6: 0347d513 srli a0,a5,0x34 23ba: 6785 lui a5,0x1 23bc: 40a7853b subw a0,a5,a0 23c0: 00003097 auipc ra,0x3 23c4: 3c4080e7 jalr 964(ra) # 5784 <sbrk> 23c8: b7bd j 2336 <copyinstr3+0x24> printf("oops\n"); 23ca: 00005517 auipc a0,0x5 23ce: 85e50513 addi a0,a0,-1954 # 6c28 <malloc+0x10e6> 23d2: 00003097 auipc ra,0x3 23d6: 6b2080e7 jalr 1714(ra) # 5a84 <printf> exit(1); 23da: 4505 li a0,1 23dc: 00003097 auipc ra,0x3 23e0: 320080e7 jalr 800(ra) # 56fc <exit> printf("unlink(%s) returned %d, not -1\n", b, ret); 23e4: 862a mv a2,a0 23e6: 85a6 mv a1,s1 23e8: 00004517 auipc a0,0x4 23ec: 30050513 addi a0,a0,768 # 66e8 <malloc+0xba6> 23f0: 00003097 auipc ra,0x3 23f4: 694080e7 jalr 1684(ra) # 5a84 <printf> exit(1); 23f8: 4505 li a0,1 23fa: 00003097 auipc ra,0x3 23fe: 302080e7 jalr 770(ra) # 56fc <exit> printf("open(%s) returned %d, not -1\n", b, fd); 2402: 862a mv a2,a0 2404: 85a6 mv a1,s1 2406: 00004517 auipc a0,0x4 240a: 30250513 addi a0,a0,770 # 6708 <malloc+0xbc6> 240e: 00003097 auipc ra,0x3 2412: 676080e7 jalr 1654(ra) # 5a84 <printf> exit(1); 2416: 4505 li a0,1 2418: 00003097 auipc ra,0x3 241c: 2e4080e7 jalr 740(ra) # 56fc <exit> printf("link(%s, %s) returned %d, not -1\n", b, b, ret); 2420: 86aa mv a3,a0 2422: 8626 mv a2,s1 2424: 85a6 mv a1,s1 2426: 00004517 auipc a0,0x4 242a: 30250513 addi a0,a0,770 # 6728 <malloc+0xbe6> 242e: 00003097 auipc ra,0x3 2432: 656080e7 jalr 1622(ra) # 5a84 <printf> exit(1); 2436: 4505 li a0,1 2438: 00003097 auipc ra,0x3 243c: 2c4080e7 jalr 708(ra) # 56fc <exit> printf("exec(%s) returned %d, not -1\n", b, fd); 2440: 567d li a2,-1 2442: 85a6 mv a1,s1 2444: 00004517 auipc a0,0x4 2448: 30c50513 addi a0,a0,780 # 6750 <malloc+0xc0e> 244c: 00003097 auipc ra,0x3 2450: 638080e7 jalr 1592(ra) # 5a84 <printf> exit(1); 2454: 4505 li a0,1 2456: 00003097 auipc ra,0x3 245a: 2a6080e7 jalr 678(ra) # 56fc <exit> 000000000000245e <rwsbrk>: { 245e: 1101 addi sp,sp,-32 2460: ec06 sd ra,24(sp) 2462: e822 sd s0,16(sp) 2464: e426 sd s1,8(sp) 2466: e04a sd s2,0(sp) 2468: 1000 addi s0,sp,32 uint64 a = (uint64) sbrk(8192); 246a: 6509 lui a0,0x2 246c: 00003097 auipc ra,0x3 2470: 318080e7 jalr 792(ra) # 5784 <sbrk> if(a == 0xffffffffffffffffLL) { 2474: 57fd li a5,-1 2476: 06f50363 beq a0,a5,24dc <rwsbrk+0x7e> 247a: 84aa mv s1,a0 if ((uint64) sbrk(-8192) == 0xffffffffffffffffLL) { 247c: 7579 lui a0,0xffffe 247e: 00003097 auipc ra,0x3 2482: 306080e7 jalr 774(ra) # 5784 <sbrk> 2486: 57fd li a5,-1 2488: 06f50763 beq a0,a5,24f6 <rwsbrk+0x98> fd = open("rwsbrk", O_CREATE|O_WRONLY); 248c: 20100593 li a1,513 2490: 00004517 auipc a0,0x4 2494: 81050513 addi a0,a0,-2032 # 5ca0 <malloc+0x15e> 2498: 00003097 auipc ra,0x3 249c: 2a4080e7 jalr 676(ra) # 573c <open> 24a0: 892a mv s2,a0 if(fd < 0){ 24a2: 06054763 bltz a0,2510 <rwsbrk+0xb2> n = write(fd, (void*)(a+4096), 1024); 24a6: 6505 lui a0,0x1 24a8: 94aa add s1,s1,a0 24aa: 40000613 li a2,1024 24ae: 85a6 mv a1,s1 24b0: 854a mv a0,s2 24b2: 00003097 auipc ra,0x3 24b6: 26a080e7 jalr 618(ra) # 571c <write> 24ba: 862a mv a2,a0 if(n >= 0){ 24bc: 06054763 bltz a0,252a <rwsbrk+0xcc> printf("write(fd, %p, 1024) returned %d, not -1\n", a+4096, n); 24c0: 85a6 mv a1,s1 24c2: 00004517 auipc a0,0x4 24c6: 7be50513 addi a0,a0,1982 # 6c80 <malloc+0x113e> 24ca: 00003097 auipc ra,0x3 24ce: 5ba080e7 jalr 1466(ra) # 5a84 <printf> exit(1); 24d2: 4505 li a0,1 24d4: 00003097 auipc ra,0x3 24d8: 228080e7 jalr 552(ra) # 56fc <exit> printf("sbrk(rwsbrk) failed\n"); 24dc: 00004517 auipc a0,0x4 24e0: 75450513 addi a0,a0,1876 # 6c30 <malloc+0x10ee> 24e4: 00003097 auipc ra,0x3 24e8: 5a0080e7 jalr 1440(ra) # 5a84 <printf> exit(1); 24ec: 4505 li a0,1 24ee: 00003097 auipc ra,0x3 24f2: 20e080e7 jalr 526(ra) # 56fc <exit> printf("sbrk(rwsbrk) shrink failed\n"); 24f6: 00004517 auipc a0,0x4 24fa: 75250513 addi a0,a0,1874 # 6c48 <malloc+0x1106> 24fe: 00003097 auipc ra,0x3 2502: 586080e7 jalr 1414(ra) # 5a84 <printf> exit(1); 2506: 4505 li a0,1 2508: 00003097 auipc ra,0x3 250c: 1f4080e7 jalr 500(ra) # 56fc <exit> printf("open(rwsbrk) failed\n"); 2510: 00004517 auipc a0,0x4 2514: 75850513 addi a0,a0,1880 # 6c68 <malloc+0x1126> 2518: 00003097 auipc ra,0x3 251c: 56c080e7 jalr 1388(ra) # 5a84 <printf> exit(1); 2520: 4505 li a0,1 2522: 00003097 auipc ra,0x3 2526: 1da080e7 jalr 474(ra) # 56fc <exit> close(fd); 252a: 854a mv a0,s2 252c: 00003097 auipc ra,0x3 2530: 1f8080e7 jalr 504(ra) # 5724 <close> unlink("rwsbrk"); 2534: 00003517 auipc a0,0x3 2538: 76c50513 addi a0,a0,1900 # 5ca0 <malloc+0x15e> 253c: 00003097 auipc ra,0x3 2540: 210080e7 jalr 528(ra) # 574c <unlink> fd = open("README", O_RDONLY); 2544: 4581 li a1,0 2546: 00004517 auipc a0,0x4 254a: be250513 addi a0,a0,-1054 # 6128 <malloc+0x5e6> 254e: 00003097 auipc ra,0x3 2552: 1ee080e7 jalr 494(ra) # 573c <open> 2556: 892a mv s2,a0 if(fd < 0){ 2558: 02054963 bltz a0,258a <rwsbrk+0x12c> n = read(fd, (void*)(a+4096), 10); 255c: 4629 li a2,10 255e: 85a6 mv a1,s1 2560: 00003097 auipc ra,0x3 2564: 1b4080e7 jalr 436(ra) # 5714 <read> 2568: 862a mv a2,a0 if(n >= 0){ 256a: 02054d63 bltz a0,25a4 <rwsbrk+0x146> printf("read(fd, %p, 10) returned %d, not -1\n", a+4096, n); 256e: 85a6 mv a1,s1 2570: 00004517 auipc a0,0x4 2574: 74050513 addi a0,a0,1856 # 6cb0 <malloc+0x116e> 2578: 00003097 auipc ra,0x3 257c: 50c080e7 jalr 1292(ra) # 5a84 <printf> exit(1); 2580: 4505 li a0,1 2582: 00003097 auipc ra,0x3 2586: 17a080e7 jalr 378(ra) # 56fc <exit> printf("open(rwsbrk) failed\n"); 258a: 00004517 auipc a0,0x4 258e: 6de50513 addi a0,a0,1758 # 6c68 <malloc+0x1126> 2592: 00003097 auipc ra,0x3 2596: 4f2080e7 jalr 1266(ra) # 5a84 <printf> exit(1); 259a: 4505 li a0,1 259c: 00003097 auipc ra,0x3 25a0: 160080e7 jalr 352(ra) # 56fc <exit> close(fd); 25a4: 854a mv a0,s2 25a6: 00003097 auipc ra,0x3 25aa: 17e080e7 jalr 382(ra) # 5724 <close> exit(0); 25ae: 4501 li a0,0 25b0: 00003097 auipc ra,0x3 25b4: 14c080e7 jalr 332(ra) # 56fc <exit> 00000000000025b8 <sbrkbasic>: { 25b8: 7139 addi sp,sp,-64 25ba: fc06 sd ra,56(sp) 25bc: f822 sd s0,48(sp) 25be: f426 sd s1,40(sp) 25c0: f04a sd s2,32(sp) 25c2: ec4e sd s3,24(sp) 25c4: e852 sd s4,16(sp) 25c6: 0080 addi s0,sp,64 25c8: 8a2a mv s4,a0 pid = fork(); 25ca: 00003097 auipc ra,0x3 25ce: 12a080e7 jalr 298(ra) # 56f4 <fork> if(pid < 0){ 25d2: 02054c63 bltz a0,260a <sbrkbasic+0x52> if(pid == 0){ 25d6: ed21 bnez a0,262e <sbrkbasic+0x76> a = sbrk(TOOMUCH); 25d8: 40000537 lui a0,0x40000 25dc: 00003097 auipc ra,0x3 25e0: 1a8080e7 jalr 424(ra) # 5784 <sbrk> if(a == (char*)0xffffffffffffffffL){ 25e4: 57fd li a5,-1 25e6: 02f50f63 beq a0,a5,2624 <sbrkbasic+0x6c> for(b = a; b < a+TOOMUCH; b += 4096){ 25ea: 400007b7 lui a5,0x40000 25ee: 97aa add a5,a5,a0 *b = 99; 25f0: 06300693 li a3,99 for(b = a; b < a+TOOMUCH; b += 4096){ 25f4: 6705 lui a4,0x1 *b = 99; 25f6: 00d50023 sb a3,0(a0) # 40000000 <__BSS_END__+0x3fff1418> for(b = a; b < a+TOOMUCH; b += 4096){ 25fa: 953a add a0,a0,a4 25fc: fef51de3 bne a0,a5,25f6 <sbrkbasic+0x3e> exit(1); 2600: 4505 li a0,1 2602: 00003097 auipc ra,0x3 2606: 0fa080e7 jalr 250(ra) # 56fc <exit> printf("fork failed in sbrkbasic\n"); 260a: 00004517 auipc a0,0x4 260e: 6ce50513 addi a0,a0,1742 # 6cd8 <malloc+0x1196> 2612: 00003097 auipc ra,0x3 2616: 472080e7 jalr 1138(ra) # 5a84 <printf> exit(1); 261a: 4505 li a0,1 261c: 00003097 auipc ra,0x3 2620: 0e0080e7 jalr 224(ra) # 56fc <exit> exit(0); 2624: 4501 li a0,0 2626: 00003097 auipc ra,0x3 262a: 0d6080e7 jalr 214(ra) # 56fc <exit> wait(&xstatus); 262e: fcc40513 addi a0,s0,-52 2632: 00003097 auipc ra,0x3 2636: 0d2080e7 jalr 210(ra) # 5704 <wait> if(xstatus == 1){ 263a: fcc42703 lw a4,-52(s0) 263e: 4785 li a5,1 2640: 00f70d63 beq a4,a5,265a <sbrkbasic+0xa2> a = sbrk(0); 2644: 4501 li a0,0 2646: 00003097 auipc ra,0x3 264a: 13e080e7 jalr 318(ra) # 5784 <sbrk> 264e: 84aa mv s1,a0 for(i = 0; i < 5000; i++){ 2650: 4901 li s2,0 2652: 6985 lui s3,0x1 2654: 38898993 addi s3,s3,904 # 1388 <copyinstr2+0x1d6> 2658: a005 j 2678 <sbrkbasic+0xc0> printf("%s: too much memory allocated!\n", s); 265a: 85d2 mv a1,s4 265c: 00004517 auipc a0,0x4 2660: 69c50513 addi a0,a0,1692 # 6cf8 <malloc+0x11b6> 2664: 00003097 auipc ra,0x3 2668: 420080e7 jalr 1056(ra) # 5a84 <printf> exit(1); 266c: 4505 li a0,1 266e: 00003097 auipc ra,0x3 2672: 08e080e7 jalr 142(ra) # 56fc <exit> a = b + 1; 2676: 84be mv s1,a5 b = sbrk(1); 2678: 4505 li a0,1 267a: 00003097 auipc ra,0x3 267e: 10a080e7 jalr 266(ra) # 5784 <sbrk> if(b != a){ 2682: 04951c63 bne a0,s1,26da <sbrkbasic+0x122> *b = 1; 2686: 4785 li a5,1 2688: 00f48023 sb a5,0(s1) a = b + 1; 268c: 00148793 addi a5,s1,1 for(i = 0; i < 5000; i++){ 2690: 2905 addiw s2,s2,1 2692: ff3912e3 bne s2,s3,2676 <sbrkbasic+0xbe> pid = fork(); 2696: 00003097 auipc ra,0x3 269a: 05e080e7 jalr 94(ra) # 56f4 <fork> 269e: 892a mv s2,a0 if(pid < 0){ 26a0: 04054d63 bltz a0,26fa <sbrkbasic+0x142> c = sbrk(1); 26a4: 4505 li a0,1 26a6: 00003097 auipc ra,0x3 26aa: 0de080e7 jalr 222(ra) # 5784 <sbrk> c = sbrk(1); 26ae: 4505 li a0,1 26b0: 00003097 auipc ra,0x3 26b4: 0d4080e7 jalr 212(ra) # 5784 <sbrk> if(c != a + 1){ 26b8: 0489 addi s1,s1,2 26ba: 04a48e63 beq s1,a0,2716 <sbrkbasic+0x15e> printf("%s: sbrk test failed post-fork\n", s); 26be: 85d2 mv a1,s4 26c0: 00004517 auipc a0,0x4 26c4: 69850513 addi a0,a0,1688 # 6d58 <malloc+0x1216> 26c8: 00003097 auipc ra,0x3 26cc: 3bc080e7 jalr 956(ra) # 5a84 <printf> exit(1); 26d0: 4505 li a0,1 26d2: 00003097 auipc ra,0x3 26d6: 02a080e7 jalr 42(ra) # 56fc <exit> printf("%s: sbrk test failed %d %x %x\n", i, a, b); 26da: 86aa mv a3,a0 26dc: 8626 mv a2,s1 26de: 85ca mv a1,s2 26e0: 00004517 auipc a0,0x4 26e4: 63850513 addi a0,a0,1592 # 6d18 <malloc+0x11d6> 26e8: 00003097 auipc ra,0x3 26ec: 39c080e7 jalr 924(ra) # 5a84 <printf> exit(1); 26f0: 4505 li a0,1 26f2: 00003097 auipc ra,0x3 26f6: 00a080e7 jalr 10(ra) # 56fc <exit> printf("%s: sbrk test fork failed\n", s); 26fa: 85d2 mv a1,s4 26fc: 00004517 auipc a0,0x4 2700: 63c50513 addi a0,a0,1596 # 6d38 <malloc+0x11f6> 2704: 00003097 auipc ra,0x3 2708: 380080e7 jalr 896(ra) # 5a84 <printf> exit(1); 270c: 4505 li a0,1 270e: 00003097 auipc ra,0x3 2712: fee080e7 jalr -18(ra) # 56fc <exit> if(pid == 0) 2716: 00091763 bnez s2,2724 <sbrkbasic+0x16c> exit(0); 271a: 4501 li a0,0 271c: 00003097 auipc ra,0x3 2720: fe0080e7 jalr -32(ra) # 56fc <exit> wait(&xstatus); 2724: fcc40513 addi a0,s0,-52 2728: 00003097 auipc ra,0x3 272c: fdc080e7 jalr -36(ra) # 5704 <wait> exit(xstatus); 2730: fcc42503 lw a0,-52(s0) 2734: 00003097 auipc ra,0x3 2738: fc8080e7 jalr -56(ra) # 56fc <exit> 000000000000273c <sbrkmuch>: { 273c: 7179 addi sp,sp,-48 273e: f406 sd ra,40(sp) 2740: f022 sd s0,32(sp) 2742: ec26 sd s1,24(sp) 2744: e84a sd s2,16(sp) 2746: e44e sd s3,8(sp) 2748: e052 sd s4,0(sp) 274a: 1800 addi s0,sp,48 274c: 89aa mv s3,a0 oldbrk = sbrk(0); 274e: 4501 li a0,0 2750: 00003097 auipc ra,0x3 2754: 034080e7 jalr 52(ra) # 5784 <sbrk> 2758: 892a mv s2,a0 a = sbrk(0); 275a: 4501 li a0,0 275c: 00003097 auipc ra,0x3 2760: 028080e7 jalr 40(ra) # 5784 <sbrk> 2764: 84aa mv s1,a0 p = sbrk(amt); 2766: 06400537 lui a0,0x6400 276a: 9d05 subw a0,a0,s1 276c: 00003097 auipc ra,0x3 2770: 018080e7 jalr 24(ra) # 5784 <sbrk> if (p != a) { 2774: 0ca49863 bne s1,a0,2844 <sbrkmuch+0x108> char *eee = sbrk(0); 2778: 4501 li a0,0 277a: 00003097 auipc ra,0x3 277e: 00a080e7 jalr 10(ra) # 5784 <sbrk> 2782: 87aa mv a5,a0 for(char *pp = a; pp < eee; pp += 4096) 2784: 00a4f963 bgeu s1,a0,2796 <sbrkmuch+0x5a> *pp = 1; 2788: 4685 li a3,1 for(char *pp = a; pp < eee; pp += 4096) 278a: 6705 lui a4,0x1 *pp = 1; 278c: 00d48023 sb a3,0(s1) for(char *pp = a; pp < eee; pp += 4096) 2790: 94ba add s1,s1,a4 2792: fef4ede3 bltu s1,a5,278c <sbrkmuch+0x50> *lastaddr = 99; 2796: 064007b7 lui a5,0x6400 279a: 06300713 li a4,99 279e: fee78fa3 sb a4,-1(a5) # 63fffff <__BSS_END__+0x63f1417> a = sbrk(0); 27a2: 4501 li a0,0 27a4: 00003097 auipc ra,0x3 27a8: fe0080e7 jalr -32(ra) # 5784 <sbrk> 27ac: 84aa mv s1,a0 c = sbrk(-PGSIZE); 27ae: 757d lui a0,0xfffff 27b0: 00003097 auipc ra,0x3 27b4: fd4080e7 jalr -44(ra) # 5784 <sbrk> if(c == (char*)0xffffffffffffffffL){ 27b8: 57fd li a5,-1 27ba: 0af50363 beq a0,a5,2860 <sbrkmuch+0x124> c = sbrk(0); 27be: 4501 li a0,0 27c0: 00003097 auipc ra,0x3 27c4: fc4080e7 jalr -60(ra) # 5784 <sbrk> if(c != a - PGSIZE){ 27c8: 77fd lui a5,0xfffff 27ca: 97a6 add a5,a5,s1 27cc: 0af51863 bne a0,a5,287c <sbrkmuch+0x140> a = sbrk(0); 27d0: 4501 li a0,0 27d2: 00003097 auipc ra,0x3 27d6: fb2080e7 jalr -78(ra) # 5784 <sbrk> 27da: 84aa mv s1,a0 c = sbrk(PGSIZE); 27dc: 6505 lui a0,0x1 27de: 00003097 auipc ra,0x3 27e2: fa6080e7 jalr -90(ra) # 5784 <sbrk> 27e6: 8a2a mv s4,a0 if(c != a || sbrk(0) != a + PGSIZE){ 27e8: 0aa49a63 bne s1,a0,289c <sbrkmuch+0x160> 27ec: 4501 li a0,0 27ee: 00003097 auipc ra,0x3 27f2: f96080e7 jalr -106(ra) # 5784 <sbrk> 27f6: 6785 lui a5,0x1 27f8: 97a6 add a5,a5,s1 27fa: 0af51163 bne a0,a5,289c <sbrkmuch+0x160> if(*lastaddr == 99){ 27fe: 064007b7 lui a5,0x6400 2802: fff7c703 lbu a4,-1(a5) # 63fffff <__BSS_END__+0x63f1417> 2806: 06300793 li a5,99 280a: 0af70963 beq a4,a5,28bc <sbrkmuch+0x180> a = sbrk(0); 280e: 4501 li a0,0 2810: 00003097 auipc ra,0x3 2814: f74080e7 jalr -140(ra) # 5784 <sbrk> 2818: 84aa mv s1,a0 c = sbrk(-(sbrk(0) - oldbrk)); 281a: 4501 li a0,0 281c: 00003097 auipc ra,0x3 2820: f68080e7 jalr -152(ra) # 5784 <sbrk> 2824: 40a9053b subw a0,s2,a0 2828: 00003097 auipc ra,0x3 282c: f5c080e7 jalr -164(ra) # 5784 <sbrk> if(c != a){ 2830: 0aa49463 bne s1,a0,28d8 <sbrkmuch+0x19c> } 2834: 70a2 ld ra,40(sp) 2836: 7402 ld s0,32(sp) 2838: 64e2 ld s1,24(sp) 283a: 6942 ld s2,16(sp) 283c: 69a2 ld s3,8(sp) 283e: 6a02 ld s4,0(sp) 2840: 6145 addi sp,sp,48 2842: 8082 ret printf("%s: sbrk test failed to grow big address space; enough phys mem?\n", s); 2844: 85ce mv a1,s3 2846: 00004517 auipc a0,0x4 284a: 53250513 addi a0,a0,1330 # 6d78 <malloc+0x1236> 284e: 00003097 auipc ra,0x3 2852: 236080e7 jalr 566(ra) # 5a84 <printf> exit(1); 2856: 4505 li a0,1 2858: 00003097 auipc ra,0x3 285c: ea4080e7 jalr -348(ra) # 56fc <exit> printf("%s: sbrk could not deallocate\n", s); 2860: 85ce mv a1,s3 2862: 00004517 auipc a0,0x4 2866: 55e50513 addi a0,a0,1374 # 6dc0 <malloc+0x127e> 286a: 00003097 auipc ra,0x3 286e: 21a080e7 jalr 538(ra) # 5a84 <printf> exit(1); 2872: 4505 li a0,1 2874: 00003097 auipc ra,0x3 2878: e88080e7 jalr -376(ra) # 56fc <exit> printf("%s: sbrk deallocation produced wrong address, a %x c %x\n", s, a, c); 287c: 86aa mv a3,a0 287e: 8626 mv a2,s1 2880: 85ce mv a1,s3 2882: 00004517 auipc a0,0x4 2886: 55e50513 addi a0,a0,1374 # 6de0 <malloc+0x129e> 288a: 00003097 auipc ra,0x3 288e: 1fa080e7 jalr 506(ra) # 5a84 <printf> exit(1); 2892: 4505 li a0,1 2894: 00003097 auipc ra,0x3 2898: e68080e7 jalr -408(ra) # 56fc <exit> printf("%s: sbrk re-allocation failed, a %x c %x\n", s, a, c); 289c: 86d2 mv a3,s4 289e: 8626 mv a2,s1 28a0: 85ce mv a1,s3 28a2: 00004517 auipc a0,0x4 28a6: 57e50513 addi a0,a0,1406 # 6e20 <malloc+0x12de> 28aa: 00003097 auipc ra,0x3 28ae: 1da080e7 jalr 474(ra) # 5a84 <printf> exit(1); 28b2: 4505 li a0,1 28b4: 00003097 auipc ra,0x3 28b8: e48080e7 jalr -440(ra) # 56fc <exit> printf("%s: sbrk de-allocation didn't really deallocate\n", s); 28bc: 85ce mv a1,s3 28be: 00004517 auipc a0,0x4 28c2: 59250513 addi a0,a0,1426 # 6e50 <malloc+0x130e> 28c6: 00003097 auipc ra,0x3 28ca: 1be080e7 jalr 446(ra) # 5a84 <printf> exit(1); 28ce: 4505 li a0,1 28d0: 00003097 auipc ra,0x3 28d4: e2c080e7 jalr -468(ra) # 56fc <exit> printf("%s: sbrk downsize failed, a %x c %x\n", s, a, c); 28d8: 86aa mv a3,a0 28da: 8626 mv a2,s1 28dc: 85ce mv a1,s3 28de: 00004517 auipc a0,0x4 28e2: 5aa50513 addi a0,a0,1450 # 6e88 <malloc+0x1346> 28e6: 00003097 auipc ra,0x3 28ea: 19e080e7 jalr 414(ra) # 5a84 <printf> exit(1); 28ee: 4505 li a0,1 28f0: 00003097 auipc ra,0x3 28f4: e0c080e7 jalr -500(ra) # 56fc <exit> 00000000000028f8 <sbrkarg>: { 28f8: 7179 addi sp,sp,-48 28fa: f406 sd ra,40(sp) 28fc: f022 sd s0,32(sp) 28fe: ec26 sd s1,24(sp) 2900: e84a sd s2,16(sp) 2902: e44e sd s3,8(sp) 2904: 1800 addi s0,sp,48 2906: 89aa mv s3,a0 a = sbrk(PGSIZE); 2908: 6505 lui a0,0x1 290a: 00003097 auipc ra,0x3 290e: e7a080e7 jalr -390(ra) # 5784 <sbrk> 2912: 892a mv s2,a0 fd = open("sbrk", O_CREATE|O_WRONLY); 2914: 20100593 li a1,513 2918: 00004517 auipc a0,0x4 291c: 59850513 addi a0,a0,1432 # 6eb0 <malloc+0x136e> 2920: 00003097 auipc ra,0x3 2924: e1c080e7 jalr -484(ra) # 573c <open> 2928: 84aa mv s1,a0 unlink("sbrk"); 292a: 00004517 auipc a0,0x4 292e: 58650513 addi a0,a0,1414 # 6eb0 <malloc+0x136e> 2932: 00003097 auipc ra,0x3 2936: e1a080e7 jalr -486(ra) # 574c <unlink> if(fd < 0) { 293a: 0404c163 bltz s1,297c <sbrkarg+0x84> if ((n = write(fd, a, PGSIZE)) < 0) { 293e: 6605 lui a2,0x1 2940: 85ca mv a1,s2 2942: 8526 mv a0,s1 2944: 00003097 auipc ra,0x3 2948: dd8080e7 jalr -552(ra) # 571c <write> 294c: 04054663 bltz a0,2998 <sbrkarg+0xa0> close(fd); 2950: 8526 mv a0,s1 2952: 00003097 auipc ra,0x3 2956: dd2080e7 jalr -558(ra) # 5724 <close> a = sbrk(PGSIZE); 295a: 6505 lui a0,0x1 295c: 00003097 auipc ra,0x3 2960: e28080e7 jalr -472(ra) # 5784 <sbrk> if(pipe((int *) a) != 0){ 2964: 00003097 auipc ra,0x3 2968: da8080e7 jalr -600(ra) # 570c <pipe> 296c: e521 bnez a0,29b4 <sbrkarg+0xbc> } 296e: 70a2 ld ra,40(sp) 2970: 7402 ld s0,32(sp) 2972: 64e2 ld s1,24(sp) 2974: 6942 ld s2,16(sp) 2976: 69a2 ld s3,8(sp) 2978: 6145 addi sp,sp,48 297a: 8082 ret printf("%s: open sbrk failed\n", s); 297c: 85ce mv a1,s3 297e: 00004517 auipc a0,0x4 2982: 53a50513 addi a0,a0,1338 # 6eb8 <malloc+0x1376> 2986: 00003097 auipc ra,0x3 298a: 0fe080e7 jalr 254(ra) # 5a84 <printf> exit(1); 298e: 4505 li a0,1 2990: 00003097 auipc ra,0x3 2994: d6c080e7 jalr -660(ra) # 56fc <exit> printf("%s: write sbrk failed\n", s); 2998: 85ce mv a1,s3 299a: 00004517 auipc a0,0x4 299e: 53650513 addi a0,a0,1334 # 6ed0 <malloc+0x138e> 29a2: 00003097 auipc ra,0x3 29a6: 0e2080e7 jalr 226(ra) # 5a84 <printf> exit(1); 29aa: 4505 li a0,1 29ac: 00003097 auipc ra,0x3 29b0: d50080e7 jalr -688(ra) # 56fc <exit> printf("%s: pipe() failed\n", s); 29b4: 85ce mv a1,s3 29b6: 00004517 auipc a0,0x4 29ba: f1a50513 addi a0,a0,-230 # 68d0 <malloc+0xd8e> 29be: 00003097 auipc ra,0x3 29c2: 0c6080e7 jalr 198(ra) # 5a84 <printf> exit(1); 29c6: 4505 li a0,1 29c8: 00003097 auipc ra,0x3 29cc: d34080e7 jalr -716(ra) # 56fc <exit> 00000000000029d0 <argptest>: { 29d0: 1101 addi sp,sp,-32 29d2: ec06 sd ra,24(sp) 29d4: e822 sd s0,16(sp) 29d6: e426 sd s1,8(sp) 29d8: e04a sd s2,0(sp) 29da: 1000 addi s0,sp,32 29dc: 892a mv s2,a0 fd = open("init", O_RDONLY); 29de: 4581 li a1,0 29e0: 00004517 auipc a0,0x4 29e4: 50850513 addi a0,a0,1288 # 6ee8 <malloc+0x13a6> 29e8: 00003097 auipc ra,0x3 29ec: d54080e7 jalr -684(ra) # 573c <open> if (fd < 0) { 29f0: 02054b63 bltz a0,2a26 <argptest+0x56> 29f4: 84aa mv s1,a0 read(fd, sbrk(0) - 1, -1); 29f6: 4501 li a0,0 29f8: 00003097 auipc ra,0x3 29fc: d8c080e7 jalr -628(ra) # 5784 <sbrk> 2a00: 567d li a2,-1 2a02: fff50593 addi a1,a0,-1 2a06: 8526 mv a0,s1 2a08: 00003097 auipc ra,0x3 2a0c: d0c080e7 jalr -756(ra) # 5714 <read> close(fd); 2a10: 8526 mv a0,s1 2a12: 00003097 auipc ra,0x3 2a16: d12080e7 jalr -750(ra) # 5724 <close> } 2a1a: 60e2 ld ra,24(sp) 2a1c: 6442 ld s0,16(sp) 2a1e: 64a2 ld s1,8(sp) 2a20: 6902 ld s2,0(sp) 2a22: 6105 addi sp,sp,32 2a24: 8082 ret printf("%s: open failed\n", s); 2a26: 85ca mv a1,s2 2a28: 00004517 auipc a0,0x4 2a2c: db850513 addi a0,a0,-584 # 67e0 <malloc+0xc9e> 2a30: 00003097 auipc ra,0x3 2a34: 054080e7 jalr 84(ra) # 5a84 <printf> exit(1); 2a38: 4505 li a0,1 2a3a: 00003097 auipc ra,0x3 2a3e: cc2080e7 jalr -830(ra) # 56fc <exit> 0000000000002a42 <sbrkbugs>: { 2a42: 1141 addi sp,sp,-16 2a44: e406 sd ra,8(sp) 2a46: e022 sd s0,0(sp) 2a48: 0800 addi s0,sp,16 int pid = fork(); 2a4a: 00003097 auipc ra,0x3 2a4e: caa080e7 jalr -854(ra) # 56f4 <fork> if(pid < 0){ 2a52: 02054263 bltz a0,2a76 <sbrkbugs+0x34> if(pid == 0){ 2a56: ed0d bnez a0,2a90 <sbrkbugs+0x4e> int sz = (uint64) sbrk(0); 2a58: 00003097 auipc ra,0x3 2a5c: d2c080e7 jalr -724(ra) # 5784 <sbrk> sbrk(-sz); 2a60: 40a0053b negw a0,a0 2a64: 00003097 auipc ra,0x3 2a68: d20080e7 jalr -736(ra) # 5784 <sbrk> exit(0); 2a6c: 4501 li a0,0 2a6e: 00003097 auipc ra,0x3 2a72: c8e080e7 jalr -882(ra) # 56fc <exit> printf("fork failed\n"); 2a76: 00004517 auipc a0,0x4 2a7a: 15a50513 addi a0,a0,346 # 6bd0 <malloc+0x108e> 2a7e: 00003097 auipc ra,0x3 2a82: 006080e7 jalr 6(ra) # 5a84 <printf> exit(1); 2a86: 4505 li a0,1 2a88: 00003097 auipc ra,0x3 2a8c: c74080e7 jalr -908(ra) # 56fc <exit> wait(0); 2a90: 4501 li a0,0 2a92: 00003097 auipc ra,0x3 2a96: c72080e7 jalr -910(ra) # 5704 <wait> pid = fork(); 2a9a: 00003097 auipc ra,0x3 2a9e: c5a080e7 jalr -934(ra) # 56f4 <fork> if(pid < 0){ 2aa2: 02054563 bltz a0,2acc <sbrkbugs+0x8a> if(pid == 0){ 2aa6: e121 bnez a0,2ae6 <sbrkbugs+0xa4> int sz = (uint64) sbrk(0); 2aa8: 00003097 auipc ra,0x3 2aac: cdc080e7 jalr -804(ra) # 5784 <sbrk> sbrk(-(sz - 3500)); 2ab0: 6785 lui a5,0x1 2ab2: dac7879b addiw a5,a5,-596 2ab6: 40a7853b subw a0,a5,a0 2aba: 00003097 auipc ra,0x3 2abe: cca080e7 jalr -822(ra) # 5784 <sbrk> exit(0); 2ac2: 4501 li a0,0 2ac4: 00003097 auipc ra,0x3 2ac8: c38080e7 jalr -968(ra) # 56fc <exit> printf("fork failed\n"); 2acc: 00004517 auipc a0,0x4 2ad0: 10450513 addi a0,a0,260 # 6bd0 <malloc+0x108e> 2ad4: 00003097 auipc ra,0x3 2ad8: fb0080e7 jalr -80(ra) # 5a84 <printf> exit(1); 2adc: 4505 li a0,1 2ade: 00003097 auipc ra,0x3 2ae2: c1e080e7 jalr -994(ra) # 56fc <exit> wait(0); 2ae6: 4501 li a0,0 2ae8: 00003097 auipc ra,0x3 2aec: c1c080e7 jalr -996(ra) # 5704 <wait> pid = fork(); 2af0: 00003097 auipc ra,0x3 2af4: c04080e7 jalr -1020(ra) # 56f4 <fork> if(pid < 0){ 2af8: 02054a63 bltz a0,2b2c <sbrkbugs+0xea> if(pid == 0){ 2afc: e529 bnez a0,2b46 <sbrkbugs+0x104> sbrk((10*4096 + 2048) - (uint64)sbrk(0)); 2afe: 00003097 auipc ra,0x3 2b02: c86080e7 jalr -890(ra) # 5784 <sbrk> 2b06: 67ad lui a5,0xb 2b08: 8007879b addiw a5,a5,-2048 2b0c: 40a7853b subw a0,a5,a0 2b10: 00003097 auipc ra,0x3 2b14: c74080e7 jalr -908(ra) # 5784 <sbrk> sbrk(-10); 2b18: 5559 li a0,-10 2b1a: 00003097 auipc ra,0x3 2b1e: c6a080e7 jalr -918(ra) # 5784 <sbrk> exit(0); 2b22: 4501 li a0,0 2b24: 00003097 auipc ra,0x3 2b28: bd8080e7 jalr -1064(ra) # 56fc <exit> printf("fork failed\n"); 2b2c: 00004517 auipc a0,0x4 2b30: 0a450513 addi a0,a0,164 # 6bd0 <malloc+0x108e> 2b34: 00003097 auipc ra,0x3 2b38: f50080e7 jalr -176(ra) # 5a84 <printf> exit(1); 2b3c: 4505 li a0,1 2b3e: 00003097 auipc ra,0x3 2b42: bbe080e7 jalr -1090(ra) # 56fc <exit> wait(0); 2b46: 4501 li a0,0 2b48: 00003097 auipc ra,0x3 2b4c: bbc080e7 jalr -1092(ra) # 5704 <wait> exit(0); 2b50: 4501 li a0,0 2b52: 00003097 auipc ra,0x3 2b56: baa080e7 jalr -1110(ra) # 56fc <exit> 0000000000002b5a <execout>: // test the exec() code that cleans up if it runs out // of memory. it's really a test that such a condition // doesn't cause a panic. void execout(char *s) { 2b5a: 715d addi sp,sp,-80 2b5c: e486 sd ra,72(sp) 2b5e: e0a2 sd s0,64(sp) 2b60: fc26 sd s1,56(sp) 2b62: f84a sd s2,48(sp) 2b64: f44e sd s3,40(sp) 2b66: f052 sd s4,32(sp) 2b68: 0880 addi s0,sp,80 for(int avail = 0; avail < 15; avail++){ 2b6a: 4901 li s2,0 2b6c: 49bd li s3,15 int pid = fork(); 2b6e: 00003097 auipc ra,0x3 2b72: b86080e7 jalr -1146(ra) # 56f4 <fork> 2b76: 84aa mv s1,a0 if(pid < 0){ 2b78: 02054063 bltz a0,2b98 <execout+0x3e> printf("fork failed\n"); exit(1); } else if(pid == 0){ 2b7c: c91d beqz a0,2bb2 <execout+0x58> close(1); char *args[] = { "echo", "x", 0 }; exec("echo", args); exit(0); } else { wait((int*)0); 2b7e: 4501 li a0,0 2b80: 00003097 auipc ra,0x3 2b84: b84080e7 jalr -1148(ra) # 5704 <wait> for(int avail = 0; avail < 15; avail++){ 2b88: 2905 addiw s2,s2,1 2b8a: ff3912e3 bne s2,s3,2b6e <execout+0x14> } } exit(0); 2b8e: 4501 li a0,0 2b90: 00003097 auipc ra,0x3 2b94: b6c080e7 jalr -1172(ra) # 56fc <exit> printf("fork failed\n"); 2b98: 00004517 auipc a0,0x4 2b9c: 03850513 addi a0,a0,56 # 6bd0 <malloc+0x108e> 2ba0: 00003097 auipc ra,0x3 2ba4: ee4080e7 jalr -284(ra) # 5a84 <printf> exit(1); 2ba8: 4505 li a0,1 2baa: 00003097 auipc ra,0x3 2bae: b52080e7 jalr -1198(ra) # 56fc <exit> if(a == 0xffffffffffffffffLL) 2bb2: 59fd li s3,-1 *(char*)(a + 4096 - 1) = 1; 2bb4: 4a05 li s4,1 uint64 a = (uint64) sbrk(4096); 2bb6: 6505 lui a0,0x1 2bb8: 00003097 auipc ra,0x3 2bbc: bcc080e7 jalr -1076(ra) # 5784 <sbrk> if(a == 0xffffffffffffffffLL) 2bc0: 01350763 beq a0,s3,2bce <execout+0x74> *(char*)(a + 4096 - 1) = 1; 2bc4: 6785 lui a5,0x1 2bc6: 953e add a0,a0,a5 2bc8: ff450fa3 sb s4,-1(a0) # fff <bigdir+0x9d> while(1){ 2bcc: b7ed j 2bb6 <execout+0x5c> for(int i = 0; i < avail; i++) 2bce: 01205a63 blez s2,2be2 <execout+0x88> sbrk(-4096); 2bd2: 757d lui a0,0xfffff 2bd4: 00003097 auipc ra,0x3 2bd8: bb0080e7 jalr -1104(ra) # 5784 <sbrk> for(int i = 0; i < avail; i++) 2bdc: 2485 addiw s1,s1,1 2bde: ff249ae3 bne s1,s2,2bd2 <execout+0x78> close(1); 2be2: 4505 li a0,1 2be4: 00003097 auipc ra,0x3 2be8: b40080e7 jalr -1216(ra) # 5724 <close> char *args[] = { "echo", "x", 0 }; 2bec: 00003517 auipc a0,0x3 2bf0: 3a450513 addi a0,a0,932 # 5f90 <malloc+0x44e> 2bf4: faa43c23 sd a0,-72(s0) 2bf8: 00003797 auipc a5,0x3 2bfc: 40878793 addi a5,a5,1032 # 6000 <malloc+0x4be> 2c00: fcf43023 sd a5,-64(s0) 2c04: fc043423 sd zero,-56(s0) exec("echo", args); 2c08: fb840593 addi a1,s0,-72 2c0c: 00003097 auipc ra,0x3 2c10: b28080e7 jalr -1240(ra) # 5734 <exec> exit(0); 2c14: 4501 li a0,0 2c16: 00003097 auipc ra,0x3 2c1a: ae6080e7 jalr -1306(ra) # 56fc <exit> 0000000000002c1e <fourteen>: { 2c1e: 1101 addi sp,sp,-32 2c20: ec06 sd ra,24(sp) 2c22: e822 sd s0,16(sp) 2c24: e426 sd s1,8(sp) 2c26: 1000 addi s0,sp,32 2c28: 84aa mv s1,a0 if(mkdir("12345678901234") != 0){ 2c2a: 00004517 auipc a0,0x4 2c2e: 49650513 addi a0,a0,1174 # 70c0 <malloc+0x157e> 2c32: 00003097 auipc ra,0x3 2c36: b32080e7 jalr -1230(ra) # 5764 <mkdir> 2c3a: e165 bnez a0,2d1a <fourteen+0xfc> if(mkdir("12345678901234/123456789012345") != 0){ 2c3c: 00004517 auipc a0,0x4 2c40: 2dc50513 addi a0,a0,732 # 6f18 <malloc+0x13d6> 2c44: 00003097 auipc ra,0x3 2c48: b20080e7 jalr -1248(ra) # 5764 <mkdir> 2c4c: e56d bnez a0,2d36 <fourteen+0x118> fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); 2c4e: 20000593 li a1,512 2c52: 00004517 auipc a0,0x4 2c56: 31e50513 addi a0,a0,798 # 6f70 <malloc+0x142e> 2c5a: 00003097 auipc ra,0x3 2c5e: ae2080e7 jalr -1310(ra) # 573c <open> if(fd < 0){ 2c62: 0e054863 bltz a0,2d52 <fourteen+0x134> close(fd); 2c66: 00003097 auipc ra,0x3 2c6a: abe080e7 jalr -1346(ra) # 5724 <close> fd = open("12345678901234/12345678901234/12345678901234", 0); 2c6e: 4581 li a1,0 2c70: 00004517 auipc a0,0x4 2c74: 37850513 addi a0,a0,888 # 6fe8 <malloc+0x14a6> 2c78: 00003097 auipc ra,0x3 2c7c: ac4080e7 jalr -1340(ra) # 573c <open> if(fd < 0){ 2c80: 0e054763 bltz a0,2d6e <fourteen+0x150> close(fd); 2c84: 00003097 auipc ra,0x3 2c88: aa0080e7 jalr -1376(ra) # 5724 <close> if(mkdir("12345678901234/12345678901234") == 0){ 2c8c: 00004517 auipc a0,0x4 2c90: 3cc50513 addi a0,a0,972 # 7058 <malloc+0x1516> 2c94: 00003097 auipc ra,0x3 2c98: ad0080e7 jalr -1328(ra) # 5764 <mkdir> 2c9c: c57d beqz a0,2d8a <fourteen+0x16c> if(mkdir("123456789012345/12345678901234") == 0){ 2c9e: 00004517 auipc a0,0x4 2ca2: 41250513 addi a0,a0,1042 # 70b0 <malloc+0x156e> 2ca6: 00003097 auipc ra,0x3 2caa: abe080e7 jalr -1346(ra) # 5764 <mkdir> 2cae: cd65 beqz a0,2da6 <fourteen+0x188> unlink("123456789012345/12345678901234"); 2cb0: 00004517 auipc a0,0x4 2cb4: 40050513 addi a0,a0,1024 # 70b0 <malloc+0x156e> 2cb8: 00003097 auipc ra,0x3 2cbc: a94080e7 jalr -1388(ra) # 574c <unlink> unlink("12345678901234/12345678901234"); 2cc0: 00004517 auipc a0,0x4 2cc4: 39850513 addi a0,a0,920 # 7058 <malloc+0x1516> 2cc8: 00003097 auipc ra,0x3 2ccc: a84080e7 jalr -1404(ra) # 574c <unlink> unlink("12345678901234/12345678901234/12345678901234"); 2cd0: 00004517 auipc a0,0x4 2cd4: 31850513 addi a0,a0,792 # 6fe8 <malloc+0x14a6> 2cd8: 00003097 auipc ra,0x3 2cdc: a74080e7 jalr -1420(ra) # 574c <unlink> unlink("123456789012345/123456789012345/123456789012345"); 2ce0: 00004517 auipc a0,0x4 2ce4: 29050513 addi a0,a0,656 # 6f70 <malloc+0x142e> 2ce8: 00003097 auipc ra,0x3 2cec: a64080e7 jalr -1436(ra) # 574c <unlink> unlink("12345678901234/123456789012345"); 2cf0: 00004517 auipc a0,0x4 2cf4: 22850513 addi a0,a0,552 # 6f18 <malloc+0x13d6> 2cf8: 00003097 auipc ra,0x3 2cfc: a54080e7 jalr -1452(ra) # 574c <unlink> unlink("12345678901234"); 2d00: 00004517 auipc a0,0x4 2d04: 3c050513 addi a0,a0,960 # 70c0 <malloc+0x157e> 2d08: 00003097 auipc ra,0x3 2d0c: a44080e7 jalr -1468(ra) # 574c <unlink> } 2d10: 60e2 ld ra,24(sp) 2d12: 6442 ld s0,16(sp) 2d14: 64a2 ld s1,8(sp) 2d16: 6105 addi sp,sp,32 2d18: 8082 ret printf("%s: mkdir 12345678901234 failed\n", s); 2d1a: 85a6 mv a1,s1 2d1c: 00004517 auipc a0,0x4 2d20: 1d450513 addi a0,a0,468 # 6ef0 <malloc+0x13ae> 2d24: 00003097 auipc ra,0x3 2d28: d60080e7 jalr -672(ra) # 5a84 <printf> exit(1); 2d2c: 4505 li a0,1 2d2e: 00003097 auipc ra,0x3 2d32: 9ce080e7 jalr -1586(ra) # 56fc <exit> printf("%s: mkdir 12345678901234/123456789012345 failed\n", s); 2d36: 85a6 mv a1,s1 2d38: 00004517 auipc a0,0x4 2d3c: 20050513 addi a0,a0,512 # 6f38 <malloc+0x13f6> 2d40: 00003097 auipc ra,0x3 2d44: d44080e7 jalr -700(ra) # 5a84 <printf> exit(1); 2d48: 4505 li a0,1 2d4a: 00003097 auipc ra,0x3 2d4e: 9b2080e7 jalr -1614(ra) # 56fc <exit> printf("%s: create 123456789012345/123456789012345/123456789012345 failed\n", s); 2d52: 85a6 mv a1,s1 2d54: 00004517 auipc a0,0x4 2d58: 24c50513 addi a0,a0,588 # 6fa0 <malloc+0x145e> 2d5c: 00003097 auipc ra,0x3 2d60: d28080e7 jalr -728(ra) # 5a84 <printf> exit(1); 2d64: 4505 li a0,1 2d66: 00003097 auipc ra,0x3 2d6a: 996080e7 jalr -1642(ra) # 56fc <exit> printf("%s: open 12345678901234/12345678901234/12345678901234 failed\n", s); 2d6e: 85a6 mv a1,s1 2d70: 00004517 auipc a0,0x4 2d74: 2a850513 addi a0,a0,680 # 7018 <malloc+0x14d6> 2d78: 00003097 auipc ra,0x3 2d7c: d0c080e7 jalr -756(ra) # 5a84 <printf> exit(1); 2d80: 4505 li a0,1 2d82: 00003097 auipc ra,0x3 2d86: 97a080e7 jalr -1670(ra) # 56fc <exit> printf("%s: mkdir 12345678901234/12345678901234 succeeded!\n", s); 2d8a: 85a6 mv a1,s1 2d8c: 00004517 auipc a0,0x4 2d90: 2ec50513 addi a0,a0,748 # 7078 <malloc+0x1536> 2d94: 00003097 auipc ra,0x3 2d98: cf0080e7 jalr -784(ra) # 5a84 <printf> exit(1); 2d9c: 4505 li a0,1 2d9e: 00003097 auipc ra,0x3 2da2: 95e080e7 jalr -1698(ra) # 56fc <exit> printf("%s: mkdir 12345678901234/123456789012345 succeeded!\n", s); 2da6: 85a6 mv a1,s1 2da8: 00004517 auipc a0,0x4 2dac: 32850513 addi a0,a0,808 # 70d0 <malloc+0x158e> 2db0: 00003097 auipc ra,0x3 2db4: cd4080e7 jalr -812(ra) # 5a84 <printf> exit(1); 2db8: 4505 li a0,1 2dba: 00003097 auipc ra,0x3 2dbe: 942080e7 jalr -1726(ra) # 56fc <exit> 0000000000002dc2 <iputtest>: { 2dc2: 1101 addi sp,sp,-32 2dc4: ec06 sd ra,24(sp) 2dc6: e822 sd s0,16(sp) 2dc8: e426 sd s1,8(sp) 2dca: 1000 addi s0,sp,32 2dcc: 84aa mv s1,a0 if(mkdir("iputdir") < 0){ 2dce: 00004517 auipc a0,0x4 2dd2: 33a50513 addi a0,a0,826 # 7108 <malloc+0x15c6> 2dd6: 00003097 auipc ra,0x3 2dda: 98e080e7 jalr -1650(ra) # 5764 <mkdir> 2dde: 04054563 bltz a0,2e28 <iputtest+0x66> if(chdir("iputdir") < 0){ 2de2: 00004517 auipc a0,0x4 2de6: 32650513 addi a0,a0,806 # 7108 <malloc+0x15c6> 2dea: 00003097 auipc ra,0x3 2dee: 982080e7 jalr -1662(ra) # 576c <chdir> 2df2: 04054963 bltz a0,2e44 <iputtest+0x82> if(unlink("../iputdir") < 0){ 2df6: 00004517 auipc a0,0x4 2dfa: 35250513 addi a0,a0,850 # 7148 <malloc+0x1606> 2dfe: 00003097 auipc ra,0x3 2e02: 94e080e7 jalr -1714(ra) # 574c <unlink> 2e06: 04054d63 bltz a0,2e60 <iputtest+0x9e> if(chdir("/") < 0){ 2e0a: 00004517 auipc a0,0x4 2e0e: 36e50513 addi a0,a0,878 # 7178 <malloc+0x1636> 2e12: 00003097 auipc ra,0x3 2e16: 95a080e7 jalr -1702(ra) # 576c <chdir> 2e1a: 06054163 bltz a0,2e7c <iputtest+0xba> } 2e1e: 60e2 ld ra,24(sp) 2e20: 6442 ld s0,16(sp) 2e22: 64a2 ld s1,8(sp) 2e24: 6105 addi sp,sp,32 2e26: 8082 ret printf("%s: mkdir failed\n", s); 2e28: 85a6 mv a1,s1 2e2a: 00004517 auipc a0,0x4 2e2e: 2e650513 addi a0,a0,742 # 7110 <malloc+0x15ce> 2e32: 00003097 auipc ra,0x3 2e36: c52080e7 jalr -942(ra) # 5a84 <printf> exit(1); 2e3a: 4505 li a0,1 2e3c: 00003097 auipc ra,0x3 2e40: 8c0080e7 jalr -1856(ra) # 56fc <exit> printf("%s: chdir iputdir failed\n", s); 2e44: 85a6 mv a1,s1 2e46: 00004517 auipc a0,0x4 2e4a: 2e250513 addi a0,a0,738 # 7128 <malloc+0x15e6> 2e4e: 00003097 auipc ra,0x3 2e52: c36080e7 jalr -970(ra) # 5a84 <printf> exit(1); 2e56: 4505 li a0,1 2e58: 00003097 auipc ra,0x3 2e5c: 8a4080e7 jalr -1884(ra) # 56fc <exit> printf("%s: unlink ../iputdir failed\n", s); 2e60: 85a6 mv a1,s1 2e62: 00004517 auipc a0,0x4 2e66: 2f650513 addi a0,a0,758 # 7158 <malloc+0x1616> 2e6a: 00003097 auipc ra,0x3 2e6e: c1a080e7 jalr -998(ra) # 5a84 <printf> exit(1); 2e72: 4505 li a0,1 2e74: 00003097 auipc ra,0x3 2e78: 888080e7 jalr -1912(ra) # 56fc <exit> printf("%s: chdir / failed\n", s); 2e7c: 85a6 mv a1,s1 2e7e: 00004517 auipc a0,0x4 2e82: 30250513 addi a0,a0,770 # 7180 <malloc+0x163e> 2e86: 00003097 auipc ra,0x3 2e8a: bfe080e7 jalr -1026(ra) # 5a84 <printf> exit(1); 2e8e: 4505 li a0,1 2e90: 00003097 auipc ra,0x3 2e94: 86c080e7 jalr -1940(ra) # 56fc <exit> 0000000000002e98 <exitiputtest>: { 2e98: 7179 addi sp,sp,-48 2e9a: f406 sd ra,40(sp) 2e9c: f022 sd s0,32(sp) 2e9e: ec26 sd s1,24(sp) 2ea0: 1800 addi s0,sp,48 2ea2: 84aa mv s1,a0 pid = fork(); 2ea4: 00003097 auipc ra,0x3 2ea8: 850080e7 jalr -1968(ra) # 56f4 <fork> if(pid < 0){ 2eac: 04054663 bltz a0,2ef8 <exitiputtest+0x60> if(pid == 0){ 2eb0: ed45 bnez a0,2f68 <exitiputtest+0xd0> if(mkdir("iputdir") < 0){ 2eb2: 00004517 auipc a0,0x4 2eb6: 25650513 addi a0,a0,598 # 7108 <malloc+0x15c6> 2eba: 00003097 auipc ra,0x3 2ebe: 8aa080e7 jalr -1878(ra) # 5764 <mkdir> 2ec2: 04054963 bltz a0,2f14 <exitiputtest+0x7c> if(chdir("iputdir") < 0){ 2ec6: 00004517 auipc a0,0x4 2eca: 24250513 addi a0,a0,578 # 7108 <malloc+0x15c6> 2ece: 00003097 auipc ra,0x3 2ed2: 89e080e7 jalr -1890(ra) # 576c <chdir> 2ed6: 04054d63 bltz a0,2f30 <exitiputtest+0x98> if(unlink("../iputdir") < 0){ 2eda: 00004517 auipc a0,0x4 2ede: 26e50513 addi a0,a0,622 # 7148 <malloc+0x1606> 2ee2: 00003097 auipc ra,0x3 2ee6: 86a080e7 jalr -1942(ra) # 574c <unlink> 2eea: 06054163 bltz a0,2f4c <exitiputtest+0xb4> exit(0); 2eee: 4501 li a0,0 2ef0: 00003097 auipc ra,0x3 2ef4: 80c080e7 jalr -2036(ra) # 56fc <exit> printf("%s: fork failed\n", s); 2ef8: 85a6 mv a1,s1 2efa: 00004517 auipc a0,0x4 2efe: 8ce50513 addi a0,a0,-1842 # 67c8 <malloc+0xc86> 2f02: 00003097 auipc ra,0x3 2f06: b82080e7 jalr -1150(ra) # 5a84 <printf> exit(1); 2f0a: 4505 li a0,1 2f0c: 00002097 auipc ra,0x2 2f10: 7f0080e7 jalr 2032(ra) # 56fc <exit> printf("%s: mkdir failed\n", s); 2f14: 85a6 mv a1,s1 2f16: 00004517 auipc a0,0x4 2f1a: 1fa50513 addi a0,a0,506 # 7110 <malloc+0x15ce> 2f1e: 00003097 auipc ra,0x3 2f22: b66080e7 jalr -1178(ra) # 5a84 <printf> exit(1); 2f26: 4505 li a0,1 2f28: 00002097 auipc ra,0x2 2f2c: 7d4080e7 jalr 2004(ra) # 56fc <exit> printf("%s: child chdir failed\n", s); 2f30: 85a6 mv a1,s1 2f32: 00004517 auipc a0,0x4 2f36: 26650513 addi a0,a0,614 # 7198 <malloc+0x1656> 2f3a: 00003097 auipc ra,0x3 2f3e: b4a080e7 jalr -1206(ra) # 5a84 <printf> exit(1); 2f42: 4505 li a0,1 2f44: 00002097 auipc ra,0x2 2f48: 7b8080e7 jalr 1976(ra) # 56fc <exit> printf("%s: unlink ../iputdir failed\n", s); 2f4c: 85a6 mv a1,s1 2f4e: 00004517 auipc a0,0x4 2f52: 20a50513 addi a0,a0,522 # 7158 <malloc+0x1616> 2f56: 00003097 auipc ra,0x3 2f5a: b2e080e7 jalr -1234(ra) # 5a84 <printf> exit(1); 2f5e: 4505 li a0,1 2f60: 00002097 auipc ra,0x2 2f64: 79c080e7 jalr 1948(ra) # 56fc <exit> wait(&xstatus); 2f68: fdc40513 addi a0,s0,-36 2f6c: 00002097 auipc ra,0x2 2f70: 798080e7 jalr 1944(ra) # 5704 <wait> exit(xstatus); 2f74: fdc42503 lw a0,-36(s0) 2f78: 00002097 auipc ra,0x2 2f7c: 784080e7 jalr 1924(ra) # 56fc <exit> 0000000000002f80 <dirtest>: { 2f80: 1101 addi sp,sp,-32 2f82: ec06 sd ra,24(sp) 2f84: e822 sd s0,16(sp) 2f86: e426 sd s1,8(sp) 2f88: 1000 addi s0,sp,32 2f8a: 84aa mv s1,a0 if(mkdir("dir0") < 0){ 2f8c: 00004517 auipc a0,0x4 2f90: 22450513 addi a0,a0,548 # 71b0 <malloc+0x166e> 2f94: 00002097 auipc ra,0x2 2f98: 7d0080e7 jalr 2000(ra) # 5764 <mkdir> 2f9c: 04054563 bltz a0,2fe6 <dirtest+0x66> if(chdir("dir0") < 0){ 2fa0: 00004517 auipc a0,0x4 2fa4: 21050513 addi a0,a0,528 # 71b0 <malloc+0x166e> 2fa8: 00002097 auipc ra,0x2 2fac: 7c4080e7 jalr 1988(ra) # 576c <chdir> 2fb0: 04054963 bltz a0,3002 <dirtest+0x82> if(chdir("..") < 0){ 2fb4: 00004517 auipc a0,0x4 2fb8: 21c50513 addi a0,a0,540 # 71d0 <malloc+0x168e> 2fbc: 00002097 auipc ra,0x2 2fc0: 7b0080e7 jalr 1968(ra) # 576c <chdir> 2fc4: 04054d63 bltz a0,301e <dirtest+0x9e> if(unlink("dir0") < 0){ 2fc8: 00004517 auipc a0,0x4 2fcc: 1e850513 addi a0,a0,488 # 71b0 <malloc+0x166e> 2fd0: 00002097 auipc ra,0x2 2fd4: 77c080e7 jalr 1916(ra) # 574c <unlink> 2fd8: 06054163 bltz a0,303a <dirtest+0xba> } 2fdc: 60e2 ld ra,24(sp) 2fde: 6442 ld s0,16(sp) 2fe0: 64a2 ld s1,8(sp) 2fe2: 6105 addi sp,sp,32 2fe4: 8082 ret printf("%s: mkdir failed\n", s); 2fe6: 85a6 mv a1,s1 2fe8: 00004517 auipc a0,0x4 2fec: 12850513 addi a0,a0,296 # 7110 <malloc+0x15ce> 2ff0: 00003097 auipc ra,0x3 2ff4: a94080e7 jalr -1388(ra) # 5a84 <printf> exit(1); 2ff8: 4505 li a0,1 2ffa: 00002097 auipc ra,0x2 2ffe: 702080e7 jalr 1794(ra) # 56fc <exit> printf("%s: chdir dir0 failed\n", s); 3002: 85a6 mv a1,s1 3004: 00004517 auipc a0,0x4 3008: 1b450513 addi a0,a0,436 # 71b8 <malloc+0x1676> 300c: 00003097 auipc ra,0x3 3010: a78080e7 jalr -1416(ra) # 5a84 <printf> exit(1); 3014: 4505 li a0,1 3016: 00002097 auipc ra,0x2 301a: 6e6080e7 jalr 1766(ra) # 56fc <exit> printf("%s: chdir .. failed\n", s); 301e: 85a6 mv a1,s1 3020: 00004517 auipc a0,0x4 3024: 1b850513 addi a0,a0,440 # 71d8 <malloc+0x1696> 3028: 00003097 auipc ra,0x3 302c: a5c080e7 jalr -1444(ra) # 5a84 <printf> exit(1); 3030: 4505 li a0,1 3032: 00002097 auipc ra,0x2 3036: 6ca080e7 jalr 1738(ra) # 56fc <exit> printf("%s: unlink dir0 failed\n", s); 303a: 85a6 mv a1,s1 303c: 00004517 auipc a0,0x4 3040: 1b450513 addi a0,a0,436 # 71f0 <malloc+0x16ae> 3044: 00003097 auipc ra,0x3 3048: a40080e7 jalr -1472(ra) # 5a84 <printf> exit(1); 304c: 4505 li a0,1 304e: 00002097 auipc ra,0x2 3052: 6ae080e7 jalr 1710(ra) # 56fc <exit> 0000000000003056 <subdir>: { 3056: 1101 addi sp,sp,-32 3058: ec06 sd ra,24(sp) 305a: e822 sd s0,16(sp) 305c: e426 sd s1,8(sp) 305e: e04a sd s2,0(sp) 3060: 1000 addi s0,sp,32 3062: 892a mv s2,a0 unlink("ff"); 3064: 00004517 auipc a0,0x4 3068: 2d450513 addi a0,a0,724 # 7338 <malloc+0x17f6> 306c: 00002097 auipc ra,0x2 3070: 6e0080e7 jalr 1760(ra) # 574c <unlink> if(mkdir("dd") != 0){ 3074: 00004517 auipc a0,0x4 3078: 19450513 addi a0,a0,404 # 7208 <malloc+0x16c6> 307c: 00002097 auipc ra,0x2 3080: 6e8080e7 jalr 1768(ra) # 5764 <mkdir> 3084: 38051663 bnez a0,3410 <subdir+0x3ba> fd = open("dd/ff", O_CREATE | O_RDWR); 3088: 20200593 li a1,514 308c: 00004517 auipc a0,0x4 3090: 19c50513 addi a0,a0,412 # 7228 <malloc+0x16e6> 3094: 00002097 auipc ra,0x2 3098: 6a8080e7 jalr 1704(ra) # 573c <open> 309c: 84aa mv s1,a0 if(fd < 0){ 309e: 38054763 bltz a0,342c <subdir+0x3d6> write(fd, "ff", 2); 30a2: 4609 li a2,2 30a4: 00004597 auipc a1,0x4 30a8: 29458593 addi a1,a1,660 # 7338 <malloc+0x17f6> 30ac: 00002097 auipc ra,0x2 30b0: 670080e7 jalr 1648(ra) # 571c <write> close(fd); 30b4: 8526 mv a0,s1 30b6: 00002097 auipc ra,0x2 30ba: 66e080e7 jalr 1646(ra) # 5724 <close> if(unlink("dd") >= 0){ 30be: 00004517 auipc a0,0x4 30c2: 14a50513 addi a0,a0,330 # 7208 <malloc+0x16c6> 30c6: 00002097 auipc ra,0x2 30ca: 686080e7 jalr 1670(ra) # 574c <unlink> 30ce: 36055d63 bgez a0,3448 <subdir+0x3f2> if(mkdir("/dd/dd") != 0){ 30d2: 00004517 auipc a0,0x4 30d6: 1ae50513 addi a0,a0,430 # 7280 <malloc+0x173e> 30da: 00002097 auipc ra,0x2 30de: 68a080e7 jalr 1674(ra) # 5764 <mkdir> 30e2: 38051163 bnez a0,3464 <subdir+0x40e> fd = open("dd/dd/ff", O_CREATE | O_RDWR); 30e6: 20200593 li a1,514 30ea: 00004517 auipc a0,0x4 30ee: 1be50513 addi a0,a0,446 # 72a8 <malloc+0x1766> 30f2: 00002097 auipc ra,0x2 30f6: 64a080e7 jalr 1610(ra) # 573c <open> 30fa: 84aa mv s1,a0 if(fd < 0){ 30fc: 38054263 bltz a0,3480 <subdir+0x42a> write(fd, "FF", 2); 3100: 4609 li a2,2 3102: 00004597 auipc a1,0x4 3106: 1d658593 addi a1,a1,470 # 72d8 <malloc+0x1796> 310a: 00002097 auipc ra,0x2 310e: 612080e7 jalr 1554(ra) # 571c <write> close(fd); 3112: 8526 mv a0,s1 3114: 00002097 auipc ra,0x2 3118: 610080e7 jalr 1552(ra) # 5724 <close> fd = open("dd/dd/../ff", 0); 311c: 4581 li a1,0 311e: 00004517 auipc a0,0x4 3122: 1c250513 addi a0,a0,450 # 72e0 <malloc+0x179e> 3126: 00002097 auipc ra,0x2 312a: 616080e7 jalr 1558(ra) # 573c <open> 312e: 84aa mv s1,a0 if(fd < 0){ 3130: 36054663 bltz a0,349c <subdir+0x446> cc = read(fd, buf, sizeof(buf)); 3134: 660d lui a2,0x3 3136: 00009597 auipc a1,0x9 313a: aa258593 addi a1,a1,-1374 # bbd8 <buf> 313e: 00002097 auipc ra,0x2 3142: 5d6080e7 jalr 1494(ra) # 5714 <read> if(cc != 2 || buf[0] != 'f'){ 3146: 4789 li a5,2 3148: 36f51863 bne a0,a5,34b8 <subdir+0x462> 314c: 00009717 auipc a4,0x9 3150: a8c74703 lbu a4,-1396(a4) # bbd8 <buf> 3154: 06600793 li a5,102 3158: 36f71063 bne a4,a5,34b8 <subdir+0x462> close(fd); 315c: 8526 mv a0,s1 315e: 00002097 auipc ra,0x2 3162: 5c6080e7 jalr 1478(ra) # 5724 <close> if(link("dd/dd/ff", "dd/dd/ffff") != 0){ 3166: 00004597 auipc a1,0x4 316a: 1ca58593 addi a1,a1,458 # 7330 <malloc+0x17ee> 316e: 00004517 auipc a0,0x4 3172: 13a50513 addi a0,a0,314 # 72a8 <malloc+0x1766> 3176: 00002097 auipc ra,0x2 317a: 5e6080e7 jalr 1510(ra) # 575c <link> 317e: 34051b63 bnez a0,34d4 <subdir+0x47e> if(unlink("dd/dd/ff") != 0){ 3182: 00004517 auipc a0,0x4 3186: 12650513 addi a0,a0,294 # 72a8 <malloc+0x1766> 318a: 00002097 auipc ra,0x2 318e: 5c2080e7 jalr 1474(ra) # 574c <unlink> 3192: 34051f63 bnez a0,34f0 <subdir+0x49a> if(open("dd/dd/ff", O_RDONLY) >= 0){ 3196: 4581 li a1,0 3198: 00004517 auipc a0,0x4 319c: 11050513 addi a0,a0,272 # 72a8 <malloc+0x1766> 31a0: 00002097 auipc ra,0x2 31a4: 59c080e7 jalr 1436(ra) # 573c <open> 31a8: 36055263 bgez a0,350c <subdir+0x4b6> if(chdir("dd") != 0){ 31ac: 00004517 auipc a0,0x4 31b0: 05c50513 addi a0,a0,92 # 7208 <malloc+0x16c6> 31b4: 00002097 auipc ra,0x2 31b8: 5b8080e7 jalr 1464(ra) # 576c <chdir> 31bc: 36051663 bnez a0,3528 <subdir+0x4d2> if(chdir("dd/../../dd") != 0){ 31c0: 00004517 auipc a0,0x4 31c4: 20850513 addi a0,a0,520 # 73c8 <malloc+0x1886> 31c8: 00002097 auipc ra,0x2 31cc: 5a4080e7 jalr 1444(ra) # 576c <chdir> 31d0: 36051a63 bnez a0,3544 <subdir+0x4ee> if(chdir("dd/../../../dd") != 0){ 31d4: 00004517 auipc a0,0x4 31d8: 22450513 addi a0,a0,548 # 73f8 <malloc+0x18b6> 31dc: 00002097 auipc ra,0x2 31e0: 590080e7 jalr 1424(ra) # 576c <chdir> 31e4: 36051e63 bnez a0,3560 <subdir+0x50a> if(chdir("./..") != 0){ 31e8: 00004517 auipc a0,0x4 31ec: 24050513 addi a0,a0,576 # 7428 <malloc+0x18e6> 31f0: 00002097 auipc ra,0x2 31f4: 57c080e7 jalr 1404(ra) # 576c <chdir> 31f8: 38051263 bnez a0,357c <subdir+0x526> fd = open("dd/dd/ffff", 0); 31fc: 4581 li a1,0 31fe: 00004517 auipc a0,0x4 3202: 13250513 addi a0,a0,306 # 7330 <malloc+0x17ee> 3206: 00002097 auipc ra,0x2 320a: 536080e7 jalr 1334(ra) # 573c <open> 320e: 84aa mv s1,a0 if(fd < 0){ 3210: 38054463 bltz a0,3598 <subdir+0x542> if(read(fd, buf, sizeof(buf)) != 2){ 3214: 660d lui a2,0x3 3216: 00009597 auipc a1,0x9 321a: 9c258593 addi a1,a1,-1598 # bbd8 <buf> 321e: 00002097 auipc ra,0x2 3222: 4f6080e7 jalr 1270(ra) # 5714 <read> 3226: 4789 li a5,2 3228: 38f51663 bne a0,a5,35b4 <subdir+0x55e> close(fd); 322c: 8526 mv a0,s1 322e: 00002097 auipc ra,0x2 3232: 4f6080e7 jalr 1270(ra) # 5724 <close> if(open("dd/dd/ff", O_RDONLY) >= 0){ 3236: 4581 li a1,0 3238: 00004517 auipc a0,0x4 323c: 07050513 addi a0,a0,112 # 72a8 <malloc+0x1766> 3240: 00002097 auipc ra,0x2 3244: 4fc080e7 jalr 1276(ra) # 573c <open> 3248: 38055463 bgez a0,35d0 <subdir+0x57a> if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ 324c: 20200593 li a1,514 3250: 00004517 auipc a0,0x4 3254: 26850513 addi a0,a0,616 # 74b8 <malloc+0x1976> 3258: 00002097 auipc ra,0x2 325c: 4e4080e7 jalr 1252(ra) # 573c <open> 3260: 38055663 bgez a0,35ec <subdir+0x596> if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ 3264: 20200593 li a1,514 3268: 00004517 auipc a0,0x4 326c: 28050513 addi a0,a0,640 # 74e8 <malloc+0x19a6> 3270: 00002097 auipc ra,0x2 3274: 4cc080e7 jalr 1228(ra) # 573c <open> 3278: 38055863 bgez a0,3608 <subdir+0x5b2> if(open("dd", O_CREATE) >= 0){ 327c: 20000593 li a1,512 3280: 00004517 auipc a0,0x4 3284: f8850513 addi a0,a0,-120 # 7208 <malloc+0x16c6> 3288: 00002097 auipc ra,0x2 328c: 4b4080e7 jalr 1204(ra) # 573c <open> 3290: 38055a63 bgez a0,3624 <subdir+0x5ce> if(open("dd", O_RDWR) >= 0){ 3294: 4589 li a1,2 3296: 00004517 auipc a0,0x4 329a: f7250513 addi a0,a0,-142 # 7208 <malloc+0x16c6> 329e: 00002097 auipc ra,0x2 32a2: 49e080e7 jalr 1182(ra) # 573c <open> 32a6: 38055d63 bgez a0,3640 <subdir+0x5ea> if(open("dd", O_WRONLY) >= 0){ 32aa: 4585 li a1,1 32ac: 00004517 auipc a0,0x4 32b0: f5c50513 addi a0,a0,-164 # 7208 <malloc+0x16c6> 32b4: 00002097 auipc ra,0x2 32b8: 488080e7 jalr 1160(ra) # 573c <open> 32bc: 3a055063 bgez a0,365c <subdir+0x606> if(link("dd/ff/ff", "dd/dd/xx") == 0){ 32c0: 00004597 auipc a1,0x4 32c4: 2b858593 addi a1,a1,696 # 7578 <malloc+0x1a36> 32c8: 00004517 auipc a0,0x4 32cc: 1f050513 addi a0,a0,496 # 74b8 <malloc+0x1976> 32d0: 00002097 auipc ra,0x2 32d4: 48c080e7 jalr 1164(ra) # 575c <link> 32d8: 3a050063 beqz a0,3678 <subdir+0x622> if(link("dd/xx/ff", "dd/dd/xx") == 0){ 32dc: 00004597 auipc a1,0x4 32e0: 29c58593 addi a1,a1,668 # 7578 <malloc+0x1a36> 32e4: 00004517 auipc a0,0x4 32e8: 20450513 addi a0,a0,516 # 74e8 <malloc+0x19a6> 32ec: 00002097 auipc ra,0x2 32f0: 470080e7 jalr 1136(ra) # 575c <link> 32f4: 3a050063 beqz a0,3694 <subdir+0x63e> if(link("dd/ff", "dd/dd/ffff") == 0){ 32f8: 00004597 auipc a1,0x4 32fc: 03858593 addi a1,a1,56 # 7330 <malloc+0x17ee> 3300: 00004517 auipc a0,0x4 3304: f2850513 addi a0,a0,-216 # 7228 <malloc+0x16e6> 3308: 00002097 auipc ra,0x2 330c: 454080e7 jalr 1108(ra) # 575c <link> 3310: 3a050063 beqz a0,36b0 <subdir+0x65a> if(mkdir("dd/ff/ff") == 0){ 3314: 00004517 auipc a0,0x4 3318: 1a450513 addi a0,a0,420 # 74b8 <malloc+0x1976> 331c: 00002097 auipc ra,0x2 3320: 448080e7 jalr 1096(ra) # 5764 <mkdir> 3324: 3a050463 beqz a0,36cc <subdir+0x676> if(mkdir("dd/xx/ff") == 0){ 3328: 00004517 auipc a0,0x4 332c: 1c050513 addi a0,a0,448 # 74e8 <malloc+0x19a6> 3330: 00002097 auipc ra,0x2 3334: 434080e7 jalr 1076(ra) # 5764 <mkdir> 3338: 3a050863 beqz a0,36e8 <subdir+0x692> if(mkdir("dd/dd/ffff") == 0){ 333c: 00004517 auipc a0,0x4 3340: ff450513 addi a0,a0,-12 # 7330 <malloc+0x17ee> 3344: 00002097 auipc ra,0x2 3348: 420080e7 jalr 1056(ra) # 5764 <mkdir> 334c: 3a050c63 beqz a0,3704 <subdir+0x6ae> if(unlink("dd/xx/ff") == 0){ 3350: 00004517 auipc a0,0x4 3354: 19850513 addi a0,a0,408 # 74e8 <malloc+0x19a6> 3358: 00002097 auipc ra,0x2 335c: 3f4080e7 jalr 1012(ra) # 574c <unlink> 3360: 3c050063 beqz a0,3720 <subdir+0x6ca> if(unlink("dd/ff/ff") == 0){ 3364: 00004517 auipc a0,0x4 3368: 15450513 addi a0,a0,340 # 74b8 <malloc+0x1976> 336c: 00002097 auipc ra,0x2 3370: 3e0080e7 jalr 992(ra) # 574c <unlink> 3374: 3c050463 beqz a0,373c <subdir+0x6e6> if(chdir("dd/ff") == 0){ 3378: 00004517 auipc a0,0x4 337c: eb050513 addi a0,a0,-336 # 7228 <malloc+0x16e6> 3380: 00002097 auipc ra,0x2 3384: 3ec080e7 jalr 1004(ra) # 576c <chdir> 3388: 3c050863 beqz a0,3758 <subdir+0x702> if(chdir("dd/xx") == 0){ 338c: 00004517 auipc a0,0x4 3390: 33c50513 addi a0,a0,828 # 76c8 <malloc+0x1b86> 3394: 00002097 auipc ra,0x2 3398: 3d8080e7 jalr 984(ra) # 576c <chdir> 339c: 3c050c63 beqz a0,3774 <subdir+0x71e> if(unlink("dd/dd/ffff") != 0){ 33a0: 00004517 auipc a0,0x4 33a4: f9050513 addi a0,a0,-112 # 7330 <malloc+0x17ee> 33a8: 00002097 auipc ra,0x2 33ac: 3a4080e7 jalr 932(ra) # 574c <unlink> 33b0: 3e051063 bnez a0,3790 <subdir+0x73a> if(unlink("dd/ff") != 0){ 33b4: 00004517 auipc a0,0x4 33b8: e7450513 addi a0,a0,-396 # 7228 <malloc+0x16e6> 33bc: 00002097 auipc ra,0x2 33c0: 390080e7 jalr 912(ra) # 574c <unlink> 33c4: 3e051463 bnez a0,37ac <subdir+0x756> if(unlink("dd") == 0){ 33c8: 00004517 auipc a0,0x4 33cc: e4050513 addi a0,a0,-448 # 7208 <malloc+0x16c6> 33d0: 00002097 auipc ra,0x2 33d4: 37c080e7 jalr 892(ra) # 574c <unlink> 33d8: 3e050863 beqz a0,37c8 <subdir+0x772> if(unlink("dd/dd") < 0){ 33dc: 00004517 auipc a0,0x4 33e0: 35c50513 addi a0,a0,860 # 7738 <malloc+0x1bf6> 33e4: 00002097 auipc ra,0x2 33e8: 368080e7 jalr 872(ra) # 574c <unlink> 33ec: 3e054c63 bltz a0,37e4 <subdir+0x78e> if(unlink("dd") < 0){ 33f0: 00004517 auipc a0,0x4 33f4: e1850513 addi a0,a0,-488 # 7208 <malloc+0x16c6> 33f8: 00002097 auipc ra,0x2 33fc: 354080e7 jalr 852(ra) # 574c <unlink> 3400: 40054063 bltz a0,3800 <subdir+0x7aa> } 3404: 60e2 ld ra,24(sp) 3406: 6442 ld s0,16(sp) 3408: 64a2 ld s1,8(sp) 340a: 6902 ld s2,0(sp) 340c: 6105 addi sp,sp,32 340e: 8082 ret printf("%s: mkdir dd failed\n", s); 3410: 85ca mv a1,s2 3412: 00004517 auipc a0,0x4 3416: dfe50513 addi a0,a0,-514 # 7210 <malloc+0x16ce> 341a: 00002097 auipc ra,0x2 341e: 66a080e7 jalr 1642(ra) # 5a84 <printf> exit(1); 3422: 4505 li a0,1 3424: 00002097 auipc ra,0x2 3428: 2d8080e7 jalr 728(ra) # 56fc <exit> printf("%s: create dd/ff failed\n", s); 342c: 85ca mv a1,s2 342e: 00004517 auipc a0,0x4 3432: e0250513 addi a0,a0,-510 # 7230 <malloc+0x16ee> 3436: 00002097 auipc ra,0x2 343a: 64e080e7 jalr 1614(ra) # 5a84 <printf> exit(1); 343e: 4505 li a0,1 3440: 00002097 auipc ra,0x2 3444: 2bc080e7 jalr 700(ra) # 56fc <exit> printf("%s: unlink dd (non-empty dir) succeeded!\n", s); 3448: 85ca mv a1,s2 344a: 00004517 auipc a0,0x4 344e: e0650513 addi a0,a0,-506 # 7250 <malloc+0x170e> 3452: 00002097 auipc ra,0x2 3456: 632080e7 jalr 1586(ra) # 5a84 <printf> exit(1); 345a: 4505 li a0,1 345c: 00002097 auipc ra,0x2 3460: 2a0080e7 jalr 672(ra) # 56fc <exit> printf("subdir mkdir dd/dd failed\n", s); 3464: 85ca mv a1,s2 3466: 00004517 auipc a0,0x4 346a: e2250513 addi a0,a0,-478 # 7288 <malloc+0x1746> 346e: 00002097 auipc ra,0x2 3472: 616080e7 jalr 1558(ra) # 5a84 <printf> exit(1); 3476: 4505 li a0,1 3478: 00002097 auipc ra,0x2 347c: 284080e7 jalr 644(ra) # 56fc <exit> printf("%s: create dd/dd/ff failed\n", s); 3480: 85ca mv a1,s2 3482: 00004517 auipc a0,0x4 3486: e3650513 addi a0,a0,-458 # 72b8 <malloc+0x1776> 348a: 00002097 auipc ra,0x2 348e: 5fa080e7 jalr 1530(ra) # 5a84 <printf> exit(1); 3492: 4505 li a0,1 3494: 00002097 auipc ra,0x2 3498: 268080e7 jalr 616(ra) # 56fc <exit> printf("%s: open dd/dd/../ff failed\n", s); 349c: 85ca mv a1,s2 349e: 00004517 auipc a0,0x4 34a2: e5250513 addi a0,a0,-430 # 72f0 <malloc+0x17ae> 34a6: 00002097 auipc ra,0x2 34aa: 5de080e7 jalr 1502(ra) # 5a84 <printf> exit(1); 34ae: 4505 li a0,1 34b0: 00002097 auipc ra,0x2 34b4: 24c080e7 jalr 588(ra) # 56fc <exit> printf("%s: dd/dd/../ff wrong content\n", s); 34b8: 85ca mv a1,s2 34ba: 00004517 auipc a0,0x4 34be: e5650513 addi a0,a0,-426 # 7310 <malloc+0x17ce> 34c2: 00002097 auipc ra,0x2 34c6: 5c2080e7 jalr 1474(ra) # 5a84 <printf> exit(1); 34ca: 4505 li a0,1 34cc: 00002097 auipc ra,0x2 34d0: 230080e7 jalr 560(ra) # 56fc <exit> printf("link dd/dd/ff dd/dd/ffff failed\n", s); 34d4: 85ca mv a1,s2 34d6: 00004517 auipc a0,0x4 34da: e6a50513 addi a0,a0,-406 # 7340 <malloc+0x17fe> 34de: 00002097 auipc ra,0x2 34e2: 5a6080e7 jalr 1446(ra) # 5a84 <printf> exit(1); 34e6: 4505 li a0,1 34e8: 00002097 auipc ra,0x2 34ec: 214080e7 jalr 532(ra) # 56fc <exit> printf("%s: unlink dd/dd/ff failed\n", s); 34f0: 85ca mv a1,s2 34f2: 00004517 auipc a0,0x4 34f6: e7650513 addi a0,a0,-394 # 7368 <malloc+0x1826> 34fa: 00002097 auipc ra,0x2 34fe: 58a080e7 jalr 1418(ra) # 5a84 <printf> exit(1); 3502: 4505 li a0,1 3504: 00002097 auipc ra,0x2 3508: 1f8080e7 jalr 504(ra) # 56fc <exit> printf("%s: open (unlinked) dd/dd/ff succeeded\n", s); 350c: 85ca mv a1,s2 350e: 00004517 auipc a0,0x4 3512: e7a50513 addi a0,a0,-390 # 7388 <malloc+0x1846> 3516: 00002097 auipc ra,0x2 351a: 56e080e7 jalr 1390(ra) # 5a84 <printf> exit(1); 351e: 4505 li a0,1 3520: 00002097 auipc ra,0x2 3524: 1dc080e7 jalr 476(ra) # 56fc <exit> printf("%s: chdir dd failed\n", s); 3528: 85ca mv a1,s2 352a: 00004517 auipc a0,0x4 352e: e8650513 addi a0,a0,-378 # 73b0 <malloc+0x186e> 3532: 00002097 auipc ra,0x2 3536: 552080e7 jalr 1362(ra) # 5a84 <printf> exit(1); 353a: 4505 li a0,1 353c: 00002097 auipc ra,0x2 3540: 1c0080e7 jalr 448(ra) # 56fc <exit> printf("%s: chdir dd/../../dd failed\n", s); 3544: 85ca mv a1,s2 3546: 00004517 auipc a0,0x4 354a: e9250513 addi a0,a0,-366 # 73d8 <malloc+0x1896> 354e: 00002097 auipc ra,0x2 3552: 536080e7 jalr 1334(ra) # 5a84 <printf> exit(1); 3556: 4505 li a0,1 3558: 00002097 auipc ra,0x2 355c: 1a4080e7 jalr 420(ra) # 56fc <exit> printf("chdir dd/../../dd failed\n", s); 3560: 85ca mv a1,s2 3562: 00004517 auipc a0,0x4 3566: ea650513 addi a0,a0,-346 # 7408 <malloc+0x18c6> 356a: 00002097 auipc ra,0x2 356e: 51a080e7 jalr 1306(ra) # 5a84 <printf> exit(1); 3572: 4505 li a0,1 3574: 00002097 auipc ra,0x2 3578: 188080e7 jalr 392(ra) # 56fc <exit> printf("%s: chdir ./.. failed\n", s); 357c: 85ca mv a1,s2 357e: 00004517 auipc a0,0x4 3582: eb250513 addi a0,a0,-334 # 7430 <malloc+0x18ee> 3586: 00002097 auipc ra,0x2 358a: 4fe080e7 jalr 1278(ra) # 5a84 <printf> exit(1); 358e: 4505 li a0,1 3590: 00002097 auipc ra,0x2 3594: 16c080e7 jalr 364(ra) # 56fc <exit> printf("%s: open dd/dd/ffff failed\n", s); 3598: 85ca mv a1,s2 359a: 00004517 auipc a0,0x4 359e: eae50513 addi a0,a0,-338 # 7448 <malloc+0x1906> 35a2: 00002097 auipc ra,0x2 35a6: 4e2080e7 jalr 1250(ra) # 5a84 <printf> exit(1); 35aa: 4505 li a0,1 35ac: 00002097 auipc ra,0x2 35b0: 150080e7 jalr 336(ra) # 56fc <exit> printf("%s: read dd/dd/ffff wrong len\n", s); 35b4: 85ca mv a1,s2 35b6: 00004517 auipc a0,0x4 35ba: eb250513 addi a0,a0,-334 # 7468 <malloc+0x1926> 35be: 00002097 auipc ra,0x2 35c2: 4c6080e7 jalr 1222(ra) # 5a84 <printf> exit(1); 35c6: 4505 li a0,1 35c8: 00002097 auipc ra,0x2 35cc: 134080e7 jalr 308(ra) # 56fc <exit> printf("%s: open (unlinked) dd/dd/ff succeeded!\n", s); 35d0: 85ca mv a1,s2 35d2: 00004517 auipc a0,0x4 35d6: eb650513 addi a0,a0,-330 # 7488 <malloc+0x1946> 35da: 00002097 auipc ra,0x2 35de: 4aa080e7 jalr 1194(ra) # 5a84 <printf> exit(1); 35e2: 4505 li a0,1 35e4: 00002097 auipc ra,0x2 35e8: 118080e7 jalr 280(ra) # 56fc <exit> printf("%s: create dd/ff/ff succeeded!\n", s); 35ec: 85ca mv a1,s2 35ee: 00004517 auipc a0,0x4 35f2: eda50513 addi a0,a0,-294 # 74c8 <malloc+0x1986> 35f6: 00002097 auipc ra,0x2 35fa: 48e080e7 jalr 1166(ra) # 5a84 <printf> exit(1); 35fe: 4505 li a0,1 3600: 00002097 auipc ra,0x2 3604: 0fc080e7 jalr 252(ra) # 56fc <exit> printf("%s: create dd/xx/ff succeeded!\n", s); 3608: 85ca mv a1,s2 360a: 00004517 auipc a0,0x4 360e: eee50513 addi a0,a0,-274 # 74f8 <malloc+0x19b6> 3612: 00002097 auipc ra,0x2 3616: 472080e7 jalr 1138(ra) # 5a84 <printf> exit(1); 361a: 4505 li a0,1 361c: 00002097 auipc ra,0x2 3620: 0e0080e7 jalr 224(ra) # 56fc <exit> printf("%s: create dd succeeded!\n", s); 3624: 85ca mv a1,s2 3626: 00004517 auipc a0,0x4 362a: ef250513 addi a0,a0,-270 # 7518 <malloc+0x19d6> 362e: 00002097 auipc ra,0x2 3632: 456080e7 jalr 1110(ra) # 5a84 <printf> exit(1); 3636: 4505 li a0,1 3638: 00002097 auipc ra,0x2 363c: 0c4080e7 jalr 196(ra) # 56fc <exit> printf("%s: open dd rdwr succeeded!\n", s); 3640: 85ca mv a1,s2 3642: 00004517 auipc a0,0x4 3646: ef650513 addi a0,a0,-266 # 7538 <malloc+0x19f6> 364a: 00002097 auipc ra,0x2 364e: 43a080e7 jalr 1082(ra) # 5a84 <printf> exit(1); 3652: 4505 li a0,1 3654: 00002097 auipc ra,0x2 3658: 0a8080e7 jalr 168(ra) # 56fc <exit> printf("%s: open dd wronly succeeded!\n", s); 365c: 85ca mv a1,s2 365e: 00004517 auipc a0,0x4 3662: efa50513 addi a0,a0,-262 # 7558 <malloc+0x1a16> 3666: 00002097 auipc ra,0x2 366a: 41e080e7 jalr 1054(ra) # 5a84 <printf> exit(1); 366e: 4505 li a0,1 3670: 00002097 auipc ra,0x2 3674: 08c080e7 jalr 140(ra) # 56fc <exit> printf("%s: link dd/ff/ff dd/dd/xx succeeded!\n", s); 3678: 85ca mv a1,s2 367a: 00004517 auipc a0,0x4 367e: f0e50513 addi a0,a0,-242 # 7588 <malloc+0x1a46> 3682: 00002097 auipc ra,0x2 3686: 402080e7 jalr 1026(ra) # 5a84 <printf> exit(1); 368a: 4505 li a0,1 368c: 00002097 auipc ra,0x2 3690: 070080e7 jalr 112(ra) # 56fc <exit> printf("%s: link dd/xx/ff dd/dd/xx succeeded!\n", s); 3694: 85ca mv a1,s2 3696: 00004517 auipc a0,0x4 369a: f1a50513 addi a0,a0,-230 # 75b0 <malloc+0x1a6e> 369e: 00002097 auipc ra,0x2 36a2: 3e6080e7 jalr 998(ra) # 5a84 <printf> exit(1); 36a6: 4505 li a0,1 36a8: 00002097 auipc ra,0x2 36ac: 054080e7 jalr 84(ra) # 56fc <exit> printf("%s: link dd/ff dd/dd/ffff succeeded!\n", s); 36b0: 85ca mv a1,s2 36b2: 00004517 auipc a0,0x4 36b6: f2650513 addi a0,a0,-218 # 75d8 <malloc+0x1a96> 36ba: 00002097 auipc ra,0x2 36be: 3ca080e7 jalr 970(ra) # 5a84 <printf> exit(1); 36c2: 4505 li a0,1 36c4: 00002097 auipc ra,0x2 36c8: 038080e7 jalr 56(ra) # 56fc <exit> printf("%s: mkdir dd/ff/ff succeeded!\n", s); 36cc: 85ca mv a1,s2 36ce: 00004517 auipc a0,0x4 36d2: f3250513 addi a0,a0,-206 # 7600 <malloc+0x1abe> 36d6: 00002097 auipc ra,0x2 36da: 3ae080e7 jalr 942(ra) # 5a84 <printf> exit(1); 36de: 4505 li a0,1 36e0: 00002097 auipc ra,0x2 36e4: 01c080e7 jalr 28(ra) # 56fc <exit> printf("%s: mkdir dd/xx/ff succeeded!\n", s); 36e8: 85ca mv a1,s2 36ea: 00004517 auipc a0,0x4 36ee: f3650513 addi a0,a0,-202 # 7620 <malloc+0x1ade> 36f2: 00002097 auipc ra,0x2 36f6: 392080e7 jalr 914(ra) # 5a84 <printf> exit(1); 36fa: 4505 li a0,1 36fc: 00002097 auipc ra,0x2 3700: 000080e7 jalr ra # 56fc <exit> printf("%s: mkdir dd/dd/ffff succeeded!\n", s); 3704: 85ca mv a1,s2 3706: 00004517 auipc a0,0x4 370a: f3a50513 addi a0,a0,-198 # 7640 <malloc+0x1afe> 370e: 00002097 auipc ra,0x2 3712: 376080e7 jalr 886(ra) # 5a84 <printf> exit(1); 3716: 4505 li a0,1 3718: 00002097 auipc ra,0x2 371c: fe4080e7 jalr -28(ra) # 56fc <exit> printf("%s: unlink dd/xx/ff succeeded!\n", s); 3720: 85ca mv a1,s2 3722: 00004517 auipc a0,0x4 3726: f4650513 addi a0,a0,-186 # 7668 <malloc+0x1b26> 372a: 00002097 auipc ra,0x2 372e: 35a080e7 jalr 858(ra) # 5a84 <printf> exit(1); 3732: 4505 li a0,1 3734: 00002097 auipc ra,0x2 3738: fc8080e7 jalr -56(ra) # 56fc <exit> printf("%s: unlink dd/ff/ff succeeded!\n", s); 373c: 85ca mv a1,s2 373e: 00004517 auipc a0,0x4 3742: f4a50513 addi a0,a0,-182 # 7688 <malloc+0x1b46> 3746: 00002097 auipc ra,0x2 374a: 33e080e7 jalr 830(ra) # 5a84 <printf> exit(1); 374e: 4505 li a0,1 3750: 00002097 auipc ra,0x2 3754: fac080e7 jalr -84(ra) # 56fc <exit> printf("%s: chdir dd/ff succeeded!\n", s); 3758: 85ca mv a1,s2 375a: 00004517 auipc a0,0x4 375e: f4e50513 addi a0,a0,-178 # 76a8 <malloc+0x1b66> 3762: 00002097 auipc ra,0x2 3766: 322080e7 jalr 802(ra) # 5a84 <printf> exit(1); 376a: 4505 li a0,1 376c: 00002097 auipc ra,0x2 3770: f90080e7 jalr -112(ra) # 56fc <exit> printf("%s: chdir dd/xx succeeded!\n", s); 3774: 85ca mv a1,s2 3776: 00004517 auipc a0,0x4 377a: f5a50513 addi a0,a0,-166 # 76d0 <malloc+0x1b8e> 377e: 00002097 auipc ra,0x2 3782: 306080e7 jalr 774(ra) # 5a84 <printf> exit(1); 3786: 4505 li a0,1 3788: 00002097 auipc ra,0x2 378c: f74080e7 jalr -140(ra) # 56fc <exit> printf("%s: unlink dd/dd/ff failed\n", s); 3790: 85ca mv a1,s2 3792: 00004517 auipc a0,0x4 3796: bd650513 addi a0,a0,-1066 # 7368 <malloc+0x1826> 379a: 00002097 auipc ra,0x2 379e: 2ea080e7 jalr 746(ra) # 5a84 <printf> exit(1); 37a2: 4505 li a0,1 37a4: 00002097 auipc ra,0x2 37a8: f58080e7 jalr -168(ra) # 56fc <exit> printf("%s: unlink dd/ff failed\n", s); 37ac: 85ca mv a1,s2 37ae: 00004517 auipc a0,0x4 37b2: f4250513 addi a0,a0,-190 # 76f0 <malloc+0x1bae> 37b6: 00002097 auipc ra,0x2 37ba: 2ce080e7 jalr 718(ra) # 5a84 <printf> exit(1); 37be: 4505 li a0,1 37c0: 00002097 auipc ra,0x2 37c4: f3c080e7 jalr -196(ra) # 56fc <exit> printf("%s: unlink non-empty dd succeeded!\n", s); 37c8: 85ca mv a1,s2 37ca: 00004517 auipc a0,0x4 37ce: f4650513 addi a0,a0,-186 # 7710 <malloc+0x1bce> 37d2: 00002097 auipc ra,0x2 37d6: 2b2080e7 jalr 690(ra) # 5a84 <printf> exit(1); 37da: 4505 li a0,1 37dc: 00002097 auipc ra,0x2 37e0: f20080e7 jalr -224(ra) # 56fc <exit> printf("%s: unlink dd/dd failed\n", s); 37e4: 85ca mv a1,s2 37e6: 00004517 auipc a0,0x4 37ea: f5a50513 addi a0,a0,-166 # 7740 <malloc+0x1bfe> 37ee: 00002097 auipc ra,0x2 37f2: 296080e7 jalr 662(ra) # 5a84 <printf> exit(1); 37f6: 4505 li a0,1 37f8: 00002097 auipc ra,0x2 37fc: f04080e7 jalr -252(ra) # 56fc <exit> printf("%s: unlink dd failed\n", s); 3800: 85ca mv a1,s2 3802: 00004517 auipc a0,0x4 3806: f5e50513 addi a0,a0,-162 # 7760 <malloc+0x1c1e> 380a: 00002097 auipc ra,0x2 380e: 27a080e7 jalr 634(ra) # 5a84 <printf> exit(1); 3812: 4505 li a0,1 3814: 00002097 auipc ra,0x2 3818: ee8080e7 jalr -280(ra) # 56fc <exit> 000000000000381c <rmdot>: { 381c: 1101 addi sp,sp,-32 381e: ec06 sd ra,24(sp) 3820: e822 sd s0,16(sp) 3822: e426 sd s1,8(sp) 3824: 1000 addi s0,sp,32 3826: 84aa mv s1,a0 if(mkdir("dots") != 0){ 3828: 00004517 auipc a0,0x4 382c: f5050513 addi a0,a0,-176 # 7778 <malloc+0x1c36> 3830: 00002097 auipc ra,0x2 3834: f34080e7 jalr -204(ra) # 5764 <mkdir> 3838: e549 bnez a0,38c2 <rmdot+0xa6> if(chdir("dots") != 0){ 383a: 00004517 auipc a0,0x4 383e: f3e50513 addi a0,a0,-194 # 7778 <malloc+0x1c36> 3842: 00002097 auipc ra,0x2 3846: f2a080e7 jalr -214(ra) # 576c <chdir> 384a: e951 bnez a0,38de <rmdot+0xc2> if(unlink(".") == 0){ 384c: 00003517 auipc a0,0x3 3850: ddc50513 addi a0,a0,-548 # 6628 <malloc+0xae6> 3854: 00002097 auipc ra,0x2 3858: ef8080e7 jalr -264(ra) # 574c <unlink> 385c: cd59 beqz a0,38fa <rmdot+0xde> if(unlink("..") == 0){ 385e: 00004517 auipc a0,0x4 3862: 97250513 addi a0,a0,-1678 # 71d0 <malloc+0x168e> 3866: 00002097 auipc ra,0x2 386a: ee6080e7 jalr -282(ra) # 574c <unlink> 386e: c545 beqz a0,3916 <rmdot+0xfa> if(chdir("/") != 0){ 3870: 00004517 auipc a0,0x4 3874: 90850513 addi a0,a0,-1784 # 7178 <malloc+0x1636> 3878: 00002097 auipc ra,0x2 387c: ef4080e7 jalr -268(ra) # 576c <chdir> 3880: e94d bnez a0,3932 <rmdot+0x116> if(unlink("dots/.") == 0){ 3882: 00004517 auipc a0,0x4 3886: f5e50513 addi a0,a0,-162 # 77e0 <malloc+0x1c9e> 388a: 00002097 auipc ra,0x2 388e: ec2080e7 jalr -318(ra) # 574c <unlink> 3892: cd55 beqz a0,394e <rmdot+0x132> if(unlink("dots/..") == 0){ 3894: 00004517 auipc a0,0x4 3898: f7450513 addi a0,a0,-140 # 7808 <malloc+0x1cc6> 389c: 00002097 auipc ra,0x2 38a0: eb0080e7 jalr -336(ra) # 574c <unlink> 38a4: c179 beqz a0,396a <rmdot+0x14e> if(unlink("dots") != 0){ 38a6: 00004517 auipc a0,0x4 38aa: ed250513 addi a0,a0,-302 # 7778 <malloc+0x1c36> 38ae: 00002097 auipc ra,0x2 38b2: e9e080e7 jalr -354(ra) # 574c <unlink> 38b6: e961 bnez a0,3986 <rmdot+0x16a> } 38b8: 60e2 ld ra,24(sp) 38ba: 6442 ld s0,16(sp) 38bc: 64a2 ld s1,8(sp) 38be: 6105 addi sp,sp,32 38c0: 8082 ret printf("%s: mkdir dots failed\n", s); 38c2: 85a6 mv a1,s1 38c4: 00004517 auipc a0,0x4 38c8: ebc50513 addi a0,a0,-324 # 7780 <malloc+0x1c3e> 38cc: 00002097 auipc ra,0x2 38d0: 1b8080e7 jalr 440(ra) # 5a84 <printf> exit(1); 38d4: 4505 li a0,1 38d6: 00002097 auipc ra,0x2 38da: e26080e7 jalr -474(ra) # 56fc <exit> printf("%s: chdir dots failed\n", s); 38de: 85a6 mv a1,s1 38e0: 00004517 auipc a0,0x4 38e4: eb850513 addi a0,a0,-328 # 7798 <malloc+0x1c56> 38e8: 00002097 auipc ra,0x2 38ec: 19c080e7 jalr 412(ra) # 5a84 <printf> exit(1); 38f0: 4505 li a0,1 38f2: 00002097 auipc ra,0x2 38f6: e0a080e7 jalr -502(ra) # 56fc <exit> printf("%s: rm . worked!\n", s); 38fa: 85a6 mv a1,s1 38fc: 00004517 auipc a0,0x4 3900: eb450513 addi a0,a0,-332 # 77b0 <malloc+0x1c6e> 3904: 00002097 auipc ra,0x2 3908: 180080e7 jalr 384(ra) # 5a84 <printf> exit(1); 390c: 4505 li a0,1 390e: 00002097 auipc ra,0x2 3912: dee080e7 jalr -530(ra) # 56fc <exit> printf("%s: rm .. worked!\n", s); 3916: 85a6 mv a1,s1 3918: 00004517 auipc a0,0x4 391c: eb050513 addi a0,a0,-336 # 77c8 <malloc+0x1c86> 3920: 00002097 auipc ra,0x2 3924: 164080e7 jalr 356(ra) # 5a84 <printf> exit(1); 3928: 4505 li a0,1 392a: 00002097 auipc ra,0x2 392e: dd2080e7 jalr -558(ra) # 56fc <exit> printf("%s: chdir / failed\n", s); 3932: 85a6 mv a1,s1 3934: 00004517 auipc a0,0x4 3938: 84c50513 addi a0,a0,-1972 # 7180 <malloc+0x163e> 393c: 00002097 auipc ra,0x2 3940: 148080e7 jalr 328(ra) # 5a84 <printf> exit(1); 3944: 4505 li a0,1 3946: 00002097 auipc ra,0x2 394a: db6080e7 jalr -586(ra) # 56fc <exit> printf("%s: unlink dots/. worked!\n", s); 394e: 85a6 mv a1,s1 3950: 00004517 auipc a0,0x4 3954: e9850513 addi a0,a0,-360 # 77e8 <malloc+0x1ca6> 3958: 00002097 auipc ra,0x2 395c: 12c080e7 jalr 300(ra) # 5a84 <printf> exit(1); 3960: 4505 li a0,1 3962: 00002097 auipc ra,0x2 3966: d9a080e7 jalr -614(ra) # 56fc <exit> printf("%s: unlink dots/.. worked!\n", s); 396a: 85a6 mv a1,s1 396c: 00004517 auipc a0,0x4 3970: ea450513 addi a0,a0,-348 # 7810 <malloc+0x1cce> 3974: 00002097 auipc ra,0x2 3978: 110080e7 jalr 272(ra) # 5a84 <printf> exit(1); 397c: 4505 li a0,1 397e: 00002097 auipc ra,0x2 3982: d7e080e7 jalr -642(ra) # 56fc <exit> printf("%s: unlink dots failed!\n", s); 3986: 85a6 mv a1,s1 3988: 00004517 auipc a0,0x4 398c: ea850513 addi a0,a0,-344 # 7830 <malloc+0x1cee> 3990: 00002097 auipc ra,0x2 3994: 0f4080e7 jalr 244(ra) # 5a84 <printf> exit(1); 3998: 4505 li a0,1 399a: 00002097 auipc ra,0x2 399e: d62080e7 jalr -670(ra) # 56fc <exit> 00000000000039a2 <dirfile>: { 39a2: 1101 addi sp,sp,-32 39a4: ec06 sd ra,24(sp) 39a6: e822 sd s0,16(sp) 39a8: e426 sd s1,8(sp) 39aa: e04a sd s2,0(sp) 39ac: 1000 addi s0,sp,32 39ae: 892a mv s2,a0 fd = open("dirfile", O_CREATE); 39b0: 20000593 li a1,512 39b4: 00002517 auipc a0,0x2 39b8: 57c50513 addi a0,a0,1404 # 5f30 <malloc+0x3ee> 39bc: 00002097 auipc ra,0x2 39c0: d80080e7 jalr -640(ra) # 573c <open> if(fd < 0){ 39c4: 0e054d63 bltz a0,3abe <dirfile+0x11c> close(fd); 39c8: 00002097 auipc ra,0x2 39cc: d5c080e7 jalr -676(ra) # 5724 <close> if(chdir("dirfile") == 0){ 39d0: 00002517 auipc a0,0x2 39d4: 56050513 addi a0,a0,1376 # 5f30 <malloc+0x3ee> 39d8: 00002097 auipc ra,0x2 39dc: d94080e7 jalr -620(ra) # 576c <chdir> 39e0: cd6d beqz a0,3ada <dirfile+0x138> fd = open("dirfile/xx", 0); 39e2: 4581 li a1,0 39e4: 00004517 auipc a0,0x4 39e8: eac50513 addi a0,a0,-340 # 7890 <malloc+0x1d4e> 39ec: 00002097 auipc ra,0x2 39f0: d50080e7 jalr -688(ra) # 573c <open> if(fd >= 0){ 39f4: 10055163 bgez a0,3af6 <dirfile+0x154> fd = open("dirfile/xx", O_CREATE); 39f8: 20000593 li a1,512 39fc: 00004517 auipc a0,0x4 3a00: e9450513 addi a0,a0,-364 # 7890 <malloc+0x1d4e> 3a04: 00002097 auipc ra,0x2 3a08: d38080e7 jalr -712(ra) # 573c <open> if(fd >= 0){ 3a0c: 10055363 bgez a0,3b12 <dirfile+0x170> if(mkdir("dirfile/xx") == 0){ 3a10: 00004517 auipc a0,0x4 3a14: e8050513 addi a0,a0,-384 # 7890 <malloc+0x1d4e> 3a18: 00002097 auipc ra,0x2 3a1c: d4c080e7 jalr -692(ra) # 5764 <mkdir> 3a20: 10050763 beqz a0,3b2e <dirfile+0x18c> if(unlink("dirfile/xx") == 0){ 3a24: 00004517 auipc a0,0x4 3a28: e6c50513 addi a0,a0,-404 # 7890 <malloc+0x1d4e> 3a2c: 00002097 auipc ra,0x2 3a30: d20080e7 jalr -736(ra) # 574c <unlink> 3a34: 10050b63 beqz a0,3b4a <dirfile+0x1a8> if(link("README", "dirfile/xx") == 0){ 3a38: 00004597 auipc a1,0x4 3a3c: e5858593 addi a1,a1,-424 # 7890 <malloc+0x1d4e> 3a40: 00002517 auipc a0,0x2 3a44: 6e850513 addi a0,a0,1768 # 6128 <malloc+0x5e6> 3a48: 00002097 auipc ra,0x2 3a4c: d14080e7 jalr -748(ra) # 575c <link> 3a50: 10050b63 beqz a0,3b66 <dirfile+0x1c4> if(unlink("dirfile") != 0){ 3a54: 00002517 auipc a0,0x2 3a58: 4dc50513 addi a0,a0,1244 # 5f30 <malloc+0x3ee> 3a5c: 00002097 auipc ra,0x2 3a60: cf0080e7 jalr -784(ra) # 574c <unlink> 3a64: 10051f63 bnez a0,3b82 <dirfile+0x1e0> fd = open(".", O_RDWR); 3a68: 4589 li a1,2 3a6a: 00003517 auipc a0,0x3 3a6e: bbe50513 addi a0,a0,-1090 # 6628 <malloc+0xae6> 3a72: 00002097 auipc ra,0x2 3a76: cca080e7 jalr -822(ra) # 573c <open> if(fd >= 0){ 3a7a: 12055263 bgez a0,3b9e <dirfile+0x1fc> fd = open(".", 0); 3a7e: 4581 li a1,0 3a80: 00003517 auipc a0,0x3 3a84: ba850513 addi a0,a0,-1112 # 6628 <malloc+0xae6> 3a88: 00002097 auipc ra,0x2 3a8c: cb4080e7 jalr -844(ra) # 573c <open> 3a90: 84aa mv s1,a0 if(write(fd, "x", 1) > 0){ 3a92: 4605 li a2,1 3a94: 00002597 auipc a1,0x2 3a98: 56c58593 addi a1,a1,1388 # 6000 <malloc+0x4be> 3a9c: 00002097 auipc ra,0x2 3aa0: c80080e7 jalr -896(ra) # 571c <write> 3aa4: 10a04b63 bgtz a0,3bba <dirfile+0x218> close(fd); 3aa8: 8526 mv a0,s1 3aaa: 00002097 auipc ra,0x2 3aae: c7a080e7 jalr -902(ra) # 5724 <close> } 3ab2: 60e2 ld ra,24(sp) 3ab4: 6442 ld s0,16(sp) 3ab6: 64a2 ld s1,8(sp) 3ab8: 6902 ld s2,0(sp) 3aba: 6105 addi sp,sp,32 3abc: 8082 ret printf("%s: create dirfile failed\n", s); 3abe: 85ca mv a1,s2 3ac0: 00004517 auipc a0,0x4 3ac4: d9050513 addi a0,a0,-624 # 7850 <malloc+0x1d0e> 3ac8: 00002097 auipc ra,0x2 3acc: fbc080e7 jalr -68(ra) # 5a84 <printf> exit(1); 3ad0: 4505 li a0,1 3ad2: 00002097 auipc ra,0x2 3ad6: c2a080e7 jalr -982(ra) # 56fc <exit> printf("%s: chdir dirfile succeeded!\n", s); 3ada: 85ca mv a1,s2 3adc: 00004517 auipc a0,0x4 3ae0: d9450513 addi a0,a0,-620 # 7870 <malloc+0x1d2e> 3ae4: 00002097 auipc ra,0x2 3ae8: fa0080e7 jalr -96(ra) # 5a84 <printf> exit(1); 3aec: 4505 li a0,1 3aee: 00002097 auipc ra,0x2 3af2: c0e080e7 jalr -1010(ra) # 56fc <exit> printf("%s: create dirfile/xx succeeded!\n", s); 3af6: 85ca mv a1,s2 3af8: 00004517 auipc a0,0x4 3afc: da850513 addi a0,a0,-600 # 78a0 <malloc+0x1d5e> 3b00: 00002097 auipc ra,0x2 3b04: f84080e7 jalr -124(ra) # 5a84 <printf> exit(1); 3b08: 4505 li a0,1 3b0a: 00002097 auipc ra,0x2 3b0e: bf2080e7 jalr -1038(ra) # 56fc <exit> printf("%s: create dirfile/xx succeeded!\n", s); 3b12: 85ca mv a1,s2 3b14: 00004517 auipc a0,0x4 3b18: d8c50513 addi a0,a0,-628 # 78a0 <malloc+0x1d5e> 3b1c: 00002097 auipc ra,0x2 3b20: f68080e7 jalr -152(ra) # 5a84 <printf> exit(1); 3b24: 4505 li a0,1 3b26: 00002097 auipc ra,0x2 3b2a: bd6080e7 jalr -1066(ra) # 56fc <exit> printf("%s: mkdir dirfile/xx succeeded!\n", s); 3b2e: 85ca mv a1,s2 3b30: 00004517 auipc a0,0x4 3b34: d9850513 addi a0,a0,-616 # 78c8 <malloc+0x1d86> 3b38: 00002097 auipc ra,0x2 3b3c: f4c080e7 jalr -180(ra) # 5a84 <printf> exit(1); 3b40: 4505 li a0,1 3b42: 00002097 auipc ra,0x2 3b46: bba080e7 jalr -1094(ra) # 56fc <exit> printf("%s: unlink dirfile/xx succeeded!\n", s); 3b4a: 85ca mv a1,s2 3b4c: 00004517 auipc a0,0x4 3b50: da450513 addi a0,a0,-604 # 78f0 <malloc+0x1dae> 3b54: 00002097 auipc ra,0x2 3b58: f30080e7 jalr -208(ra) # 5a84 <printf> exit(1); 3b5c: 4505 li a0,1 3b5e: 00002097 auipc ra,0x2 3b62: b9e080e7 jalr -1122(ra) # 56fc <exit> printf("%s: link to dirfile/xx succeeded!\n", s); 3b66: 85ca mv a1,s2 3b68: 00004517 auipc a0,0x4 3b6c: db050513 addi a0,a0,-592 # 7918 <malloc+0x1dd6> 3b70: 00002097 auipc ra,0x2 3b74: f14080e7 jalr -236(ra) # 5a84 <printf> exit(1); 3b78: 4505 li a0,1 3b7a: 00002097 auipc ra,0x2 3b7e: b82080e7 jalr -1150(ra) # 56fc <exit> printf("%s: unlink dirfile failed!\n", s); 3b82: 85ca mv a1,s2 3b84: 00004517 auipc a0,0x4 3b88: dbc50513 addi a0,a0,-580 # 7940 <malloc+0x1dfe> 3b8c: 00002097 auipc ra,0x2 3b90: ef8080e7 jalr -264(ra) # 5a84 <printf> exit(1); 3b94: 4505 li a0,1 3b96: 00002097 auipc ra,0x2 3b9a: b66080e7 jalr -1178(ra) # 56fc <exit> printf("%s: open . for writing succeeded!\n", s); 3b9e: 85ca mv a1,s2 3ba0: 00004517 auipc a0,0x4 3ba4: dc050513 addi a0,a0,-576 # 7960 <malloc+0x1e1e> 3ba8: 00002097 auipc ra,0x2 3bac: edc080e7 jalr -292(ra) # 5a84 <printf> exit(1); 3bb0: 4505 li a0,1 3bb2: 00002097 auipc ra,0x2 3bb6: b4a080e7 jalr -1206(ra) # 56fc <exit> printf("%s: write . succeeded!\n", s); 3bba: 85ca mv a1,s2 3bbc: 00004517 auipc a0,0x4 3bc0: dcc50513 addi a0,a0,-564 # 7988 <malloc+0x1e46> 3bc4: 00002097 auipc ra,0x2 3bc8: ec0080e7 jalr -320(ra) # 5a84 <printf> exit(1); 3bcc: 4505 li a0,1 3bce: 00002097 auipc ra,0x2 3bd2: b2e080e7 jalr -1234(ra) # 56fc <exit> 0000000000003bd6 <iref>: { 3bd6: 7139 addi sp,sp,-64 3bd8: fc06 sd ra,56(sp) 3bda: f822 sd s0,48(sp) 3bdc: f426 sd s1,40(sp) 3bde: f04a sd s2,32(sp) 3be0: ec4e sd s3,24(sp) 3be2: e852 sd s4,16(sp) 3be4: e456 sd s5,8(sp) 3be6: e05a sd s6,0(sp) 3be8: 0080 addi s0,sp,64 3bea: 8b2a mv s6,a0 3bec: 03300913 li s2,51 if(mkdir("irefd") != 0){ 3bf0: 00004a17 auipc s4,0x4 3bf4: db0a0a13 addi s4,s4,-592 # 79a0 <malloc+0x1e5e> mkdir(""); 3bf8: 00004497 auipc s1,0x4 3bfc: 8b848493 addi s1,s1,-1864 # 74b0 <malloc+0x196e> link("README", ""); 3c00: 00002a97 auipc s5,0x2 3c04: 528a8a93 addi s5,s5,1320 # 6128 <malloc+0x5e6> fd = open("xx", O_CREATE); 3c08: 00004997 auipc s3,0x4 3c0c: c9098993 addi s3,s3,-880 # 7898 <malloc+0x1d56> 3c10: a891 j 3c64 <iref+0x8e> printf("%s: mkdir irefd failed\n", s); 3c12: 85da mv a1,s6 3c14: 00004517 auipc a0,0x4 3c18: d9450513 addi a0,a0,-620 # 79a8 <malloc+0x1e66> 3c1c: 00002097 auipc ra,0x2 3c20: e68080e7 jalr -408(ra) # 5a84 <printf> exit(1); 3c24: 4505 li a0,1 3c26: 00002097 auipc ra,0x2 3c2a: ad6080e7 jalr -1322(ra) # 56fc <exit> printf("%s: chdir irefd failed\n", s); 3c2e: 85da mv a1,s6 3c30: 00004517 auipc a0,0x4 3c34: d9050513 addi a0,a0,-624 # 79c0 <malloc+0x1e7e> 3c38: 00002097 auipc ra,0x2 3c3c: e4c080e7 jalr -436(ra) # 5a84 <printf> exit(1); 3c40: 4505 li a0,1 3c42: 00002097 auipc ra,0x2 3c46: aba080e7 jalr -1350(ra) # 56fc <exit> close(fd); 3c4a: 00002097 auipc ra,0x2 3c4e: ada080e7 jalr -1318(ra) # 5724 <close> 3c52: a889 j 3ca4 <iref+0xce> unlink("xx"); 3c54: 854e mv a0,s3 3c56: 00002097 auipc ra,0x2 3c5a: af6080e7 jalr -1290(ra) # 574c <unlink> for(i = 0; i < NINODE + 1; i++){ 3c5e: 397d addiw s2,s2,-1 3c60: 06090063 beqz s2,3cc0 <iref+0xea> if(mkdir("irefd") != 0){ 3c64: 8552 mv a0,s4 3c66: 00002097 auipc ra,0x2 3c6a: afe080e7 jalr -1282(ra) # 5764 <mkdir> 3c6e: f155 bnez a0,3c12 <iref+0x3c> if(chdir("irefd") != 0){ 3c70: 8552 mv a0,s4 3c72: 00002097 auipc ra,0x2 3c76: afa080e7 jalr -1286(ra) # 576c <chdir> 3c7a: f955 bnez a0,3c2e <iref+0x58> mkdir(""); 3c7c: 8526 mv a0,s1 3c7e: 00002097 auipc ra,0x2 3c82: ae6080e7 jalr -1306(ra) # 5764 <mkdir> link("README", ""); 3c86: 85a6 mv a1,s1 3c88: 8556 mv a0,s5 3c8a: 00002097 auipc ra,0x2 3c8e: ad2080e7 jalr -1326(ra) # 575c <link> fd = open("", O_CREATE); 3c92: 20000593 li a1,512 3c96: 8526 mv a0,s1 3c98: 00002097 auipc ra,0x2 3c9c: aa4080e7 jalr -1372(ra) # 573c <open> if(fd >= 0) 3ca0: fa0555e3 bgez a0,3c4a <iref+0x74> fd = open("xx", O_CREATE); 3ca4: 20000593 li a1,512 3ca8: 854e mv a0,s3 3caa: 00002097 auipc ra,0x2 3cae: a92080e7 jalr -1390(ra) # 573c <open> if(fd >= 0) 3cb2: fa0541e3 bltz a0,3c54 <iref+0x7e> close(fd); 3cb6: 00002097 auipc ra,0x2 3cba: a6e080e7 jalr -1426(ra) # 5724 <close> 3cbe: bf59 j 3c54 <iref+0x7e> 3cc0: 03300493 li s1,51 chdir(".."); 3cc4: 00003997 auipc s3,0x3 3cc8: 50c98993 addi s3,s3,1292 # 71d0 <malloc+0x168e> unlink("irefd"); 3ccc: 00004917 auipc s2,0x4 3cd0: cd490913 addi s2,s2,-812 # 79a0 <malloc+0x1e5e> chdir(".."); 3cd4: 854e mv a0,s3 3cd6: 00002097 auipc ra,0x2 3cda: a96080e7 jalr -1386(ra) # 576c <chdir> unlink("irefd"); 3cde: 854a mv a0,s2 3ce0: 00002097 auipc ra,0x2 3ce4: a6c080e7 jalr -1428(ra) # 574c <unlink> for(i = 0; i < NINODE + 1; i++){ 3ce8: 34fd addiw s1,s1,-1 3cea: f4ed bnez s1,3cd4 <iref+0xfe> chdir("/"); 3cec: 00003517 auipc a0,0x3 3cf0: 48c50513 addi a0,a0,1164 # 7178 <malloc+0x1636> 3cf4: 00002097 auipc ra,0x2 3cf8: a78080e7 jalr -1416(ra) # 576c <chdir> } 3cfc: 70e2 ld ra,56(sp) 3cfe: 7442 ld s0,48(sp) 3d00: 74a2 ld s1,40(sp) 3d02: 7902 ld s2,32(sp) 3d04: 69e2 ld s3,24(sp) 3d06: 6a42 ld s4,16(sp) 3d08: 6aa2 ld s5,8(sp) 3d0a: 6b02 ld s6,0(sp) 3d0c: 6121 addi sp,sp,64 3d0e: 8082 ret 0000000000003d10 <openiputtest>: { 3d10: 7179 addi sp,sp,-48 3d12: f406 sd ra,40(sp) 3d14: f022 sd s0,32(sp) 3d16: ec26 sd s1,24(sp) 3d18: 1800 addi s0,sp,48 3d1a: 84aa mv s1,a0 if(mkdir("oidir") < 0){ 3d1c: 00004517 auipc a0,0x4 3d20: cbc50513 addi a0,a0,-836 # 79d8 <malloc+0x1e96> 3d24: 00002097 auipc ra,0x2 3d28: a40080e7 jalr -1472(ra) # 5764 <mkdir> 3d2c: 04054263 bltz a0,3d70 <openiputtest+0x60> pid = fork(); 3d30: 00002097 auipc ra,0x2 3d34: 9c4080e7 jalr -1596(ra) # 56f4 <fork> if(pid < 0){ 3d38: 04054a63 bltz a0,3d8c <openiputtest+0x7c> if(pid == 0){ 3d3c: e93d bnez a0,3db2 <openiputtest+0xa2> int fd = open("oidir", O_RDWR); 3d3e: 4589 li a1,2 3d40: 00004517 auipc a0,0x4 3d44: c9850513 addi a0,a0,-872 # 79d8 <malloc+0x1e96> 3d48: 00002097 auipc ra,0x2 3d4c: 9f4080e7 jalr -1548(ra) # 573c <open> if(fd >= 0){ 3d50: 04054c63 bltz a0,3da8 <openiputtest+0x98> printf("%s: open directory for write succeeded\n", s); 3d54: 85a6 mv a1,s1 3d56: 00004517 auipc a0,0x4 3d5a: ca250513 addi a0,a0,-862 # 79f8 <malloc+0x1eb6> 3d5e: 00002097 auipc ra,0x2 3d62: d26080e7 jalr -730(ra) # 5a84 <printf> exit(1); 3d66: 4505 li a0,1 3d68: 00002097 auipc ra,0x2 3d6c: 994080e7 jalr -1644(ra) # 56fc <exit> printf("%s: mkdir oidir failed\n", s); 3d70: 85a6 mv a1,s1 3d72: 00004517 auipc a0,0x4 3d76: c6e50513 addi a0,a0,-914 # 79e0 <malloc+0x1e9e> 3d7a: 00002097 auipc ra,0x2 3d7e: d0a080e7 jalr -758(ra) # 5a84 <printf> exit(1); 3d82: 4505 li a0,1 3d84: 00002097 auipc ra,0x2 3d88: 978080e7 jalr -1672(ra) # 56fc <exit> printf("%s: fork failed\n", s); 3d8c: 85a6 mv a1,s1 3d8e: 00003517 auipc a0,0x3 3d92: a3a50513 addi a0,a0,-1478 # 67c8 <malloc+0xc86> 3d96: 00002097 auipc ra,0x2 3d9a: cee080e7 jalr -786(ra) # 5a84 <printf> exit(1); 3d9e: 4505 li a0,1 3da0: 00002097 auipc ra,0x2 3da4: 95c080e7 jalr -1700(ra) # 56fc <exit> exit(0); 3da8: 4501 li a0,0 3daa: 00002097 auipc ra,0x2 3dae: 952080e7 jalr -1710(ra) # 56fc <exit> sleep(1); 3db2: 4505 li a0,1 3db4: 00002097 auipc ra,0x2 3db8: 9d8080e7 jalr -1576(ra) # 578c <sleep> if(unlink("oidir") != 0){ 3dbc: 00004517 auipc a0,0x4 3dc0: c1c50513 addi a0,a0,-996 # 79d8 <malloc+0x1e96> 3dc4: 00002097 auipc ra,0x2 3dc8: 988080e7 jalr -1656(ra) # 574c <unlink> 3dcc: cd19 beqz a0,3dea <openiputtest+0xda> printf("%s: unlink failed\n", s); 3dce: 85a6 mv a1,s1 3dd0: 00003517 auipc a0,0x3 3dd4: be850513 addi a0,a0,-1048 # 69b8 <malloc+0xe76> 3dd8: 00002097 auipc ra,0x2 3ddc: cac080e7 jalr -852(ra) # 5a84 <printf> exit(1); 3de0: 4505 li a0,1 3de2: 00002097 auipc ra,0x2 3de6: 91a080e7 jalr -1766(ra) # 56fc <exit> wait(&xstatus); 3dea: fdc40513 addi a0,s0,-36 3dee: 00002097 auipc ra,0x2 3df2: 916080e7 jalr -1770(ra) # 5704 <wait> exit(xstatus); 3df6: fdc42503 lw a0,-36(s0) 3dfa: 00002097 auipc ra,0x2 3dfe: 902080e7 jalr -1790(ra) # 56fc <exit> 0000000000003e02 <forkforkfork>: { 3e02: 1101 addi sp,sp,-32 3e04: ec06 sd ra,24(sp) 3e06: e822 sd s0,16(sp) 3e08: e426 sd s1,8(sp) 3e0a: 1000 addi s0,sp,32 3e0c: 84aa mv s1,a0 unlink("stopforking"); 3e0e: 00004517 auipc a0,0x4 3e12: c1250513 addi a0,a0,-1006 # 7a20 <malloc+0x1ede> 3e16: 00002097 auipc ra,0x2 3e1a: 936080e7 jalr -1738(ra) # 574c <unlink> int pid = fork(); 3e1e: 00002097 auipc ra,0x2 3e22: 8d6080e7 jalr -1834(ra) # 56f4 <fork> if(pid < 0){ 3e26: 04054563 bltz a0,3e70 <forkforkfork+0x6e> if(pid == 0){ 3e2a: c12d beqz a0,3e8c <forkforkfork+0x8a> sleep(20); // two seconds 3e2c: 4551 li a0,20 3e2e: 00002097 auipc ra,0x2 3e32: 95e080e7 jalr -1698(ra) # 578c <sleep> close(open("stopforking", O_CREATE|O_RDWR)); 3e36: 20200593 li a1,514 3e3a: 00004517 auipc a0,0x4 3e3e: be650513 addi a0,a0,-1050 # 7a20 <malloc+0x1ede> 3e42: 00002097 auipc ra,0x2 3e46: 8fa080e7 jalr -1798(ra) # 573c <open> 3e4a: 00002097 auipc ra,0x2 3e4e: 8da080e7 jalr -1830(ra) # 5724 <close> wait(0); 3e52: 4501 li a0,0 3e54: 00002097 auipc ra,0x2 3e58: 8b0080e7 jalr -1872(ra) # 5704 <wait> sleep(10); // one second 3e5c: 4529 li a0,10 3e5e: 00002097 auipc ra,0x2 3e62: 92e080e7 jalr -1746(ra) # 578c <sleep> } 3e66: 60e2 ld ra,24(sp) 3e68: 6442 ld s0,16(sp) 3e6a: 64a2 ld s1,8(sp) 3e6c: 6105 addi sp,sp,32 3e6e: 8082 ret printf("%s: fork failed", s); 3e70: 85a6 mv a1,s1 3e72: 00003517 auipc a0,0x3 3e76: b1650513 addi a0,a0,-1258 # 6988 <malloc+0xe46> 3e7a: 00002097 auipc ra,0x2 3e7e: c0a080e7 jalr -1014(ra) # 5a84 <printf> exit(1); 3e82: 4505 li a0,1 3e84: 00002097 auipc ra,0x2 3e88: 878080e7 jalr -1928(ra) # 56fc <exit> int fd = open("stopforking", 0); 3e8c: 00004497 auipc s1,0x4 3e90: b9448493 addi s1,s1,-1132 # 7a20 <malloc+0x1ede> 3e94: 4581 li a1,0 3e96: 8526 mv a0,s1 3e98: 00002097 auipc ra,0x2 3e9c: 8a4080e7 jalr -1884(ra) # 573c <open> if(fd >= 0){ 3ea0: 02055463 bgez a0,3ec8 <forkforkfork+0xc6> if(fork() < 0){ 3ea4: 00002097 auipc ra,0x2 3ea8: 850080e7 jalr -1968(ra) # 56f4 <fork> 3eac: fe0554e3 bgez a0,3e94 <forkforkfork+0x92> close(open("stopforking", O_CREATE|O_RDWR)); 3eb0: 20200593 li a1,514 3eb4: 8526 mv a0,s1 3eb6: 00002097 auipc ra,0x2 3eba: 886080e7 jalr -1914(ra) # 573c <open> 3ebe: 00002097 auipc ra,0x2 3ec2: 866080e7 jalr -1946(ra) # 5724 <close> 3ec6: b7f9 j 3e94 <forkforkfork+0x92> exit(0); 3ec8: 4501 li a0,0 3eca: 00002097 auipc ra,0x2 3ece: 832080e7 jalr -1998(ra) # 56fc <exit> 0000000000003ed2 <killstatus>: { 3ed2: 7139 addi sp,sp,-64 3ed4: fc06 sd ra,56(sp) 3ed6: f822 sd s0,48(sp) 3ed8: f426 sd s1,40(sp) 3eda: f04a sd s2,32(sp) 3edc: ec4e sd s3,24(sp) 3ede: e852 sd s4,16(sp) 3ee0: 0080 addi s0,sp,64 3ee2: 8a2a mv s4,a0 3ee4: 06400913 li s2,100 if(xst != -1) { 3ee8: 59fd li s3,-1 int pid1 = fork(); 3eea: 00002097 auipc ra,0x2 3eee: 80a080e7 jalr -2038(ra) # 56f4 <fork> 3ef2: 84aa mv s1,a0 if(pid1 < 0){ 3ef4: 02054f63 bltz a0,3f32 <killstatus+0x60> if(pid1 == 0){ 3ef8: c939 beqz a0,3f4e <killstatus+0x7c> sleep(1); 3efa: 4505 li a0,1 3efc: 00002097 auipc ra,0x2 3f00: 890080e7 jalr -1904(ra) # 578c <sleep> kill(pid1); 3f04: 8526 mv a0,s1 3f06: 00002097 auipc ra,0x2 3f0a: 826080e7 jalr -2010(ra) # 572c <kill> wait(&xst); 3f0e: fcc40513 addi a0,s0,-52 3f12: 00001097 auipc ra,0x1 3f16: 7f2080e7 jalr 2034(ra) # 5704 <wait> if(xst != -1) { 3f1a: fcc42783 lw a5,-52(s0) 3f1e: 03379d63 bne a5,s3,3f58 <killstatus+0x86> for(int i = 0; i < 100; i++){ 3f22: 397d addiw s2,s2,-1 3f24: fc0913e3 bnez s2,3eea <killstatus+0x18> exit(0); 3f28: 4501 li a0,0 3f2a: 00001097 auipc ra,0x1 3f2e: 7d2080e7 jalr 2002(ra) # 56fc <exit> printf("%s: fork failed\n", s); 3f32: 85d2 mv a1,s4 3f34: 00003517 auipc a0,0x3 3f38: 89450513 addi a0,a0,-1900 # 67c8 <malloc+0xc86> 3f3c: 00002097 auipc ra,0x2 3f40: b48080e7 jalr -1208(ra) # 5a84 <printf> exit(1); 3f44: 4505 li a0,1 3f46: 00001097 auipc ra,0x1 3f4a: 7b6080e7 jalr 1974(ra) # 56fc <exit> getpid(); 3f4e: 00002097 auipc ra,0x2 3f52: 82e080e7 jalr -2002(ra) # 577c <getpid> while(1) { 3f56: bfe5 j 3f4e <killstatus+0x7c> printf("%s: status should be -1\n", s); 3f58: 85d2 mv a1,s4 3f5a: 00004517 auipc a0,0x4 3f5e: ad650513 addi a0,a0,-1322 # 7a30 <malloc+0x1eee> 3f62: 00002097 auipc ra,0x2 3f66: b22080e7 jalr -1246(ra) # 5a84 <printf> exit(1); 3f6a: 4505 li a0,1 3f6c: 00001097 auipc ra,0x1 3f70: 790080e7 jalr 1936(ra) # 56fc <exit> 0000000000003f74 <preempt>: { 3f74: 7139 addi sp,sp,-64 3f76: fc06 sd ra,56(sp) 3f78: f822 sd s0,48(sp) 3f7a: f426 sd s1,40(sp) 3f7c: f04a sd s2,32(sp) 3f7e: ec4e sd s3,24(sp) 3f80: e852 sd s4,16(sp) 3f82: 0080 addi s0,sp,64 3f84: 892a mv s2,a0 pid1 = fork(); 3f86: 00001097 auipc ra,0x1 3f8a: 76e080e7 jalr 1902(ra) # 56f4 <fork> if(pid1 < 0) { 3f8e: 00054563 bltz a0,3f98 <preempt+0x24> 3f92: 84aa mv s1,a0 if(pid1 == 0) 3f94: e105 bnez a0,3fb4 <preempt+0x40> for(;;) 3f96: a001 j 3f96 <preempt+0x22> printf("%s: fork failed", s); 3f98: 85ca mv a1,s2 3f9a: 00003517 auipc a0,0x3 3f9e: 9ee50513 addi a0,a0,-1554 # 6988 <malloc+0xe46> 3fa2: 00002097 auipc ra,0x2 3fa6: ae2080e7 jalr -1310(ra) # 5a84 <printf> exit(1); 3faa: 4505 li a0,1 3fac: 00001097 auipc ra,0x1 3fb0: 750080e7 jalr 1872(ra) # 56fc <exit> pid2 = fork(); 3fb4: 00001097 auipc ra,0x1 3fb8: 740080e7 jalr 1856(ra) # 56f4 <fork> 3fbc: 89aa mv s3,a0 if(pid2 < 0) { 3fbe: 00054463 bltz a0,3fc6 <preempt+0x52> if(pid2 == 0) 3fc2: e105 bnez a0,3fe2 <preempt+0x6e> for(;;) 3fc4: a001 j 3fc4 <preempt+0x50> printf("%s: fork failed\n", s); 3fc6: 85ca mv a1,s2 3fc8: 00003517 auipc a0,0x3 3fcc: 80050513 addi a0,a0,-2048 # 67c8 <malloc+0xc86> 3fd0: 00002097 auipc ra,0x2 3fd4: ab4080e7 jalr -1356(ra) # 5a84 <printf> exit(1); 3fd8: 4505 li a0,1 3fda: 00001097 auipc ra,0x1 3fde: 722080e7 jalr 1826(ra) # 56fc <exit> pipe(pfds); 3fe2: fc840513 addi a0,s0,-56 3fe6: 00001097 auipc ra,0x1 3fea: 726080e7 jalr 1830(ra) # 570c <pipe> pid3 = fork(); 3fee: 00001097 auipc ra,0x1 3ff2: 706080e7 jalr 1798(ra) # 56f4 <fork> 3ff6: 8a2a mv s4,a0 if(pid3 < 0) { 3ff8: 02054e63 bltz a0,4034 <preempt+0xc0> if(pid3 == 0){ 3ffc: e525 bnez a0,4064 <preempt+0xf0> close(pfds[0]); 3ffe: fc842503 lw a0,-56(s0) 4002: 00001097 auipc ra,0x1 4006: 722080e7 jalr 1826(ra) # 5724 <close> if(write(pfds[1], "x", 1) != 1) 400a: 4605 li a2,1 400c: 00002597 auipc a1,0x2 4010: ff458593 addi a1,a1,-12 # 6000 <malloc+0x4be> 4014: fcc42503 lw a0,-52(s0) 4018: 00001097 auipc ra,0x1 401c: 704080e7 jalr 1796(ra) # 571c <write> 4020: 4785 li a5,1 4022: 02f51763 bne a0,a5,4050 <preempt+0xdc> close(pfds[1]); 4026: fcc42503 lw a0,-52(s0) 402a: 00001097 auipc ra,0x1 402e: 6fa080e7 jalr 1786(ra) # 5724 <close> for(;;) 4032: a001 j 4032 <preempt+0xbe> printf("%s: fork failed\n", s); 4034: 85ca mv a1,s2 4036: 00002517 auipc a0,0x2 403a: 79250513 addi a0,a0,1938 # 67c8 <malloc+0xc86> 403e: 00002097 auipc ra,0x2 4042: a46080e7 jalr -1466(ra) # 5a84 <printf> exit(1); 4046: 4505 li a0,1 4048: 00001097 auipc ra,0x1 404c: 6b4080e7 jalr 1716(ra) # 56fc <exit> printf("%s: preempt write error", s); 4050: 85ca mv a1,s2 4052: 00004517 auipc a0,0x4 4056: 9fe50513 addi a0,a0,-1538 # 7a50 <malloc+0x1f0e> 405a: 00002097 auipc ra,0x2 405e: a2a080e7 jalr -1494(ra) # 5a84 <printf> 4062: b7d1 j 4026 <preempt+0xb2> close(pfds[1]); 4064: fcc42503 lw a0,-52(s0) 4068: 00001097 auipc ra,0x1 406c: 6bc080e7 jalr 1724(ra) # 5724 <close> if(read(pfds[0], buf, sizeof(buf)) != 1){ 4070: 660d lui a2,0x3 4072: 00008597 auipc a1,0x8 4076: b6658593 addi a1,a1,-1178 # bbd8 <buf> 407a: fc842503 lw a0,-56(s0) 407e: 00001097 auipc ra,0x1 4082: 696080e7 jalr 1686(ra) # 5714 <read> 4086: 4785 li a5,1 4088: 02f50363 beq a0,a5,40ae <preempt+0x13a> printf("%s: preempt read error", s); 408c: 85ca mv a1,s2 408e: 00004517 auipc a0,0x4 4092: 9da50513 addi a0,a0,-1574 # 7a68 <malloc+0x1f26> 4096: 00002097 auipc ra,0x2 409a: 9ee080e7 jalr -1554(ra) # 5a84 <printf> } 409e: 70e2 ld ra,56(sp) 40a0: 7442 ld s0,48(sp) 40a2: 74a2 ld s1,40(sp) 40a4: 7902 ld s2,32(sp) 40a6: 69e2 ld s3,24(sp) 40a8: 6a42 ld s4,16(sp) 40aa: 6121 addi sp,sp,64 40ac: 8082 ret close(pfds[0]); 40ae: fc842503 lw a0,-56(s0) 40b2: 00001097 auipc ra,0x1 40b6: 672080e7 jalr 1650(ra) # 5724 <close> printf("kill... "); 40ba: 00004517 auipc a0,0x4 40be: 9c650513 addi a0,a0,-1594 # 7a80 <malloc+0x1f3e> 40c2: 00002097 auipc ra,0x2 40c6: 9c2080e7 jalr -1598(ra) # 5a84 <printf> kill(pid1); 40ca: 8526 mv a0,s1 40cc: 00001097 auipc ra,0x1 40d0: 660080e7 jalr 1632(ra) # 572c <kill> kill(pid2); 40d4: 854e mv a0,s3 40d6: 00001097 auipc ra,0x1 40da: 656080e7 jalr 1622(ra) # 572c <kill> kill(pid3); 40de: 8552 mv a0,s4 40e0: 00001097 auipc ra,0x1 40e4: 64c080e7 jalr 1612(ra) # 572c <kill> printf("wait... "); 40e8: 00004517 auipc a0,0x4 40ec: 9a850513 addi a0,a0,-1624 # 7a90 <malloc+0x1f4e> 40f0: 00002097 auipc ra,0x2 40f4: 994080e7 jalr -1644(ra) # 5a84 <printf> wait(0); 40f8: 4501 li a0,0 40fa: 00001097 auipc ra,0x1 40fe: 60a080e7 jalr 1546(ra) # 5704 <wait> wait(0); 4102: 4501 li a0,0 4104: 00001097 auipc ra,0x1 4108: 600080e7 jalr 1536(ra) # 5704 <wait> wait(0); 410c: 4501 li a0,0 410e: 00001097 auipc ra,0x1 4112: 5f6080e7 jalr 1526(ra) # 5704 <wait> 4116: b761 j 409e <preempt+0x12a> 0000000000004118 <reparent>: { 4118: 7179 addi sp,sp,-48 411a: f406 sd ra,40(sp) 411c: f022 sd s0,32(sp) 411e: ec26 sd s1,24(sp) 4120: e84a sd s2,16(sp) 4122: e44e sd s3,8(sp) 4124: e052 sd s4,0(sp) 4126: 1800 addi s0,sp,48 4128: 89aa mv s3,a0 int master_pid = getpid(); 412a: 00001097 auipc ra,0x1 412e: 652080e7 jalr 1618(ra) # 577c <getpid> 4132: 8a2a mv s4,a0 4134: 0c800913 li s2,200 int pid = fork(); 4138: 00001097 auipc ra,0x1 413c: 5bc080e7 jalr 1468(ra) # 56f4 <fork> 4140: 84aa mv s1,a0 if(pid < 0){ 4142: 02054263 bltz a0,4166 <reparent+0x4e> if(pid){ 4146: cd21 beqz a0,419e <reparent+0x86> if(wait(0) != pid){ 4148: 4501 li a0,0 414a: 00001097 auipc ra,0x1 414e: 5ba080e7 jalr 1466(ra) # 5704 <wait> 4152: 02951863 bne a0,s1,4182 <reparent+0x6a> for(int i = 0; i < 200; i++){ 4156: 397d addiw s2,s2,-1 4158: fe0910e3 bnez s2,4138 <reparent+0x20> exit(0); 415c: 4501 li a0,0 415e: 00001097 auipc ra,0x1 4162: 59e080e7 jalr 1438(ra) # 56fc <exit> printf("%s: fork failed\n", s); 4166: 85ce mv a1,s3 4168: 00002517 auipc a0,0x2 416c: 66050513 addi a0,a0,1632 # 67c8 <malloc+0xc86> 4170: 00002097 auipc ra,0x2 4174: 914080e7 jalr -1772(ra) # 5a84 <printf> exit(1); 4178: 4505 li a0,1 417a: 00001097 auipc ra,0x1 417e: 582080e7 jalr 1410(ra) # 56fc <exit> printf("%s: wait wrong pid\n", s); 4182: 85ce mv a1,s3 4184: 00002517 auipc a0,0x2 4188: 7cc50513 addi a0,a0,1996 # 6950 <malloc+0xe0e> 418c: 00002097 auipc ra,0x2 4190: 8f8080e7 jalr -1800(ra) # 5a84 <printf> exit(1); 4194: 4505 li a0,1 4196: 00001097 auipc ra,0x1 419a: 566080e7 jalr 1382(ra) # 56fc <exit> int pid2 = fork(); 419e: 00001097 auipc ra,0x1 41a2: 556080e7 jalr 1366(ra) # 56f4 <fork> if(pid2 < 0){ 41a6: 00054763 bltz a0,41b4 <reparent+0x9c> exit(0); 41aa: 4501 li a0,0 41ac: 00001097 auipc ra,0x1 41b0: 550080e7 jalr 1360(ra) # 56fc <exit> kill(master_pid); 41b4: 8552 mv a0,s4 41b6: 00001097 auipc ra,0x1 41ba: 576080e7 jalr 1398(ra) # 572c <kill> exit(1); 41be: 4505 li a0,1 41c0: 00001097 auipc ra,0x1 41c4: 53c080e7 jalr 1340(ra) # 56fc <exit> 00000000000041c8 <sbrkfail>: { 41c8: 7119 addi sp,sp,-128 41ca: fc86 sd ra,120(sp) 41cc: f8a2 sd s0,112(sp) 41ce: f4a6 sd s1,104(sp) 41d0: f0ca sd s2,96(sp) 41d2: ecce sd s3,88(sp) 41d4: e8d2 sd s4,80(sp) 41d6: e4d6 sd s5,72(sp) 41d8: 0100 addi s0,sp,128 41da: 8aaa mv s5,a0 if(pipe(fds) != 0){ 41dc: fb040513 addi a0,s0,-80 41e0: 00001097 auipc ra,0x1 41e4: 52c080e7 jalr 1324(ra) # 570c <pipe> 41e8: e901 bnez a0,41f8 <sbrkfail+0x30> 41ea: f8040493 addi s1,s0,-128 41ee: fa840993 addi s3,s0,-88 41f2: 8926 mv s2,s1 if(pids[i] != -1) 41f4: 5a7d li s4,-1 41f6: a085 j 4256 <sbrkfail+0x8e> printf("%s: pipe() failed\n", s); 41f8: 85d6 mv a1,s5 41fa: 00002517 auipc a0,0x2 41fe: 6d650513 addi a0,a0,1750 # 68d0 <malloc+0xd8e> 4202: 00002097 auipc ra,0x2 4206: 882080e7 jalr -1918(ra) # 5a84 <printf> exit(1); 420a: 4505 li a0,1 420c: 00001097 auipc ra,0x1 4210: 4f0080e7 jalr 1264(ra) # 56fc <exit> sbrk(BIG - (uint64)sbrk(0)); 4214: 00001097 auipc ra,0x1 4218: 570080e7 jalr 1392(ra) # 5784 <sbrk> 421c: 064007b7 lui a5,0x6400 4220: 40a7853b subw a0,a5,a0 4224: 00001097 auipc ra,0x1 4228: 560080e7 jalr 1376(ra) # 5784 <sbrk> write(fds[1], "x", 1); 422c: 4605 li a2,1 422e: 00002597 auipc a1,0x2 4232: dd258593 addi a1,a1,-558 # 6000 <malloc+0x4be> 4236: fb442503 lw a0,-76(s0) 423a: 00001097 auipc ra,0x1 423e: 4e2080e7 jalr 1250(ra) # 571c <write> for(;;) sleep(1000); 4242: 3e800513 li a0,1000 4246: 00001097 auipc ra,0x1 424a: 546080e7 jalr 1350(ra) # 578c <sleep> 424e: bfd5 j 4242 <sbrkfail+0x7a> for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 4250: 0911 addi s2,s2,4 4252: 03390563 beq s2,s3,427c <sbrkfail+0xb4> if((pids[i] = fork()) == 0){ 4256: 00001097 auipc ra,0x1 425a: 49e080e7 jalr 1182(ra) # 56f4 <fork> 425e: 00a92023 sw a0,0(s2) 4262: d94d beqz a0,4214 <sbrkfail+0x4c> if(pids[i] != -1) 4264: ff4506e3 beq a0,s4,4250 <sbrkfail+0x88> read(fds[0], &scratch, 1); 4268: 4605 li a2,1 426a: faf40593 addi a1,s0,-81 426e: fb042503 lw a0,-80(s0) 4272: 00001097 auipc ra,0x1 4276: 4a2080e7 jalr 1186(ra) # 5714 <read> 427a: bfd9 j 4250 <sbrkfail+0x88> c = sbrk(PGSIZE); 427c: 6505 lui a0,0x1 427e: 00001097 auipc ra,0x1 4282: 506080e7 jalr 1286(ra) # 5784 <sbrk> 4286: 8a2a mv s4,a0 if(pids[i] == -1) 4288: 597d li s2,-1 428a: a021 j 4292 <sbrkfail+0xca> for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 428c: 0491 addi s1,s1,4 428e: 01348f63 beq s1,s3,42ac <sbrkfail+0xe4> if(pids[i] == -1) 4292: 4088 lw a0,0(s1) 4294: ff250ce3 beq a0,s2,428c <sbrkfail+0xc4> kill(pids[i]); 4298: 00001097 auipc ra,0x1 429c: 494080e7 jalr 1172(ra) # 572c <kill> wait(0); 42a0: 4501 li a0,0 42a2: 00001097 auipc ra,0x1 42a6: 462080e7 jalr 1122(ra) # 5704 <wait> 42aa: b7cd j 428c <sbrkfail+0xc4> if(c == (char*)0xffffffffffffffffL){ 42ac: 57fd li a5,-1 42ae: 04fa0163 beq s4,a5,42f0 <sbrkfail+0x128> pid = fork(); 42b2: 00001097 auipc ra,0x1 42b6: 442080e7 jalr 1090(ra) # 56f4 <fork> 42ba: 84aa mv s1,a0 if(pid < 0){ 42bc: 04054863 bltz a0,430c <sbrkfail+0x144> if(pid == 0){ 42c0: c525 beqz a0,4328 <sbrkfail+0x160> wait(&xstatus); 42c2: fbc40513 addi a0,s0,-68 42c6: 00001097 auipc ra,0x1 42ca: 43e080e7 jalr 1086(ra) # 5704 <wait> if(xstatus != -1 && xstatus != 2) 42ce: fbc42783 lw a5,-68(s0) 42d2: 577d li a4,-1 42d4: 00e78563 beq a5,a4,42de <sbrkfail+0x116> 42d8: 4709 li a4,2 42da: 08e79d63 bne a5,a4,4374 <sbrkfail+0x1ac> } 42de: 70e6 ld ra,120(sp) 42e0: 7446 ld s0,112(sp) 42e2: 74a6 ld s1,104(sp) 42e4: 7906 ld s2,96(sp) 42e6: 69e6 ld s3,88(sp) 42e8: 6a46 ld s4,80(sp) 42ea: 6aa6 ld s5,72(sp) 42ec: 6109 addi sp,sp,128 42ee: 8082 ret printf("%s: failed sbrk leaked memory\n", s); 42f0: 85d6 mv a1,s5 42f2: 00003517 auipc a0,0x3 42f6: 7ae50513 addi a0,a0,1966 # 7aa0 <malloc+0x1f5e> 42fa: 00001097 auipc ra,0x1 42fe: 78a080e7 jalr 1930(ra) # 5a84 <printf> exit(1); 4302: 4505 li a0,1 4304: 00001097 auipc ra,0x1 4308: 3f8080e7 jalr 1016(ra) # 56fc <exit> printf("%s: fork failed\n", s); 430c: 85d6 mv a1,s5 430e: 00002517 auipc a0,0x2 4312: 4ba50513 addi a0,a0,1210 # 67c8 <malloc+0xc86> 4316: 00001097 auipc ra,0x1 431a: 76e080e7 jalr 1902(ra) # 5a84 <printf> exit(1); 431e: 4505 li a0,1 4320: 00001097 auipc ra,0x1 4324: 3dc080e7 jalr 988(ra) # 56fc <exit> a = sbrk(0); 4328: 4501 li a0,0 432a: 00001097 auipc ra,0x1 432e: 45a080e7 jalr 1114(ra) # 5784 <sbrk> 4332: 892a mv s2,a0 sbrk(10*BIG); 4334: 3e800537 lui a0,0x3e800 4338: 00001097 auipc ra,0x1 433c: 44c080e7 jalr 1100(ra) # 5784 <sbrk> for (i = 0; i < 10*BIG; i += PGSIZE) { 4340: 87ca mv a5,s2 4342: 3e800737 lui a4,0x3e800 4346: 993a add s2,s2,a4 4348: 6705 lui a4,0x1 n += *(a+i); 434a: 0007c683 lbu a3,0(a5) # 6400000 <__BSS_END__+0x63f1418> 434e: 9cb5 addw s1,s1,a3 for (i = 0; i < 10*BIG; i += PGSIZE) { 4350: 97ba add a5,a5,a4 4352: ff279ce3 bne a5,s2,434a <sbrkfail+0x182> printf("%s: allocate a lot of memory succeeded %d\n", s, n); 4356: 8626 mv a2,s1 4358: 85d6 mv a1,s5 435a: 00003517 auipc a0,0x3 435e: 76650513 addi a0,a0,1894 # 7ac0 <malloc+0x1f7e> 4362: 00001097 auipc ra,0x1 4366: 722080e7 jalr 1826(ra) # 5a84 <printf> exit(1); 436a: 4505 li a0,1 436c: 00001097 auipc ra,0x1 4370: 390080e7 jalr 912(ra) # 56fc <exit> exit(1); 4374: 4505 li a0,1 4376: 00001097 auipc ra,0x1 437a: 386080e7 jalr 902(ra) # 56fc <exit> 000000000000437e <mem>: { 437e: 7139 addi sp,sp,-64 4380: fc06 sd ra,56(sp) 4382: f822 sd s0,48(sp) 4384: f426 sd s1,40(sp) 4386: f04a sd s2,32(sp) 4388: ec4e sd s3,24(sp) 438a: 0080 addi s0,sp,64 438c: 89aa mv s3,a0 if((pid = fork()) == 0){ 438e: 00001097 auipc ra,0x1 4392: 366080e7 jalr 870(ra) # 56f4 <fork> m1 = 0; 4396: 4481 li s1,0 while((m2 = malloc(10001)) != 0){ 4398: 6909 lui s2,0x2 439a: 71190913 addi s2,s2,1809 # 2711 <sbrkbasic+0x159> if((pid = fork()) == 0){ 439e: c115 beqz a0,43c2 <mem+0x44> wait(&xstatus); 43a0: fcc40513 addi a0,s0,-52 43a4: 00001097 auipc ra,0x1 43a8: 360080e7 jalr 864(ra) # 5704 <wait> if(xstatus == -1){ 43ac: fcc42503 lw a0,-52(s0) 43b0: 57fd li a5,-1 43b2: 06f50363 beq a0,a5,4418 <mem+0x9a> exit(xstatus); 43b6: 00001097 auipc ra,0x1 43ba: 346080e7 jalr 838(ra) # 56fc <exit> *(char**)m2 = m1; 43be: e104 sd s1,0(a0) m1 = m2; 43c0: 84aa mv s1,a0 while((m2 = malloc(10001)) != 0){ 43c2: 854a mv a0,s2 43c4: 00001097 auipc ra,0x1 43c8: 77e080e7 jalr 1918(ra) # 5b42 <malloc> 43cc: f96d bnez a0,43be <mem+0x40> while(m1){ 43ce: c881 beqz s1,43de <mem+0x60> m2 = *(char**)m1; 43d0: 8526 mv a0,s1 43d2: 6084 ld s1,0(s1) free(m1); 43d4: 00001097 auipc ra,0x1 43d8: 6e6080e7 jalr 1766(ra) # 5aba <free> while(m1){ 43dc: f8f5 bnez s1,43d0 <mem+0x52> m1 = malloc(1024*20); 43de: 6515 lui a0,0x5 43e0: 00001097 auipc ra,0x1 43e4: 762080e7 jalr 1890(ra) # 5b42 <malloc> if(m1 == 0){ 43e8: c911 beqz a0,43fc <mem+0x7e> free(m1); 43ea: 00001097 auipc ra,0x1 43ee: 6d0080e7 jalr 1744(ra) # 5aba <free> exit(0); 43f2: 4501 li a0,0 43f4: 00001097 auipc ra,0x1 43f8: 308080e7 jalr 776(ra) # 56fc <exit> printf("couldn't allocate mem?!!\n", s); 43fc: 85ce mv a1,s3 43fe: 00003517 auipc a0,0x3 4402: 6f250513 addi a0,a0,1778 # 7af0 <malloc+0x1fae> 4406: 00001097 auipc ra,0x1 440a: 67e080e7 jalr 1662(ra) # 5a84 <printf> exit(1); 440e: 4505 li a0,1 4410: 00001097 auipc ra,0x1 4414: 2ec080e7 jalr 748(ra) # 56fc <exit> exit(0); 4418: 4501 li a0,0 441a: 00001097 auipc ra,0x1 441e: 2e2080e7 jalr 738(ra) # 56fc <exit> 0000000000004422 <sharedfd>: { 4422: 7159 addi sp,sp,-112 4424: f486 sd ra,104(sp) 4426: f0a2 sd s0,96(sp) 4428: eca6 sd s1,88(sp) 442a: e8ca sd s2,80(sp) 442c: e4ce sd s3,72(sp) 442e: e0d2 sd s4,64(sp) 4430: fc56 sd s5,56(sp) 4432: f85a sd s6,48(sp) 4434: f45e sd s7,40(sp) 4436: 1880 addi s0,sp,112 4438: 8a2a mv s4,a0 unlink("sharedfd"); 443a: 00002517 auipc a0,0x2 443e: 98650513 addi a0,a0,-1658 # 5dc0 <malloc+0x27e> 4442: 00001097 auipc ra,0x1 4446: 30a080e7 jalr 778(ra) # 574c <unlink> fd = open("sharedfd", O_CREATE|O_RDWR); 444a: 20200593 li a1,514 444e: 00002517 auipc a0,0x2 4452: 97250513 addi a0,a0,-1678 # 5dc0 <malloc+0x27e> 4456: 00001097 auipc ra,0x1 445a: 2e6080e7 jalr 742(ra) # 573c <open> if(fd < 0){ 445e: 04054a63 bltz a0,44b2 <sharedfd+0x90> 4462: 892a mv s2,a0 pid = fork(); 4464: 00001097 auipc ra,0x1 4468: 290080e7 jalr 656(ra) # 56f4 <fork> 446c: 89aa mv s3,a0 memset(buf, pid==0?'c':'p', sizeof(buf)); 446e: 06300593 li a1,99 4472: c119 beqz a0,4478 <sharedfd+0x56> 4474: 07000593 li a1,112 4478: 4629 li a2,10 447a: fa040513 addi a0,s0,-96 447e: 00001097 auipc ra,0x1 4482: 026080e7 jalr 38(ra) # 54a4 <memset> 4486: 3e800493 li s1,1000 if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ 448a: 4629 li a2,10 448c: fa040593 addi a1,s0,-96 4490: 854a mv a0,s2 4492: 00001097 auipc ra,0x1 4496: 28a080e7 jalr 650(ra) # 571c <write> 449a: 47a9 li a5,10 449c: 02f51963 bne a0,a5,44ce <sharedfd+0xac> for(i = 0; i < N; i++){ 44a0: 34fd addiw s1,s1,-1 44a2: f4e5 bnez s1,448a <sharedfd+0x68> if(pid == 0) { 44a4: 04099363 bnez s3,44ea <sharedfd+0xc8> exit(0); 44a8: 4501 li a0,0 44aa: 00001097 auipc ra,0x1 44ae: 252080e7 jalr 594(ra) # 56fc <exit> printf("%s: cannot open sharedfd for writing", s); 44b2: 85d2 mv a1,s4 44b4: 00003517 auipc a0,0x3 44b8: 65c50513 addi a0,a0,1628 # 7b10 <malloc+0x1fce> 44bc: 00001097 auipc ra,0x1 44c0: 5c8080e7 jalr 1480(ra) # 5a84 <printf> exit(1); 44c4: 4505 li a0,1 44c6: 00001097 auipc ra,0x1 44ca: 236080e7 jalr 566(ra) # 56fc <exit> printf("%s: write sharedfd failed\n", s); 44ce: 85d2 mv a1,s4 44d0: 00003517 auipc a0,0x3 44d4: 66850513 addi a0,a0,1640 # 7b38 <malloc+0x1ff6> 44d8: 00001097 auipc ra,0x1 44dc: 5ac080e7 jalr 1452(ra) # 5a84 <printf> exit(1); 44e0: 4505 li a0,1 44e2: 00001097 auipc ra,0x1 44e6: 21a080e7 jalr 538(ra) # 56fc <exit> wait(&xstatus); 44ea: f9c40513 addi a0,s0,-100 44ee: 00001097 auipc ra,0x1 44f2: 216080e7 jalr 534(ra) # 5704 <wait> if(xstatus != 0) 44f6: f9c42983 lw s3,-100(s0) 44fa: 00098763 beqz s3,4508 <sharedfd+0xe6> exit(xstatus); 44fe: 854e mv a0,s3 4500: 00001097 auipc ra,0x1 4504: 1fc080e7 jalr 508(ra) # 56fc <exit> close(fd); 4508: 854a mv a0,s2 450a: 00001097 auipc ra,0x1 450e: 21a080e7 jalr 538(ra) # 5724 <close> fd = open("sharedfd", 0); 4512: 4581 li a1,0 4514: 00002517 auipc a0,0x2 4518: 8ac50513 addi a0,a0,-1876 # 5dc0 <malloc+0x27e> 451c: 00001097 auipc ra,0x1 4520: 220080e7 jalr 544(ra) # 573c <open> 4524: 8baa mv s7,a0 nc = np = 0; 4526: 8ace mv s5,s3 if(fd < 0){ 4528: 02054563 bltz a0,4552 <sharedfd+0x130> 452c: faa40913 addi s2,s0,-86 if(buf[i] == 'c') 4530: 06300493 li s1,99 if(buf[i] == 'p') 4534: 07000b13 li s6,112 while((n = read(fd, buf, sizeof(buf))) > 0){ 4538: 4629 li a2,10 453a: fa040593 addi a1,s0,-96 453e: 855e mv a0,s7 4540: 00001097 auipc ra,0x1 4544: 1d4080e7 jalr 468(ra) # 5714 <read> 4548: 02a05f63 blez a0,4586 <sharedfd+0x164> 454c: fa040793 addi a5,s0,-96 4550: a01d j 4576 <sharedfd+0x154> printf("%s: cannot open sharedfd for reading\n", s); 4552: 85d2 mv a1,s4 4554: 00003517 auipc a0,0x3 4558: 60450513 addi a0,a0,1540 # 7b58 <malloc+0x2016> 455c: 00001097 auipc ra,0x1 4560: 528080e7 jalr 1320(ra) # 5a84 <printf> exit(1); 4564: 4505 li a0,1 4566: 00001097 auipc ra,0x1 456a: 196080e7 jalr 406(ra) # 56fc <exit> nc++; 456e: 2985 addiw s3,s3,1 for(i = 0; i < sizeof(buf); i++){ 4570: 0785 addi a5,a5,1 4572: fd2783e3 beq a5,s2,4538 <sharedfd+0x116> if(buf[i] == 'c') 4576: 0007c703 lbu a4,0(a5) 457a: fe970ae3 beq a4,s1,456e <sharedfd+0x14c> if(buf[i] == 'p') 457e: ff6719e3 bne a4,s6,4570 <sharedfd+0x14e> np++; 4582: 2a85 addiw s5,s5,1 4584: b7f5 j 4570 <sharedfd+0x14e> close(fd); 4586: 855e mv a0,s7 4588: 00001097 auipc ra,0x1 458c: 19c080e7 jalr 412(ra) # 5724 <close> unlink("sharedfd"); 4590: 00002517 auipc a0,0x2 4594: 83050513 addi a0,a0,-2000 # 5dc0 <malloc+0x27e> 4598: 00001097 auipc ra,0x1 459c: 1b4080e7 jalr 436(ra) # 574c <unlink> if(nc == N*SZ && np == N*SZ){ 45a0: 6789 lui a5,0x2 45a2: 71078793 addi a5,a5,1808 # 2710 <sbrkbasic+0x158> 45a6: 00f99763 bne s3,a5,45b4 <sharedfd+0x192> 45aa: 6789 lui a5,0x2 45ac: 71078793 addi a5,a5,1808 # 2710 <sbrkbasic+0x158> 45b0: 02fa8063 beq s5,a5,45d0 <sharedfd+0x1ae> printf("%s: nc/np test fails\n", s); 45b4: 85d2 mv a1,s4 45b6: 00003517 auipc a0,0x3 45ba: 5ca50513 addi a0,a0,1482 # 7b80 <malloc+0x203e> 45be: 00001097 auipc ra,0x1 45c2: 4c6080e7 jalr 1222(ra) # 5a84 <printf> exit(1); 45c6: 4505 li a0,1 45c8: 00001097 auipc ra,0x1 45cc: 134080e7 jalr 308(ra) # 56fc <exit> exit(0); 45d0: 4501 li a0,0 45d2: 00001097 auipc ra,0x1 45d6: 12a080e7 jalr 298(ra) # 56fc <exit> 00000000000045da <fourfiles>: { 45da: 7171 addi sp,sp,-176 45dc: f506 sd ra,168(sp) 45de: f122 sd s0,160(sp) 45e0: ed26 sd s1,152(sp) 45e2: e94a sd s2,144(sp) 45e4: e54e sd s3,136(sp) 45e6: e152 sd s4,128(sp) 45e8: fcd6 sd s5,120(sp) 45ea: f8da sd s6,112(sp) 45ec: f4de sd s7,104(sp) 45ee: f0e2 sd s8,96(sp) 45f0: ece6 sd s9,88(sp) 45f2: e8ea sd s10,80(sp) 45f4: e4ee sd s11,72(sp) 45f6: 1900 addi s0,sp,176 45f8: f4a43c23 sd a0,-168(s0) char *names[] = { "f0", "f1", "f2", "f3" }; 45fc: 00001797 auipc a5,0x1 4600: 62c78793 addi a5,a5,1580 # 5c28 <malloc+0xe6> 4604: f6f43823 sd a5,-144(s0) 4608: 00001797 auipc a5,0x1 460c: 62878793 addi a5,a5,1576 # 5c30 <malloc+0xee> 4610: f6f43c23 sd a5,-136(s0) 4614: 00001797 auipc a5,0x1 4618: 62478793 addi a5,a5,1572 # 5c38 <malloc+0xf6> 461c: f8f43023 sd a5,-128(s0) 4620: 00001797 auipc a5,0x1 4624: 62078793 addi a5,a5,1568 # 5c40 <malloc+0xfe> 4628: f8f43423 sd a5,-120(s0) for(pi = 0; pi < NCHILD; pi++){ 462c: f7040c13 addi s8,s0,-144 char *names[] = { "f0", "f1", "f2", "f3" }; 4630: 8962 mv s2,s8 for(pi = 0; pi < NCHILD; pi++){ 4632: 4481 li s1,0 4634: 4a11 li s4,4 fname = names[pi]; 4636: 00093983 ld s3,0(s2) unlink(fname); 463a: 854e mv a0,s3 463c: 00001097 auipc ra,0x1 4640: 110080e7 jalr 272(ra) # 574c <unlink> pid = fork(); 4644: 00001097 auipc ra,0x1 4648: 0b0080e7 jalr 176(ra) # 56f4 <fork> if(pid < 0){ 464c: 04054463 bltz a0,4694 <fourfiles+0xba> if(pid == 0){ 4650: c12d beqz a0,46b2 <fourfiles+0xd8> for(pi = 0; pi < NCHILD; pi++){ 4652: 2485 addiw s1,s1,1 4654: 0921 addi s2,s2,8 4656: ff4490e3 bne s1,s4,4636 <fourfiles+0x5c> 465a: 4491 li s1,4 wait(&xstatus); 465c: f6c40513 addi a0,s0,-148 4660: 00001097 auipc ra,0x1 4664: 0a4080e7 jalr 164(ra) # 5704 <wait> if(xstatus != 0) 4668: f6c42b03 lw s6,-148(s0) 466c: 0c0b1e63 bnez s6,4748 <fourfiles+0x16e> for(pi = 0; pi < NCHILD; pi++){ 4670: 34fd addiw s1,s1,-1 4672: f4ed bnez s1,465c <fourfiles+0x82> 4674: 03000b93 li s7,48 while((n = read(fd, buf, sizeof(buf))) > 0){ 4678: 00007a17 auipc s4,0x7 467c: 560a0a13 addi s4,s4,1376 # bbd8 <buf> 4680: 00007a97 auipc s5,0x7 4684: 559a8a93 addi s5,s5,1369 # bbd9 <buf+0x1> if(total != N*SZ){ 4688: 6d85 lui s11,0x1 468a: 770d8d93 addi s11,s11,1904 # 1770 <pipe1+0x32> for(i = 0; i < NCHILD; i++){ 468e: 03400d13 li s10,52 4692: aa1d j 47c8 <fourfiles+0x1ee> printf("fork failed\n", s); 4694: f5843583 ld a1,-168(s0) 4698: 00002517 auipc a0,0x2 469c: 53850513 addi a0,a0,1336 # 6bd0 <malloc+0x108e> 46a0: 00001097 auipc ra,0x1 46a4: 3e4080e7 jalr 996(ra) # 5a84 <printf> exit(1); 46a8: 4505 li a0,1 46aa: 00001097 auipc ra,0x1 46ae: 052080e7 jalr 82(ra) # 56fc <exit> fd = open(fname, O_CREATE | O_RDWR); 46b2: 20200593 li a1,514 46b6: 854e mv a0,s3 46b8: 00001097 auipc ra,0x1 46bc: 084080e7 jalr 132(ra) # 573c <open> 46c0: 892a mv s2,a0 if(fd < 0){ 46c2: 04054763 bltz a0,4710 <fourfiles+0x136> memset(buf, '0'+pi, SZ); 46c6: 1f400613 li a2,500 46ca: 0304859b addiw a1,s1,48 46ce: 00007517 auipc a0,0x7 46d2: 50a50513 addi a0,a0,1290 # bbd8 <buf> 46d6: 00001097 auipc ra,0x1 46da: dce080e7 jalr -562(ra) # 54a4 <memset> 46de: 44b1 li s1,12 if((n = write(fd, buf, SZ)) != SZ){ 46e0: 00007997 auipc s3,0x7 46e4: 4f898993 addi s3,s3,1272 # bbd8 <buf> 46e8: 1f400613 li a2,500 46ec: 85ce mv a1,s3 46ee: 854a mv a0,s2 46f0: 00001097 auipc ra,0x1 46f4: 02c080e7 jalr 44(ra) # 571c <write> 46f8: 85aa mv a1,a0 46fa: 1f400793 li a5,500 46fe: 02f51863 bne a0,a5,472e <fourfiles+0x154> for(i = 0; i < N; i++){ 4702: 34fd addiw s1,s1,-1 4704: f0f5 bnez s1,46e8 <fourfiles+0x10e> exit(0); 4706: 4501 li a0,0 4708: 00001097 auipc ra,0x1 470c: ff4080e7 jalr -12(ra) # 56fc <exit> printf("create failed\n", s); 4710: f5843583 ld a1,-168(s0) 4714: 00003517 auipc a0,0x3 4718: 48450513 addi a0,a0,1156 # 7b98 <malloc+0x2056> 471c: 00001097 auipc ra,0x1 4720: 368080e7 jalr 872(ra) # 5a84 <printf> exit(1); 4724: 4505 li a0,1 4726: 00001097 auipc ra,0x1 472a: fd6080e7 jalr -42(ra) # 56fc <exit> printf("write failed %d\n", n); 472e: 00003517 auipc a0,0x3 4732: 47a50513 addi a0,a0,1146 # 7ba8 <malloc+0x2066> 4736: 00001097 auipc ra,0x1 473a: 34e080e7 jalr 846(ra) # 5a84 <printf> exit(1); 473e: 4505 li a0,1 4740: 00001097 auipc ra,0x1 4744: fbc080e7 jalr -68(ra) # 56fc <exit> exit(xstatus); 4748: 855a mv a0,s6 474a: 00001097 auipc ra,0x1 474e: fb2080e7 jalr -78(ra) # 56fc <exit> printf("wrong char\n", s); 4752: f5843583 ld a1,-168(s0) 4756: 00003517 auipc a0,0x3 475a: 46a50513 addi a0,a0,1130 # 7bc0 <malloc+0x207e> 475e: 00001097 auipc ra,0x1 4762: 326080e7 jalr 806(ra) # 5a84 <printf> exit(1); 4766: 4505 li a0,1 4768: 00001097 auipc ra,0x1 476c: f94080e7 jalr -108(ra) # 56fc <exit> total += n; 4770: 00a9093b addw s2,s2,a0 while((n = read(fd, buf, sizeof(buf))) > 0){ 4774: 660d lui a2,0x3 4776: 85d2 mv a1,s4 4778: 854e mv a0,s3 477a: 00001097 auipc ra,0x1 477e: f9a080e7 jalr -102(ra) # 5714 <read> 4782: 02a05363 blez a0,47a8 <fourfiles+0x1ce> 4786: 00007797 auipc a5,0x7 478a: 45278793 addi a5,a5,1106 # bbd8 <buf> 478e: fff5069b addiw a3,a0,-1 4792: 1682 slli a3,a3,0x20 4794: 9281 srli a3,a3,0x20 4796: 96d6 add a3,a3,s5 if(buf[j] != '0'+i){ 4798: 0007c703 lbu a4,0(a5) 479c: fa971be3 bne a4,s1,4752 <fourfiles+0x178> for(j = 0; j < n; j++){ 47a0: 0785 addi a5,a5,1 47a2: fed79be3 bne a5,a3,4798 <fourfiles+0x1be> 47a6: b7e9 j 4770 <fourfiles+0x196> close(fd); 47a8: 854e mv a0,s3 47aa: 00001097 auipc ra,0x1 47ae: f7a080e7 jalr -134(ra) # 5724 <close> if(total != N*SZ){ 47b2: 03b91863 bne s2,s11,47e2 <fourfiles+0x208> unlink(fname); 47b6: 8566 mv a0,s9 47b8: 00001097 auipc ra,0x1 47bc: f94080e7 jalr -108(ra) # 574c <unlink> for(i = 0; i < NCHILD; i++){ 47c0: 0c21 addi s8,s8,8 47c2: 2b85 addiw s7,s7,1 47c4: 03ab8d63 beq s7,s10,47fe <fourfiles+0x224> fname = names[i]; 47c8: 000c3c83 ld s9,0(s8) fd = open(fname, 0); 47cc: 4581 li a1,0 47ce: 8566 mv a0,s9 47d0: 00001097 auipc ra,0x1 47d4: f6c080e7 jalr -148(ra) # 573c <open> 47d8: 89aa mv s3,a0 total = 0; 47da: 895a mv s2,s6 if(buf[j] != '0'+i){ 47dc: 000b849b sext.w s1,s7 while((n = read(fd, buf, sizeof(buf))) > 0){ 47e0: bf51 j 4774 <fourfiles+0x19a> printf("wrong length %d\n", total); 47e2: 85ca mv a1,s2 47e4: 00003517 auipc a0,0x3 47e8: 3ec50513 addi a0,a0,1004 # 7bd0 <malloc+0x208e> 47ec: 00001097 auipc ra,0x1 47f0: 298080e7 jalr 664(ra) # 5a84 <printf> exit(1); 47f4: 4505 li a0,1 47f6: 00001097 auipc ra,0x1 47fa: f06080e7 jalr -250(ra) # 56fc <exit> } 47fe: 70aa ld ra,168(sp) 4800: 740a ld s0,160(sp) 4802: 64ea ld s1,152(sp) 4804: 694a ld s2,144(sp) 4806: 69aa ld s3,136(sp) 4808: 6a0a ld s4,128(sp) 480a: 7ae6 ld s5,120(sp) 480c: 7b46 ld s6,112(sp) 480e: 7ba6 ld s7,104(sp) 4810: 7c06 ld s8,96(sp) 4812: 6ce6 ld s9,88(sp) 4814: 6d46 ld s10,80(sp) 4816: 6da6 ld s11,72(sp) 4818: 614d addi sp,sp,176 481a: 8082 ret 000000000000481c <concreate>: { 481c: 7135 addi sp,sp,-160 481e: ed06 sd ra,152(sp) 4820: e922 sd s0,144(sp) 4822: e526 sd s1,136(sp) 4824: e14a sd s2,128(sp) 4826: fcce sd s3,120(sp) 4828: f8d2 sd s4,112(sp) 482a: f4d6 sd s5,104(sp) 482c: f0da sd s6,96(sp) 482e: ecde sd s7,88(sp) 4830: 1100 addi s0,sp,160 4832: 89aa mv s3,a0 file[0] = 'C'; 4834: 04300793 li a5,67 4838: faf40423 sb a5,-88(s0) file[2] = '\0'; 483c: fa040523 sb zero,-86(s0) for(i = 0; i < N; i++){ 4840: 4901 li s2,0 if(pid && (i % 3) == 1){ 4842: 4b0d li s6,3 4844: 4a85 li s5,1 link("C0", file); 4846: 00003b97 auipc s7,0x3 484a: 3a2b8b93 addi s7,s7,930 # 7be8 <malloc+0x20a6> for(i = 0; i < N; i++){ 484e: 02800a13 li s4,40 4852: acc1 j 4b22 <concreate+0x306> link("C0", file); 4854: fa840593 addi a1,s0,-88 4858: 855e mv a0,s7 485a: 00001097 auipc ra,0x1 485e: f02080e7 jalr -254(ra) # 575c <link> if(pid == 0) { 4862: a45d j 4b08 <concreate+0x2ec> } else if(pid == 0 && (i % 5) == 1){ 4864: 4795 li a5,5 4866: 02f9693b remw s2,s2,a5 486a: 4785 li a5,1 486c: 02f90b63 beq s2,a5,48a2 <concreate+0x86> fd = open(file, O_CREATE | O_RDWR); 4870: 20200593 li a1,514 4874: fa840513 addi a0,s0,-88 4878: 00001097 auipc ra,0x1 487c: ec4080e7 jalr -316(ra) # 573c <open> if(fd < 0){ 4880: 26055b63 bgez a0,4af6 <concreate+0x2da> printf("concreate create %s failed\n", file); 4884: fa840593 addi a1,s0,-88 4888: 00003517 auipc a0,0x3 488c: 36850513 addi a0,a0,872 # 7bf0 <malloc+0x20ae> 4890: 00001097 auipc ra,0x1 4894: 1f4080e7 jalr 500(ra) # 5a84 <printf> exit(1); 4898: 4505 li a0,1 489a: 00001097 auipc ra,0x1 489e: e62080e7 jalr -414(ra) # 56fc <exit> link("C0", file); 48a2: fa840593 addi a1,s0,-88 48a6: 00003517 auipc a0,0x3 48aa: 34250513 addi a0,a0,834 # 7be8 <malloc+0x20a6> 48ae: 00001097 auipc ra,0x1 48b2: eae080e7 jalr -338(ra) # 575c <link> exit(0); 48b6: 4501 li a0,0 48b8: 00001097 auipc ra,0x1 48bc: e44080e7 jalr -444(ra) # 56fc <exit> exit(1); 48c0: 4505 li a0,1 48c2: 00001097 auipc ra,0x1 48c6: e3a080e7 jalr -454(ra) # 56fc <exit> memset(fa, 0, sizeof(fa)); 48ca: 02800613 li a2,40 48ce: 4581 li a1,0 48d0: f8040513 addi a0,s0,-128 48d4: 00001097 auipc ra,0x1 48d8: bd0080e7 jalr -1072(ra) # 54a4 <memset> fd = open(".", 0); 48dc: 4581 li a1,0 48de: 00002517 auipc a0,0x2 48e2: d4a50513 addi a0,a0,-694 # 6628 <malloc+0xae6> 48e6: 00001097 auipc ra,0x1 48ea: e56080e7 jalr -426(ra) # 573c <open> 48ee: 892a mv s2,a0 n = 0; 48f0: 8aa6 mv s5,s1 if(de.name[0] == 'C' && de.name[2] == '\0'){ 48f2: 04300a13 li s4,67 if(i < 0 || i >= sizeof(fa)){ 48f6: 02700b13 li s6,39 fa[i] = 1; 48fa: 4b85 li s7,1 while(read(fd, &de, sizeof(de)) > 0){ 48fc: 4641 li a2,16 48fe: f7040593 addi a1,s0,-144 4902: 854a mv a0,s2 4904: 00001097 auipc ra,0x1 4908: e10080e7 jalr -496(ra) # 5714 <read> 490c: 08a05163 blez a0,498e <concreate+0x172> if(de.inum == 0) 4910: f7045783 lhu a5,-144(s0) 4914: d7e5 beqz a5,48fc <concreate+0xe0> if(de.name[0] == 'C' && de.name[2] == '\0'){ 4916: f7244783 lbu a5,-142(s0) 491a: ff4791e3 bne a5,s4,48fc <concreate+0xe0> 491e: f7444783 lbu a5,-140(s0) 4922: ffe9 bnez a5,48fc <concreate+0xe0> i = de.name[1] - '0'; 4924: f7344783 lbu a5,-141(s0) 4928: fd07879b addiw a5,a5,-48 492c: 0007871b sext.w a4,a5 if(i < 0 || i >= sizeof(fa)){ 4930: 00eb6f63 bltu s6,a4,494e <concreate+0x132> if(fa[i]){ 4934: fb040793 addi a5,s0,-80 4938: 97ba add a5,a5,a4 493a: fd07c783 lbu a5,-48(a5) 493e: eb85 bnez a5,496e <concreate+0x152> fa[i] = 1; 4940: fb040793 addi a5,s0,-80 4944: 973e add a4,a4,a5 4946: fd770823 sb s7,-48(a4) # fd0 <bigdir+0x6e> n++; 494a: 2a85 addiw s5,s5,1 494c: bf45 j 48fc <concreate+0xe0> printf("%s: concreate weird file %s\n", s, de.name); 494e: f7240613 addi a2,s0,-142 4952: 85ce mv a1,s3 4954: 00003517 auipc a0,0x3 4958: 2bc50513 addi a0,a0,700 # 7c10 <malloc+0x20ce> 495c: 00001097 auipc ra,0x1 4960: 128080e7 jalr 296(ra) # 5a84 <printf> exit(1); 4964: 4505 li a0,1 4966: 00001097 auipc ra,0x1 496a: d96080e7 jalr -618(ra) # 56fc <exit> printf("%s: concreate duplicate file %s\n", s, de.name); 496e: f7240613 addi a2,s0,-142 4972: 85ce mv a1,s3 4974: 00003517 auipc a0,0x3 4978: 2bc50513 addi a0,a0,700 # 7c30 <malloc+0x20ee> 497c: 00001097 auipc ra,0x1 4980: 108080e7 jalr 264(ra) # 5a84 <printf> exit(1); 4984: 4505 li a0,1 4986: 00001097 auipc ra,0x1 498a: d76080e7 jalr -650(ra) # 56fc <exit> close(fd); 498e: 854a mv a0,s2 4990: 00001097 auipc ra,0x1 4994: d94080e7 jalr -620(ra) # 5724 <close> if(n != N){ 4998: 02800793 li a5,40 499c: 00fa9763 bne s5,a5,49aa <concreate+0x18e> if(((i % 3) == 0 && pid == 0) || 49a0: 4a8d li s5,3 49a2: 4b05 li s6,1 for(i = 0; i < N; i++){ 49a4: 02800a13 li s4,40 49a8: a8c9 j 4a7a <concreate+0x25e> printf("%s: concreate not enough files in directory listing\n", s); 49aa: 85ce mv a1,s3 49ac: 00003517 auipc a0,0x3 49b0: 2ac50513 addi a0,a0,684 # 7c58 <malloc+0x2116> 49b4: 00001097 auipc ra,0x1 49b8: 0d0080e7 jalr 208(ra) # 5a84 <printf> exit(1); 49bc: 4505 li a0,1 49be: 00001097 auipc ra,0x1 49c2: d3e080e7 jalr -706(ra) # 56fc <exit> printf("%s: fork failed\n", s); 49c6: 85ce mv a1,s3 49c8: 00002517 auipc a0,0x2 49cc: e0050513 addi a0,a0,-512 # 67c8 <malloc+0xc86> 49d0: 00001097 auipc ra,0x1 49d4: 0b4080e7 jalr 180(ra) # 5a84 <printf> exit(1); 49d8: 4505 li a0,1 49da: 00001097 auipc ra,0x1 49de: d22080e7 jalr -734(ra) # 56fc <exit> close(open(file, 0)); 49e2: 4581 li a1,0 49e4: fa840513 addi a0,s0,-88 49e8: 00001097 auipc ra,0x1 49ec: d54080e7 jalr -684(ra) # 573c <open> 49f0: 00001097 auipc ra,0x1 49f4: d34080e7 jalr -716(ra) # 5724 <close> close(open(file, 0)); 49f8: 4581 li a1,0 49fa: fa840513 addi a0,s0,-88 49fe: 00001097 auipc ra,0x1 4a02: d3e080e7 jalr -706(ra) # 573c <open> 4a06: 00001097 auipc ra,0x1 4a0a: d1e080e7 jalr -738(ra) # 5724 <close> close(open(file, 0)); 4a0e: 4581 li a1,0 4a10: fa840513 addi a0,s0,-88 4a14: 00001097 auipc ra,0x1 4a18: d28080e7 jalr -728(ra) # 573c <open> 4a1c: 00001097 auipc ra,0x1 4a20: d08080e7 jalr -760(ra) # 5724 <close> close(open(file, 0)); 4a24: 4581 li a1,0 4a26: fa840513 addi a0,s0,-88 4a2a: 00001097 auipc ra,0x1 4a2e: d12080e7 jalr -750(ra) # 573c <open> 4a32: 00001097 auipc ra,0x1 4a36: cf2080e7 jalr -782(ra) # 5724 <close> close(open(file, 0)); 4a3a: 4581 li a1,0 4a3c: fa840513 addi a0,s0,-88 4a40: 00001097 auipc ra,0x1 4a44: cfc080e7 jalr -772(ra) # 573c <open> 4a48: 00001097 auipc ra,0x1 4a4c: cdc080e7 jalr -804(ra) # 5724 <close> close(open(file, 0)); 4a50: 4581 li a1,0 4a52: fa840513 addi a0,s0,-88 4a56: 00001097 auipc ra,0x1 4a5a: ce6080e7 jalr -794(ra) # 573c <open> 4a5e: 00001097 auipc ra,0x1 4a62: cc6080e7 jalr -826(ra) # 5724 <close> if(pid == 0) 4a66: 08090363 beqz s2,4aec <concreate+0x2d0> wait(0); 4a6a: 4501 li a0,0 4a6c: 00001097 auipc ra,0x1 4a70: c98080e7 jalr -872(ra) # 5704 <wait> for(i = 0; i < N; i++){ 4a74: 2485 addiw s1,s1,1 4a76: 0f448563 beq s1,s4,4b60 <concreate+0x344> file[1] = '0' + i; 4a7a: 0304879b addiw a5,s1,48 4a7e: faf404a3 sb a5,-87(s0) pid = fork(); 4a82: 00001097 auipc ra,0x1 4a86: c72080e7 jalr -910(ra) # 56f4 <fork> 4a8a: 892a mv s2,a0 if(pid < 0){ 4a8c: f2054de3 bltz a0,49c6 <concreate+0x1aa> if(((i % 3) == 0 && pid == 0) || 4a90: 0354e73b remw a4,s1,s5 4a94: 00a767b3 or a5,a4,a0 4a98: 2781 sext.w a5,a5 4a9a: d7a1 beqz a5,49e2 <concreate+0x1c6> 4a9c: 01671363 bne a4,s6,4aa2 <concreate+0x286> ((i % 3) == 1 && pid != 0)){ 4aa0: f129 bnez a0,49e2 <concreate+0x1c6> unlink(file); 4aa2: fa840513 addi a0,s0,-88 4aa6: 00001097 auipc ra,0x1 4aaa: ca6080e7 jalr -858(ra) # 574c <unlink> unlink(file); 4aae: fa840513 addi a0,s0,-88 4ab2: 00001097 auipc ra,0x1 4ab6: c9a080e7 jalr -870(ra) # 574c <unlink> unlink(file); 4aba: fa840513 addi a0,s0,-88 4abe: 00001097 auipc ra,0x1 4ac2: c8e080e7 jalr -882(ra) # 574c <unlink> unlink(file); 4ac6: fa840513 addi a0,s0,-88 4aca: 00001097 auipc ra,0x1 4ace: c82080e7 jalr -894(ra) # 574c <unlink> unlink(file); 4ad2: fa840513 addi a0,s0,-88 4ad6: 00001097 auipc ra,0x1 4ada: c76080e7 jalr -906(ra) # 574c <unlink> unlink(file); 4ade: fa840513 addi a0,s0,-88 4ae2: 00001097 auipc ra,0x1 4ae6: c6a080e7 jalr -918(ra) # 574c <unlink> 4aea: bfb5 j 4a66 <concreate+0x24a> exit(0); 4aec: 4501 li a0,0 4aee: 00001097 auipc ra,0x1 4af2: c0e080e7 jalr -1010(ra) # 56fc <exit> close(fd); 4af6: 00001097 auipc ra,0x1 4afa: c2e080e7 jalr -978(ra) # 5724 <close> if(pid == 0) { 4afe: bb65 j 48b6 <concreate+0x9a> close(fd); 4b00: 00001097 auipc ra,0x1 4b04: c24080e7 jalr -988(ra) # 5724 <close> wait(&xstatus); 4b08: f6c40513 addi a0,s0,-148 4b0c: 00001097 auipc ra,0x1 4b10: bf8080e7 jalr -1032(ra) # 5704 <wait> if(xstatus != 0) 4b14: f6c42483 lw s1,-148(s0) 4b18: da0494e3 bnez s1,48c0 <concreate+0xa4> for(i = 0; i < N; i++){ 4b1c: 2905 addiw s2,s2,1 4b1e: db4906e3 beq s2,s4,48ca <concreate+0xae> file[1] = '0' + i; 4b22: 0309079b addiw a5,s2,48 4b26: faf404a3 sb a5,-87(s0) unlink(file); 4b2a: fa840513 addi a0,s0,-88 4b2e: 00001097 auipc ra,0x1 4b32: c1e080e7 jalr -994(ra) # 574c <unlink> pid = fork(); 4b36: 00001097 auipc ra,0x1 4b3a: bbe080e7 jalr -1090(ra) # 56f4 <fork> if(pid && (i % 3) == 1){ 4b3e: d20503e3 beqz a0,4864 <concreate+0x48> 4b42: 036967bb remw a5,s2,s6 4b46: d15787e3 beq a5,s5,4854 <concreate+0x38> fd = open(file, O_CREATE | O_RDWR); 4b4a: 20200593 li a1,514 4b4e: fa840513 addi a0,s0,-88 4b52: 00001097 auipc ra,0x1 4b56: bea080e7 jalr -1046(ra) # 573c <open> if(fd < 0){ 4b5a: fa0553e3 bgez a0,4b00 <concreate+0x2e4> 4b5e: b31d j 4884 <concreate+0x68> } 4b60: 60ea ld ra,152(sp) 4b62: 644a ld s0,144(sp) 4b64: 64aa ld s1,136(sp) 4b66: 690a ld s2,128(sp) 4b68: 79e6 ld s3,120(sp) 4b6a: 7a46 ld s4,112(sp) 4b6c: 7aa6 ld s5,104(sp) 4b6e: 7b06 ld s6,96(sp) 4b70: 6be6 ld s7,88(sp) 4b72: 610d addi sp,sp,160 4b74: 8082 ret 0000000000004b76 <bigfile>: { 4b76: 7139 addi sp,sp,-64 4b78: fc06 sd ra,56(sp) 4b7a: f822 sd s0,48(sp) 4b7c: f426 sd s1,40(sp) 4b7e: f04a sd s2,32(sp) 4b80: ec4e sd s3,24(sp) 4b82: e852 sd s4,16(sp) 4b84: e456 sd s5,8(sp) 4b86: 0080 addi s0,sp,64 4b88: 8aaa mv s5,a0 unlink("bigfile.dat"); 4b8a: 00003517 auipc a0,0x3 4b8e: 10650513 addi a0,a0,262 # 7c90 <malloc+0x214e> 4b92: 00001097 auipc ra,0x1 4b96: bba080e7 jalr -1094(ra) # 574c <unlink> fd = open("bigfile.dat", O_CREATE | O_RDWR); 4b9a: 20200593 li a1,514 4b9e: 00003517 auipc a0,0x3 4ba2: 0f250513 addi a0,a0,242 # 7c90 <malloc+0x214e> 4ba6: 00001097 auipc ra,0x1 4baa: b96080e7 jalr -1130(ra) # 573c <open> 4bae: 89aa mv s3,a0 for(i = 0; i < N; i++){ 4bb0: 4481 li s1,0 memset(buf, i, SZ); 4bb2: 00007917 auipc s2,0x7 4bb6: 02690913 addi s2,s2,38 # bbd8 <buf> for(i = 0; i < N; i++){ 4bba: 4a51 li s4,20 if(fd < 0){ 4bbc: 0a054063 bltz a0,4c5c <bigfile+0xe6> memset(buf, i, SZ); 4bc0: 25800613 li a2,600 4bc4: 85a6 mv a1,s1 4bc6: 854a mv a0,s2 4bc8: 00001097 auipc ra,0x1 4bcc: 8dc080e7 jalr -1828(ra) # 54a4 <memset> if(write(fd, buf, SZ) != SZ){ 4bd0: 25800613 li a2,600 4bd4: 85ca mv a1,s2 4bd6: 854e mv a0,s3 4bd8: 00001097 auipc ra,0x1 4bdc: b44080e7 jalr -1212(ra) # 571c <write> 4be0: 25800793 li a5,600 4be4: 08f51a63 bne a0,a5,4c78 <bigfile+0x102> for(i = 0; i < N; i++){ 4be8: 2485 addiw s1,s1,1 4bea: fd449be3 bne s1,s4,4bc0 <bigfile+0x4a> close(fd); 4bee: 854e mv a0,s3 4bf0: 00001097 auipc ra,0x1 4bf4: b34080e7 jalr -1228(ra) # 5724 <close> fd = open("bigfile.dat", 0); 4bf8: 4581 li a1,0 4bfa: 00003517 auipc a0,0x3 4bfe: 09650513 addi a0,a0,150 # 7c90 <malloc+0x214e> 4c02: 00001097 auipc ra,0x1 4c06: b3a080e7 jalr -1222(ra) # 573c <open> 4c0a: 8a2a mv s4,a0 total = 0; 4c0c: 4981 li s3,0 for(i = 0; ; i++){ 4c0e: 4481 li s1,0 cc = read(fd, buf, SZ/2); 4c10: 00007917 auipc s2,0x7 4c14: fc890913 addi s2,s2,-56 # bbd8 <buf> if(fd < 0){ 4c18: 06054e63 bltz a0,4c94 <bigfile+0x11e> cc = read(fd, buf, SZ/2); 4c1c: 12c00613 li a2,300 4c20: 85ca mv a1,s2 4c22: 8552 mv a0,s4 4c24: 00001097 auipc ra,0x1 4c28: af0080e7 jalr -1296(ra) # 5714 <read> if(cc < 0){ 4c2c: 08054263 bltz a0,4cb0 <bigfile+0x13a> if(cc == 0) 4c30: c971 beqz a0,4d04 <bigfile+0x18e> if(cc != SZ/2){ 4c32: 12c00793 li a5,300 4c36: 08f51b63 bne a0,a5,4ccc <bigfile+0x156> if(buf[0] != i/2 || buf[SZ/2-1] != i/2){ 4c3a: 01f4d79b srliw a5,s1,0x1f 4c3e: 9fa5 addw a5,a5,s1 4c40: 4017d79b sraiw a5,a5,0x1 4c44: 00094703 lbu a4,0(s2) 4c48: 0af71063 bne a4,a5,4ce8 <bigfile+0x172> 4c4c: 12b94703 lbu a4,299(s2) 4c50: 08f71c63 bne a4,a5,4ce8 <bigfile+0x172> total += cc; 4c54: 12c9899b addiw s3,s3,300 for(i = 0; ; i++){ 4c58: 2485 addiw s1,s1,1 cc = read(fd, buf, SZ/2); 4c5a: b7c9 j 4c1c <bigfile+0xa6> printf("%s: cannot create bigfile", s); 4c5c: 85d6 mv a1,s5 4c5e: 00003517 auipc a0,0x3 4c62: 04250513 addi a0,a0,66 # 7ca0 <malloc+0x215e> 4c66: 00001097 auipc ra,0x1 4c6a: e1e080e7 jalr -482(ra) # 5a84 <printf> exit(1); 4c6e: 4505 li a0,1 4c70: 00001097 auipc ra,0x1 4c74: a8c080e7 jalr -1396(ra) # 56fc <exit> printf("%s: write bigfile failed\n", s); 4c78: 85d6 mv a1,s5 4c7a: 00003517 auipc a0,0x3 4c7e: 04650513 addi a0,a0,70 # 7cc0 <malloc+0x217e> 4c82: 00001097 auipc ra,0x1 4c86: e02080e7 jalr -510(ra) # 5a84 <printf> exit(1); 4c8a: 4505 li a0,1 4c8c: 00001097 auipc ra,0x1 4c90: a70080e7 jalr -1424(ra) # 56fc <exit> printf("%s: cannot open bigfile\n", s); 4c94: 85d6 mv a1,s5 4c96: 00003517 auipc a0,0x3 4c9a: 04a50513 addi a0,a0,74 # 7ce0 <malloc+0x219e> 4c9e: 00001097 auipc ra,0x1 4ca2: de6080e7 jalr -538(ra) # 5a84 <printf> exit(1); 4ca6: 4505 li a0,1 4ca8: 00001097 auipc ra,0x1 4cac: a54080e7 jalr -1452(ra) # 56fc <exit> printf("%s: read bigfile failed\n", s); 4cb0: 85d6 mv a1,s5 4cb2: 00003517 auipc a0,0x3 4cb6: 04e50513 addi a0,a0,78 # 7d00 <malloc+0x21be> 4cba: 00001097 auipc ra,0x1 4cbe: dca080e7 jalr -566(ra) # 5a84 <printf> exit(1); 4cc2: 4505 li a0,1 4cc4: 00001097 auipc ra,0x1 4cc8: a38080e7 jalr -1480(ra) # 56fc <exit> printf("%s: short read bigfile\n", s); 4ccc: 85d6 mv a1,s5 4cce: 00003517 auipc a0,0x3 4cd2: 05250513 addi a0,a0,82 # 7d20 <malloc+0x21de> 4cd6: 00001097 auipc ra,0x1 4cda: dae080e7 jalr -594(ra) # 5a84 <printf> exit(1); 4cde: 4505 li a0,1 4ce0: 00001097 auipc ra,0x1 4ce4: a1c080e7 jalr -1508(ra) # 56fc <exit> printf("%s: read bigfile wrong data\n", s); 4ce8: 85d6 mv a1,s5 4cea: 00003517 auipc a0,0x3 4cee: 04e50513 addi a0,a0,78 # 7d38 <malloc+0x21f6> 4cf2: 00001097 auipc ra,0x1 4cf6: d92080e7 jalr -622(ra) # 5a84 <printf> exit(1); 4cfa: 4505 li a0,1 4cfc: 00001097 auipc ra,0x1 4d00: a00080e7 jalr -1536(ra) # 56fc <exit> close(fd); 4d04: 8552 mv a0,s4 4d06: 00001097 auipc ra,0x1 4d0a: a1e080e7 jalr -1506(ra) # 5724 <close> if(total != N*SZ){ 4d0e: 678d lui a5,0x3 4d10: ee078793 addi a5,a5,-288 # 2ee0 <exitiputtest+0x48> 4d14: 02f99363 bne s3,a5,4d3a <bigfile+0x1c4> unlink("bigfile.dat"); 4d18: 00003517 auipc a0,0x3 4d1c: f7850513 addi a0,a0,-136 # 7c90 <malloc+0x214e> 4d20: 00001097 auipc ra,0x1 4d24: a2c080e7 jalr -1492(ra) # 574c <unlink> } 4d28: 70e2 ld ra,56(sp) 4d2a: 7442 ld s0,48(sp) 4d2c: 74a2 ld s1,40(sp) 4d2e: 7902 ld s2,32(sp) 4d30: 69e2 ld s3,24(sp) 4d32: 6a42 ld s4,16(sp) 4d34: 6aa2 ld s5,8(sp) 4d36: 6121 addi sp,sp,64 4d38: 8082 ret printf("%s: read bigfile wrong total\n", s); 4d3a: 85d6 mv a1,s5 4d3c: 00003517 auipc a0,0x3 4d40: 01c50513 addi a0,a0,28 # 7d58 <malloc+0x2216> 4d44: 00001097 auipc ra,0x1 4d48: d40080e7 jalr -704(ra) # 5a84 <printf> exit(1); 4d4c: 4505 li a0,1 4d4e: 00001097 auipc ra,0x1 4d52: 9ae080e7 jalr -1618(ra) # 56fc <exit> 0000000000004d56 <fsfull>: { 4d56: 7171 addi sp,sp,-176 4d58: f506 sd ra,168(sp) 4d5a: f122 sd s0,160(sp) 4d5c: ed26 sd s1,152(sp) 4d5e: e94a sd s2,144(sp) 4d60: e54e sd s3,136(sp) 4d62: e152 sd s4,128(sp) 4d64: fcd6 sd s5,120(sp) 4d66: f8da sd s6,112(sp) 4d68: f4de sd s7,104(sp) 4d6a: f0e2 sd s8,96(sp) 4d6c: ece6 sd s9,88(sp) 4d6e: e8ea sd s10,80(sp) 4d70: e4ee sd s11,72(sp) 4d72: 1900 addi s0,sp,176 printf("fsfull test\n"); 4d74: 00003517 auipc a0,0x3 4d78: 00450513 addi a0,a0,4 # 7d78 <malloc+0x2236> 4d7c: 00001097 auipc ra,0x1 4d80: d08080e7 jalr -760(ra) # 5a84 <printf> for(nfiles = 0; ; nfiles++){ 4d84: 4481 li s1,0 name[0] = 'f'; 4d86: 06600d13 li s10,102 name[1] = '0' + nfiles / 1000; 4d8a: 3e800c13 li s8,1000 name[2] = '0' + (nfiles % 1000) / 100; 4d8e: 06400b93 li s7,100 name[3] = '0' + (nfiles % 100) / 10; 4d92: 4b29 li s6,10 printf("writing %s\n", name); 4d94: 00003c97 auipc s9,0x3 4d98: ff4c8c93 addi s9,s9,-12 # 7d88 <malloc+0x2246> int total = 0; 4d9c: 4d81 li s11,0 int cc = write(fd, buf, BSIZE); 4d9e: 00007a17 auipc s4,0x7 4da2: e3aa0a13 addi s4,s4,-454 # bbd8 <buf> name[0] = 'f'; 4da6: f5a40823 sb s10,-176(s0) name[1] = '0' + nfiles / 1000; 4daa: 0384c7bb divw a5,s1,s8 4dae: 0307879b addiw a5,a5,48 4db2: f4f408a3 sb a5,-175(s0) name[2] = '0' + (nfiles % 1000) / 100; 4db6: 0384e7bb remw a5,s1,s8 4dba: 0377c7bb divw a5,a5,s7 4dbe: 0307879b addiw a5,a5,48 4dc2: f4f40923 sb a5,-174(s0) name[3] = '0' + (nfiles % 100) / 10; 4dc6: 0374e7bb remw a5,s1,s7 4dca: 0367c7bb divw a5,a5,s6 4dce: 0307879b addiw a5,a5,48 4dd2: f4f409a3 sb a5,-173(s0) name[4] = '0' + (nfiles % 10); 4dd6: 0364e7bb remw a5,s1,s6 4dda: 0307879b addiw a5,a5,48 4dde: f4f40a23 sb a5,-172(s0) name[5] = '\0'; 4de2: f4040aa3 sb zero,-171(s0) printf("writing %s\n", name); 4de6: f5040593 addi a1,s0,-176 4dea: 8566 mv a0,s9 4dec: 00001097 auipc ra,0x1 4df0: c98080e7 jalr -872(ra) # 5a84 <printf> int fd = open(name, O_CREATE|O_RDWR); 4df4: 20200593 li a1,514 4df8: f5040513 addi a0,s0,-176 4dfc: 00001097 auipc ra,0x1 4e00: 940080e7 jalr -1728(ra) # 573c <open> 4e04: 892a mv s2,a0 if(fd < 0){ 4e06: 0a055663 bgez a0,4eb2 <fsfull+0x15c> printf("open %s failed\n", name); 4e0a: f5040593 addi a1,s0,-176 4e0e: 00003517 auipc a0,0x3 4e12: f8a50513 addi a0,a0,-118 # 7d98 <malloc+0x2256> 4e16: 00001097 auipc ra,0x1 4e1a: c6e080e7 jalr -914(ra) # 5a84 <printf> while(nfiles >= 0){ 4e1e: 0604c363 bltz s1,4e84 <fsfull+0x12e> name[0] = 'f'; 4e22: 06600b13 li s6,102 name[1] = '0' + nfiles / 1000; 4e26: 3e800a13 li s4,1000 name[2] = '0' + (nfiles % 1000) / 100; 4e2a: 06400993 li s3,100 name[3] = '0' + (nfiles % 100) / 10; 4e2e: 4929 li s2,10 while(nfiles >= 0){ 4e30: 5afd li s5,-1 name[0] = 'f'; 4e32: f5640823 sb s6,-176(s0) name[1] = '0' + nfiles / 1000; 4e36: 0344c7bb divw a5,s1,s4 4e3a: 0307879b addiw a5,a5,48 4e3e: f4f408a3 sb a5,-175(s0) name[2] = '0' + (nfiles % 1000) / 100; 4e42: 0344e7bb remw a5,s1,s4 4e46: 0337c7bb divw a5,a5,s3 4e4a: 0307879b addiw a5,a5,48 4e4e: f4f40923 sb a5,-174(s0) name[3] = '0' + (nfiles % 100) / 10; 4e52: 0334e7bb remw a5,s1,s3 4e56: 0327c7bb divw a5,a5,s2 4e5a: 0307879b addiw a5,a5,48 4e5e: f4f409a3 sb a5,-173(s0) name[4] = '0' + (nfiles % 10); 4e62: 0324e7bb remw a5,s1,s2 4e66: 0307879b addiw a5,a5,48 4e6a: f4f40a23 sb a5,-172(s0) name[5] = '\0'; 4e6e: f4040aa3 sb zero,-171(s0) unlink(name); 4e72: f5040513 addi a0,s0,-176 4e76: 00001097 auipc ra,0x1 4e7a: 8d6080e7 jalr -1834(ra) # 574c <unlink> nfiles--; 4e7e: 34fd addiw s1,s1,-1 while(nfiles >= 0){ 4e80: fb5499e3 bne s1,s5,4e32 <fsfull+0xdc> printf("fsfull test finished\n"); 4e84: 00003517 auipc a0,0x3 4e88: f3450513 addi a0,a0,-204 # 7db8 <malloc+0x2276> 4e8c: 00001097 auipc ra,0x1 4e90: bf8080e7 jalr -1032(ra) # 5a84 <printf> } 4e94: 70aa ld ra,168(sp) 4e96: 740a ld s0,160(sp) 4e98: 64ea ld s1,152(sp) 4e9a: 694a ld s2,144(sp) 4e9c: 69aa ld s3,136(sp) 4e9e: 6a0a ld s4,128(sp) 4ea0: 7ae6 ld s5,120(sp) 4ea2: 7b46 ld s6,112(sp) 4ea4: 7ba6 ld s7,104(sp) 4ea6: 7c06 ld s8,96(sp) 4ea8: 6ce6 ld s9,88(sp) 4eaa: 6d46 ld s10,80(sp) 4eac: 6da6 ld s11,72(sp) 4eae: 614d addi sp,sp,176 4eb0: 8082 ret int total = 0; 4eb2: 89ee mv s3,s11 if(cc < BSIZE) 4eb4: 3ff00a93 li s5,1023 int cc = write(fd, buf, BSIZE); 4eb8: 40000613 li a2,1024 4ebc: 85d2 mv a1,s4 4ebe: 854a mv a0,s2 4ec0: 00001097 auipc ra,0x1 4ec4: 85c080e7 jalr -1956(ra) # 571c <write> if(cc < BSIZE) 4ec8: 00aad563 bge s5,a0,4ed2 <fsfull+0x17c> total += cc; 4ecc: 00a989bb addw s3,s3,a0 while(1){ 4ed0: b7e5 j 4eb8 <fsfull+0x162> printf("wrote %d bytes\n", total); 4ed2: 85ce mv a1,s3 4ed4: 00003517 auipc a0,0x3 4ed8: ed450513 addi a0,a0,-300 # 7da8 <malloc+0x2266> 4edc: 00001097 auipc ra,0x1 4ee0: ba8080e7 jalr -1112(ra) # 5a84 <printf> close(fd); 4ee4: 854a mv a0,s2 4ee6: 00001097 auipc ra,0x1 4eea: 83e080e7 jalr -1986(ra) # 5724 <close> if(total == 0) 4eee: f20988e3 beqz s3,4e1e <fsfull+0xc8> for(nfiles = 0; ; nfiles++){ 4ef2: 2485 addiw s1,s1,1 4ef4: bd4d j 4da6 <fsfull+0x50> 0000000000004ef6 <rand>: { 4ef6: 1141 addi sp,sp,-16 4ef8: e422 sd s0,8(sp) 4efa: 0800 addi s0,sp,16 randstate = randstate * 1664525 + 1013904223; 4efc: 00003717 auipc a4,0x3 4f00: 4b470713 addi a4,a4,1204 # 83b0 <randstate> 4f04: 6308 ld a0,0(a4) 4f06: 001967b7 lui a5,0x196 4f0a: 60d78793 addi a5,a5,1549 # 19660d <__BSS_END__+0x187a25> 4f0e: 02f50533 mul a0,a0,a5 4f12: 3c6ef7b7 lui a5,0x3c6ef 4f16: 35f78793 addi a5,a5,863 # 3c6ef35f <__BSS_END__+0x3c6e0777> 4f1a: 953e add a0,a0,a5 4f1c: e308 sd a0,0(a4) } 4f1e: 2501 sext.w a0,a0 4f20: 6422 ld s0,8(sp) 4f22: 0141 addi sp,sp,16 4f24: 8082 ret 0000000000004f26 <badwrite>: { 4f26: 7179 addi sp,sp,-48 4f28: f406 sd ra,40(sp) 4f2a: f022 sd s0,32(sp) 4f2c: ec26 sd s1,24(sp) 4f2e: e84a sd s2,16(sp) 4f30: e44e sd s3,8(sp) 4f32: e052 sd s4,0(sp) 4f34: 1800 addi s0,sp,48 unlink("junk"); 4f36: 00003517 auipc a0,0x3 4f3a: e9a50513 addi a0,a0,-358 # 7dd0 <malloc+0x228e> 4f3e: 00001097 auipc ra,0x1 4f42: 80e080e7 jalr -2034(ra) # 574c <unlink> 4f46: 25800913 li s2,600 int fd = open("junk", O_CREATE|O_WRONLY); 4f4a: 00003997 auipc s3,0x3 4f4e: e8698993 addi s3,s3,-378 # 7dd0 <malloc+0x228e> write(fd, (char*)0xffffffffffL, 1); 4f52: 5a7d li s4,-1 4f54: 018a5a13 srli s4,s4,0x18 int fd = open("junk", O_CREATE|O_WRONLY); 4f58: 20100593 li a1,513 4f5c: 854e mv a0,s3 4f5e: 00000097 auipc ra,0x0 4f62: 7de080e7 jalr 2014(ra) # 573c <open> 4f66: 84aa mv s1,a0 if(fd < 0){ 4f68: 06054b63 bltz a0,4fde <badwrite+0xb8> write(fd, (char*)0xffffffffffL, 1); 4f6c: 4605 li a2,1 4f6e: 85d2 mv a1,s4 4f70: 00000097 auipc ra,0x0 4f74: 7ac080e7 jalr 1964(ra) # 571c <write> close(fd); 4f78: 8526 mv a0,s1 4f7a: 00000097 auipc ra,0x0 4f7e: 7aa080e7 jalr 1962(ra) # 5724 <close> unlink("junk"); 4f82: 854e mv a0,s3 4f84: 00000097 auipc ra,0x0 4f88: 7c8080e7 jalr 1992(ra) # 574c <unlink> for(int i = 0; i < assumed_free; i++){ 4f8c: 397d addiw s2,s2,-1 4f8e: fc0915e3 bnez s2,4f58 <badwrite+0x32> int fd = open("junk", O_CREATE|O_WRONLY); 4f92: 20100593 li a1,513 4f96: 00003517 auipc a0,0x3 4f9a: e3a50513 addi a0,a0,-454 # 7dd0 <malloc+0x228e> 4f9e: 00000097 auipc ra,0x0 4fa2: 79e080e7 jalr 1950(ra) # 573c <open> 4fa6: 84aa mv s1,a0 if(fd < 0){ 4fa8: 04054863 bltz a0,4ff8 <badwrite+0xd2> if(write(fd, "x", 1) != 1){ 4fac: 4605 li a2,1 4fae: 00001597 auipc a1,0x1 4fb2: 05258593 addi a1,a1,82 # 6000 <malloc+0x4be> 4fb6: 00000097 auipc ra,0x0 4fba: 766080e7 jalr 1894(ra) # 571c <write> 4fbe: 4785 li a5,1 4fc0: 04f50963 beq a0,a5,5012 <badwrite+0xec> printf("write failed\n"); 4fc4: 00003517 auipc a0,0x3 4fc8: e2c50513 addi a0,a0,-468 # 7df0 <malloc+0x22ae> 4fcc: 00001097 auipc ra,0x1 4fd0: ab8080e7 jalr -1352(ra) # 5a84 <printf> exit(1); 4fd4: 4505 li a0,1 4fd6: 00000097 auipc ra,0x0 4fda: 726080e7 jalr 1830(ra) # 56fc <exit> printf("open junk failed\n"); 4fde: 00003517 auipc a0,0x3 4fe2: dfa50513 addi a0,a0,-518 # 7dd8 <malloc+0x2296> 4fe6: 00001097 auipc ra,0x1 4fea: a9e080e7 jalr -1378(ra) # 5a84 <printf> exit(1); 4fee: 4505 li a0,1 4ff0: 00000097 auipc ra,0x0 4ff4: 70c080e7 jalr 1804(ra) # 56fc <exit> printf("open junk failed\n"); 4ff8: 00003517 auipc a0,0x3 4ffc: de050513 addi a0,a0,-544 # 7dd8 <malloc+0x2296> 5000: 00001097 auipc ra,0x1 5004: a84080e7 jalr -1404(ra) # 5a84 <printf> exit(1); 5008: 4505 li a0,1 500a: 00000097 auipc ra,0x0 500e: 6f2080e7 jalr 1778(ra) # 56fc <exit> close(fd); 5012: 8526 mv a0,s1 5014: 00000097 auipc ra,0x0 5018: 710080e7 jalr 1808(ra) # 5724 <close> unlink("junk"); 501c: 00003517 auipc a0,0x3 5020: db450513 addi a0,a0,-588 # 7dd0 <malloc+0x228e> 5024: 00000097 auipc ra,0x0 5028: 728080e7 jalr 1832(ra) # 574c <unlink> exit(0); 502c: 4501 li a0,0 502e: 00000097 auipc ra,0x0 5032: 6ce080e7 jalr 1742(ra) # 56fc <exit> 0000000000005036 <countfree>: // because out of memory with lazy allocation results in the process // taking a fault and being killed, fork and report back. // int countfree() { 5036: 7139 addi sp,sp,-64 5038: fc06 sd ra,56(sp) 503a: f822 sd s0,48(sp) 503c: f426 sd s1,40(sp) 503e: f04a sd s2,32(sp) 5040: ec4e sd s3,24(sp) 5042: 0080 addi s0,sp,64 int fds[2]; if(pipe(fds) < 0){ 5044: fc840513 addi a0,s0,-56 5048: 00000097 auipc ra,0x0 504c: 6c4080e7 jalr 1732(ra) # 570c <pipe> 5050: 06054763 bltz a0,50be <countfree+0x88> printf("pipe() failed in countfree()\n"); exit(1); } int pid = fork(); 5054: 00000097 auipc ra,0x0 5058: 6a0080e7 jalr 1696(ra) # 56f4 <fork> if(pid < 0){ 505c: 06054e63 bltz a0,50d8 <countfree+0xa2> printf("fork failed in countfree()\n"); exit(1); } if(pid == 0){ 5060: ed51 bnez a0,50fc <countfree+0xc6> close(fds[0]); 5062: fc842503 lw a0,-56(s0) 5066: 00000097 auipc ra,0x0 506a: 6be080e7 jalr 1726(ra) # 5724 <close> while(1){ uint64 a = (uint64) sbrk(4096); if(a == 0xffffffffffffffff){ 506e: 597d li s2,-1 break; } // modify the memory to make sure it's really allocated. *(char *)(a + 4096 - 1) = 1; 5070: 4485 li s1,1 // report back one more page. if(write(fds[1], "x", 1) != 1){ 5072: 00001997 auipc s3,0x1 5076: f8e98993 addi s3,s3,-114 # 6000 <malloc+0x4be> uint64 a = (uint64) sbrk(4096); 507a: 6505 lui a0,0x1 507c: 00000097 auipc ra,0x0 5080: 708080e7 jalr 1800(ra) # 5784 <sbrk> if(a == 0xffffffffffffffff){ 5084: 07250763 beq a0,s2,50f2 <countfree+0xbc> *(char *)(a + 4096 - 1) = 1; 5088: 6785 lui a5,0x1 508a: 953e add a0,a0,a5 508c: fe950fa3 sb s1,-1(a0) # fff <bigdir+0x9d> if(write(fds[1], "x", 1) != 1){ 5090: 8626 mv a2,s1 5092: 85ce mv a1,s3 5094: fcc42503 lw a0,-52(s0) 5098: 00000097 auipc ra,0x0 509c: 684080e7 jalr 1668(ra) # 571c <write> 50a0: fc950de3 beq a0,s1,507a <countfree+0x44> printf("write() failed in countfree()\n"); 50a4: 00003517 auipc a0,0x3 50a8: d9c50513 addi a0,a0,-612 # 7e40 <malloc+0x22fe> 50ac: 00001097 auipc ra,0x1 50b0: 9d8080e7 jalr -1576(ra) # 5a84 <printf> exit(1); 50b4: 4505 li a0,1 50b6: 00000097 auipc ra,0x0 50ba: 646080e7 jalr 1606(ra) # 56fc <exit> printf("pipe() failed in countfree()\n"); 50be: 00003517 auipc a0,0x3 50c2: d4250513 addi a0,a0,-702 # 7e00 <malloc+0x22be> 50c6: 00001097 auipc ra,0x1 50ca: 9be080e7 jalr -1602(ra) # 5a84 <printf> exit(1); 50ce: 4505 li a0,1 50d0: 00000097 auipc ra,0x0 50d4: 62c080e7 jalr 1580(ra) # 56fc <exit> printf("fork failed in countfree()\n"); 50d8: 00003517 auipc a0,0x3 50dc: d4850513 addi a0,a0,-696 # 7e20 <malloc+0x22de> 50e0: 00001097 auipc ra,0x1 50e4: 9a4080e7 jalr -1628(ra) # 5a84 <printf> exit(1); 50e8: 4505 li a0,1 50ea: 00000097 auipc ra,0x0 50ee: 612080e7 jalr 1554(ra) # 56fc <exit> } } exit(0); 50f2: 4501 li a0,0 50f4: 00000097 auipc ra,0x0 50f8: 608080e7 jalr 1544(ra) # 56fc <exit> } close(fds[1]); 50fc: fcc42503 lw a0,-52(s0) 5100: 00000097 auipc ra,0x0 5104: 624080e7 jalr 1572(ra) # 5724 <close> int n = 0; 5108: 4481 li s1,0 while(1){ char c; int cc = read(fds[0], &c, 1); 510a: 4605 li a2,1 510c: fc740593 addi a1,s0,-57 5110: fc842503 lw a0,-56(s0) 5114: 00000097 auipc ra,0x0 5118: 600080e7 jalr 1536(ra) # 5714 <read> if(cc < 0){ 511c: 00054563 bltz a0,5126 <countfree+0xf0> printf("read() failed in countfree()\n"); exit(1); } if(cc == 0) 5120: c105 beqz a0,5140 <countfree+0x10a> break; n += 1; 5122: 2485 addiw s1,s1,1 while(1){ 5124: b7dd j 510a <countfree+0xd4> printf("read() failed in countfree()\n"); 5126: 00003517 auipc a0,0x3 512a: d3a50513 addi a0,a0,-710 # 7e60 <malloc+0x231e> 512e: 00001097 auipc ra,0x1 5132: 956080e7 jalr -1706(ra) # 5a84 <printf> exit(1); 5136: 4505 li a0,1 5138: 00000097 auipc ra,0x0 513c: 5c4080e7 jalr 1476(ra) # 56fc <exit> } close(fds[0]); 5140: fc842503 lw a0,-56(s0) 5144: 00000097 auipc ra,0x0 5148: 5e0080e7 jalr 1504(ra) # 5724 <close> wait((int*)0); 514c: 4501 li a0,0 514e: 00000097 auipc ra,0x0 5152: 5b6080e7 jalr 1462(ra) # 5704 <wait> return n; } 5156: 8526 mv a0,s1 5158: 70e2 ld ra,56(sp) 515a: 7442 ld s0,48(sp) 515c: 74a2 ld s1,40(sp) 515e: 7902 ld s2,32(sp) 5160: 69e2 ld s3,24(sp) 5162: 6121 addi sp,sp,64 5164: 8082 ret 0000000000005166 <run>: // run each test in its own process. run returns 1 if child's exit() // indicates success. int run(void f(char *), char *s) { 5166: 7179 addi sp,sp,-48 5168: f406 sd ra,40(sp) 516a: f022 sd s0,32(sp) 516c: ec26 sd s1,24(sp) 516e: e84a sd s2,16(sp) 5170: 1800 addi s0,sp,48 5172: 84aa mv s1,a0 5174: 892e mv s2,a1 int pid; int xstatus; printf("test %s: ", s); 5176: 00003517 auipc a0,0x3 517a: d0a50513 addi a0,a0,-758 # 7e80 <malloc+0x233e> 517e: 00001097 auipc ra,0x1 5182: 906080e7 jalr -1786(ra) # 5a84 <printf> if((pid = fork()) < 0) { 5186: 00000097 auipc ra,0x0 518a: 56e080e7 jalr 1390(ra) # 56f4 <fork> 518e: 02054e63 bltz a0,51ca <run+0x64> printf("runtest: fork error\n"); exit(1); } if(pid == 0) { 5192: c929 beqz a0,51e4 <run+0x7e> f(s); exit(0); } else { wait(&xstatus); 5194: fdc40513 addi a0,s0,-36 5198: 00000097 auipc ra,0x0 519c: 56c080e7 jalr 1388(ra) # 5704 <wait> if(xstatus != 0) 51a0: fdc42783 lw a5,-36(s0) 51a4: c7b9 beqz a5,51f2 <run+0x8c> printf("FAILED\n"); 51a6: 00003517 auipc a0,0x3 51aa: d0250513 addi a0,a0,-766 # 7ea8 <malloc+0x2366> 51ae: 00001097 auipc ra,0x1 51b2: 8d6080e7 jalr -1834(ra) # 5a84 <printf> else printf("OK\n"); return xstatus == 0; 51b6: fdc42503 lw a0,-36(s0) } } 51ba: 00153513 seqz a0,a0 51be: 70a2 ld ra,40(sp) 51c0: 7402 ld s0,32(sp) 51c2: 64e2 ld s1,24(sp) 51c4: 6942 ld s2,16(sp) 51c6: 6145 addi sp,sp,48 51c8: 8082 ret printf("runtest: fork error\n"); 51ca: 00003517 auipc a0,0x3 51ce: cc650513 addi a0,a0,-826 # 7e90 <malloc+0x234e> 51d2: 00001097 auipc ra,0x1 51d6: 8b2080e7 jalr -1870(ra) # 5a84 <printf> exit(1); 51da: 4505 li a0,1 51dc: 00000097 auipc ra,0x0 51e0: 520080e7 jalr 1312(ra) # 56fc <exit> f(s); 51e4: 854a mv a0,s2 51e6: 9482 jalr s1 exit(0); 51e8: 4501 li a0,0 51ea: 00000097 auipc ra,0x0 51ee: 512080e7 jalr 1298(ra) # 56fc <exit> printf("OK\n"); 51f2: 00003517 auipc a0,0x3 51f6: cbe50513 addi a0,a0,-834 # 7eb0 <malloc+0x236e> 51fa: 00001097 auipc ra,0x1 51fe: 88a080e7 jalr -1910(ra) # 5a84 <printf> 5202: bf55 j 51b6 <run+0x50> 0000000000005204 <main>: int main(int argc, char *argv[]) { 5204: c0010113 addi sp,sp,-1024 5208: 3e113c23 sd ra,1016(sp) 520c: 3e813823 sd s0,1008(sp) 5210: 3e913423 sd s1,1000(sp) 5214: 3f213023 sd s2,992(sp) 5218: 3d313c23 sd s3,984(sp) 521c: 3d413823 sd s4,976(sp) 5220: 3d513423 sd s5,968(sp) 5224: 3d613023 sd s6,960(sp) 5228: 40010413 addi s0,sp,1024 522c: 89aa mv s3,a0 int continuous = 0; char *justone = 0; if(argc == 2 && strcmp(argv[1], "-c") == 0){ 522e: 4789 li a5,2 5230: 08f50763 beq a0,a5,52be <main+0xba> continuous = 1; } else if(argc == 2 && strcmp(argv[1], "-C") == 0){ continuous = 2; } else if(argc == 2 && argv[1][0] != '-'){ justone = argv[1]; } else if(argc > 1){ 5234: 4785 li a5,1 char *justone = 0; 5236: 4901 li s2,0 } else if(argc > 1){ 5238: 0ca7c163 blt a5,a0,52fa <main+0xf6> } struct test { void (*f)(char *); char *s; } tests[] = { 523c: 00003797 auipc a5,0x3 5240: d8c78793 addi a5,a5,-628 # 7fc8 <malloc+0x2486> 5244: c0040713 addi a4,s0,-1024 5248: 00003817 auipc a6,0x3 524c: 14080813 addi a6,a6,320 # 8388 <malloc+0x2846> 5250: 6388 ld a0,0(a5) 5252: 678c ld a1,8(a5) 5254: 6b90 ld a2,16(a5) 5256: 6f94 ld a3,24(a5) 5258: e308 sd a0,0(a4) 525a: e70c sd a1,8(a4) 525c: eb10 sd a2,16(a4) 525e: ef14 sd a3,24(a4) 5260: 02078793 addi a5,a5,32 5264: 02070713 addi a4,a4,32 5268: ff0794e3 bne a5,a6,5250 <main+0x4c> exit(1); } } } printf("usertests starting\n"); 526c: 00003517 auipc a0,0x3 5270: cfc50513 addi a0,a0,-772 # 7f68 <malloc+0x2426> 5274: 00001097 auipc ra,0x1 5278: 810080e7 jalr -2032(ra) # 5a84 <printf> int free0 = countfree(); 527c: 00000097 auipc ra,0x0 5280: dba080e7 jalr -582(ra) # 5036 <countfree> 5284: 8a2a mv s4,a0 int free1 = 0; int fail = 0; for (struct test *t = tests; t->s != 0; t++) { 5286: c0843503 ld a0,-1016(s0) 528a: c0040493 addi s1,s0,-1024 int fail = 0; 528e: 4981 li s3,0 if((justone == 0) || strcmp(t->s, justone) == 0) { if(!run(t->f, t->s)) fail = 1; 5290: 4a85 li s5,1 for (struct test *t = tests; t->s != 0; t++) { 5292: e55d bnez a0,5340 <main+0x13c> } if(fail){ printf("SOME TESTS FAILED\n"); exit(1); } else if((free1 = countfree()) < free0){ 5294: 00000097 auipc ra,0x0 5298: da2080e7 jalr -606(ra) # 5036 <countfree> 529c: 85aa mv a1,a0 529e: 0f455163 bge a0,s4,5380 <main+0x17c> printf("FAILED -- lost some free pages %d (out of %d)\n", free1, free0); 52a2: 8652 mv a2,s4 52a4: 00003517 auipc a0,0x3 52a8: c7c50513 addi a0,a0,-900 # 7f20 <malloc+0x23de> 52ac: 00000097 auipc ra,0x0 52b0: 7d8080e7 jalr 2008(ra) # 5a84 <printf> exit(1); 52b4: 4505 li a0,1 52b6: 00000097 auipc ra,0x0 52ba: 446080e7 jalr 1094(ra) # 56fc <exit> 52be: 84ae mv s1,a1 if(argc == 2 && strcmp(argv[1], "-c") == 0){ 52c0: 00003597 auipc a1,0x3 52c4: bf858593 addi a1,a1,-1032 # 7eb8 <malloc+0x2376> 52c8: 6488 ld a0,8(s1) 52ca: 00000097 auipc ra,0x0 52ce: 184080e7 jalr 388(ra) # 544e <strcmp> 52d2: 10050563 beqz a0,53dc <main+0x1d8> } else if(argc == 2 && strcmp(argv[1], "-C") == 0){ 52d6: 00003597 auipc a1,0x3 52da: cca58593 addi a1,a1,-822 # 7fa0 <malloc+0x245e> 52de: 6488 ld a0,8(s1) 52e0: 00000097 auipc ra,0x0 52e4: 16e080e7 jalr 366(ra) # 544e <strcmp> 52e8: c97d beqz a0,53de <main+0x1da> } else if(argc == 2 && argv[1][0] != '-'){ 52ea: 0084b903 ld s2,8(s1) 52ee: 00094703 lbu a4,0(s2) 52f2: 02d00793 li a5,45 52f6: f4f713e3 bne a4,a5,523c <main+0x38> printf("Usage: usertests [-c] [testname]\n"); 52fa: 00003517 auipc a0,0x3 52fe: bc650513 addi a0,a0,-1082 # 7ec0 <malloc+0x237e> 5302: 00000097 auipc ra,0x0 5306: 782080e7 jalr 1922(ra) # 5a84 <printf> exit(1); 530a: 4505 li a0,1 530c: 00000097 auipc ra,0x0 5310: 3f0080e7 jalr 1008(ra) # 56fc <exit> exit(1); 5314: 4505 li a0,1 5316: 00000097 auipc ra,0x0 531a: 3e6080e7 jalr 998(ra) # 56fc <exit> printf("FAILED -- lost %d free pages\n", free0 - free1); 531e: 40a905bb subw a1,s2,a0 5322: 855a mv a0,s6 5324: 00000097 auipc ra,0x0 5328: 760080e7 jalr 1888(ra) # 5a84 <printf> if(continuous != 2) 532c: 09498463 beq s3,s4,53b4 <main+0x1b0> exit(1); 5330: 4505 li a0,1 5332: 00000097 auipc ra,0x0 5336: 3ca080e7 jalr 970(ra) # 56fc <exit> for (struct test *t = tests; t->s != 0; t++) { 533a: 04c1 addi s1,s1,16 533c: 6488 ld a0,8(s1) 533e: c115 beqz a0,5362 <main+0x15e> if((justone == 0) || strcmp(t->s, justone) == 0) { 5340: 00090863 beqz s2,5350 <main+0x14c> 5344: 85ca mv a1,s2 5346: 00000097 auipc ra,0x0 534a: 108080e7 jalr 264(ra) # 544e <strcmp> 534e: f575 bnez a0,533a <main+0x136> if(!run(t->f, t->s)) 5350: 648c ld a1,8(s1) 5352: 6088 ld a0,0(s1) 5354: 00000097 auipc ra,0x0 5358: e12080e7 jalr -494(ra) # 5166 <run> 535c: fd79 bnez a0,533a <main+0x136> fail = 1; 535e: 89d6 mv s3,s5 5360: bfe9 j 533a <main+0x136> if(fail){ 5362: f20989e3 beqz s3,5294 <main+0x90> printf("SOME TESTS FAILED\n"); 5366: 00003517 auipc a0,0x3 536a: ba250513 addi a0,a0,-1118 # 7f08 <malloc+0x23c6> 536e: 00000097 auipc ra,0x0 5372: 716080e7 jalr 1814(ra) # 5a84 <printf> exit(1); 5376: 4505 li a0,1 5378: 00000097 auipc ra,0x0 537c: 384080e7 jalr 900(ra) # 56fc <exit> } else { printf("ALL TESTS PASSED\n"); 5380: 00003517 auipc a0,0x3 5384: bd050513 addi a0,a0,-1072 # 7f50 <malloc+0x240e> 5388: 00000097 auipc ra,0x0 538c: 6fc080e7 jalr 1788(ra) # 5a84 <printf> exit(0); 5390: 4501 li a0,0 5392: 00000097 auipc ra,0x0 5396: 36a080e7 jalr 874(ra) # 56fc <exit> printf("SOME TESTS FAILED\n"); 539a: 8556 mv a0,s5 539c: 00000097 auipc ra,0x0 53a0: 6e8080e7 jalr 1768(ra) # 5a84 <printf> if(continuous != 2) 53a4: f74998e3 bne s3,s4,5314 <main+0x110> int free1 = countfree(); 53a8: 00000097 auipc ra,0x0 53ac: c8e080e7 jalr -882(ra) # 5036 <countfree> if(free1 < free0){ 53b0: f72547e3 blt a0,s2,531e <main+0x11a> int free0 = countfree(); 53b4: 00000097 auipc ra,0x0 53b8: c82080e7 jalr -894(ra) # 5036 <countfree> 53bc: 892a mv s2,a0 for (struct test *t = tests; t->s != 0; t++) { 53be: c0843583 ld a1,-1016(s0) 53c2: d1fd beqz a1,53a8 <main+0x1a4> 53c4: c0040493 addi s1,s0,-1024 if(!run(t->f, t->s)){ 53c8: 6088 ld a0,0(s1) 53ca: 00000097 auipc ra,0x0 53ce: d9c080e7 jalr -612(ra) # 5166 <run> 53d2: d561 beqz a0,539a <main+0x196> for (struct test *t = tests; t->s != 0; t++) { 53d4: 04c1 addi s1,s1,16 53d6: 648c ld a1,8(s1) 53d8: f9e5 bnez a1,53c8 <main+0x1c4> 53da: b7f9 j 53a8 <main+0x1a4> continuous = 1; 53dc: 4985 li s3,1 } tests[] = { 53de: 00003797 auipc a5,0x3 53e2: bea78793 addi a5,a5,-1046 # 7fc8 <malloc+0x2486> 53e6: c0040713 addi a4,s0,-1024 53ea: 00003817 auipc a6,0x3 53ee: f9e80813 addi a6,a6,-98 # 8388 <malloc+0x2846> 53f2: 6388 ld a0,0(a5) 53f4: 678c ld a1,8(a5) 53f6: 6b90 ld a2,16(a5) 53f8: 6f94 ld a3,24(a5) 53fa: e308 sd a0,0(a4) 53fc: e70c sd a1,8(a4) 53fe: eb10 sd a2,16(a4) 5400: ef14 sd a3,24(a4) 5402: 02078793 addi a5,a5,32 5406: 02070713 addi a4,a4,32 540a: ff0794e3 bne a5,a6,53f2 <main+0x1ee> printf("continuous usertests starting\n"); 540e: 00003517 auipc a0,0x3 5412: b7250513 addi a0,a0,-1166 # 7f80 <malloc+0x243e> 5416: 00000097 auipc ra,0x0 541a: 66e080e7 jalr 1646(ra) # 5a84 <printf> printf("SOME TESTS FAILED\n"); 541e: 00003a97 auipc s5,0x3 5422: aeaa8a93 addi s5,s5,-1302 # 7f08 <malloc+0x23c6> if(continuous != 2) 5426: 4a09 li s4,2 printf("FAILED -- lost %d free pages\n", free0 - free1); 5428: 00003b17 auipc s6,0x3 542c: ac0b0b13 addi s6,s6,-1344 # 7ee8 <malloc+0x23a6> 5430: b751 j 53b4 <main+0x1b0> 0000000000005432 <strcpy>: #include "kernel/fcntl.h" #include "user/user.h" char* strcpy(char *s, const char *t) { 5432: 1141 addi sp,sp,-16 5434: e422 sd s0,8(sp) 5436: 0800 addi s0,sp,16 char *os; os = s; while((*s++ = *t++) != 0) 5438: 87aa mv a5,a0 543a: 0585 addi a1,a1,1 543c: 0785 addi a5,a5,1 543e: fff5c703 lbu a4,-1(a1) 5442: fee78fa3 sb a4,-1(a5) 5446: fb75 bnez a4,543a <strcpy+0x8> ; return os; } 5448: 6422 ld s0,8(sp) 544a: 0141 addi sp,sp,16 544c: 8082 ret 000000000000544e <strcmp>: int strcmp(const char *p, const char *q) { 544e: 1141 addi sp,sp,-16 5450: e422 sd s0,8(sp) 5452: 0800 addi s0,sp,16 while(*p && *p == *q) 5454: 00054783 lbu a5,0(a0) 5458: cb91 beqz a5,546c <strcmp+0x1e> 545a: 0005c703 lbu a4,0(a1) 545e: 00f71763 bne a4,a5,546c <strcmp+0x1e> p++, q++; 5462: 0505 addi a0,a0,1 5464: 0585 addi a1,a1,1 while(*p && *p == *q) 5466: 00054783 lbu a5,0(a0) 546a: fbe5 bnez a5,545a <strcmp+0xc> return (uchar)*p - (uchar)*q; 546c: 0005c503 lbu a0,0(a1) } 5470: 40a7853b subw a0,a5,a0 5474: 6422 ld s0,8(sp) 5476: 0141 addi sp,sp,16 5478: 8082 ret 000000000000547a <strlen>: uint strlen(const char *s) { 547a: 1141 addi sp,sp,-16 547c: e422 sd s0,8(sp) 547e: 0800 addi s0,sp,16 int n; for(n = 0; s[n]; n++) 5480: 00054783 lbu a5,0(a0) 5484: cf91 beqz a5,54a0 <strlen+0x26> 5486: 0505 addi a0,a0,1 5488: 87aa mv a5,a0 548a: 4685 li a3,1 548c: 9e89 subw a3,a3,a0 548e: 00f6853b addw a0,a3,a5 5492: 0785 addi a5,a5,1 5494: fff7c703 lbu a4,-1(a5) 5498: fb7d bnez a4,548e <strlen+0x14> ; return n; } 549a: 6422 ld s0,8(sp) 549c: 0141 addi sp,sp,16 549e: 8082 ret for(n = 0; s[n]; n++) 54a0: 4501 li a0,0 54a2: bfe5 j 549a <strlen+0x20> 00000000000054a4 <memset>: void* memset(void *dst, int c, uint n) { 54a4: 1141 addi sp,sp,-16 54a6: e422 sd s0,8(sp) 54a8: 0800 addi s0,sp,16 char *cdst = (char *) dst; int i; for(i = 0; i < n; i++){ 54aa: ca19 beqz a2,54c0 <memset+0x1c> 54ac: 87aa mv a5,a0 54ae: 1602 slli a2,a2,0x20 54b0: 9201 srli a2,a2,0x20 54b2: 00a60733 add a4,a2,a0 cdst[i] = c; 54b6: 00b78023 sb a1,0(a5) for(i = 0; i < n; i++){ 54ba: 0785 addi a5,a5,1 54bc: fee79de3 bne a5,a4,54b6 <memset+0x12> } return dst; } 54c0: 6422 ld s0,8(sp) 54c2: 0141 addi sp,sp,16 54c4: 8082 ret 00000000000054c6 <strchr>: char* strchr(const char *s, char c) { 54c6: 1141 addi sp,sp,-16 54c8: e422 sd s0,8(sp) 54ca: 0800 addi s0,sp,16 for(; *s; s++) 54cc: 00054783 lbu a5,0(a0) 54d0: cb99 beqz a5,54e6 <strchr+0x20> if(*s == c) 54d2: 00f58763 beq a1,a5,54e0 <strchr+0x1a> for(; *s; s++) 54d6: 0505 addi a0,a0,1 54d8: 00054783 lbu a5,0(a0) 54dc: fbfd bnez a5,54d2 <strchr+0xc> return (char*)s; return 0; 54de: 4501 li a0,0 } 54e0: 6422 ld s0,8(sp) 54e2: 0141 addi sp,sp,16 54e4: 8082 ret return 0; 54e6: 4501 li a0,0 54e8: bfe5 j 54e0 <strchr+0x1a> 00000000000054ea <gets>: char* gets(char *buf, int max) { 54ea: 711d addi sp,sp,-96 54ec: ec86 sd ra,88(sp) 54ee: e8a2 sd s0,80(sp) 54f0: e4a6 sd s1,72(sp) 54f2: e0ca sd s2,64(sp) 54f4: fc4e sd s3,56(sp) 54f6: f852 sd s4,48(sp) 54f8: f456 sd s5,40(sp) 54fa: f05a sd s6,32(sp) 54fc: ec5e sd s7,24(sp) 54fe: 1080 addi s0,sp,96 5500: 8baa mv s7,a0 5502: 8a2e mv s4,a1 int i, cc; char c; for(i=0; i+1 < max; ){ 5504: 892a mv s2,a0 5506: 4481 li s1,0 cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 5508: 4aa9 li s5,10 550a: 4b35 li s6,13 for(i=0; i+1 < max; ){ 550c: 89a6 mv s3,s1 550e: 2485 addiw s1,s1,1 5510: 0344d863 bge s1,s4,5540 <gets+0x56> cc = read(0, &c, 1); 5514: 4605 li a2,1 5516: faf40593 addi a1,s0,-81 551a: 4501 li a0,0 551c: 00000097 auipc ra,0x0 5520: 1f8080e7 jalr 504(ra) # 5714 <read> if(cc < 1) 5524: 00a05e63 blez a0,5540 <gets+0x56> buf[i++] = c; 5528: faf44783 lbu a5,-81(s0) 552c: 00f90023 sb a5,0(s2) if(c == '\n' || c == '\r') 5530: 01578763 beq a5,s5,553e <gets+0x54> 5534: 0905 addi s2,s2,1 5536: fd679be3 bne a5,s6,550c <gets+0x22> for(i=0; i+1 < max; ){ 553a: 89a6 mv s3,s1 553c: a011 j 5540 <gets+0x56> 553e: 89a6 mv s3,s1 break; } buf[i] = '\0'; 5540: 99de add s3,s3,s7 5542: 00098023 sb zero,0(s3) return buf; } 5546: 855e mv a0,s7 5548: 60e6 ld ra,88(sp) 554a: 6446 ld s0,80(sp) 554c: 64a6 ld s1,72(sp) 554e: 6906 ld s2,64(sp) 5550: 79e2 ld s3,56(sp) 5552: 7a42 ld s4,48(sp) 5554: 7aa2 ld s5,40(sp) 5556: 7b02 ld s6,32(sp) 5558: 6be2 ld s7,24(sp) 555a: 6125 addi sp,sp,96 555c: 8082 ret 000000000000555e <stat>: int stat(const char *n, struct stat *st) { 555e: 1101 addi sp,sp,-32 5560: ec06 sd ra,24(sp) 5562: e822 sd s0,16(sp) 5564: e426 sd s1,8(sp) 5566: e04a sd s2,0(sp) 5568: 1000 addi s0,sp,32 556a: 892e mv s2,a1 int fd; int r; fd = open(n, O_RDONLY); 556c: 4581 li a1,0 556e: 00000097 auipc ra,0x0 5572: 1ce080e7 jalr 462(ra) # 573c <open> if(fd < 0) 5576: 02054563 bltz a0,55a0 <stat+0x42> 557a: 84aa mv s1,a0 return -1; r = fstat(fd, st); 557c: 85ca mv a1,s2 557e: 00000097 auipc ra,0x0 5582: 1d6080e7 jalr 470(ra) # 5754 <fstat> 5586: 892a mv s2,a0 close(fd); 5588: 8526 mv a0,s1 558a: 00000097 auipc ra,0x0 558e: 19a080e7 jalr 410(ra) # 5724 <close> return r; } 5592: 854a mv a0,s2 5594: 60e2 ld ra,24(sp) 5596: 6442 ld s0,16(sp) 5598: 64a2 ld s1,8(sp) 559a: 6902 ld s2,0(sp) 559c: 6105 addi sp,sp,32 559e: 8082 ret return -1; 55a0: 597d li s2,-1 55a2: bfc5 j 5592 <stat+0x34> 00000000000055a4 <atoi>: int atoi(const char *s) { 55a4: 1141 addi sp,sp,-16 55a6: e422 sd s0,8(sp) 55a8: 0800 addi s0,sp,16 int n; n = 0; while('0' <= *s && *s <= '9') 55aa: 00054603 lbu a2,0(a0) 55ae: fd06079b addiw a5,a2,-48 55b2: 0ff7f793 andi a5,a5,255 55b6: 4725 li a4,9 55b8: 02f76963 bltu a4,a5,55ea <atoi+0x46> 55bc: 86aa mv a3,a0 n = 0; 55be: 4501 li a0,0 while('0' <= *s && *s <= '9') 55c0: 45a5 li a1,9 n = n*10 + *s++ - '0'; 55c2: 0685 addi a3,a3,1 55c4: 0025179b slliw a5,a0,0x2 55c8: 9fa9 addw a5,a5,a0 55ca: 0017979b slliw a5,a5,0x1 55ce: 9fb1 addw a5,a5,a2 55d0: fd07851b addiw a0,a5,-48 while('0' <= *s && *s <= '9') 55d4: 0006c603 lbu a2,0(a3) 55d8: fd06071b addiw a4,a2,-48 55dc: 0ff77713 andi a4,a4,255 55e0: fee5f1e3 bgeu a1,a4,55c2 <atoi+0x1e> return n; } 55e4: 6422 ld s0,8(sp) 55e6: 0141 addi sp,sp,16 55e8: 8082 ret n = 0; 55ea: 4501 li a0,0 55ec: bfe5 j 55e4 <atoi+0x40> 00000000000055ee <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 55ee: 1141 addi sp,sp,-16 55f0: e422 sd s0,8(sp) 55f2: 0800 addi s0,sp,16 char *dst; const char *src; dst = vdst; src = vsrc; if (src > dst) { 55f4: 02b57463 bgeu a0,a1,561c <memmove+0x2e> while(n-- > 0) 55f8: 00c05f63 blez a2,5616 <memmove+0x28> 55fc: 1602 slli a2,a2,0x20 55fe: 9201 srli a2,a2,0x20 5600: 00c507b3 add a5,a0,a2 dst = vdst; 5604: 872a mv a4,a0 *dst++ = *src++; 5606: 0585 addi a1,a1,1 5608: 0705 addi a4,a4,1 560a: fff5c683 lbu a3,-1(a1) 560e: fed70fa3 sb a3,-1(a4) while(n-- > 0) 5612: fee79ae3 bne a5,a4,5606 <memmove+0x18> src += n; while(n-- > 0) *--dst = *--src; } return vdst; } 5616: 6422 ld s0,8(sp) 5618: 0141 addi sp,sp,16 561a: 8082 ret dst += n; 561c: 00c50733 add a4,a0,a2 src += n; 5620: 95b2 add a1,a1,a2 while(n-- > 0) 5622: fec05ae3 blez a2,5616 <memmove+0x28> 5626: fff6079b addiw a5,a2,-1 562a: 1782 slli a5,a5,0x20 562c: 9381 srli a5,a5,0x20 562e: fff7c793 not a5,a5 5632: 97ba add a5,a5,a4 *--dst = *--src; 5634: 15fd addi a1,a1,-1 5636: 177d addi a4,a4,-1 5638: 0005c683 lbu a3,0(a1) 563c: 00d70023 sb a3,0(a4) while(n-- > 0) 5640: fee79ae3 bne a5,a4,5634 <memmove+0x46> 5644: bfc9 j 5616 <memmove+0x28> 0000000000005646 <memcmp>: int memcmp(const void *s1, const void *s2, uint n) { 5646: 1141 addi sp,sp,-16 5648: e422 sd s0,8(sp) 564a: 0800 addi s0,sp,16 const char *p1 = s1, *p2 = s2; while (n-- > 0) { 564c: ca05 beqz a2,567c <memcmp+0x36> 564e: fff6069b addiw a3,a2,-1 5652: 1682 slli a3,a3,0x20 5654: 9281 srli a3,a3,0x20 5656: 0685 addi a3,a3,1 5658: 96aa add a3,a3,a0 if (*p1 != *p2) { 565a: 00054783 lbu a5,0(a0) 565e: 0005c703 lbu a4,0(a1) 5662: 00e79863 bne a5,a4,5672 <memcmp+0x2c> return *p1 - *p2; } p1++; 5666: 0505 addi a0,a0,1 p2++; 5668: 0585 addi a1,a1,1 while (n-- > 0) { 566a: fed518e3 bne a0,a3,565a <memcmp+0x14> } return 0; 566e: 4501 li a0,0 5670: a019 j 5676 <memcmp+0x30> return *p1 - *p2; 5672: 40e7853b subw a0,a5,a4 } 5676: 6422 ld s0,8(sp) 5678: 0141 addi sp,sp,16 567a: 8082 ret return 0; 567c: 4501 li a0,0 567e: bfe5 j 5676 <memcmp+0x30> 0000000000005680 <memcpy>: void * memcpy(void *dst, const void *src, uint n) { 5680: 1141 addi sp,sp,-16 5682: e406 sd ra,8(sp) 5684: e022 sd s0,0(sp) 5686: 0800 addi s0,sp,16 return memmove(dst, src, n); 5688: 00000097 auipc ra,0x0 568c: f66080e7 jalr -154(ra) # 55ee <memmove> } 5690: 60a2 ld ra,8(sp) 5692: 6402 ld s0,0(sp) 5694: 0141 addi sp,sp,16 5696: 8082 ret 0000000000005698 <my_strcat>: // functions added by us char* my_strcat(char* destination, const char* source) { 5698: 1141 addi sp,sp,-16 569a: e422 sd s0,8(sp) 569c: 0800 addi s0,sp,16 int i, j; // move to the end of destination string for (i = 0; destination[i] != '\0'; i++); 569e: 00054783 lbu a5,0(a0) 56a2: c7a9 beqz a5,56ec <my_strcat+0x54> 56a4: 00150713 addi a4,a0,1 56a8: 87ba mv a5,a4 56aa: 4685 li a3,1 56ac: 9e99 subw a3,a3,a4 56ae: 00f6863b addw a2,a3,a5 56b2: 0785 addi a5,a5,1 56b4: fff7c703 lbu a4,-1(a5) 56b8: fb7d bnez a4,56ae <my_strcat+0x16> // i now points to terminating null character in destination // Appends characters of source to the destination string for (j = 0; source[j] != '\0'; j++) 56ba: 0005c683 lbu a3,0(a1) 56be: ca8d beqz a3,56f0 <my_strcat+0x58> 56c0: 4785 li a5,1 destination[i + j] = source[j]; 56c2: 00f60733 add a4,a2,a5 56c6: 972a add a4,a4,a0 56c8: fed70fa3 sb a3,-1(a4) for (j = 0; source[j] != '\0'; j++) 56cc: 0007881b sext.w a6,a5 56d0: 0785 addi a5,a5,1 56d2: 00f58733 add a4,a1,a5 56d6: fff74683 lbu a3,-1(a4) 56da: f6e5 bnez a3,56c2 <my_strcat+0x2a> // null terminate destination string destination[i + j] = '\0'; 56dc: 0106063b addw a2,a2,a6 56e0: 962a add a2,a2,a0 56e2: 00060023 sb zero,0(a2) # 3000 <dirtest+0x80> // destination is returned by standard strcat() return destination; 56e6: 6422 ld s0,8(sp) 56e8: 0141 addi sp,sp,16 56ea: 8082 ret for (i = 0; destination[i] != '\0'; i++); 56ec: 4601 li a2,0 56ee: b7f1 j 56ba <my_strcat+0x22> for (j = 0; source[j] != '\0'; j++) 56f0: 4801 li a6,0 56f2: b7ed j 56dc <my_strcat+0x44> 00000000000056f4 <fork>: # generated by usys.pl - do not edit #include "kernel/syscall.h" .global fork fork: li a7, SYS_fork 56f4: 4885 li a7,1 ecall 56f6: 00000073 ecall ret 56fa: 8082 ret 00000000000056fc <exit>: .global exit exit: li a7, SYS_exit 56fc: 4889 li a7,2 ecall 56fe: 00000073 ecall ret 5702: 8082 ret 0000000000005704 <wait>: .global wait wait: li a7, SYS_wait 5704: 488d li a7,3 ecall 5706: 00000073 ecall ret 570a: 8082 ret 000000000000570c <pipe>: .global pipe pipe: li a7, SYS_pipe 570c: 4891 li a7,4 ecall 570e: 00000073 ecall ret 5712: 8082 ret 0000000000005714 <read>: .global read read: li a7, SYS_read 5714: 4895 li a7,5 ecall 5716: 00000073 ecall ret 571a: 8082 ret 000000000000571c <write>: .global write write: li a7, SYS_write 571c: 48c1 li a7,16 ecall 571e: 00000073 ecall ret 5722: 8082 ret 0000000000005724 <close>: .global close close: li a7, SYS_close 5724: 48d5 li a7,21 ecall 5726: 00000073 ecall ret 572a: 8082 ret 000000000000572c <kill>: .global kill kill: li a7, SYS_kill 572c: 4899 li a7,6 ecall 572e: 00000073 ecall ret 5732: 8082 ret 0000000000005734 <exec>: .global exec exec: li a7, SYS_exec 5734: 489d li a7,7 ecall 5736: 00000073 ecall ret 573a: 8082 ret 000000000000573c <open>: .global open open: li a7, SYS_open 573c: 48bd li a7,15 ecall 573e: 00000073 ecall ret 5742: 8082 ret 0000000000005744 <mknod>: .global mknod mknod: li a7, SYS_mknod 5744: 48c5 li a7,17 ecall 5746: 00000073 ecall ret 574a: 8082 ret 000000000000574c <unlink>: .global unlink unlink: li a7, SYS_unlink 574c: 48c9 li a7,18 ecall 574e: 00000073 ecall ret 5752: 8082 ret 0000000000005754 <fstat>: .global fstat fstat: li a7, SYS_fstat 5754: 48a1 li a7,8 ecall 5756: 00000073 ecall ret 575a: 8082 ret 000000000000575c <link>: .global link link: li a7, SYS_link 575c: 48cd li a7,19 ecall 575e: 00000073 ecall ret 5762: 8082 ret 0000000000005764 <mkdir>: .global mkdir mkdir: li a7, SYS_mkdir 5764: 48d1 li a7,20 ecall 5766: 00000073 ecall ret 576a: 8082 ret 000000000000576c <chdir>: .global chdir chdir: li a7, SYS_chdir 576c: 48a5 li a7,9 ecall 576e: 00000073 ecall ret 5772: 8082 ret 0000000000005774 <dup>: .global dup dup: li a7, SYS_dup 5774: 48a9 li a7,10 ecall 5776: 00000073 ecall ret 577a: 8082 ret 000000000000577c <getpid>: .global getpid getpid: li a7, SYS_getpid 577c: 48ad li a7,11 ecall 577e: 00000073 ecall ret 5782: 8082 ret 0000000000005784 <sbrk>: .global sbrk sbrk: li a7, SYS_sbrk 5784: 48b1 li a7,12 ecall 5786: 00000073 ecall ret 578a: 8082 ret 000000000000578c <sleep>: .global sleep sleep: li a7, SYS_sleep 578c: 48b5 li a7,13 ecall 578e: 00000073 ecall ret 5792: 8082 ret 0000000000005794 <uptime>: .global uptime uptime: li a7, SYS_uptime 5794: 48b9 li a7,14 ecall 5796: 00000073 ecall ret 579a: 8082 ret 000000000000579c <trace>: .global trace trace: li a7, SYS_trace 579c: 48d9 li a7,22 ecall 579e: 00000073 ecall ret 57a2: 8082 ret 00000000000057a4 <wait_stat>: .global wait_stat wait_stat: li a7, SYS_wait_stat 57a4: 48dd li a7,23 ecall 57a6: 00000073 ecall ret 57aa: 8082 ret 00000000000057ac <putc>: static char digits[] = "0123456789ABCDEF"; static void putc(int fd, char c) { 57ac: 1101 addi sp,sp,-32 57ae: ec06 sd ra,24(sp) 57b0: e822 sd s0,16(sp) 57b2: 1000 addi s0,sp,32 57b4: feb407a3 sb a1,-17(s0) write(fd, &c, 1); 57b8: 4605 li a2,1 57ba: fef40593 addi a1,s0,-17 57be: 00000097 auipc ra,0x0 57c2: f5e080e7 jalr -162(ra) # 571c <write> } 57c6: 60e2 ld ra,24(sp) 57c8: 6442 ld s0,16(sp) 57ca: 6105 addi sp,sp,32 57cc: 8082 ret 00000000000057ce <printint>: static void printint(int fd, int xx, int base, int sgn) { 57ce: 7139 addi sp,sp,-64 57d0: fc06 sd ra,56(sp) 57d2: f822 sd s0,48(sp) 57d4: f426 sd s1,40(sp) 57d6: f04a sd s2,32(sp) 57d8: ec4e sd s3,24(sp) 57da: 0080 addi s0,sp,64 57dc: 84aa mv s1,a0 char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 57de: c299 beqz a3,57e4 <printint+0x16> 57e0: 0805c863 bltz a1,5870 <printint+0xa2> neg = 1; x = -xx; } else { x = xx; 57e4: 2581 sext.w a1,a1 neg = 0; 57e6: 4881 li a7,0 57e8: fc040693 addi a3,s0,-64 } i = 0; 57ec: 4701 li a4,0 do{ buf[i++] = digits[x % base]; 57ee: 2601 sext.w a2,a2 57f0: 00003517 auipc a0,0x3 57f4: ba050513 addi a0,a0,-1120 # 8390 <digits> 57f8: 883a mv a6,a4 57fa: 2705 addiw a4,a4,1 57fc: 02c5f7bb remuw a5,a1,a2 5800: 1782 slli a5,a5,0x20 5802: 9381 srli a5,a5,0x20 5804: 97aa add a5,a5,a0 5806: 0007c783 lbu a5,0(a5) 580a: 00f68023 sb a5,0(a3) }while((x /= base) != 0); 580e: 0005879b sext.w a5,a1 5812: 02c5d5bb divuw a1,a1,a2 5816: 0685 addi a3,a3,1 5818: fec7f0e3 bgeu a5,a2,57f8 <printint+0x2a> if(neg) 581c: 00088b63 beqz a7,5832 <printint+0x64> buf[i++] = '-'; 5820: fd040793 addi a5,s0,-48 5824: 973e add a4,a4,a5 5826: 02d00793 li a5,45 582a: fef70823 sb a5,-16(a4) 582e: 0028071b addiw a4,a6,2 while(--i >= 0) 5832: 02e05863 blez a4,5862 <printint+0x94> 5836: fc040793 addi a5,s0,-64 583a: 00e78933 add s2,a5,a4 583e: fff78993 addi s3,a5,-1 5842: 99ba add s3,s3,a4 5844: 377d addiw a4,a4,-1 5846: 1702 slli a4,a4,0x20 5848: 9301 srli a4,a4,0x20 584a: 40e989b3 sub s3,s3,a4 putc(fd, buf[i]); 584e: fff94583 lbu a1,-1(s2) 5852: 8526 mv a0,s1 5854: 00000097 auipc ra,0x0 5858: f58080e7 jalr -168(ra) # 57ac <putc> while(--i >= 0) 585c: 197d addi s2,s2,-1 585e: ff3918e3 bne s2,s3,584e <printint+0x80> } 5862: 70e2 ld ra,56(sp) 5864: 7442 ld s0,48(sp) 5866: 74a2 ld s1,40(sp) 5868: 7902 ld s2,32(sp) 586a: 69e2 ld s3,24(sp) 586c: 6121 addi sp,sp,64 586e: 8082 ret x = -xx; 5870: 40b005bb negw a1,a1 neg = 1; 5874: 4885 li a7,1 x = -xx; 5876: bf8d j 57e8 <printint+0x1a> 0000000000005878 <vprintf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void vprintf(int fd, const char *fmt, va_list ap) { 5878: 7119 addi sp,sp,-128 587a: fc86 sd ra,120(sp) 587c: f8a2 sd s0,112(sp) 587e: f4a6 sd s1,104(sp) 5880: f0ca sd s2,96(sp) 5882: ecce sd s3,88(sp) 5884: e8d2 sd s4,80(sp) 5886: e4d6 sd s5,72(sp) 5888: e0da sd s6,64(sp) 588a: fc5e sd s7,56(sp) 588c: f862 sd s8,48(sp) 588e: f466 sd s9,40(sp) 5890: f06a sd s10,32(sp) 5892: ec6e sd s11,24(sp) 5894: 0100 addi s0,sp,128 char *s; int c, i, state; state = 0; for(i = 0; fmt[i]; i++){ 5896: 0005c903 lbu s2,0(a1) 589a: 18090f63 beqz s2,5a38 <vprintf+0x1c0> 589e: 8aaa mv s5,a0 58a0: 8b32 mv s6,a2 58a2: 00158493 addi s1,a1,1 state = 0; 58a6: 4981 li s3,0 if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 58a8: 02500a13 li s4,37 if(c == 'd'){ 58ac: 06400c13 li s8,100 printint(fd, va_arg(ap, int), 10, 1); } else if(c == 'l') { 58b0: 06c00c93 li s9,108 printint(fd, va_arg(ap, uint64), 10, 0); } else if(c == 'x') { 58b4: 07800d13 li s10,120 printint(fd, va_arg(ap, int), 16, 0); } else if(c == 'p') { 58b8: 07000d93 li s11,112 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 58bc: 00003b97 auipc s7,0x3 58c0: ad4b8b93 addi s7,s7,-1324 # 8390 <digits> 58c4: a839 j 58e2 <vprintf+0x6a> putc(fd, c); 58c6: 85ca mv a1,s2 58c8: 8556 mv a0,s5 58ca: 00000097 auipc ra,0x0 58ce: ee2080e7 jalr -286(ra) # 57ac <putc> 58d2: a019 j 58d8 <vprintf+0x60> } else if(state == '%'){ 58d4: 01498f63 beq s3,s4,58f2 <vprintf+0x7a> for(i = 0; fmt[i]; i++){ 58d8: 0485 addi s1,s1,1 58da: fff4c903 lbu s2,-1(s1) 58de: 14090d63 beqz s2,5a38 <vprintf+0x1c0> c = fmt[i] & 0xff; 58e2: 0009079b sext.w a5,s2 if(state == 0){ 58e6: fe0997e3 bnez s3,58d4 <vprintf+0x5c> if(c == '%'){ 58ea: fd479ee3 bne a5,s4,58c6 <vprintf+0x4e> state = '%'; 58ee: 89be mv s3,a5 58f0: b7e5 j 58d8 <vprintf+0x60> if(c == 'd'){ 58f2: 05878063 beq a5,s8,5932 <vprintf+0xba> } else if(c == 'l') { 58f6: 05978c63 beq a5,s9,594e <vprintf+0xd6> } else if(c == 'x') { 58fa: 07a78863 beq a5,s10,596a <vprintf+0xf2> } else if(c == 'p') { 58fe: 09b78463 beq a5,s11,5986 <vprintf+0x10e> printptr(fd, va_arg(ap, uint64)); } else if(c == 's'){ 5902: 07300713 li a4,115 5906: 0ce78663 beq a5,a4,59d2 <vprintf+0x15a> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 590a: 06300713 li a4,99 590e: 0ee78e63 beq a5,a4,5a0a <vprintf+0x192> putc(fd, va_arg(ap, uint)); } else if(c == '%'){ 5912: 11478863 beq a5,s4,5a22 <vprintf+0x1aa> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 5916: 85d2 mv a1,s4 5918: 8556 mv a0,s5 591a: 00000097 auipc ra,0x0 591e: e92080e7 jalr -366(ra) # 57ac <putc> putc(fd, c); 5922: 85ca mv a1,s2 5924: 8556 mv a0,s5 5926: 00000097 auipc ra,0x0 592a: e86080e7 jalr -378(ra) # 57ac <putc> } state = 0; 592e: 4981 li s3,0 5930: b765 j 58d8 <vprintf+0x60> printint(fd, va_arg(ap, int), 10, 1); 5932: 008b0913 addi s2,s6,8 5936: 4685 li a3,1 5938: 4629 li a2,10 593a: 000b2583 lw a1,0(s6) 593e: 8556 mv a0,s5 5940: 00000097 auipc ra,0x0 5944: e8e080e7 jalr -370(ra) # 57ce <printint> 5948: 8b4a mv s6,s2 state = 0; 594a: 4981 li s3,0 594c: b771 j 58d8 <vprintf+0x60> printint(fd, va_arg(ap, uint64), 10, 0); 594e: 008b0913 addi s2,s6,8 5952: 4681 li a3,0 5954: 4629 li a2,10 5956: 000b2583 lw a1,0(s6) 595a: 8556 mv a0,s5 595c: 00000097 auipc ra,0x0 5960: e72080e7 jalr -398(ra) # 57ce <printint> 5964: 8b4a mv s6,s2 state = 0; 5966: 4981 li s3,0 5968: bf85 j 58d8 <vprintf+0x60> printint(fd, va_arg(ap, int), 16, 0); 596a: 008b0913 addi s2,s6,8 596e: 4681 li a3,0 5970: 4641 li a2,16 5972: 000b2583 lw a1,0(s6) 5976: 8556 mv a0,s5 5978: 00000097 auipc ra,0x0 597c: e56080e7 jalr -426(ra) # 57ce <printint> 5980: 8b4a mv s6,s2 state = 0; 5982: 4981 li s3,0 5984: bf91 j 58d8 <vprintf+0x60> printptr(fd, va_arg(ap, uint64)); 5986: 008b0793 addi a5,s6,8 598a: f8f43423 sd a5,-120(s0) 598e: 000b3983 ld s3,0(s6) putc(fd, '0'); 5992: 03000593 li a1,48 5996: 8556 mv a0,s5 5998: 00000097 auipc ra,0x0 599c: e14080e7 jalr -492(ra) # 57ac <putc> putc(fd, 'x'); 59a0: 85ea mv a1,s10 59a2: 8556 mv a0,s5 59a4: 00000097 auipc ra,0x0 59a8: e08080e7 jalr -504(ra) # 57ac <putc> 59ac: 4941 li s2,16 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 59ae: 03c9d793 srli a5,s3,0x3c 59b2: 97de add a5,a5,s7 59b4: 0007c583 lbu a1,0(a5) 59b8: 8556 mv a0,s5 59ba: 00000097 auipc ra,0x0 59be: df2080e7 jalr -526(ra) # 57ac <putc> for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4) 59c2: 0992 slli s3,s3,0x4 59c4: 397d addiw s2,s2,-1 59c6: fe0914e3 bnez s2,59ae <vprintf+0x136> printptr(fd, va_arg(ap, uint64)); 59ca: f8843b03 ld s6,-120(s0) state = 0; 59ce: 4981 li s3,0 59d0: b721 j 58d8 <vprintf+0x60> s = va_arg(ap, char*); 59d2: 008b0993 addi s3,s6,8 59d6: 000b3903 ld s2,0(s6) if(s == 0) 59da: 02090163 beqz s2,59fc <vprintf+0x184> while(*s != 0){ 59de: 00094583 lbu a1,0(s2) 59e2: c9a1 beqz a1,5a32 <vprintf+0x1ba> putc(fd, *s); 59e4: 8556 mv a0,s5 59e6: 00000097 auipc ra,0x0 59ea: dc6080e7 jalr -570(ra) # 57ac <putc> s++; 59ee: 0905 addi s2,s2,1 while(*s != 0){ 59f0: 00094583 lbu a1,0(s2) 59f4: f9e5 bnez a1,59e4 <vprintf+0x16c> s = va_arg(ap, char*); 59f6: 8b4e mv s6,s3 state = 0; 59f8: 4981 li s3,0 59fa: bdf9 j 58d8 <vprintf+0x60> s = "(null)"; 59fc: 00003917 auipc s2,0x3 5a00: 98c90913 addi s2,s2,-1652 # 8388 <malloc+0x2846> while(*s != 0){ 5a04: 02800593 li a1,40 5a08: bff1 j 59e4 <vprintf+0x16c> putc(fd, va_arg(ap, uint)); 5a0a: 008b0913 addi s2,s6,8 5a0e: 000b4583 lbu a1,0(s6) 5a12: 8556 mv a0,s5 5a14: 00000097 auipc ra,0x0 5a18: d98080e7 jalr -616(ra) # 57ac <putc> 5a1c: 8b4a mv s6,s2 state = 0; 5a1e: 4981 li s3,0 5a20: bd65 j 58d8 <vprintf+0x60> putc(fd, c); 5a22: 85d2 mv a1,s4 5a24: 8556 mv a0,s5 5a26: 00000097 auipc ra,0x0 5a2a: d86080e7 jalr -634(ra) # 57ac <putc> state = 0; 5a2e: 4981 li s3,0 5a30: b565 j 58d8 <vprintf+0x60> s = va_arg(ap, char*); 5a32: 8b4e mv s6,s3 state = 0; 5a34: 4981 li s3,0 5a36: b54d j 58d8 <vprintf+0x60> } } } 5a38: 70e6 ld ra,120(sp) 5a3a: 7446 ld s0,112(sp) 5a3c: 74a6 ld s1,104(sp) 5a3e: 7906 ld s2,96(sp) 5a40: 69e6 ld s3,88(sp) 5a42: 6a46 ld s4,80(sp) 5a44: 6aa6 ld s5,72(sp) 5a46: 6b06 ld s6,64(sp) 5a48: 7be2 ld s7,56(sp) 5a4a: 7c42 ld s8,48(sp) 5a4c: 7ca2 ld s9,40(sp) 5a4e: 7d02 ld s10,32(sp) 5a50: 6de2 ld s11,24(sp) 5a52: 6109 addi sp,sp,128 5a54: 8082 ret 0000000000005a56 <fprintf>: void fprintf(int fd, const char *fmt, ...) { 5a56: 715d addi sp,sp,-80 5a58: ec06 sd ra,24(sp) 5a5a: e822 sd s0,16(sp) 5a5c: 1000 addi s0,sp,32 5a5e: e010 sd a2,0(s0) 5a60: e414 sd a3,8(s0) 5a62: e818 sd a4,16(s0) 5a64: ec1c sd a5,24(s0) 5a66: 03043023 sd a6,32(s0) 5a6a: 03143423 sd a7,40(s0) va_list ap; va_start(ap, fmt); 5a6e: fe843423 sd s0,-24(s0) vprintf(fd, fmt, ap); 5a72: 8622 mv a2,s0 5a74: 00000097 auipc ra,0x0 5a78: e04080e7 jalr -508(ra) # 5878 <vprintf> } 5a7c: 60e2 ld ra,24(sp) 5a7e: 6442 ld s0,16(sp) 5a80: 6161 addi sp,sp,80 5a82: 8082 ret 0000000000005a84 <printf>: void printf(const char *fmt, ...) { 5a84: 711d addi sp,sp,-96 5a86: ec06 sd ra,24(sp) 5a88: e822 sd s0,16(sp) 5a8a: 1000 addi s0,sp,32 5a8c: e40c sd a1,8(s0) 5a8e: e810 sd a2,16(s0) 5a90: ec14 sd a3,24(s0) 5a92: f018 sd a4,32(s0) 5a94: f41c sd a5,40(s0) 5a96: 03043823 sd a6,48(s0) 5a9a: 03143c23 sd a7,56(s0) va_list ap; va_start(ap, fmt); 5a9e: 00840613 addi a2,s0,8 5aa2: fec43423 sd a2,-24(s0) vprintf(1, fmt, ap); 5aa6: 85aa mv a1,a0 5aa8: 4505 li a0,1 5aaa: 00000097 auipc ra,0x0 5aae: dce080e7 jalr -562(ra) # 5878 <vprintf> } 5ab2: 60e2 ld ra,24(sp) 5ab4: 6442 ld s0,16(sp) 5ab6: 6125 addi sp,sp,96 5ab8: 8082 ret 0000000000005aba <free>: static Header base; static Header *freep; void free(void *ap) { 5aba: 1141 addi sp,sp,-16 5abc: e422 sd s0,8(sp) 5abe: 0800 addi s0,sp,16 Header *bp, *p; bp = (Header*)ap - 1; 5ac0: ff050693 addi a3,a0,-16 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5ac4: 00003797 auipc a5,0x3 5ac8: 8f47b783 ld a5,-1804(a5) # 83b8 <freep> 5acc: a805 j 5afc <free+0x42> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 5ace: 4618 lw a4,8(a2) 5ad0: 9db9 addw a1,a1,a4 5ad2: feb52c23 sw a1,-8(a0) bp->s.ptr = p->s.ptr->s.ptr; 5ad6: 6398 ld a4,0(a5) 5ad8: 6318 ld a4,0(a4) 5ada: fee53823 sd a4,-16(a0) 5ade: a091 j 5b22 <free+0x68> } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 5ae0: ff852703 lw a4,-8(a0) 5ae4: 9e39 addw a2,a2,a4 5ae6: c790 sw a2,8(a5) p->s.ptr = bp->s.ptr; 5ae8: ff053703 ld a4,-16(a0) 5aec: e398 sd a4,0(a5) 5aee: a099 j 5b34 <free+0x7a> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5af0: 6398 ld a4,0(a5) 5af2: 00e7e463 bltu a5,a4,5afa <free+0x40> 5af6: 00e6ea63 bltu a3,a4,5b0a <free+0x50> { 5afa: 87ba mv a5,a4 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5afc: fed7fae3 bgeu a5,a3,5af0 <free+0x36> 5b00: 6398 ld a4,0(a5) 5b02: 00e6e463 bltu a3,a4,5b0a <free+0x50> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5b06: fee7eae3 bltu a5,a4,5afa <free+0x40> if(bp + bp->s.size == p->s.ptr){ 5b0a: ff852583 lw a1,-8(a0) 5b0e: 6390 ld a2,0(a5) 5b10: 02059813 slli a6,a1,0x20 5b14: 01c85713 srli a4,a6,0x1c 5b18: 9736 add a4,a4,a3 5b1a: fae60ae3 beq a2,a4,5ace <free+0x14> bp->s.ptr = p->s.ptr; 5b1e: fec53823 sd a2,-16(a0) if(p + p->s.size == bp){ 5b22: 4790 lw a2,8(a5) 5b24: 02061593 slli a1,a2,0x20 5b28: 01c5d713 srli a4,a1,0x1c 5b2c: 973e add a4,a4,a5 5b2e: fae689e3 beq a3,a4,5ae0 <free+0x26> } else p->s.ptr = bp; 5b32: e394 sd a3,0(a5) freep = p; 5b34: 00003717 auipc a4,0x3 5b38: 88f73223 sd a5,-1916(a4) # 83b8 <freep> } 5b3c: 6422 ld s0,8(sp) 5b3e: 0141 addi sp,sp,16 5b40: 8082 ret 0000000000005b42 <malloc>: return freep; } void* malloc(uint nbytes) { 5b42: 7139 addi sp,sp,-64 5b44: fc06 sd ra,56(sp) 5b46: f822 sd s0,48(sp) 5b48: f426 sd s1,40(sp) 5b4a: f04a sd s2,32(sp) 5b4c: ec4e sd s3,24(sp) 5b4e: e852 sd s4,16(sp) 5b50: e456 sd s5,8(sp) 5b52: e05a sd s6,0(sp) 5b54: 0080 addi s0,sp,64 Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 5b56: 02051493 slli s1,a0,0x20 5b5a: 9081 srli s1,s1,0x20 5b5c: 04bd addi s1,s1,15 5b5e: 8091 srli s1,s1,0x4 5b60: 0014899b addiw s3,s1,1 5b64: 0485 addi s1,s1,1 if((prevp = freep) == 0){ 5b66: 00003517 auipc a0,0x3 5b6a: 85253503 ld a0,-1966(a0) # 83b8 <freep> 5b6e: c515 beqz a0,5b9a <malloc+0x58> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 5b70: 611c ld a5,0(a0) if(p->s.size >= nunits){ 5b72: 4798 lw a4,8(a5) 5b74: 02977f63 bgeu a4,s1,5bb2 <malloc+0x70> 5b78: 8a4e mv s4,s3 5b7a: 0009871b sext.w a4,s3 5b7e: 6685 lui a3,0x1 5b80: 00d77363 bgeu a4,a3,5b86 <malloc+0x44> 5b84: 6a05 lui s4,0x1 5b86: 000a0b1b sext.w s6,s4 p = sbrk(nu * sizeof(Header)); 5b8a: 004a1a1b slliw s4,s4,0x4 p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 5b8e: 00003917 auipc s2,0x3 5b92: 82a90913 addi s2,s2,-2006 # 83b8 <freep> if(p == (char*)-1) 5b96: 5afd li s5,-1 5b98: a895 j 5c0c <malloc+0xca> base.s.ptr = freep = prevp = &base; 5b9a: 00009797 auipc a5,0x9 5b9e: 03e78793 addi a5,a5,62 # ebd8 <base> 5ba2: 00003717 auipc a4,0x3 5ba6: 80f73b23 sd a5,-2026(a4) # 83b8 <freep> 5baa: e39c sd a5,0(a5) base.s.size = 0; 5bac: 0007a423 sw zero,8(a5) if(p->s.size >= nunits){ 5bb0: b7e1 j 5b78 <malloc+0x36> if(p->s.size == nunits) 5bb2: 02e48c63 beq s1,a4,5bea <malloc+0xa8> p->s.size -= nunits; 5bb6: 4137073b subw a4,a4,s3 5bba: c798 sw a4,8(a5) p += p->s.size; 5bbc: 02071693 slli a3,a4,0x20 5bc0: 01c6d713 srli a4,a3,0x1c 5bc4: 97ba add a5,a5,a4 p->s.size = nunits; 5bc6: 0137a423 sw s3,8(a5) freep = prevp; 5bca: 00002717 auipc a4,0x2 5bce: 7ea73723 sd a0,2030(a4) # 83b8 <freep> return (void*)(p + 1); 5bd2: 01078513 addi a0,a5,16 if((p = morecore(nunits)) == 0) return 0; } } 5bd6: 70e2 ld ra,56(sp) 5bd8: 7442 ld s0,48(sp) 5bda: 74a2 ld s1,40(sp) 5bdc: 7902 ld s2,32(sp) 5bde: 69e2 ld s3,24(sp) 5be0: 6a42 ld s4,16(sp) 5be2: 6aa2 ld s5,8(sp) 5be4: 6b02 ld s6,0(sp) 5be6: 6121 addi sp,sp,64 5be8: 8082 ret prevp->s.ptr = p->s.ptr; 5bea: 6398 ld a4,0(a5) 5bec: e118 sd a4,0(a0) 5bee: bff1 j 5bca <malloc+0x88> hp->s.size = nu; 5bf0: 01652423 sw s6,8(a0) free((void*)(hp + 1)); 5bf4: 0541 addi a0,a0,16 5bf6: 00000097 auipc ra,0x0 5bfa: ec4080e7 jalr -316(ra) # 5aba <free> return freep; 5bfe: 00093503 ld a0,0(s2) if((p = morecore(nunits)) == 0) 5c02: d971 beqz a0,5bd6 <malloc+0x94> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 5c04: 611c ld a5,0(a0) if(p->s.size >= nunits){ 5c06: 4798 lw a4,8(a5) 5c08: fa9775e3 bgeu a4,s1,5bb2 <malloc+0x70> if(p == freep) 5c0c: 00093703 ld a4,0(s2) 5c10: 853e mv a0,a5 5c12: fef719e3 bne a4,a5,5c04 <malloc+0xc2> p = sbrk(nu * sizeof(Header)); 5c16: 8552 mv a0,s4 5c18: 00000097 auipc ra,0x0 5c1c: b6c080e7 jalr -1172(ra) # 5784 <sbrk> if(p == (char*)-1) 5c20: fd5518e3 bne a0,s5,5bf0 <malloc+0xae> return 0; 5c24: 4501 li a0,0 5c26: bf45 j 5bd6 <malloc+0x94>
src/config-tasks.adb
mfkiwl/ewok-kernel-security-OS
65
19503
with interfaces; use interfaces; with types; use types; with config.memlayout; with ewok.debug; package body config.tasks with spark_mode => off is package CFGAPP renames config.applications; package CFGMEM renames config.memlayout; procedure zeroify_bss (id : in config.applications.t_real_task_id) is begin if CFGAPP.list(id).bss_size > 0 then declare bss_address : constant system_address := CFGMEM.apps_region.ram_memory_addr + CFGAPP.list(id).data_offset + to_unsigned_32 (CFGAPP.list(id).data_size) + to_unsigned_32 (CFGAPP.list(id).stack_size); bss_region : byte_array (1 .. to_unsigned_32 (CFGAPP.list(id).bss_size)) with address => to_address (bss_address); begin ewok.debug.log (ewok.debug.INFO, "zeroify bss: task " & id'image & ", at " & system_address'image (bss_address) & ", " & unsigned_16'image (CFGAPP.list(id).bss_size) & " bytes"); bss_region := (others => 0); end; end if; end zeroify_bss; procedure copy_data_to_ram (id : in config.applications.t_real_task_id) is begin if CFGAPP.list(id).data_size > 0 then declare data_in_flash_address : constant system_address := CFGMEM.apps_region.flash_memory_addr + CFGAPP.list(id).data_flash_offset; data_in_flash : byte_array (1 .. to_unsigned_32 (CFGAPP.list(id).data_size)) with address => to_address (data_in_flash_address); data_in_ram_address : constant system_address := CFGMEM.apps_region.ram_memory_addr + CFGAPP.list(id).data_offset + to_unsigned_32 (CFGAPP.list(id).stack_size); data_in_ram : byte_array (1 .. to_unsigned_32 (CFGAPP.list(id).data_size)) with address => to_address (data_in_ram_address); begin ewok.debug.log (ewok.debug.INFO, "task " & id'image & ": copy data from " & system_address'image (data_in_flash_address) & " to " & system_address'image (data_in_ram_address) & ", size " & CFGAPP.list(id).data_size'image); data_in_ram := data_in_flash; end; end if; end copy_data_to_ram; end config.tasks;
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1726.asm
ljhsiun2/medusa
9
93144
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r9 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0xfae2, %rdi nop and $64496, %rax vmovups (%rdi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r13 nop nop nop nop xor %r9, %r9 lea addresses_WC_ht+0xa2e0, %rbx nop nop nop nop xor $65467, %rsi mov (%rbx), %r10d nop nop nop nop inc %r13 lea addresses_D_ht+0x8324, %r9 nop nop nop nop nop sub %rsi, %rsi movb (%r9), %al nop nop nop sub %r9, %r9 lea addresses_UC_ht+0xaf24, %r9 clflush (%r9) nop sub %r10, %r10 mov (%r9), %edi nop nop nop nop nop add %r13, %r13 lea addresses_normal_ht+0x4114, %r13 add $31806, %rdi mov $0x6162636465666768, %rbx movq %rbx, %xmm3 movups %xmm3, (%r13) nop nop nop add %rax, %rax lea addresses_A_ht+0x16fe4, %rsi lea addresses_UC_ht+0x16224, %rdi nop nop nop nop dec %r10 mov $127, %rcx rep movsw nop nop nop and $16420, %rbx lea addresses_UC_ht+0x1daa4, %rsi lea addresses_D_ht+0x1e024, %rdi clflush (%rsi) nop nop nop nop inc %r13 mov $66, %rcx rep movsb nop nop nop nop add %rbx, %rbx lea addresses_normal_ht+0x16a24, %rsi lea addresses_A_ht+0x1004e, %rdi nop nop nop inc %rbx mov $31, %rcx rep movsl nop nop cmp %rax, %rax lea addresses_D_ht+0xba24, %rsi lea addresses_UC_ht+0xa5e2, %rdi xor %r10, %r10 mov $5, %rcx rep movsl nop nop nop xor %r10, %r10 lea addresses_UC_ht+0x1c624, %rsi lea addresses_WC_ht+0x176a4, %rdi nop nop xor %rax, %rax mov $88, %rcx rep movsl nop nop nop nop xor $40111, %r13 lea addresses_normal_ht+0x8224, %r9 nop nop nop nop cmp $39031, %r10 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 movups %xmm3, (%r9) nop nop nop nop nop cmp $58584, %r10 lea addresses_UC_ht+0x1d224, %r9 nop nop and %r13, %r13 movw $0x6162, (%r9) lfence pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r9 push %rbx push %rcx push %rsi // Store lea addresses_PSE+0x10524, %r9 nop nop nop nop add $35746, %r12 mov $0x5152535455565758, %r13 movq %r13, %xmm4 movups %xmm4, (%r9) nop xor $14934, %r9 // Store lea addresses_RW+0x6436, %rsi nop and $38244, %rbx movw $0x5152, (%rsi) nop nop nop cmp $56046, %r12 // Faulty Load lea addresses_WT+0x3a24, %r10 nop nop nop nop inc %rcx movb (%r10), %bl lea oracles, %rsi and $0xff, %rbx shlq $12, %rbx mov (%rsi,%rbx,1), %rbx pop %rsi pop %rcx pop %rbx pop %r9 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 11}} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
serial.asm
luciodj/WAV-1K
1
163885
; ; serial.asm ; #include "main.inc" #include "sdmmc.inc" GLOBAL serial_init, getch, putch, putsz, puts, GLOBAL putHex, printf, printLBA, putNL, dump serial_data IDATA _HexTemp res 1 _HexTemp2 res 1 _HexCount res 1 _HexRows res 1 _BSRsave res 1 serial CODE serial_init ; init 9600 baud @32MHz ifndef __SKIP banksel BAUD1CON set_sfr BAUD1CON, 0x08 set_sfr RC1STA, 0x90 set_sfr TX1STA, 0x24 set_sfr SP1BRGL, 0x40 set_sfr SP1BRGH, 0x03 endif retlw 1 getch ; output W = received data banksel PIR3 btfss PIR3,RCIF bra $-1 banksel RC1REG btfss RC1STA,OERR bra no_err bcf RC1STA,SPEN bsf RC1STA,SPEN no_err movf RC1REG,W return putch ; input W = data to transmit ifndef __SKIP banksel PIR3 wait_until PIR3,TXIF banksel TX1REG movwf TX1REG banksel _HexTemp endif return putsz ; input FSR1 = points to zero terminated ascii string ; moviw FSR1++ btfsc STATUS,Z return call putch goto putsz puts call putsz putNL movlw 0x0D call putch movlw 0x0A goto putch putHex ifndef __SKIP banksel _HexTemp movwf _HexTemp swapf _HexTemp,W andlw 0xf addlw 0x30 movwf _HexTemp2 movlw 0x3A subwf _HexTemp2,W movf _HexTemp2,W bnc $+2 addlw 7 call putch movf _HexTemp,W andlw 0xf addlw 0x30 movwf _HexTemp2 movlw 0x3A subwf _HexTemp2,W movf _HexTemp2,W bnc $+2 addlw 7 endif goto putch printf banksel _HexTemp ; save W movwf _HexTemp call putsz ; print string movf _HexTemp,W call putHex ; followed by the hex value of W goto putNL printLBA movf BSR,W ; save the bank banksel _BSRsave movwf _BSRsave call putsz ; print the string movf LBA+2,W ; print hex LBA call putHex movf LBA+1,W call putHex movf LBA,W call putHex ; CRLF call putNL movf _BSRsave,W movwf BSR return dump ; input W: number of rows to print ; input FSR0 : buffer pointer ifndef __SKIP banksel _HexCount movwf _HexRows dumpRowL movf FSR0L,W call putHex movlw ':' call putch movlw .16 movwf _HexCount dumpByteL moviw FSR0++ call putHex movlw ' ' call putch decfsz _HexCount goto dumpByteL call putNL decfsz _HexRows goto dumpRowL endif retlw 0 END
compiler/OQASM2.g4
czhao39/xacc-ibm
0
7763
/* * Copyright (c) 2017, UT-Battelle * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the xacc 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 <COPYRIGHT HOLDER> 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. * * Originally devloped by: * <NAME>, Oak Ridge National Laboratory, March 2017 * * Updated by: * <NAME>, Oak Ridge National Laboratory, July 2018 * * An ANTLR4 specification for Version 2.0 of the IBM Open QASM Grammar * See https://github.com/IBM/qiskit-openqasm for the written spec * */ grammar OQASM2; /* This part of the grammar is particular to XACC */ /**********************************************************************/ xaccsrc : xacckernel* ; xacckernel : '__qpu__' kernelname=id '(' 'AcceleratorBuffer' acceleratorbuffer=id ( ',' typedparam )* ')' '{' mainprog '}' ; typedparam : type param ; type : 'int' | 'double' | 'float' ; kernelcall : kernelname=id '(' param? ( ',' param )* ')' ; /***********************************************************************/ /* The main program */ mainprog : comment* OPENQASM real ';' program? ; /* The actual program statements */ program : (line)+ ; line : statement+ | comment | include+ ; /* A program statement */ statement : regdecl ';' | gatedecl | opaque ';' | qop ';' | conditional ';' | kernelcall ';' ; /* A program comment */ comment : COMMENT ; /* An include statemnent */ include : 'include' filename ';' ; filename : string ; /* Register declarations, called 'decl' in OQASM spec */ regdecl : qreg qregister | creg cregister ; /* A register and its size */ qregister : id '[' registersize ']' | id ; cregister : id '[' registersize ']' | id ; registersize : INT ; /* A gate declaration */ gatedecl : gate gatename gatearglist gatebody? ; /* A gate name */ gatename : id | id '(' paramlist? ')' ; /* A coma-separated list of gate arguments */ gatearglist : gatearg (',' gatearg)* ; /* A gate argument */ /* FIXME: Should this be qregister or anything? Spec is unclear */ gatearg : id '[' INT ']' | id ; /* The body of the gate declaration */ gatebody : '{' gateprog '}' ; /* The program defining the gate */ gateprog : gateline* ; /* statements in the gateprog must be semicolon terminated */ gateline : uop ';' ; /* A list of parameters */ paramlist : param (',' paramlist)? ; /* A parameter */ param : id ; /* An opaque gate declaration */ opaque : OPAQUE opaquename opaquearglist ; /* An opaque gate name */ opaquename : id | id '(' paramlist? ')' ; /* A coma-separated list of opaqueargs */ opaquearglist : opaquearg (',' opaquearglist)? ; /* A argument to opaque function */ opaquearg : id '[' INT ']' ; /* A quantum operation */ /* FIXME: Spec calls for 'reset' keyword but this clashes with antlr parser.reset() * we use 'reeset' instead..ha-ha, I know, right? */ qop : uop | reeset | measure | barrier ; /* A unitary operation */ uop : 'U' '(' explist? ')' gatearg # U | 'CX' gatearg ',' gatearg # CX | gatename ( '(' explist ')' )? gatearglist # UserDefGate ; /* A classical conditional expression */ conditional : 'if' '(' id '==' INT ')' action ; /* An action in a conditional branch is a quantum operation */ action : qop ; /* A list of expressions */ explist : exp ( ',' exp )* ; /* An expression */ exp : real | INT | 'pi' | id | exp '+' exp | exp '-' exp | exp '*' exp | exp '/' exp | '-'exp | exp '^' exp | '(' exp ')' | unaryop '(' exp ')' ; /* unary operations */ unaryop : 'sin' | 'cos' | 'tan' | 'exp' | 'ln' | 'sqrt' ; /* A quantum register declaration */ qreg : QREG ; /* A classical register declaration */ creg : CREG ; /* A gate declaration */ gate : GATE ; /* A measure declaration */ measure : MEASURE (qbit = gatearg | qregister) '->' (cbit = gatearg | cregister) ; /* A reset declaration */ reeset : RESET (gatearg | qregister | cregister) ; /* A barrier declaration */ barrier : BARRIER gatearglist ; /* variable identity */ id : ID ; /* real numbers */ real : REAL ; /* strings are enclosed in quotes */ string : STRING ; /* Tokens for the grammer */ /* Comment */ COMMENT : '//' ~ [\r\n]* EOL ; /* quantum register init opcode */ QREG : 'qreg' ; /* classical register init opcode */ CREG : 'creg' ; /* gate opcode */ GATE : 'gate' ; /* measurement opcode */ MEASURE : 'measure' ; /* reset opcode */ RESET : 'reset' ; /* barrier opcode */ BARRIER : 'barrier' ; /* Grammer header */ OPENQASM : 'OpenQASM' | 'OPENQASM' ; /* Opaque gate label */ OPAQUE : 'opaque' ; /* id, ego, and super-ego */ ID : [a-z][A-Za-z0-9_]* ; /* Keep it real...numbers */ REAL : INT ( '.' (INT)? ) ; /* Non-negative integers */ INT : ('0'..'9')+ ; /* Strings include numbers and slashes */ STRING : '"' ~ ["]* '"' ; /* Whitespaces, we skip'em */ WS : [ \t\r\n] -> skip ; /* This is the end of the line, boys */ EOL : '\r'? '\n' ;
samizdat-viewlog.applescript
rinchen/fesc
0
622
<gh_stars>0 on clicked theObject -- Read in the preferences try do shell script "open /var/log/news" on error display dialog "Error: /var/log/news is missing. If you recently installed Samizdat or you did not setup syslogd, this is normal." end try end clicked
setoid-cats/Category/Diagram.agda
heades/AUGL
0
4807
module Category.Diagram where open import Level renaming (suc to lsuc) open import Equality.Eq open import Setoid.Total open import Category.Category open import Category.Funct open import Category.Preorder -- Diagrams are functors from an index category J to a category ℂ. We -- think of J as the scheme of the diagram in ℂ. record Diagram {l₁ l₂ : Level} (J : Cat {l₁}) (ℂ : Cat {l₂}) : Set (l₁ ⊔ l₂) where field diag : Functor J ℂ -- A commutative diagram is a diagram from a preorder to a category ℂ. -- The preorder axiom garauntees that any diagram must commute because -- there is only one composition. Mixing this with the fact that -- functors preserve composition implies that there can only be one -- composition in ℂ. This definition goes against the references -- -- nLab and Awedoy's book -- that comm. diagrams must be functors from -- posets. In fact we can prove that a PO is enough. See the next -- module. record Comm-Diagram {l₁ l₂ : Level} (J : PO {l₁}) (ℂ : Cat {l₂}) : Set (l₁ ⊔ l₂) where field diag : Diagram (po-cat J) ℂ open Comm-Diagram -- The underlying functor of a diagram. UFunc : {l l' : Level}{J : PO {l}}{ℂ : Cat {l'}} → Comm-Diagram J ℂ → Functor (po-cat J) ℂ UFunc D = Diagram.diag (diag D) -- This module shows that comm. squares can be modeled by POs. module Commutative-Squares where open 4PO record Comm-Square' {l : Level} (ℂ : Cat {l}) (om : 4Obj → Obj ℂ) (g : el (Hom ℂ (om i₁) (om i₂))) (h : el (Hom ℂ (om i₂) (om i₄))) (j : el (Hom ℂ (om i₁) (om i₃))) (k : el (Hom ℂ (om i₃) (om i₄))) : Set l where field Sq : {a b : 4Obj {l}} → SetoidFun (4Hom a b) (Hom ℂ (om a) (om b)) sq-max₁ : ⟨ Hom ℂ (om i₁) (om i₂) ⟩[ appT Sq f₁ ≡ g ] sq-max₂ : ⟨ Hom ℂ (om i₁) (om i₃) ⟩[ appT Sq f₂ ≡ j ] sq-max₃ : ⟨ Hom ℂ (om i₂) (om i₄) ⟩[ appT Sq f₃ ≡ h ] sq-max₄ : ⟨ Hom ℂ (om i₃) (om i₄) ⟩[ appT Sq f₄ ≡ k ] sq-funct-id : {i : 4Obj} → ⟨ Hom ℂ (om i) (om i) ⟩[ appT Sq (4Id {_}{i}) ≡ id ℂ ] sq-funct-comp : ∀{i j k : 4Obj {l}}{a : el (4Hom i j)}{b : el (4Hom j k)} → ⟨ Hom ℂ (om i) (om k) ⟩[ appT Sq (a ○[ 4Comp {l}{i}{j}{k} ] b) ≡ (appT Sq a) ○[ comp ℂ ] (appT Sq b) ] open Comm-Square' -- A default function from the objects of the 4PO to the objects of -- a square in ℂ. sq-default-om : {l : Level}{ℂ : Cat {l}} → Obj ℂ → Obj ℂ → Obj ℂ → Obj ℂ → (4Obj {l} → Obj ℂ) sq-default-om A B D C i₁ = A sq-default-om A B D C i₂ = B sq-default-om A B D C i₃ = D sq-default-om A B D C i₄ = C -- Commutative squares in ℂ. Comm-Square : {l : Level}{ℂ : Cat {l}} → (A B D C : Obj ℂ) → (g : el (Hom ℂ A B)) → (h : el (Hom ℂ B C)) → (j : el (Hom ℂ A D)) → (k : el (Hom ℂ D C)) → Set l Comm-Square {_} {ℂ} A B D C g h j k = Comm-Square' ℂ (sq-default-om {_} {ℂ} A B D C) g h j k -- Commutative squares are functors. Comm-Square-is-Functor : ∀{l}{ℂ : Cat {l}}{A B D C} → {g : el (Hom ℂ A B)} → {h : el (Hom ℂ B C)} → {j : el (Hom ℂ A D)} → {k : el (Hom ℂ D C)} → Comm-Square {_} {ℂ} A B D C g h j k → Functor {l} 4cat ℂ Comm-Square-is-Functor {_} {ℂ} {A} {B} {D} {C} {g} {h} {j} {k} sq = record { omap = sq-default-om {_}{ℂ} A B D C; fmap = λ {A₁} {B₁} → Sq sq {A₁} {B₁}; idPF = sq-funct-id sq; compPF = λ {A₁} {B₁} {C₁} {f} {g₁} → sq-funct-comp sq {A₁}{B₁}{C₁}{f}{g₁} } -- The former now implies that we have a commutative diagram. Comm-Square-is-Comm-Diagram : ∀{l}{ℂ : Cat {l}}{A B D C} → {g : el (Hom ℂ A B)} → {h : el (Hom ℂ B C)} → {j : el (Hom ℂ A D)} → {k : el (Hom ℂ D C)} → Comm-Square {_} {ℂ} A B D C g h j k → Comm-Diagram {l}{l} 4po ℂ Comm-Square-is-Comm-Diagram {l}{ℂ}{g}{h}{j}{k} sq = record { diag = record { diag = Comm-Square-is-Functor sq } } -- If we have a commutative square, then it commutes in ℂ. Comm-Square-Commutes : ∀{l}{ℂ : Cat {l}}{A B D C} → {g : el (Hom ℂ A B)} → {h : el (Hom ℂ B C)} → {j : el (Hom ℂ A D)} → {k : el (Hom ℂ D C)} → Comm-Square {_} {ℂ} A B D C g h j k → ⟨ Hom ℂ A C ⟩[ g ○[ comp ℂ ] h ≡ j ○[ comp ℂ ] k ] Comm-Square-Commutes {l}{ℂ}{A}{B}{D}{C}{g}{h}{j}{k} sq with sq-funct-comp sq {i₁}{i₂}{i₄}{f₁}{f₃} | sq-funct-comp sq {i₁}{i₃}{i₄}{f₂}{f₄} ... | sq-eq₁ | sq-eq₂ with transPf (parEqPf (eqRpf (Hom ℂ A C))) (symPf (parEqPf (eqRpf (Hom ℂ A C))) sq-eq₁) sq-eq₂ ... | sq-eq₃ with eq-comp-all {_}{ℂ}{A}{B}{C}{g} {appT {_}{_}{4Hom i₁ i₂} {Hom ℂ A B} (Sq sq {i₁}{i₂}) f₁} {h} {appT (Sq sq {i₂}{i₄}) f₃} (symPf (parEqPf (eqRpf (Hom ℂ A B))) (sq-max₁ sq)) (symPf (parEqPf (eqRpf (Hom ℂ B C))) (sq-max₃ sq)) ... | sq-eq₄ with eq-comp-all {_}{ℂ}{A}{D}{C} {appT {_}{_}{4Hom i₁ i₃} {Hom ℂ A D} (Sq sq {i₁}{i₃}) f₂} {j} {appT (Sq sq {i₃}{i₄}) f₄} {k} (sq-max₂ sq) (sq-max₄ sq) ... | sq-eq₅ with transPf (parEqPf (eqRpf (Hom ℂ A C))) sq-eq₄ sq-eq₃ ... | sq-eq₆ = transPf (parEqPf (eqRpf (Hom ℂ A C))) sq-eq₆ sq-eq₅
PiQ/SAT.agda
DreamLinuxer/popl21-artifact
5
5623
<filename>PiQ/SAT.agda module PiQ.SAT where open import Data.Unit open import Data.Sum open import Data.Product open import Data.Nat open import Data.Nat.Properties open import Data.List as L open import Data.Maybe open import Relation.Binary.PropositionalEquality open import PiQ.Syntax open import PiQ.Eval open import PiQ.Examples -- Given reversible F : 𝔹^n ↔ 𝔹^n, generate a circuit to find x̅ such that F(x̅) = (𝔽,…) -- via running (LOOP F)(𝔽,𝔽̅). -- (id↔ ⊗ F)((LOOP F)(𝔽,𝔽̅)) = (𝔽,𝔽,…) LOOP : ∀ {n} → 𝔹^ n ↔ 𝔹^ n → 𝔹 ×ᵤ 𝔹^ n ↔ 𝔹 ×ᵤ 𝔹^ n LOOP {0} F = id↔ LOOP {1} F = id↔ ⊗ F LOOP {suc (suc n)} F = trace₊ ((dist ⊕ id↔) ⨾ [A+B]+C=[A+C]+B ⨾ (factor ⊕ id↔) ⨾ ((RESET ⨾ (id↔ ⊗ F) ⨾ COPY ⨾ (id↔ ⊗ ! F)) ⊕ id↔) ⨾ (dist ⊕ id↔) ⨾ [A+B]+C=[A+C]+B ⨾ (factor ⊕ (id↔ ⊗ INCR))) MERGE : (n m : ℕ) → 𝔹^ n ×ᵤ 𝔹^ m ↔ 𝔹^ (n + m) MERGE 0 m = unite⋆l MERGE 1 0 = unite⋆r MERGE 1 (suc m) = id↔ MERGE (suc (suc n)) m = assocr⋆ ⨾ (id↔ ⊗ MERGE (suc n) m) SPLIT : (n m : ℕ) → 𝔹^ (n + m) ↔ 𝔹^ n ×ᵤ 𝔹^ m SPLIT n m = ! MERGE n m ~_ : ∀ {n} → 𝔹^ (1 + n) ↔ 𝔹^ (1 + n) → 𝔹^ (1 + n) ↔ 𝔹^ (1 + n) ~_ {zero} F = F ~_ {suc n} F = F ⨾ NOT ⊗ id↔ -- Given a function G : 𝔹^n → 𝔹 there exists a reversible Gʳ : 𝔹^(1+n) ↔ 𝔹^(1+n) such that Gʳ(𝔽,xⁿ) = (F(xⁿ),…) -- SAT(Gʳ) = tt iff ∃ xⁿ . G(xⁿ) = 𝕋 SAT : ∀ {n} → 𝔹^ (1 + n) ↔ 𝔹^ (1 + n) → 𝟙 ↔ 𝟙 SAT {n} Gʳ = trace⋆ (𝔽^ (3 + n)) (id↔ ⊗ ((id↔ ⊗ (LOOP (~ Gʳ) ⨾ (id↔ ⊗ SPLIT 1 n))) ⨾ (id↔ ⊗ (assocl⋆ ⨾ (COPY ⊗ id↔) ⨾ assocr⋆)) ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ ((id↔ ⊗ MERGE 1 n) ⨾ LOOP⁻¹ (~ Gʳ))))) where LOOP⁻¹ : ∀ {n} → 𝔹^ n ↔ 𝔹^ n → 𝔹 ×ᵤ 𝔹^ n ↔ 𝔹 ×ᵤ 𝔹^ n LOOP⁻¹ F = ! (LOOP F) module SAT_test where -- Examples -- AND(𝔽,a,b) = AND(a∧b,a,b) AND : 𝔹^ 3 ↔ 𝔹^ 3 AND = FST2LAST ⨾ (dist ⨾ (id↔ ⊕ (id↔ ⊗ (dist ⨾ (id↔ ⊕ (id↔ ⊗ swap₊)) ⨾ factor))) ⨾ factor) ⨾ FST2LAST⁻¹ NAND : 𝔹^ 3 ↔ 𝔹^ 3 NAND = AND ⨾ (NOT ⊗ id↔) -- OR(𝔽,a,b) = OR(a∨b,a,b) OR : 𝔹^ 3 ↔ 𝔹^ 3 OR = FST2LAST ⨾ (dist ⨾ ((id↔ ⊗ (dist ⨾ (id↔ ⊕ (id↔ ⊗ swap₊)) ⨾ factor)) ⊕ (id↔ ⊗ (id↔ ⊗ swap₊))) ⨾ factor) ⨾ FST2LAST⁻¹ NOR : 𝔹^ 3 ↔ 𝔹^ 3 NOR = OR ⨾ (NOT ⊗ id↔) -- XOR(a,b) = XOR(a xor b,b) XOR : 𝔹^ 2 ↔ 𝔹^ 2 XOR = distl ⨾ (id↔ ⊕ (swap₊ ⊗ id↔)) ⨾ factorl tests : List ⟦ 𝔹^ 3 ⟧ tests = (𝔽 , 𝔽 , 𝔽) ∷ (𝔽 , 𝔽 , 𝕋) ∷ (𝔽 , 𝕋 , 𝔽) ∷ (𝔽 , 𝕋 , 𝕋) ∷ (𝕋 , 𝔽 , 𝔽) ∷ (𝕋 , 𝔽 , 𝕋) ∷ (𝕋 , 𝕋 , 𝔽) ∷ (𝕋 , 𝕋 , 𝕋) ∷ [] -- Ex₁(𝔽,a,b) = ((a∧b) xor (a∧b),_,_) -- ¬∃a,b . Ex₁(𝔽,a,b) = (𝕋,…) Ex₁ : 𝔹^ 3 ↔ 𝔹^ 3 Ex₁ = trace⋆ (𝔽^ 1) (swap⋆ ⨾ (id↔ ⊗ AND) ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ AND) ⨾ assocl⋆ ⨾ (XOR ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ ! AND) ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ swap⋆ ) tests₁ = L.map (eval' Ex₁) tests -- Ex₂(𝔽,a,b) = ((a∧b) xor (a∨b),_,_) -- ∃a,b . Ex₂(𝔽,a,b) = (𝕋,…) Ex₂ : 𝔹^ 3 ↔ 𝔹^ 3 Ex₂ = trace⋆ (𝔽^ 1) (swap⋆ ⨾ (id↔ ⊗ AND) ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ OR) ⨾ assocl⋆ ⨾ (XOR ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ ! OR) ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ swap⋆ ) tests₂ = L.map (eval' Ex₂) tests -- Ex₃(𝔽,a,b) = (((a∧b) ∧ (a xor b)),_,_) -- ¬∃a,b . Ex₃(𝔽,a,b) = (𝕋,…) Ex₃ : 𝔹^ 3 ↔ 𝔹^ 3 Ex₃ = trace⋆ (𝔽^ 1) (swap⋆ ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ id↔ ⊗ F ⨾ (id↔ ⊗ assocl⋆) ⨾ assocl⋆ ⨾ (AND ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ assocr⋆) ⨾ id↔ ⊗ ! F ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ swap⋆) where F : 𝔹^ 3 ↔ 𝔹^ 3 F = AND ⨾ (id↔ ⊗ XOR) tests₃ = L.map (eval' Ex₃) tests -- Ex₄(𝔽,a,b) = (((a∨b) ∧ (a xor b)),_,_) -- ∃a,b . Ex₄(𝔽,a,b) = (𝕋,…) Ex₄ : 𝔹^ 3 ↔ 𝔹^ 3 Ex₄ = trace⋆ (𝔽^ 1) (swap⋆ ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ id↔ ⊗ F ⨾ (id↔ ⊗ assocl⋆) ⨾ assocl⋆ ⨾ (AND ⊗ id↔) ⨾ assocr⋆ ⨾ (id↔ ⊗ assocr⋆) ⨾ id↔ ⊗ ! F ⨾ assocl⋆ ⨾ (swap⋆ ⊗ id↔) ⨾ assocr⋆ ⨾ swap⋆) where F : 𝔹^ 3 ↔ 𝔹^ 3 F = OR ⨾ (id↔ ⊗ XOR) tests₄ = L.map (eval' Ex₄) tests SAT-tests : List (𝟙 ↔ 𝟙) SAT-tests = (SAT AND) ∷ (SAT OR) ∷ (SAT XOR) ∷ (SAT Ex₁) ∷ (SAT Ex₂) ∷ (SAT Ex₃) ∷ (SAT Ex₄) ∷ [] results : List (Maybe (Σ[ t ∈ 𝕌 ] ⟦ t ⟧) × ℕ) results = L.map (λ c → eval' c tt) SAT-tests -- (just (𝟙 , tt) , 3923) ∷ -- (just (𝟙 , tt) , 2035) ∷ -- (just (𝟙 , tt) , 1347) ∷ -- (nothing , 10386) ∷ -- (just (𝟙 , tt) , 4307) ∷ -- (nothing , 11442) ∷ -- (just (𝟙 , tt) , 4827) ∷ []
Transynther/x86/_processed/US/_zr_/i7-8650U_0xd2.log_2213_649.asm
ljhsiun2/medusa
9
9031
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x15342, %r9 nop nop nop sub $284, %r14 vmovups (%r9), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %r15 nop nop nop xor $46912, %rdi lea addresses_UC_ht+0xad96, %r9 nop nop dec %rdx mov (%r9), %r13w inc %r9 lea addresses_WT_ht+0x12bbc, %r13 add %rdx, %rdx mov $0x6162636465666768, %rdi movq %rdi, (%r13) nop nop nop nop add %rdx, %rdx lea addresses_WT_ht+0x8032, %rsi lea addresses_A_ht+0x160e2, %rdi nop nop sub %rdx, %rdx mov $109, %rcx rep movsl nop nop nop nop add $64876, %rcx lea addresses_WT_ht+0x1c0e2, %rsi lea addresses_UC_ht+0x989e, %rdi nop nop nop nop and %r14, %r14 mov $37, %rcx rep movsb nop inc %rdx lea addresses_normal_ht+0x11402, %rcx nop add %r13, %r13 movl $0x61626364, (%rcx) nop nop nop xor %r14, %r14 lea addresses_WT_ht+0xf65c, %rsi xor %rdi, %rdi mov (%rsi), %cx and %r9, %r9 lea addresses_WT_ht+0x12b20, %rdx nop nop nop cmp %rsi, %rsi movw $0x6162, (%rdx) nop sub %rdx, %rdx lea addresses_UC_ht+0x48e2, %rsi lea addresses_UC_ht+0xd882, %rdi clflush (%rsi) nop cmp $26759, %r13 mov $4, %rcx rep movsw nop nop nop nop cmp %rdx, %rdx lea addresses_normal_ht+0xe5a2, %rsi lea addresses_UC_ht+0x1bcfa, %rdi clflush (%rdi) nop nop xor $5873, %rdx mov $83, %rcx rep movsb nop nop sub %r9, %r9 lea addresses_WT_ht+0x102d6, %r9 nop nop nop nop nop dec %rsi movb $0x61, (%r9) nop nop nop nop nop and $28449, %r13 lea addresses_WC_ht+0x130e2, %rsi lea addresses_UC_ht+0x14e2, %rdi nop xor $60967, %r13 mov $90, %rcx rep movsq xor $61755, %r14 lea addresses_normal_ht+0xb4e2, %r15 nop nop xor %r9, %r9 mov (%r15), %r13d nop nop nop xor %r13, %r13 lea addresses_A_ht+0x6d82, %rdx nop nop nop nop nop inc %rdi mov $0x6162636465666768, %r14 movq %r14, (%rdx) nop nop nop nop nop xor $30383, %rdx lea addresses_D_ht+0x1d462, %rcx nop nop nop nop nop sub %rdx, %rdx mov (%rcx), %r9d add %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %rbp push %rbx push %rcx push %rdx push %rsi // Store lea addresses_WT+0x11262, %rbx nop nop nop inc %rdx movb $0x51, (%rbx) and %rbx, %rbx // Store lea addresses_D+0x1b1ec, %r11 nop nop nop nop nop and $9329, %rcx movw $0x5152, (%r11) sub %rbx, %rbx // Store lea addresses_WC+0x9b22, %rbp clflush (%rbp) nop nop nop xor $7627, %r11 mov $0x5152535455565758, %rbx movq %rbx, %xmm1 vmovups %ymm1, (%rbp) and %rdx, %rdx // Store lea addresses_normal+0x1dce2, %rbx nop nop inc %rcx mov $0x5152535455565758, %rbp movq %rbp, %xmm6 movntdq %xmm6, (%rbx) nop nop nop add %rbp, %rbp // Store lea addresses_PSE+0xd69a, %rdx nop nop nop and %rsi, %rsi mov $0x5152535455565758, %rcx movq %rcx, (%rdx) nop and $27602, %rdx // Store lea addresses_normal+0x10e02, %r11 xor $14986, %rdx mov $0x5152535455565758, %rbx movq %rbx, (%r11) // Exception!!! nop nop nop nop mov (0), %rsi nop nop nop nop nop xor $18200, %rbx // Faulty Load lea addresses_US+0x40e2, %rbx nop nop xor $51067, %rcx mov (%rbx), %r10w lea oracles, %rsi and $0xff, %r10 shlq $12, %r10 mov (%rsi,%r10,1), %r10 pop %rsi pop %rdx pop %rcx pop %rbx pop %rbp pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True, 'NT': True, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'00': 2213} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
alloy4fun_models/trashltl/models/1/LM3DTgWzAHAZqziwZ.als
Kaixi26/org.alloytools.alloy
0
1267
<reponame>Kaixi26/org.alloytools.alloy open main pred idLM3DTgWzAHAZqziwZ_prop2 { some File since no File } pred __repair { idLM3DTgWzAHAZqziwZ_prop2 } check __repair { idLM3DTgWzAHAZqziwZ_prop2 <=> prop2o }
src/util/sprite/f7.asm
olifink/qspread
0
4813
<gh_stars>0 * Sprite f7 section sprite xdef mes_f7 include 'dev8_keys_sysspr' mes_f7 dc.b 0,sp.f7 * end
oeis/023/A023551.asm
neoneye/loda-programs
11
94421
<reponame>neoneye/loda-programs<gh_stars>10-100 ; A023551: Self-convolution of natural numbers >= 3. ; 9,24,46,76,115,164,224,296,381,480,594,724,871,1036,1220,1424,1649,1896,2166,2460,2779,3124,3496,3896,4325,4784,5274,5796,6351,6940,7564,8224,8921,9656,10430,11244,12099,12996,13936,14920,15949,17024,18146,19316,20535,21804,23124,24496,25921,27400,28934,30524,32171,33876,35640,37464,39349,41296,43306,45380,47519,49724,51996,54336,56745,59224,61774,64396,67091,69860,72704,75624,78621,81696,84850,88084,91399,94796,98276,101840,105489,109224,113046,116956,120955,125044,129224,133496,137861,142320 add $0,3 mov $1,10 add $1,$0 bin $0,2 mul $0,$1 div $0,3 sub $0,4
Driver/Printer/PScript/pscriptPDL.asm
steakknife/pcgeos
504
19916
<filename>Driver/Printer/PScript/pscriptPDL.asm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Berkeley Softworks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: PostScript printer driver FILE: pscriptPDL.asm AUTHOR: <NAME>, 14 Feb 1991 ROUTINES: Name Description ---- ----------- PrintSetPageTransform PDL-specific function to set the transformation matrix for the current page PrintGString PDL_specific function to print a gstring REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 2/91 Initial revision DESCRIPTION: This file containt the escape functions that are specific to PDL printers $Id: pscriptPDL.asm,v 1.1 97/04/18 11:56:09 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CommonCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintSetPageTransform %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the transformatrion matrix for the current page CALLED BY: GLOBAL (DR_PRINT_ESC_SET_PAGE_TRANSFORM) PASS: bx - PState handle dx:si - pointer to TransMatrix RETURN: ax - error code as returned from TransExportRaw DESTROYED: nothing PSEUDO CODE/STRATEGY: emit some PostScript code to set the current transformation matrix variable. This code assumes a function that currently exists in the PC/GEOS PostScript prolog called SDT (for SetDefaultTransform). This function (currently) does not alter the PostScript graphics state, it merely sets a PC/GEOS-defined PostScript variable, and is used later to set the default transformation for the page. Also, the passed TransMatrix should NOT include the transformation required to conform to the PostScript coordinate system. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 02/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrintSetPageTransform proc far uses es, di, bx, bp .enter ; we're passed a PState handle, not the segment here. push bx ; save handle call MemLock mov bp, ax ; usually held here mov es, ax ; es -> PState ; we need to translate all the values into ascii, then write ; out a buffer with the matrix and the function call. First ; lock down the PState and get the file handle to write to. mov ds, dx mov dx, es:[PS_expansionInfo] ; get options blk han push es ; save PState seg mov bx, dx call MemLock mov es, ax mov di, es:[GEO_hFile] ; get file handle call MemUnlock pop es ; restore PState seg call EmitTransform ; send transform ; now set the paper size (so the reversal of the coordinate ; system will work OK) call EmitPaperSize ; ; release the PState before we go pop bx call MemUnlock clc ; just leave carry .leave ret PrintSetPageTransform endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintGString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Print a graphics string CALLED BY: GLOBAL (DR_PRINT_ESC_PRINT_GSTRING) PASS: bx - PState handle si - GString handle cx - GString flags (record, type GSControl) RETURN: ax - stop code returned from GrDrawGString DESTROYED: nothing PSEUDO CODE/STRATEGY: pass off all the work to the PostScript Translation Lib KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 02/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrintGString proc far uses ds, dx, di, cx, bx, bp .enter ; first we need to lock down the PState push bx call MemLock mov bp, ax ; this is easy. Just call the TransExport function in the ; PostScript translation library mov ds, bp ; ds -> PState mov dx, ds:[PS_expansionInfo] ; get opts block handle mov bx, dx call MemLock mov ds, ax mov di, ds:[GEO_hFile] ; get file handle call MemUnlock or cx, mask GSC_NEW_PAGE ; make sure this is set mov ds, bp ; ds -> PState mov bx, ds:[PS_epsLibrary] mov ax, TR_EXPORT_LOW call CallEPSLibrary mov ax, cx ; return flag fr GrDrawGString ; release the PState pop bx call MemUnlock clc .leave ret PrintGString endp CommonCode ends
tests/crew-test_data-tests.ads
thindil/steamsky
80
20442
-- This package has been generated automatically by GNATtest. -- Do not edit any part of it, see GNATtest documentation for more details. -- begin read only with Gnattest_Generated; package Crew.Test_Data.Tests is type Test is new GNATtest_Generated.GNATtest_Standard.Crew.Test_Data .Test with null record; procedure Test_GainExp_685058_5db064(Gnattest_T: in out Test); -- crew.ads:277:4:GainExp:Test_GainExp procedure Test_GenerateMemberName_b4591b_b29bd9(Gnattest_T: in out Test); -- crew.ads:291:4:GenerateMemberName:Test_GenerateMemberName procedure Test_FindCabin_c60907_006804(Gnattest_T: in out Test); -- crew.ads:307:4:FindCabin:Test_FindCabin procedure Test_UpdateCrew_123b55_011eae(Gnattest_T: in out Test); -- crew.ads:319:4:UpdateCrew:Test_UpdateCrew procedure Test_WaitForRest_237f93_b046aa(Gnattest_T: in out Test); -- crew.ads:328:4:WaitForRest:Test_WaitForRest procedure Test_GetSkillLevelName_b5615e_35c4c0(Gnattest_T: in out Test); -- crew.ads:340:4:GetSkillLevelName:Test_GetSkillLevelName procedure Test_GetAttributeLevelName_ac08df_7fd836(Gnattest_T: in out Test); -- crew.ads:352:4:GetAttributeLevelName:Test_GetAttributeLevelName procedure Test_DailyPayment_62db86_0bfd06(Gnattest_T: in out Test); -- crew.ads:361:4:DailyPayment:Test_DailyPayment procedure Test_GetTrainingToolQuality_32b7f3_512b79 (Gnattest_T: in out Test); -- crew.ads:376:4:GetTrainingToolQuality:Test_GetTrainingToolQuality end Crew.Test_Data.Tests; -- end read only
Categories/Coequalizer.agda
copumpkin/categories
98
5148
module Categories.Coequalizer where
1A/S5/PIM/tps/tp4/exemple_dates.adb
MOUDDENEHamza/ENSEEIHT
4
1539
<filename>1A/S5/PIM/tps/tp4/exemple_dates.adb with Ada.Text_IO; use Ada.Text_IO; with Dates; use Dates; procedure Exemple_Dates is Une_Date : T_Date; begin -- Initialiser une date Initialiser (Une_Date, 1, OCTOBRE, 2018); -- L'afficher Afficher (Une_Date); New_Line; end Exemple_Dates;
1-ep_AppDev/src/value_cycle_time.asm
brown9804/Dragon12_MC9S12DP256
0
104428
<reponame>brown9804/Dragon12_MC9S12DP256 ; Autor: ; <NAME>, Belinda ; <EMAIL> ; Initial position of BClr is $E5 LDD #$FE3D LDX #$1030 LDAB #$10 STD b,X ;- ; B -> $1041 mem position ... value $FE ; A -> $1040 mem position ... value $E5 BSET b,X,$55 ; $FE | $55 = $FF (+) BCLR a,X,$37 ; $E5 * ~($37) = $C0 LDD #$FE3D ; 2 cycles LDX #$1030 ; 2 cycles LDAB #$10 ; 1 cycles STD b,X ; 2 cycles BSET b,X,$55 ; 4 cycles BCLR a,X,$37 ; 4 cycles ; -------------- ; 15 cycles ;Time ----> 15 cycles .... ; (1/24 MHz) * 15 cycles = 6.25 ×10-9 seconds
externals/mpir-3.0.0/mpn/x86_64w/divrem_2.asm
JaminChan/eos_win
12
4046
<filename>externals/mpir-3.0.0/mpn/x86_64w/divrem_2.asm<gh_stars>10-100 ; PROLOGUE(mpn_divrem_2) ; x86-64 mpn_divrem_2 -- Divide an mpn number by a normalized 2-limb number. ; Copyright 2007, 2008 Free Software Foundation, Inc. ; Copyright <NAME> 2010 (Conversion to yasm format) ; This file is part of the GNU MP Library. ; The GNU MP Library is free software; you can redistribute it and/or modify ; it under the terms of the GNU Lesser General Public License as published ; by the Free Software Foundation; either version 3 of the License, or (at ; your option) any later version. ; The GNU MP Library is distributed in the hope that it will be useful, but ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public ; License for more details. ; You should have received a copy of the GNU Lesser General Public License ; mp_limb_t mpn_divrem_2(mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr) ; rax rdi rsi rdx rcx r8 ; rax rcx rdx r8 r9 [rsp+40] %include 'yasm_mac.inc' BITS 64 TEXT %define reg_save_list rbx, rbp, rsi, rdi, r12, r13, r14, r15 xalign 16 WIN64_GCC_PROC mpn_divrem_2, 5, frame lea rax, [rdx+rcx*8] mov r13, rsi lea r12, [rax-24] mov rbp, rdi mov r11, [r8+8] mov r9, [rax-8] mov r8, [r8] mov r10, [rax-16] xor r15d, r15d cmp r11, r9 ja .1 setb dl cmp r8, r10 setbe al or dl, al jne .10 .1: lea rbx, [rcx+r13-3] test rbx, rbx js .14 mov rdx, r11 mov rax, -1 not rdx div r11 mov rdx, r11 mov rdi, rax imul rdx, rax mov r14, rdx mul r8 mov rcx, rdx mov rdx, -1 add r14, r8 adc rdx, 0 add r14, rcx adc rdx, 0 js .3 .2: dec rdi sub r14, r11 sbb rdx, 0 jns .2 .3: %ifdef NEW lea rbp, [rbp+rbx*8] mov rcx, rbx mov rbx, r9 mov r9, rdi mov r14, r10 mov rsi, r11 neg rsi xalign 16 .4: mov rax, r9 mul rbx add rax, r14 mov r10, rax adc rdx, rbx mov rdi, rdx imul rdx, rsi mov rax, r8 lea rbx, [rdx+r14] mul rdi xor r14d, r14d cmp r13, rcx jg .5 mov r14, [r12] sub r12, 8 .5: sub r14, r8 sbb rbx, r11 sub r14, rax sbb rbx, rdx inc rdi xor edx, edx cmp rbx, r10 mov rax, r8 adc rdx, -1 add rdi, rdx and rax, rdx and rdx, r11 add r14, rax adc rbx, rdx cmp rbx, r11 jae .11 .6: mov [rbp], rdi sub rbp, 8 dec rcx jns .4 mov r10, r14 mov r9, rbx %else lea rbp, [rbp+rbx*8] mov rcx, rbx mov rax, r9 mov rsi, r10 xalign 16 .7: mov r14, rax mul rdi mov r9, r11 add rax, rsi mov rbx, rax adc rdx, r14 lea r10, [rdx+1] mov rax, rdx imul r9, rdx sub rsi, r9 xor r9d, r9d mul r8 cmp r13, rcx jg .8 mov r9, [r12] sub r12, 8 .8: sub r9, r8 sbb rsi, r11 sub r9, rax sbb rsi, rdx cmp rsi, rbx sbb rax, rax not rax add r10, rax mov rbx, r8 and rbx, rax and rax, r11 add r9, rbx adc rax, rsi cmp r11, rax jbe .12 .9: mov [rbp], r10 sub rbp, 8 mov rsi, r9 dec rcx jns .7 mov r10, rsi mov r9, rax %endif jmp .14 .10:inc r15d sub r10, r8 sbb r9, r11 jmp .1 %ifdef NEW .11:seta dl cmp r14, r8 setae al orb al, dl je .6 inc rdi sub r14, r8 sbb rbx, r11 jmp .6 %else .12:jb .13 cmp r9, r8 jb .9 .13:inc r10 sub r9, r8 sbb rax, r11 jmp .9 %endif .14:mov [r12+8], r10 mov [r12+16], r9 mov rax, r15 WIN64_GCC_END end
projects/batfish/src/main/antlr4/org/batfish/grammar/flatjuniper/FlatJuniper_isis.g4
sskausik08/Wilco
1
318
parser grammar FlatJuniper_isis; import FlatJuniper_common; options { tokenVocab = FlatJuniperLexer; } is_export : EXPORT ( policies += variable )+ ; is_interface : INTERFACE ( id = interface_id | WILDCARD ) ( apply | isi_level | isi_null | isi_passive | isi_point_to_point ) ; is_level : LEVEL ( DEC | WILDCARD ) ( isl_disable | isl_enable | isl_null | isl_wide_metrics_only ) ; is_no_ipv4_routing : NO_IPV4_ROUTING ; is_null : ( LSP_LIFETIME | SPF_OPTIONS | OVERLOAD | TRACEOPTIONS ) null_filler ; is_rib_group : RIB_GROUP INET name = variable ; is_traffic_engineering : TRAFFIC_ENGINEERING ( ist_credibility_protocol_preference | ist_family_shortcuts | ist_multipath ) ; isi_level : LEVEL DEC ( isil_enable | isil_metric | isil_te_metric | isil_null ) ; isi_null : ( BFD_LIVENESS_DETECTION | HELLO_PADDING | LSP_INTERVAL | NO_ADJACENCY_DOWN_NOTIFICATION ) null_filler ; isi_passive : PASSIVE ; isi_point_to_point : POINT_TO_POINT ; isil_enable : ENABLE ; isil_metric : METRIC DEC ; isil_null : ( HELLO_AUTHENTICATION_KEY | HELLO_AUTHENTICATION_TYPE | HELLO_INTERVAL | HOLD_TIME ) null_filler ; isil_te_metric : TE_METRIC DEC ; isl_disable : DISABLE ; isl_enable : ENABLE ; isl_null : ( AUTHENTICATION_KEY | AUTHENTICATION_TYPE | PREFIX_EXPORT_LIMIT ) null_filler ; isl_wide_metrics_only : WIDE_METRICS_ONLY ; ist_credibility_protocol_preference : CREDIBILITY_PROTOCOL_PREFERENCE ; ist_family_shortcuts : FAMILY ( INET | INET6 ) SHORTCUTS ; ist_multipath : MULTIPATH LSP_EQUAL_COST ; p_isis : ISIS ( apply | is_export | is_interface | is_level | is_null | is_no_ipv4_routing | is_rib_group | is_traffic_engineering ) ;
dino/lcs/123p/A3.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
8568
<gh_stars>1-10 copyright zengfr site:http://github.com/zengfr/romhack 004DDE move.b D0, ($a3,A0) 004DE2 move.b D0, ($4e6,A5) [123p+ A3] 0163E6 move.b ($a3,A6), D0 0163EA move.w D0, (A0) [123p+ A3] 018446 add.b ($3317,A5), D0 01844A tst.b ($33f4,A5) [123p+ A3] 018452 add.b ($3497,A5), D0 018456 tst.b ($3574,A5) [123p+ A3] 01845E add.b ($3617,A5), D0 018462 add.b D0, D0 [123p+ A3] 018538 tst.b ($a3,A6) 01853C beq $18564 [123p+ A3] 01BFD0 move.b ($a3,A6), D0 [123p+ 5] 01BFD4 beq $1c016 [123p+ A3] 01BFD6 subq.b #1, ($a3,A6) 01BFDA bpl $1bfe0 [123p+ A3] 01BFEC addq.b #1, ($a3,A6) 01BFF0 jsr $184e2.l [123p+ A3] 01BFF6 subq.b #1, ($a3,A6) 01BFFA move.b ($24,A6), D5 [123p+ A3] copyright zengfr site:http://github.com/zengfr/romhack
include/gid/gid-decoding_pnm.ads
docandrew/troodon
5
3106
-- Portable pixmap format (PPM) -- Portable graymap format (PGM) -- Portable bitmap format (PBM) private package GID.Decoding_PNM is -------------------- -- Image decoding -- -------------------- generic type Primary_color_range is mod <>; with procedure Set_X_Y (x, y: Natural); with procedure Put_Pixel ( red, green, blue : Primary_color_range; alpha : Primary_color_range ); with procedure Feedback (percents: Natural); -- procedure Load (image: in out Image_descriptor); function Get_Token( stream : Stream_Access; needs_EOL : Boolean:= False; single_char : Boolean:= False ) return String; function Get_Integer( stream : Stream_Access; needs_EOL : Boolean:= False; single_char : Boolean:= False ) return Integer; function Get_Positive_32( stream : Stream_Access; needs_EOL : Boolean:= False; single_char : Boolean:= False ) return Positive_32; end GID.Decoding_PNM;
oeis/003/A003714.asm
neoneye/loda-programs
11
27567
; A003714: Fibbinary numbers: if n = F(i1) + F(i2) + ... + F(ik) is the Zeckendorf representation of n (i.e., write n in Fibonacci number system) then a(n) = 2^(i1 - 2) + 2^(i2 - 2) + ... + 2^(ik - 2). Also numbers whose binary representation contains no two adjacent 1's. ; Submitted by <NAME> ; 0,1,2,4,5,8,9,10,16,17,18,20,21,32,33,34,36,37,40,41,42,64,65,66,68,69,72,73,74,80,81,82,84,85,128,129,130,132,133,136,137,138,144,145,146,148,149,160,161,162,164,165,168,169,170,256,257,258,260,261,264,265,266,272,273,274,276,277,288,289,290,292,293,296,297,298,320,321,322,324,325,328,329,330,336,337,338,340,341,512,513,514,516,517,520,521,522,528,529,530 seq $0,22340 ; Even Fibbinary numbers (A003714); also 2*Fibbinary(n). div $0,2
dino/lcs/item/0.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
165817
<filename>dino/lcs/item/0.asm copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 0048E6 move.l D0, (A4)+ 0048E8 move.l D0, (A4)+ 004AC2 cmpi.b #$1, ($0,A6) 004AC8 bne $4ada [item+ 0] 004B80 cmpi.b #$1, ($0,A6) 004B86 bne $4b3e [item+ 0] 004D38 move.l D0, (A4)+ 004D3A move.l D0, (A4)+ 005ACC cmpi.b #$1, ($0,A1) 005AD2 bne $5bd6 [item+ 0] 005BEE tst.b ($0,A0) 005BF2 beq $5c08 [item+ 0] 005CB8 tst.b ($0,A0) 005CBC beq $5cd2 [item+ 0] 005E6E tst.b ($0,A0) 005E72 beq $5e88 [item+ 0] 0065AE move.b #$1, ($0,A0) 0065B4 move.w ($2,A6), ($2,A0) [item+ 0] 00AA98 tst.b ($0,A0) 00AA9C beq $aaba [item+ 0] 00FE30 move.b #$1, ($0,A0) 00FE36 move.w ($4,A2), ($20,A0) [enemy+ 0, etc+ 0, item+ 0] 011984 btst #$0, ($0,A3) 01198A beq $1199c [item+ 0] 011FDE move.b #$2, ($0,A3) 011FE4 move.b ($2,A2), ($2,A3) [item+ 0] 0120FE cmpa.l (A2), A3 012100 beq $12132 [item+ 0, item+ 2] 012158 move.b #$2, ($0,A3) 01215E move.b ($5e,A2), ($5e,A3) [item+ 0] 012312 move.b #$2, ($0,A3) 012318 move.b #$ff, ($2,A3) [item+ 0] 0233CE tst.b ($0,A6) 0233D2 beq $233d8 [item+ 0] 0248C6 move.b #$2, ($0,A6) 0248CC bra $248f0 [item+ 0] 024B90 move.b #$1, ($0,A0) 024B96 move.w #$0, ($20,A0) [item+ 0] 024BD4 move.b #$1, ($0,A0) 024BDA move.w #$10, ($20,A0) [item+ 0] 024C0E move.b #$1, ($0,A0) 024C14 move.w #$24, ($20,A0) [item+ 0] 025EC2 move.b #$2, ($0,A6) 025EC8 bra $25ef2 [item+ 0] 02607A move.b #$2, ($0,A6) [item+59] 026080 move.w #$500, ($16,A6) [item+ 0] 026136 btst #$0, ($0,A6) 02613C beq $26146 [item+ 0] 026270 move.b #$1, ($0,A0) 026276 move.w ($2,A6), ($2,A0) [item+ 0] 02641E move.b #$1, ($0,A0) 026424 move.w ($2,A6), ($2,A0) [item+ 0] 02645E move.b #$1, ($0,A0) 026464 move.w ($2,A6), ($2,A0) [item+ 0] 026496 move.b #$1, ($0,A0) 02649C move.w ($2,A6), ($2,A0) [item+ 0] 027DE2 move.b #$1, ($0,A0) 027DE8 move.w ($2,A6), ($2,A0) [item+ 0] 028E28 move.b #$2, ($0,A6) 028E2E subq.b #1, D0 [item+ 0] 028E38 move.b #$1, ($0,A6) 028E3E moveq #$1, D1 [item+ 0] 029130 move.b #$2, ($0,A6) 029136 moveq #$0, D0 [item+ 0] 029E6C move.b #$1, ($0,A0) 029E72 move.w ($2,A6), ($2,A0) [item+ 0] 029FDE move.b #$1, ($0,A0) 029FE4 move.w ($2,A6), ($2,A0) [item+ 0] 02A506 move.b #$1, ($0,A0) 02A50C move.w #$2c, ($20,A0) [item+ 0] 032768 tst.b ($0,A0) 03276C beq $327be [item+ 0] 05139C move.b #$1, ($0,A0) 0513A2 move.w #$0, ($20,A0) [item+ 0] 055A4C move.b #$1, ($0,A0) 055A52 move.w #$0, ($20,A0) [item+ 0] 05738E move.b #$1, ($0,A0) 057394 move.w #$0, ($20,A0) [item+ 0] 05F056 move.b #$1, ($0,A0) 05F05C move.w #$0, ($20,A0) [item+ 0] 07B73A move.b #$1, ($0,A0) 07B740 move.w ($2,A6), ($2,A0) [item+ 0] 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
compiler/asm/stdlib/main.asm
Champii/Twio
0
89607
dw videoaddr 0 dw ursor 0 global strlen: push c put [bp-4] c put 0 a loop2: inc c inc a cmp [c]B 0 jneq :loop2 pop c ret global putstr: push c put [bp-4] c loop: push [c]B call :aff pop inc c cmp [c]B 0 jneq :loop pop c ret global aff: push a push b put [bp-4] a put [videoaddr] b add [ursor] b outb b a inc [ursor] pop b pop a ret
programs/oeis/048/A048330.asm
neoneye/loda
22
160198
<reponame>neoneye/loda<filename>programs/oeis/048/A048330.asm ; A048330: a(n) in base 5 is a repdigit. ; 0,1,2,3,4,6,12,18,24,31,62,93,124,156,312,468,624,781,1562,2343,3124,3906,7812,11718,15624,19531,39062,58593,78124,97656,195312,292968,390624,488281,976562,1464843,1953124,2441406,4882812,7324218,9765624,12207031,24414062,36621093,48828124,61035156,122070312,183105468,244140624,305175781,610351562,915527343,1220703124,1525878906,3051757812,4577636718,6103515624,7629394531,15258789062,22888183593,30517578124,38146972656,76293945312,114440917968,152587890624,190734863281,381469726562,572204589843,762939453124,953674316406,1907348632812,2861022949218,3814697265624,4768371582031,9536743164062,14305114746093,19073486328124,23841857910156,47683715820312,71525573730468,95367431640624,119209289550781,238418579101562,357627868652343,476837158203124,596046447753906,1192092895507812,1788139343261718,2384185791015624,2980232238769531,5960464477539062,8940696716308593,11920928955078124,14901161193847656,29802322387695312,44703483581542968,59604644775390624,74505805969238281,149011611938476562,223517417907714843 mov $3,1 lpb $0 lpb $0 mov $2,$0 trn $0,4 mul $3,5 add $1,$3 lpe mul $1,$2 lpe div $1,5 mov $0,$1
applet/aide/source/aide.adb
charlie5/aIDE
3
19178
<gh_stars>1-10 with aIDE.GUI, aIDE.Palette.of_packages, AdaM.Entity, AdaM.parse, AdaM.Assist, AdaM.compilation, AdaM.library_Item, AdaM.library_Unit, AdaM.library_Unit.a_body, AdaM.Partition, AdaM.Program, AdaM.program_Library, AdaM.program_Unit, AdaM.task_Unit, AdaM.protected_Unit, AdaM.protected_Entry, AdaM.generic_Unit, AdaM.Declaration.of_package, AdaM.Declaration.of_exception, AdaM.Declaration.of_generic, AdaM.Declaration.of_instantiation, AdaM.Declaration.of_type, AdaM.Declaration.of_subtype, AdaM.Declaration.of_object, AdaM.Declaration.of_subprogram, AdaM.Declaration.of_number, AdaM.Declaration.of_null_procedure, AdaM.Declaration.of_expression_function, AdaM.Declaration.of_renaming.a_generic, AdaM.Declaration.of_renaming.a_package, AdaM.Declaration.of_renaming.a_subprogram, AdaM. package_Body, AdaM.subprogram_Body, AdaM.with_Clause, AdaM. use_Clause, AdaM. use_Clause.for_package, AdaM. use_Clause.for_type, AdaM.context_Clause, AdaM.context_Item, AdaM.body_Stub, Shell, ada.Directories, ada.Characters.handling, ada.Strings.unbounded, ada.Streams.Stream_IO, ada.Text_IO; package body aIDE is -- Applet State -- first_Run : Boolean := False; pragma Unreferenced (first_Run); procedure define_standard_Ada_Types is use Shell, ada.Text_IO; begin -- Build the standard ada tree file. -- -- put_Line ("rm *.adt: " & command_Output (to_Command ("rm ./*.adt"))); -- put_Line ("gnatmake output: " & Command_Output (to_Command ("gnatmake -c -gnatc -gnatt ./assets/asis/all_standard_ada.adb"))); -- the_Environ := AdaM.Assist.known_Environment; -- the_Environ.print; -- the_entity_Environ := AdaM.Assist.known_Entities; -- the_entity_Environ := AdaM.parse; the_entity_Environ.add_package_Standard; -- for Each of ada_Family -- loop -- declare -- Prefix : constant String := "/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/adainclude/"; -- Arg : constant String := Each.all; -- begin -- AdaM.parse (Prefix & Arg, into => the_entity_Environ); -- end; -- end loop; declare Prefix : constant String := "/eden/forge/applet/tool/aIDE/applet/aide/test/"; Arg : constant String := "test_package.ads"; begin AdaM.parse (Prefix & Arg, into => the_entity_Environ); end; the_entity_Environ.print_Entities; end define_standard_Ada_Types; procedure define is use ada.Directories; begin -- Restore the aIDE applets persistent state. -- declare use AdaM, ada.Streams.Stream_IO; the_File : File_Type; the_Stream : Stream_Access; begin open (the_File, in_File, ".adam-store/aide.stream"); the_Stream := Stream (the_File); -- AdaM.Environment.item'read (the_Stream, the_Environ); AdaM.Environment.item'read (the_Stream, the_entity_Environ); Subprogram.view 'read (the_Stream, the_selected_App); Subprogram.Vector 'read (the_Stream, all_Apps); Palette.of_packages.recent_Packages.read (the_Stream); a_Package .view 'read (the_Stream, the_applet_Package); close (the_File); exception when ada.Streams.Stream_IO.Name_Error => first_Run := True; Ada.Text_IO.put_Line ("define_standard_Ada_Types **************************************"); define_standard_Ada_Types; the_selected_App := Subprogram.new_Subprogram (Name => anonymous_Procedure); -- Create initial test precedure.. all_Apps.append (the_selected_App); the_applet_Package := the_entity_Environ.standard_Package; -- the_applet_Package := the_entity_Environ.find ("Ada.Strings"); end; end define; procedure destruct is begin -- Store the aIDE applets persistent state. -- declare use AdaM, ada.Streams.Stream_IO; the_File : File_Type; the_Stream : Stream_Access; begin create (the_File, out_File, ".adam-store/aide.stream"); the_Stream := Stream (the_File); -- AdaM.Environment.item'write (the_Stream, the_Environ); AdaM.Environment.item'write (the_Stream, the_entity_Environ); Subprogram.view 'write (the_Stream, the_selected_App); Subprogram.vector 'write (the_Stream, all_Apps); Palette.of_packages.recent_Packages.write (the_Stream); a_Package.view 'write (the_Stream, the_applet_Package); close (the_File); end; end destruct; procedure start is begin aIDE.define; aIDE.GUI.open; end start; procedure stop is begin aIDE.destruct; end stop; -- Apps -- function fetch_App (Named : in AdaM.Identifier) return adam.Subprogram.view is use AdaM; begin for Each of all_Apps loop if Each.Name = Named then return Each; end if; end loop; return null; end fetch_App; procedure build_Project is use aIDE.GUI, Shell, ada.Directories; project_Name : constant String := "hello"; generated_source_Path : constant String := "generated-source"; begin clear_Log; log ("========================"); log ("=== Building Project ==="); log ("=== ==="); if Exists (generated_source_Path) then delete_Tree (generated_source_Path); -- Clear the generated source folder. end if; create_Path (generated_source_Path); generate_Apps: begin log ("", 2); log ("Generating apps ... "); log; for Each of all_Apps loop declare use AdaM; the_App : constant AdaM.Subprogram.view := Each; begin log (" ... " & (+the_App.Name)); -- Generate the app body source. -- declare use ada.Characters.handling, ada.Strings.unbounded, ada.Text_IO; the_File : File_type; the_Filename : constant String := generated_source_Path & "/" & to_Lower (String (the_App.Name)) & ".adb"; the_Source : constant AdaM.Text_Vectors.Vector := the_App.to_Source; begin create (the_File, out_File, the_Filename); for Each of the_Source loop put_Line (the_File, to_String (Each)); end loop; close (the_File); end; end; end loop; end generate_Apps; -- Generate the main project file. -- declare use ada.Characters.handling, ada.Strings.unbounded, ada.Text_IO; use type AdaM.Subprogram.view; the_File : File_type; the_Filename : constant String := to_Lower (project_Name) & ".gpr"; procedure add (the_Line : in String) is begin put_Line (the_File, the_Line); end add; begin create (the_File, out_File, the_Filename); add ("project " & project_Name & " is"); add (""); add (" for Source_Dirs use (""" & generated_source_Path & """);"); add (" for Main use ("); for Each of all_Apps loop add (" """ & to_Lower (String (Each.Name)) & ".adb"""); if Each /= all_Apps.last_Element then add (","); end if; end loop; add (" );"); add (""); add (" for Object_Dir use ""build"";"); add (" for Exec_Dir use ""."";"); add (""); add (" package Builder is"); add (" for Default_Switches (""ada"") use (""-g"", ""-j5"");"); add (" end Builder;"); add (""); add ("end " & project_Name & ";"); close (the_File); end; -- Build the applet. -- declare use ada.Characters.Handling, ada.Strings.Unbounded, ada.Text_IO; the_Filename : constant String := to_Lower (project_Name) & ".gpr"; begin log ("", 2); log ("Cleaning ..."); log; log (command_Output (to_Command ("gnatclean -P " & the_Filename))); if Exists ("./build") then delete_Tree ("./build"); -- Clear the build folder. end if; create_Path ("./build"); log ("", 2); log ("Compiling ..."); log; declare the_Command : constant Shell.Command := to_Command ("gprbuild -P " & the_Filename); Results : constant Shell.Command_Results := Results_of (the_Command); begin log (Output_of (Results)); log (Errors_of (Results)); end; end; -- Launch the applets. -- for Each of all_Apps loop declare use AdaM, Ada.Characters.handling; app_Filename : constant String := to_Lower ("./" & String (Each.Name)); begin if Exists (app_Filename) then log ("", 2); log ("Launching '" & (+Each.Name) & "' ..."); log; declare Output : constant String := command_Output (to_Command (app_Filename)); begin if Output = "" then log ("<null output>"); else log (Output); end if; end; end if; end; end loop; log ("", 2); log ("=== ==="); log ("=== Project Built ==="); log ("====================="); end build_Project; end aIDE;
Transynther/x86/_processed/AVXALIGN/_zr_/i9-9900K_12_0xca.log_1_1671.asm
ljhsiun2/medusa
9
17188
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r15 push %r8 push %r9 push %rcx push %rdi push %rsi lea addresses_UC_ht+0x8444, %rsi lea addresses_normal_ht+0x1290c, %rdi nop nop nop nop and %r11, %r11 mov $14, %rcx rep movsl nop dec %r15 lea addresses_WC_ht+0x13444, %rsi lea addresses_WC_ht+0x1de44, %rdi nop dec %r9 mov $112, %rcx rep movsl nop nop nop nop nop xor $25550, %rdi lea addresses_UC_ht+0x1c974, %rsi lea addresses_normal_ht+0x162c4, %rdi nop dec %r12 mov $59, %rcx rep movsb nop and $59999, %rcx lea addresses_A_ht+0xd644, %rsi lea addresses_A_ht+0xb6bc, %rdi clflush (%rsi) xor $21297, %r12 mov $29, %rcx rep movsb nop nop sub %r9, %r9 lea addresses_A_ht+0x1ef24, %r9 nop xor $36290, %r15 movw $0x6162, (%r9) nop nop nop add %r11, %r11 lea addresses_A_ht+0x1a21c, %rsi lea addresses_normal_ht+0x8944, %rdi inc %r15 mov $21, %rcx rep movsw nop nop nop and $36254, %r12 lea addresses_WC_ht+0x6e44, %rcx nop nop nop inc %rdi movl $0x61626364, (%rcx) nop nop nop nop nop cmp $65452, %r12 lea addresses_normal_ht+0x18eac, %r12 nop nop nop nop nop lfence movl $0x61626364, (%r12) nop nop nop nop inc %rsi lea addresses_D_ht+0x16644, %rsi lea addresses_WT_ht+0x8344, %rdi clflush (%rsi) dec %r8 mov $105, %rcx rep movsw nop nop nop nop nop xor %r11, %r11 lea addresses_WT_ht+0xd104, %rsi lea addresses_WC_ht+0x1347c, %rdi clflush (%rsi) nop nop nop nop and %r11, %r11 mov $20, %rcx rep movsq nop nop and %rdi, %rdi lea addresses_WT_ht+0x1384, %rsi nop xor %r9, %r9 vmovups (%rsi), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdi nop nop nop cmp $27861, %r12 lea addresses_A_ht+0x19ce4, %r11 nop nop nop nop nop dec %r9 movw $0x6162, (%r11) nop nop sub $20945, %rsi lea addresses_A_ht+0xa444, %r11 clflush (%r11) nop nop nop nop nop add $28119, %rsi movb $0x61, (%r11) sub %r8, %r8 lea addresses_normal_ht+0x11044, %rsi lea addresses_WC_ht+0x12844, %rdi nop nop inc %r15 mov $7, %rcx rep movsq nop nop cmp $20493, %r15 lea addresses_UC_ht+0x9d08, %r11 nop nop nop nop add %rsi, %rsi mov $0x6162636465666768, %r8 movq %r8, (%r11) nop nop nop nop sub %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r15 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_UC+0xe544, %rsi lea addresses_WT+0x1cc44, %rdi and %rbp, %rbp mov $16, %rcx rep movsq nop nop add $25365, %rsi // Store mov $0x541a4f00000004c4, %rbp sub %rdx, %rdx movl $0x51525354, (%rbp) xor %rcx, %rcx // Store lea addresses_A+0x1b984, %rsi nop nop nop cmp $26327, %rax movw $0x5152, (%rsi) sub $22808, %rax // Faulty Load mov $0xc44, %rsi nop sub %r15, %r15 vmovntdqa (%rsi), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rbp lea oracles, %rcx and $0xff, %rbp shlq $12, %rbp mov (%rcx,%rbp,1), %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r15 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WT', 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 6}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_P', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 11}, 'dst': {'same': True, 'type': 'addresses_WC_ht', 'congruent': 9}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 3}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': True, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'00': 1} 00 */
source/compiler/generated/google-protobuf-descriptor.adb
mgrojo/protobuf
12
22813
<filename>source/compiler/generated/google-protobuf-descriptor.adb with Ada.Unchecked_Deallocation; with PB_Support.IO; with PB_Support.Internal; package body Google.Protobuf.Descriptor is package Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Descriptor_Proto, Google.Protobuf.Descriptor.Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Extension_Range_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Extension_Range, Google.Protobuf.Descriptor.Extension_Range_Vector, Google.Protobuf.Descriptor.Append); package Reserved_Range_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Reserved_Range, Google.Protobuf.Descriptor.Reserved_Range_Vector, Google.Protobuf.Descriptor.Append); package Enum_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Enum_Descriptor_Proto, Google.Protobuf.Descriptor.Enum_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Enum_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Enum_Options, Google.Protobuf.Descriptor.Enum_Options_Vector, Google.Protobuf.Descriptor.Append); package Enum_Value_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Enum_Value_Descriptor_Proto, Google.Protobuf.Descriptor.Enum_Value_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Enum_Value_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Enum_Value_Options, Google.Protobuf.Descriptor.Enum_Value_Options_Vector, Google.Protobuf.Descriptor.Append); package Field_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Field_Descriptor_Proto, Google.Protobuf.Descriptor.Field_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); type Integer_Label is range 1 .. 3 with Size => Google.Protobuf.Descriptor.Label'Size; package Label_IO is new PB_Support.IO.Enum_IO (Google.Protobuf.Descriptor.Label, Integer_Label, Google.Protobuf.Descriptor.Label_Vectors); type Integer_PB_Type is range 1 .. 18 with Size => Google.Protobuf.Descriptor.PB_Type'Size; package PB_Type_IO is new PB_Support.IO.Enum_IO (Google.Protobuf.Descriptor.PB_Type, Integer_PB_Type, Google.Protobuf.Descriptor.PB_Type_Vectors); package Field_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Field_Options, Google.Protobuf.Descriptor.Field_Options_Vector, Google.Protobuf.Descriptor.Append); type Integer_CType is range 0 .. 2 with Size => Google.Protobuf.Descriptor.CType'Size; package CType_IO is new PB_Support.IO.Enum_IO (Google.Protobuf.Descriptor.CType, Integer_CType, Google.Protobuf.Descriptor.CType_Vectors); type Integer_JSType is range 0 .. 2 with Size => Google.Protobuf.Descriptor.JSType'Size; package JSType_IO is new PB_Support.IO.Enum_IO (Google.Protobuf.Descriptor.JSType, Integer_JSType, Google.Protobuf.Descriptor.JSType_Vectors); package File_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.File_Descriptor_Proto, Google.Protobuf.Descriptor.File_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package File_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.File_Options, Google.Protobuf.Descriptor.File_Options_Vector, Google.Protobuf.Descriptor.Append); type Integer_Optimize_Mode is range 1 .. 3 with Size => Google.Protobuf.Descriptor.Optimize_Mode'Size; package Optimize_Mode_IO is new PB_Support.IO.Enum_IO (Google.Protobuf.Descriptor.Optimize_Mode, Integer_Optimize_Mode, Google.Protobuf.Descriptor.Optimize_Mode_Vectors); package Annotation_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Annotation, Google.Protobuf.Descriptor.Annotation_Vector, Google.Protobuf.Descriptor.Append); package Message_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Message_Options, Google.Protobuf.Descriptor.Message_Options_Vector, Google.Protobuf.Descriptor.Append); package Method_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Method_Descriptor_Proto, Google.Protobuf.Descriptor.Method_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Method_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Method_Options, Google.Protobuf.Descriptor.Method_Options_Vector, Google.Protobuf.Descriptor.Append); package Oneof_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Oneof_Descriptor_Proto, Google.Protobuf.Descriptor.Oneof_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Oneof_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Oneof_Options, Google.Protobuf.Descriptor.Oneof_Options_Vector, Google.Protobuf.Descriptor.Append); package Service_Descriptor_Proto_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Service_Descriptor_Proto, Google.Protobuf.Descriptor.Service_Descriptor_Proto_Vector, Google.Protobuf.Descriptor.Append); package Service_Options_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Service_Options, Google.Protobuf.Descriptor.Service_Options_Vector, Google.Protobuf.Descriptor.Append); package Source_Code_Info_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Source_Code_Info, Google.Protobuf.Descriptor.Source_Code_Info_Vector, Google.Protobuf.Descriptor.Append); package Location_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Location, Google.Protobuf.Descriptor.Location_Vector, Google.Protobuf.Descriptor.Append); package Uninterpreted_Option_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Uninterpreted_Option, Google.Protobuf.Descriptor.Uninterpreted_Option_Vector, Google.Protobuf.Descriptor.Append); package Name_Part_IO is new PB_Support.IO.Message_IO (Google.Protobuf.Descriptor.Name_Part, Google.Protobuf.Descriptor.Name_Part_Vector, Google.Protobuf.Descriptor.Append); function Length (Self : File_Descriptor_Set_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out File_Descriptor_Set_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (File_Descriptor_Set_Array, File_Descriptor_Set_Array_Access); procedure Append (Self : in out File_Descriptor_Set_Vector; V : File_Descriptor_Set) is Init_Length : constant Positive := Positive'Max (1, 256 / File_Descriptor_Set'Size); begin if Self.Length = 0 then Self.Data := new File_Descriptor_Set_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new File_Descriptor_Set_Array' (Self.Data.all & File_Descriptor_Set_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out File_Descriptor_Set_Vector) is begin if Self.Length > 0 then Self.Data := new File_Descriptor_Set_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out File_Descriptor_Set_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_File_Descriptor_Set_Variable_Reference (Self : aliased in out File_Descriptor_Set_Vector; Index : Positive) return File_Descriptor_Set_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Descriptor_Set_Variable_Reference; not overriding function Get_File_Descriptor_Set_Constant_Reference (Self : aliased File_Descriptor_Set_Vector; Index : Positive) return File_Descriptor_Set_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Descriptor_Set_Constant_Reference; procedure Read_File_Descriptor_Set (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out File_Descriptor_Set) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => File_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.File); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_File_Descriptor_Set; procedure Write_File_Descriptor_Set (Stream : access Ada.Streams.Root_Stream_Type'Class; V : File_Descriptor_Set) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_File_Descriptor_Set (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; for J in 1 .. V.File.Length loop WS.Write_Key ((1, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.File_Descriptor_Proto'Write (Stream, V.File (J)); end loop; if WS.End_Message then Write_File_Descriptor_Set (WS'Access, V); end if; end; end Write_File_Descriptor_Set; function Length (Self : File_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out File_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (File_Descriptor_Proto_Array, File_Descriptor_Proto_Array_Access); procedure Append (Self : in out File_Descriptor_Proto_Vector; V : File_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / File_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new File_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new File_Descriptor_Proto_Array' (Self.Data.all & File_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out File_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new File_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out File_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_File_Descriptor_Proto_Variable_Reference (Self : aliased in out File_Descriptor_Proto_Vector; Index : Positive) return File_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Descriptor_Proto_Variable_Reference; not overriding function Get_File_Descriptor_Proto_Constant_Reference (Self : aliased File_Descriptor_Proto_Vector; Index : Positive) return File_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Descriptor_Proto_Constant_Reference; procedure Read_File_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out File_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => if not V.PB_Package.Is_Set then V.PB_Package := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.PB_Package.Value); when 3 => PB_Support.IO.Read_Vector (Stream, Key.Encoding, V.Dependency); when 10 => PB_Support.IO.Read_Varint_Vector (Stream, Key.Encoding, V.Public_Dependency); when 11 => PB_Support.IO.Read_Varint_Vector (Stream, Key.Encoding, V.Weak_Dependency); when 4 => Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Message_Type); when 5 => Enum_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Enum_Type); when 6 => Service_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Service); when 7 => Field_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Extension); when 8 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; File_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when 9 => if not V.Source_Code_Info.Is_Set then V.Source_Code_Info := (True, others => <>); end if; Source_Code_Info_IO.Read (Stream, Key.Encoding, V.Source_Code_Info.Value); when 12 => if not V.Syntax.Is_Set then V.Syntax := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Syntax.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_File_Descriptor_Proto; procedure Write_File_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : File_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_File_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; if V.PB_Package.Is_Set then WS.Write (2, V.PB_Package.Value); end if; WS.Write (3, V.Dependency); WS.Write_Varint (10, V.Public_Dependency); WS.Write_Varint (11, V.Weak_Dependency); for J in 1 .. V.Message_Type.Length loop WS.Write_Key ((4, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Descriptor_Proto'Write (Stream, V.Message_Type (J)); end loop; for J in 1 .. V.Enum_Type.Length loop WS.Write_Key ((5, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Enum_Descriptor_Proto'Write (Stream, V.Enum_Type (J)); end loop; for J in 1 .. V.Service.Length loop WS.Write_Key ((6, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Service_Descriptor_Proto'Write (Stream, V.Service (J)); end loop; for J in 1 .. V.Extension.Length loop WS.Write_Key ((7, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Field_Descriptor_Proto'Write (Stream, V.Extension (J)); end loop; if V.Options.Is_Set then WS.Write_Key ((8, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.File_Options'Write (Stream, V.Options.Value); end if; if V.Source_Code_Info.Is_Set then WS.Write_Key ((9, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Source_Code_Info'Write (Stream, V.Source_Code_Info.Value); end if; if V.Syntax.Is_Set then WS.Write (12, V.Syntax.Value); end if; if WS.End_Message then Write_File_Descriptor_Proto (WS'Access, V); end if; end; end Write_File_Descriptor_Proto; function Length (Self : Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Descriptor_Proto_Array, Descriptor_Proto_Array_Access); procedure Append (Self : in out Descriptor_Proto_Vector; V : Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Descriptor_Proto_Array' (Self.Data.all & Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Descriptor_Proto_Variable_Reference (Self : aliased in out Descriptor_Proto_Vector; Index : Positive) return Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Descriptor_Proto_Variable_Reference; not overriding function Get_Descriptor_Proto_Constant_Reference (Self : aliased Descriptor_Proto_Vector; Index : Positive) return Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Descriptor_Proto_Constant_Reference; procedure Read_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => Field_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Field); when 6 => Field_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Extension); when 3 => Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Nested_Type); when 4 => Enum_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Enum_Type); when 5 => Extension_Range_IO.Read_Vector (Stream, Key.Encoding, V.Extension_Range); when 8 => Oneof_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Oneof_Decl); when 7 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Message_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when 9 => Reserved_Range_IO.Read_Vector (Stream, Key.Encoding, V.Reserved_Range); when 10 => PB_Support.IO.Read_Vector (Stream, Key.Encoding, V.Reserved_Name); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Descriptor_Proto; procedure Write_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; for J in 1 .. V.Field.Length loop WS.Write_Key ((2, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Field_Descriptor_Proto'Write (Stream, V.Field (J)); end loop; for J in 1 .. V.Extension.Length loop WS.Write_Key ((6, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Field_Descriptor_Proto'Write (Stream, V.Extension (J)); end loop; for J in 1 .. V.Nested_Type.Length loop WS.Write_Key ((3, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Descriptor_Proto'Write (Stream, V.Nested_Type (J)); end loop; for J in 1 .. V.Enum_Type.Length loop WS.Write_Key ((4, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Enum_Descriptor_Proto'Write (Stream, V.Enum_Type (J)); end loop; for J in 1 .. V.Extension_Range.Length loop WS.Write_Key ((5, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Extension_Range'Write (Stream, V.Extension_Range (J)); end loop; for J in 1 .. V.Oneof_Decl.Length loop WS.Write_Key ((8, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Oneof_Descriptor_Proto'Write (Stream, V.Oneof_Decl (J)); end loop; if V.Options.Is_Set then WS.Write_Key ((7, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Message_Options'Write (Stream, V.Options.Value); end if; for J in 1 .. V.Reserved_Range.Length loop WS.Write_Key ((9, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Reserved_Range'Write (Stream, V.Reserved_Range (J)); end loop; WS.Write (10, V.Reserved_Name); if WS.End_Message then Write_Descriptor_Proto (WS'Access, V); end if; end; end Write_Descriptor_Proto; function Length (Self : Extension_Range_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Extension_Range_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Extension_Range_Array, Extension_Range_Array_Access); procedure Append (Self : in out Extension_Range_Vector; V : Extension_Range) is Init_Length : constant Positive := Positive'Max (1, 256 / Extension_Range'Size); begin if Self.Length = 0 then Self.Data := new Extension_Range_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Extension_Range_Array' (Self.Data.all & Extension_Range_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Extension_Range_Vector) is begin if Self.Length > 0 then Self.Data := new Extension_Range_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Extension_Range_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Extension_Range_Variable_Reference (Self : aliased in out Extension_Range_Vector; Index : Positive) return Extension_Range_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Extension_Range_Variable_Reference; not overriding function Get_Extension_Range_Constant_Reference (Self : aliased Extension_Range_Vector; Index : Positive) return Extension_Range_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Extension_Range_Constant_Reference; procedure Read_Extension_Range (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Extension_Range) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Start.Is_Set then V.Start := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Start.Value); when 2 => if not V.PB_End.Is_Set then V.PB_End := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.PB_End.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Extension_Range; procedure Write_Extension_Range (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Extension_Range) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Extension_Range (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Start.Is_Set then WS.Write_Varint (1, V.Start.Value); end if; if V.PB_End.Is_Set then WS.Write_Varint (2, V.PB_End.Value); end if; if WS.End_Message then Write_Extension_Range (WS'Access, V); end if; end; end Write_Extension_Range; function Length (Self : Reserved_Range_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Reserved_Range_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Reserved_Range_Array, Reserved_Range_Array_Access); procedure Append (Self : in out Reserved_Range_Vector; V : Reserved_Range) is Init_Length : constant Positive := Positive'Max (1, 256 / Reserved_Range'Size); begin if Self.Length = 0 then Self.Data := new Reserved_Range_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Reserved_Range_Array' (Self.Data.all & Reserved_Range_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Reserved_Range_Vector) is begin if Self.Length > 0 then Self.Data := new Reserved_Range_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Reserved_Range_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Reserved_Range_Variable_Reference (Self : aliased in out Reserved_Range_Vector; Index : Positive) return Reserved_Range_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Reserved_Range_Variable_Reference; not overriding function Get_Reserved_Range_Constant_Reference (Self : aliased Reserved_Range_Vector; Index : Positive) return Reserved_Range_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Reserved_Range_Constant_Reference; procedure Read_Reserved_Range (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Reserved_Range) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Start.Is_Set then V.Start := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Start.Value); when 2 => if not V.PB_End.Is_Set then V.PB_End := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.PB_End.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Reserved_Range; procedure Write_Reserved_Range (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Reserved_Range) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Reserved_Range (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Start.Is_Set then WS.Write_Varint (1, V.Start.Value); end if; if V.PB_End.Is_Set then WS.Write_Varint (2, V.PB_End.Value); end if; if WS.End_Message then Write_Reserved_Range (WS'Access, V); end if; end; end Write_Reserved_Range; function Length (Self : Field_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Field_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Field_Descriptor_Proto_Array, Field_Descriptor_Proto_Array_Access); procedure Append (Self : in out Field_Descriptor_Proto_Vector; V : Field_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Field_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Field_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Field_Descriptor_Proto_Array' (Self.Data.all & Field_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Field_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Field_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Field_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Field_Descriptor_Proto_Variable_Reference (Self : aliased in out Field_Descriptor_Proto_Vector; Index : Positive) return Field_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Field_Descriptor_Proto_Variable_Reference; not overriding function Get_Field_Descriptor_Proto_Constant_Reference (Self : aliased Field_Descriptor_Proto_Vector; Index : Positive) return Field_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Field_Descriptor_Proto_Constant_Reference; procedure Read_Field_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Field_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 3 => if not V.Number.Is_Set then V.Number := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Number.Value); when 4 => if not V.Label.Is_Set then V.Label := (True, others => <>); end if; Label_IO.Read (Stream, Key.Encoding, V.Label.Value); when 5 => if not V.PB_Type.Is_Set then V.PB_Type := (True, others => <>); end if; PB_Type_IO.Read (Stream, Key.Encoding, V.PB_Type.Value); when 6 => if not V.Type_Name.Is_Set then V.Type_Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Type_Name.Value); when 2 => if not V.Extendee.Is_Set then V.Extendee := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Extendee.Value); when 7 => if not V.Default_Value.Is_Set then V.Default_Value := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Default_Value.Value); when 9 => if not V.Oneof_Index.Is_Set then V.Oneof_Index := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Oneof_Index.Value); when 10 => if not V.Json_Name.Is_Set then V.Json_Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Json_Name.Value); when 8 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Field_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Field_Descriptor_Proto; procedure Write_Field_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Field_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Field_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; if V.Number.Is_Set then WS.Write_Varint (3, V.Number.Value); end if; if V.Label.Is_Set then Label_IO.Write (WS, 4, V.Label.Value); end if; if V.PB_Type.Is_Set then PB_Type_IO.Write (WS, 5, V.PB_Type.Value); end if; if V.Type_Name.Is_Set then WS.Write (6, V.Type_Name.Value); end if; if V.Extendee.Is_Set then WS.Write (2, V.Extendee.Value); end if; if V.Default_Value.Is_Set then WS.Write (7, V.Default_Value.Value); end if; if V.Oneof_Index.Is_Set then WS.Write_Varint (9, V.Oneof_Index.Value); end if; if V.Json_Name.Is_Set then WS.Write (10, V.Json_Name.Value); end if; if V.Options.Is_Set then WS.Write_Key ((8, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Field_Options'Write (Stream, V.Options.Value); end if; if WS.End_Message then Write_Field_Descriptor_Proto (WS'Access, V); end if; end; end Write_Field_Descriptor_Proto; function Length (Self : Oneof_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Oneof_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Oneof_Descriptor_Proto_Array, Oneof_Descriptor_Proto_Array_Access); procedure Append (Self : in out Oneof_Descriptor_Proto_Vector; V : Oneof_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Oneof_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Oneof_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Oneof_Descriptor_Proto_Array' (Self.Data.all & Oneof_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Oneof_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Oneof_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Oneof_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Oneof_Descriptor_Proto_Variable_Reference (Self : aliased in out Oneof_Descriptor_Proto_Vector; Index : Positive) return Oneof_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Oneof_Descriptor_Proto_Variable_Reference; not overriding function Get_Oneof_Descriptor_Proto_Constant_Reference (Self : aliased Oneof_Descriptor_Proto_Vector; Index : Positive) return Oneof_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Oneof_Descriptor_Proto_Constant_Reference; procedure Read_Oneof_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Oneof_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Oneof_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Oneof_Descriptor_Proto; procedure Write_Oneof_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Oneof_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Oneof_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; if V.Options.Is_Set then WS.Write_Key ((2, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Oneof_Options'Write (Stream, V.Options.Value); end if; if WS.End_Message then Write_Oneof_Descriptor_Proto (WS'Access, V); end if; end; end Write_Oneof_Descriptor_Proto; function Length (Self : Enum_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Enum_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Enum_Descriptor_Proto_Array, Enum_Descriptor_Proto_Array_Access); procedure Append (Self : in out Enum_Descriptor_Proto_Vector; V : Enum_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Enum_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Enum_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Enum_Descriptor_Proto_Array' (Self.Data.all & Enum_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Enum_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Enum_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Enum_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Enum_Descriptor_Proto_Variable_Reference (Self : aliased in out Enum_Descriptor_Proto_Vector; Index : Positive) return Enum_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Descriptor_Proto_Variable_Reference; not overriding function Get_Enum_Descriptor_Proto_Constant_Reference (Self : aliased Enum_Descriptor_Proto_Vector; Index : Positive) return Enum_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Descriptor_Proto_Constant_Reference; procedure Read_Enum_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Enum_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => Enum_Value_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Value); when 3 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Enum_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Enum_Descriptor_Proto; procedure Write_Enum_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Enum_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Enum_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; for J in 1 .. V.Value.Length loop WS.Write_Key ((2, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Enum_Value_Descriptor_Proto'Write (Stream, V.Value (J)); end loop; if V.Options.Is_Set then WS.Write_Key ((3, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Enum_Options'Write (Stream, V.Options.Value); end if; if WS.End_Message then Write_Enum_Descriptor_Proto (WS'Access, V); end if; end; end Write_Enum_Descriptor_Proto; function Length (Self : Enum_Value_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Enum_Value_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Enum_Value_Descriptor_Proto_Array, Enum_Value_Descriptor_Proto_Array_Access); procedure Append (Self : in out Enum_Value_Descriptor_Proto_Vector; V : Enum_Value_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Enum_Value_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Enum_Value_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Enum_Value_Descriptor_Proto_Array' (Self.Data.all & Enum_Value_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Enum_Value_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Enum_Value_Descriptor_Proto_Array' (Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Enum_Value_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Enum_Value_Descriptor_Proto_Variable_Reference (Self : aliased in out Enum_Value_Descriptor_Proto_Vector; Index : Positive) return Enum_Value_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Value_Descriptor_Proto_Variable_Reference; not overriding function Get_Enum_Value_Descriptor_Proto_Constant_Reference (Self : aliased Enum_Value_Descriptor_Proto_Vector; Index : Positive) return Enum_Value_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Value_Descriptor_Proto_Constant_Reference; procedure Read_Enum_Value_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Enum_Value_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => if not V.Number.Is_Set then V.Number := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Number.Value); when 3 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Enum_Value_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Enum_Value_Descriptor_Proto; procedure Write_Enum_Value_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Enum_Value_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Enum_Value_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; if V.Number.Is_Set then WS.Write_Varint (2, V.Number.Value); end if; if V.Options.Is_Set then WS.Write_Key ((3, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Enum_Value_Options'Write (Stream, V.Options.Value); end if; if WS.End_Message then Write_Enum_Value_Descriptor_Proto (WS'Access, V); end if; end; end Write_Enum_Value_Descriptor_Proto; function Length (Self : Service_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Service_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Service_Descriptor_Proto_Array, Service_Descriptor_Proto_Array_Access); procedure Append (Self : in out Service_Descriptor_Proto_Vector; V : Service_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Service_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Service_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Service_Descriptor_Proto_Array' (Self.Data.all & Service_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Service_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Service_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Service_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Service_Descriptor_Proto_Variable_Reference (Self : aliased in out Service_Descriptor_Proto_Vector; Index : Positive) return Service_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Service_Descriptor_Proto_Variable_Reference; not overriding function Get_Service_Descriptor_Proto_Constant_Reference (Self : aliased Service_Descriptor_Proto_Vector; Index : Positive) return Service_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Service_Descriptor_Proto_Constant_Reference; procedure Read_Service_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Service_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => Method_Descriptor_Proto_IO.Read_Vector (Stream, Key.Encoding, V.Method); when 3 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Service_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Service_Descriptor_Proto; procedure Write_Service_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Service_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Service_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; for J in 1 .. V.Method.Length loop WS.Write_Key ((2, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Method_Descriptor_Proto'Write (Stream, V.Method (J)); end loop; if V.Options.Is_Set then WS.Write_Key ((3, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Service_Options'Write (Stream, V.Options.Value); end if; if WS.End_Message then Write_Service_Descriptor_Proto (WS'Access, V); end if; end; end Write_Service_Descriptor_Proto; function Length (Self : Method_Descriptor_Proto_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Method_Descriptor_Proto_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Method_Descriptor_Proto_Array, Method_Descriptor_Proto_Array_Access); procedure Append (Self : in out Method_Descriptor_Proto_Vector; V : Method_Descriptor_Proto) is Init_Length : constant Positive := Positive'Max (1, 256 / Method_Descriptor_Proto'Size); begin if Self.Length = 0 then Self.Data := new Method_Descriptor_Proto_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Method_Descriptor_Proto_Array' (Self.Data.all & Method_Descriptor_Proto_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Method_Descriptor_Proto_Vector) is begin if Self.Length > 0 then Self.Data := new Method_Descriptor_Proto_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Method_Descriptor_Proto_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Method_Descriptor_Proto_Variable_Reference (Self : aliased in out Method_Descriptor_Proto_Vector; Index : Positive) return Method_Descriptor_Proto_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Method_Descriptor_Proto_Variable_Reference; not overriding function Get_Method_Descriptor_Proto_Constant_Reference (Self : aliased Method_Descriptor_Proto_Vector; Index : Positive) return Method_Descriptor_Proto_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Method_Descriptor_Proto_Constant_Reference; procedure Read_Method_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Method_Descriptor_Proto) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Name.Is_Set then V.Name := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Name.Value); when 2 => if not V.Input_Type.Is_Set then V.Input_Type := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Input_Type.Value); when 3 => if not V.Output_Type.Is_Set then V.Output_Type := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Output_Type.Value); when 4 => if not V.Options.Is_Set then V.Options := (True, others => <>); end if; Method_Options_IO.Read (Stream, Key.Encoding, V.Options.Value); when 5 => if not V.Client_Streaming.Is_Set then V.Client_Streaming := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Client_Streaming.Value); when 6 => if not V.Server_Streaming.Is_Set then V.Server_Streaming := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Server_Streaming.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Method_Descriptor_Proto; procedure Write_Method_Descriptor_Proto (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Method_Descriptor_Proto) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Method_Descriptor_Proto (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Name.Is_Set then WS.Write (1, V.Name.Value); end if; if V.Input_Type.Is_Set then WS.Write (2, V.Input_Type.Value); end if; if V.Output_Type.Is_Set then WS.Write (3, V.Output_Type.Value); end if; if V.Options.Is_Set then WS.Write_Key ((4, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Method_Options'Write (Stream, V.Options.Value); end if; if V.Client_Streaming.Is_Set then WS.Write (5, V.Client_Streaming.Value); end if; if V.Server_Streaming.Is_Set then WS.Write (6, V.Server_Streaming.Value); end if; if WS.End_Message then Write_Method_Descriptor_Proto (WS'Access, V); end if; end; end Write_Method_Descriptor_Proto; function Length (Self : File_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out File_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (File_Options_Array, File_Options_Array_Access); procedure Append (Self : in out File_Options_Vector; V : File_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / File_Options'Size); begin if Self.Length = 0 then Self.Data := new File_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new File_Options_Array' (Self.Data.all & File_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out File_Options_Vector) is begin if Self.Length > 0 then Self.Data := new File_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out File_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_File_Options_Variable_Reference (Self : aliased in out File_Options_Vector; Index : Positive) return File_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Options_Variable_Reference; not overriding function Get_File_Options_Constant_Reference (Self : aliased File_Options_Vector; Index : Positive) return File_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_File_Options_Constant_Reference; procedure Read_File_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out File_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Java_Package.Is_Set then V.Java_Package := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_Package.Value); when 8 => if not V.Java_Outer_Classname.Is_Set then V.Java_Outer_Classname := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_Outer_Classname.Value); when 10 => if not V.Java_Multiple_Files.Is_Set then V.Java_Multiple_Files := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_Multiple_Files.Value); when 20 => if not V.Java_Generate_Equals_And_Hash.Is_Set then V.Java_Generate_Equals_And_Hash := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_Generate_Equals_And_Hash.Value); when 27 => if not V.Java_String_Check_Utf_8.Is_Set then V.Java_String_Check_Utf_8 := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_String_Check_Utf_8.Value); when 9 => if not V.Optimize_For.Is_Set then V.Optimize_For := (True, others => <>); end if; Optimize_Mode_IO.Read (Stream, Key.Encoding, V.Optimize_For.Value); when 11 => if not V.Go_Package.Is_Set then V.Go_Package := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Go_Package.Value); when 16 => if not V.Cc_Generic_Services.Is_Set then V.Cc_Generic_Services := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Cc_Generic_Services.Value); when 17 => if not V.Java_Generic_Services.Is_Set then V.Java_Generic_Services := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Java_Generic_Services.Value); when 18 => if not V.Py_Generic_Services.Is_Set then V.Py_Generic_Services := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Py_Generic_Services.Value); when 23 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 31 => if not V.Cc_Enable_Arenas.Is_Set then V.Cc_Enable_Arenas := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Cc_Enable_Arenas.Value); when 36 => if not V.Objc_Class_Prefix.Is_Set then V.Objc_Class_Prefix := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Objc_Class_Prefix.Value); when 37 => if not V.Csharp_Namespace.Is_Set then V.Csharp_Namespace := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Csharp_Namespace.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_File_Options; procedure Write_File_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : File_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_File_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Java_Package.Is_Set then WS.Write (1, V.Java_Package.Value); end if; if V.Java_Outer_Classname.Is_Set then WS.Write (8, V.Java_Outer_Classname.Value); end if; if V.Java_Multiple_Files.Is_Set then WS.Write (10, V.Java_Multiple_Files.Value); end if; if V.Java_Generate_Equals_And_Hash.Is_Set then WS.Write (20, V.Java_Generate_Equals_And_Hash.Value); end if; if V.Java_String_Check_Utf_8.Is_Set then WS.Write (27, V.Java_String_Check_Utf_8.Value); end if; if V.Optimize_For.Is_Set then Optimize_Mode_IO.Write (WS, 9, V.Optimize_For.Value); end if; if V.Go_Package.Is_Set then WS.Write (11, V.Go_Package.Value); end if; if V.Cc_Generic_Services.Is_Set then WS.Write (16, V.Cc_Generic_Services.Value); end if; if V.Java_Generic_Services.Is_Set then WS.Write (17, V.Java_Generic_Services.Value); end if; if V.Py_Generic_Services.Is_Set then WS.Write (18, V.Py_Generic_Services.Value); end if; if V.Deprecated.Is_Set then WS.Write (23, V.Deprecated.Value); end if; if V.Cc_Enable_Arenas.Is_Set then WS.Write (31, V.Cc_Enable_Arenas.Value); end if; if V.Objc_Class_Prefix.Is_Set then WS.Write (36, V.Objc_Class_Prefix.Value); end if; if V.Csharp_Namespace.Is_Set then WS.Write (37, V.Csharp_Namespace.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_File_Options (WS'Access, V); end if; end; end Write_File_Options; function Length (Self : Message_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Message_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Message_Options_Array, Message_Options_Array_Access); procedure Append (Self : in out Message_Options_Vector; V : Message_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Message_Options'Size); begin if Self.Length = 0 then Self.Data := new Message_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Message_Options_Array' (Self.Data.all & Message_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Message_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Message_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Message_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Message_Options_Variable_Reference (Self : aliased in out Message_Options_Vector; Index : Positive) return Message_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Message_Options_Variable_Reference; not overriding function Get_Message_Options_Constant_Reference (Self : aliased Message_Options_Vector; Index : Positive) return Message_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Message_Options_Constant_Reference; procedure Read_Message_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Message_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Message_Set_Wire_Format.Is_Set then V.Message_Set_Wire_Format := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Message_Set_Wire_Format.Value); when 2 => if not V.No_Standard_Descriptor_Accessor.Is_Set then V.No_Standard_Descriptor_Accessor := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.No_Standard_Descriptor_Accessor.Value); when 3 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 7 => if not V.Map_Entry.Is_Set then V.Map_Entry := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Map_Entry.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Message_Options; procedure Write_Message_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Message_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Message_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Message_Set_Wire_Format.Is_Set then WS.Write (1, V.Message_Set_Wire_Format.Value); end if; if V.No_Standard_Descriptor_Accessor.Is_Set then WS.Write (2, V.No_Standard_Descriptor_Accessor.Value); end if; if V.Deprecated.Is_Set then WS.Write (3, V.Deprecated.Value); end if; if V.Map_Entry.Is_Set then WS.Write (7, V.Map_Entry.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Message_Options (WS'Access, V); end if; end; end Write_Message_Options; function Length (Self : Field_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Field_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Field_Options_Array, Field_Options_Array_Access); procedure Append (Self : in out Field_Options_Vector; V : Field_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Field_Options'Size); begin if Self.Length = 0 then Self.Data := new Field_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Field_Options_Array' (Self.Data.all & Field_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Field_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Field_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Field_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Field_Options_Variable_Reference (Self : aliased in out Field_Options_Vector; Index : Positive) return Field_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Field_Options_Variable_Reference; not overriding function Get_Field_Options_Constant_Reference (Self : aliased Field_Options_Vector; Index : Positive) return Field_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Field_Options_Constant_Reference; procedure Read_Field_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Field_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Ctype.Is_Set then V.Ctype := (True, others => <>); end if; CType_IO.Read (Stream, Key.Encoding, V.Ctype.Value); when 2 => if not V.Packed.Is_Set then V.Packed := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Packed.Value); when 6 => if not V.Jstype.Is_Set then V.Jstype := (True, others => <>); end if; JSType_IO.Read (Stream, Key.Encoding, V.Jstype.Value); when 5 => if not V.Lazy.Is_Set then V.Lazy := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Lazy.Value); when 3 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 10 => if not V.Weak.Is_Set then V.Weak := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Weak.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Field_Options; procedure Write_Field_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Field_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Field_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Ctype.Is_Set then CType_IO.Write (WS, 1, V.Ctype.Value); end if; if V.Packed.Is_Set then WS.Write (2, V.Packed.Value); end if; if V.Jstype.Is_Set then JSType_IO.Write (WS, 6, V.Jstype.Value); end if; if V.Lazy.Is_Set then WS.Write (5, V.Lazy.Value); end if; if V.Deprecated.Is_Set then WS.Write (3, V.Deprecated.Value); end if; if V.Weak.Is_Set then WS.Write (10, V.Weak.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Field_Options (WS'Access, V); end if; end; end Write_Field_Options; function Length (Self : Oneof_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Oneof_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Oneof_Options_Array, Oneof_Options_Array_Access); procedure Append (Self : in out Oneof_Options_Vector; V : Oneof_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Oneof_Options'Size); begin if Self.Length = 0 then Self.Data := new Oneof_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Oneof_Options_Array' (Self.Data.all & Oneof_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Oneof_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Oneof_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Oneof_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Oneof_Options_Variable_Reference (Self : aliased in out Oneof_Options_Vector; Index : Positive) return Oneof_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Oneof_Options_Variable_Reference; not overriding function Get_Oneof_Options_Constant_Reference (Self : aliased Oneof_Options_Vector; Index : Positive) return Oneof_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Oneof_Options_Constant_Reference; procedure Read_Oneof_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Oneof_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Oneof_Options; procedure Write_Oneof_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Oneof_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Oneof_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Oneof_Options (WS'Access, V); end if; end; end Write_Oneof_Options; function Length (Self : Enum_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Enum_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Enum_Options_Array, Enum_Options_Array_Access); procedure Append (Self : in out Enum_Options_Vector; V : Enum_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Enum_Options'Size); begin if Self.Length = 0 then Self.Data := new Enum_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Enum_Options_Array' (Self.Data.all & Enum_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Enum_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Enum_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Enum_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Enum_Options_Variable_Reference (Self : aliased in out Enum_Options_Vector; Index : Positive) return Enum_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Options_Variable_Reference; not overriding function Get_Enum_Options_Constant_Reference (Self : aliased Enum_Options_Vector; Index : Positive) return Enum_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Options_Constant_Reference; procedure Read_Enum_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Enum_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 2 => if not V.Allow_Alias.Is_Set then V.Allow_Alias := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Allow_Alias.Value); when 3 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Enum_Options; procedure Write_Enum_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Enum_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Enum_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Allow_Alias.Is_Set then WS.Write (2, V.Allow_Alias.Value); end if; if V.Deprecated.Is_Set then WS.Write (3, V.Deprecated.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Enum_Options (WS'Access, V); end if; end; end Write_Enum_Options; function Length (Self : Enum_Value_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Enum_Value_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Enum_Value_Options_Array, Enum_Value_Options_Array_Access); procedure Append (Self : in out Enum_Value_Options_Vector; V : Enum_Value_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Enum_Value_Options'Size); begin if Self.Length = 0 then Self.Data := new Enum_Value_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Enum_Value_Options_Array' (Self.Data.all & Enum_Value_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Enum_Value_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Enum_Value_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Enum_Value_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Enum_Value_Options_Variable_Reference (Self : aliased in out Enum_Value_Options_Vector; Index : Positive) return Enum_Value_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Value_Options_Variable_Reference; not overriding function Get_Enum_Value_Options_Constant_Reference (Self : aliased Enum_Value_Options_Vector; Index : Positive) return Enum_Value_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Enum_Value_Options_Constant_Reference; procedure Read_Enum_Value_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Enum_Value_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Enum_Value_Options; procedure Write_Enum_Value_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Enum_Value_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Enum_Value_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Deprecated.Is_Set then WS.Write (1, V.Deprecated.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Enum_Value_Options (WS'Access, V); end if; end; end Write_Enum_Value_Options; function Length (Self : Service_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Service_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Service_Options_Array, Service_Options_Array_Access); procedure Append (Self : in out Service_Options_Vector; V : Service_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Service_Options'Size); begin if Self.Length = 0 then Self.Data := new Service_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Service_Options_Array' (Self.Data.all & Service_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Service_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Service_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Service_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Service_Options_Variable_Reference (Self : aliased in out Service_Options_Vector; Index : Positive) return Service_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Service_Options_Variable_Reference; not overriding function Get_Service_Options_Constant_Reference (Self : aliased Service_Options_Vector; Index : Positive) return Service_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Service_Options_Constant_Reference; procedure Read_Service_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Service_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 33 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Service_Options; procedure Write_Service_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Service_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Service_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Deprecated.Is_Set then WS.Write (33, V.Deprecated.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Service_Options (WS'Access, V); end if; end; end Write_Service_Options; function Length (Self : Method_Options_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Method_Options_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Method_Options_Array, Method_Options_Array_Access); procedure Append (Self : in out Method_Options_Vector; V : Method_Options) is Init_Length : constant Positive := Positive'Max (1, 256 / Method_Options'Size); begin if Self.Length = 0 then Self.Data := new Method_Options_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Method_Options_Array' (Self.Data.all & Method_Options_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Method_Options_Vector) is begin if Self.Length > 0 then Self.Data := new Method_Options_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Method_Options_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Method_Options_Variable_Reference (Self : aliased in out Method_Options_Vector; Index : Positive) return Method_Options_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Method_Options_Variable_Reference; not overriding function Get_Method_Options_Constant_Reference (Self : aliased Method_Options_Vector; Index : Positive) return Method_Options_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Method_Options_Constant_Reference; procedure Read_Method_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Method_Options) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 33 => if not V.Deprecated.Is_Set then V.Deprecated := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Deprecated.Value); when 999 => Uninterpreted_Option_IO.Read_Vector (Stream, Key.Encoding, V.Uninterpreted_Option); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Method_Options; procedure Write_Method_Options (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Method_Options) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Method_Options (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; if V.Deprecated.Is_Set then WS.Write (33, V.Deprecated.Value); end if; for J in 1 .. V.Uninterpreted_Option.Length loop WS.Write_Key ((999, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Uninterpreted_Option'Write (Stream, V.Uninterpreted_Option (J)); end loop; if WS.End_Message then Write_Method_Options (WS'Access, V); end if; end; end Write_Method_Options; function Length (Self : Uninterpreted_Option_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Uninterpreted_Option_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Uninterpreted_Option_Array, Uninterpreted_Option_Array_Access); procedure Append (Self : in out Uninterpreted_Option_Vector; V : Uninterpreted_Option) is Init_Length : constant Positive := Positive'Max (1, 256 / Uninterpreted_Option'Size); begin if Self.Length = 0 then Self.Data := new Uninterpreted_Option_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Uninterpreted_Option_Array' (Self.Data.all & Uninterpreted_Option_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Uninterpreted_Option_Vector) is begin if Self.Length > 0 then Self.Data := new Uninterpreted_Option_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Uninterpreted_Option_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Uninterpreted_Option_Variable_Reference (Self : aliased in out Uninterpreted_Option_Vector; Index : Positive) return Uninterpreted_Option_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Uninterpreted_Option_Variable_Reference; not overriding function Get_Uninterpreted_Option_Constant_Reference (Self : aliased Uninterpreted_Option_Vector; Index : Positive) return Uninterpreted_Option_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Uninterpreted_Option_Constant_Reference; procedure Read_Uninterpreted_Option (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Uninterpreted_Option) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 2 => Name_Part_IO.Read_Vector (Stream, Key.Encoding, V.Name); when 3 => if not V.Identifier_Value.Is_Set then V.Identifier_Value := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Identifier_Value.Value); when 4 => if not V.Positive_Int_Value.Is_Set then V.Positive_Int_Value := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Positive_Int_Value.Value); when 5 => if not V.Negative_Int_Value.Is_Set then V.Negative_Int_Value := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.Negative_Int_Value.Value); when 6 => if not V.Double_Value.Is_Set then V.Double_Value := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Double_Value.Value); when 7 => if not V.String_Value.Is_Set then V.String_Value := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.String_Value.Value); when 8 => if not V.Aggregate_Value.Is_Set then V.Aggregate_Value := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Aggregate_Value.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Uninterpreted_Option; procedure Write_Uninterpreted_Option (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Uninterpreted_Option) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Uninterpreted_Option (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; for J in 1 .. V.Name.Length loop WS.Write_Key ((2, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Name_Part'Write (Stream, V.Name (J)); end loop; if V.Identifier_Value.Is_Set then WS.Write (3, V.Identifier_Value.Value); end if; if V.Positive_Int_Value.Is_Set then WS.Write_Varint (4, V.Positive_Int_Value.Value); end if; if V.Negative_Int_Value.Is_Set then WS.Write_Varint (5, V.Negative_Int_Value.Value); end if; if V.Double_Value.Is_Set then WS.Write (6, V.Double_Value.Value); end if; if V.String_Value.Is_Set then WS.Write (7, V.String_Value.Value); end if; if V.Aggregate_Value.Is_Set then WS.Write (8, V.Aggregate_Value.Value); end if; if WS.End_Message then Write_Uninterpreted_Option (WS'Access, V); end if; end; end Write_Uninterpreted_Option; function Length (Self : Name_Part_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Name_Part_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Name_Part_Array, Name_Part_Array_Access); procedure Append (Self : in out Name_Part_Vector; V : Name_Part) is Init_Length : constant Positive := Positive'Max (1, 256 / Name_Part'Size); begin if Self.Length = 0 then Self.Data := new Name_Part_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Name_Part_Array' (Self.Data.all & Name_Part_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Name_Part_Vector) is begin if Self.Length > 0 then Self.Data := new Name_Part_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Name_Part_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Name_Part_Variable_Reference (Self : aliased in out Name_Part_Vector; Index : Positive) return Name_Part_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Name_Part_Variable_Reference; not overriding function Get_Name_Part_Constant_Reference (Self : aliased Name_Part_Vector; Index : Positive) return Name_Part_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Name_Part_Constant_Reference; procedure Read_Name_Part (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Name_Part) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => PB_Support.IO.Read (Stream, Key.Encoding, V.Name_Part); when 2 => PB_Support.IO.Read (Stream, Key.Encoding, V.Is_Extension); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Name_Part; procedure Write_Name_Part (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Name_Part) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Name_Part (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; WS.Write (1, V.Name_Part); WS.Write (2, V.Is_Extension); if WS.End_Message then Write_Name_Part (WS'Access, V); end if; end; end Write_Name_Part; function Length (Self : Source_Code_Info_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Source_Code_Info_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Source_Code_Info_Array, Source_Code_Info_Array_Access); procedure Append (Self : in out Source_Code_Info_Vector; V : Source_Code_Info) is Init_Length : constant Positive := Positive'Max (1, 256 / Source_Code_Info'Size); begin if Self.Length = 0 then Self.Data := new Source_Code_Info_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Source_Code_Info_Array' (Self.Data.all & Source_Code_Info_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Source_Code_Info_Vector) is begin if Self.Length > 0 then Self.Data := new Source_Code_Info_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Source_Code_Info_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Source_Code_Info_Variable_Reference (Self : aliased in out Source_Code_Info_Vector; Index : Positive) return Source_Code_Info_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Source_Code_Info_Variable_Reference; not overriding function Get_Source_Code_Info_Constant_Reference (Self : aliased Source_Code_Info_Vector; Index : Positive) return Source_Code_Info_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Source_Code_Info_Constant_Reference; procedure Read_Source_Code_Info (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Source_Code_Info) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => Location_IO.Read_Vector (Stream, Key.Encoding, V.Location); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Source_Code_Info; procedure Write_Source_Code_Info (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Source_Code_Info) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Source_Code_Info (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; for J in 1 .. V.Location.Length loop WS.Write_Key ((1, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Location'Write (Stream, V.Location (J)); end loop; if WS.End_Message then Write_Source_Code_Info (WS'Access, V); end if; end; end Write_Source_Code_Info; function Length (Self : Location_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Location_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Location_Array, Location_Array_Access); procedure Append (Self : in out Location_Vector; V : Location) is Init_Length : constant Positive := Positive'Max (1, 256 / Location'Size); begin if Self.Length = 0 then Self.Data := new Location_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Location_Array' (Self.Data.all & Location_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Location_Vector) is begin if Self.Length > 0 then Self.Data := new Location_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Location_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Location_Variable_Reference (Self : aliased in out Location_Vector; Index : Positive) return Location_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Location_Variable_Reference; not overriding function Get_Location_Constant_Reference (Self : aliased Location_Vector; Index : Positive) return Location_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Location_Constant_Reference; procedure Read_Location (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Location) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => PB_Support.IO.Read_Varint_Vector (Stream, Key.Encoding, V.Path); when 2 => PB_Support.IO.Read_Varint_Vector (Stream, Key.Encoding, V.Span); when 3 => if not V.Leading_Comments.Is_Set then V.Leading_Comments := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Leading_Comments.Value); when 4 => if not V.Trailing_Comments.Is_Set then V.Trailing_Comments := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Trailing_Comments.Value); when 6 => PB_Support.IO.Read_Vector (Stream, Key.Encoding, V.Leading_Detached_Comments); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Location; procedure Write_Location (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Location) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Location (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; WS.Write_Varint_Packed (1, V.Path); WS.Write_Varint_Packed (2, V.Span); if V.Leading_Comments.Is_Set then WS.Write (3, V.Leading_Comments.Value); end if; if V.Trailing_Comments.Is_Set then WS.Write (4, V.Trailing_Comments.Value); end if; WS.Write (6, V.Leading_Detached_Comments); if WS.End_Message then Write_Location (WS'Access, V); end if; end; end Write_Location; function Length (Self : Generated_Code_Info_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Generated_Code_Info_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Generated_Code_Info_Array, Generated_Code_Info_Array_Access); procedure Append (Self : in out Generated_Code_Info_Vector; V : Generated_Code_Info) is Init_Length : constant Positive := Positive'Max (1, 256 / Generated_Code_Info'Size); begin if Self.Length = 0 then Self.Data := new Generated_Code_Info_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Generated_Code_Info_Array' (Self.Data.all & Generated_Code_Info_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Generated_Code_Info_Vector) is begin if Self.Length > 0 then Self.Data := new Generated_Code_Info_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Generated_Code_Info_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Generated_Code_Info_Variable_Reference (Self : aliased in out Generated_Code_Info_Vector; Index : Positive) return Generated_Code_Info_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Generated_Code_Info_Variable_Reference; not overriding function Get_Generated_Code_Info_Constant_Reference (Self : aliased Generated_Code_Info_Vector; Index : Positive) return Generated_Code_Info_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Generated_Code_Info_Constant_Reference; procedure Read_Generated_Code_Info (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Generated_Code_Info) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => Annotation_IO.Read_Vector (Stream, Key.Encoding, V.Annotation); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Generated_Code_Info; procedure Write_Generated_Code_Info (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Generated_Code_Info) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Generated_Code_Info (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; for J in 1 .. V.Annotation.Length loop WS.Write_Key ((1, PB_Support.Length_Delimited)); Google.Protobuf.Descriptor.Annotation'Write (Stream, V.Annotation (J)); end loop; if WS.End_Message then Write_Generated_Code_Info (WS'Access, V); end if; end; end Write_Generated_Code_Info; function Length (Self : Annotation_Vector) return Natural is begin return Self.Length; end Length; procedure Clear (Self : in out Annotation_Vector) is begin Self.Length := 0; end Clear; procedure Free is new Ada.Unchecked_Deallocation (Annotation_Array, Annotation_Array_Access); procedure Append (Self : in out Annotation_Vector; V : Annotation) is Init_Length : constant Positive := Positive'Max (1, 256 / Annotation'Size); begin if Self.Length = 0 then Self.Data := new Annotation_Array (1 .. Init_Length); elsif Self.Length = Self.Data'Last then Self.Data := new Annotation_Array' (Self.Data.all & Annotation_Array'(1 .. Self.Length => <>)); end if; Self.Length := Self.Length + 1; Self.Data (Self.Length) := V; end Append; overriding procedure Adjust (Self : in out Annotation_Vector) is begin if Self.Length > 0 then Self.Data := new Annotation_Array'(Self.Data (1 .. Self.Length)); end if; end Adjust; overriding procedure Finalize (Self : in out Annotation_Vector) is begin if Self.Data /= null then Free (Self.Data); end if; end Finalize; not overriding function Get_Annotation_Variable_Reference (Self : aliased in out Annotation_Vector; Index : Positive) return Annotation_Variable_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Annotation_Variable_Reference; not overriding function Get_Annotation_Constant_Reference (Self : aliased Annotation_Vector; Index : Positive) return Annotation_Constant_Reference is begin return (Element => Self.Data (Index)'Access); end Get_Annotation_Constant_Reference; procedure Read_Annotation (Stream : access Ada.Streams.Root_Stream_Type'Class; V : out Annotation) is Key : aliased PB_Support.IO.Key; begin while PB_Support.IO.Read_Key (Stream, Key'Access) loop case Key.Field is when 1 => PB_Support.IO.Read_Varint_Vector (Stream, Key.Encoding, V.Path); when 2 => if not V.Source_File.Is_Set then V.Source_File := (True, others => <>); end if; PB_Support.IO.Read (Stream, Key.Encoding, V.Source_File.Value); when 3 => if not V.PB_Begin.Is_Set then V.PB_Begin := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.PB_Begin.Value); when 4 => if not V.PB_End.Is_Set then V.PB_End := (True, others => <>); end if; PB_Support.IO.Read_Varint (Stream, Key.Encoding, V.PB_End.Value); when others => PB_Support.IO.Unknown_Field (Stream, Key.Encoding); end case; end loop; end Read_Annotation; procedure Write_Annotation (Stream : access Ada.Streams.Root_Stream_Type'Class; V : Annotation) is begin if Stream.all not in PB_Support.Internal.Stream then declare WS : aliased PB_Support.Internal.Stream (Stream); begin Write_Annotation (WS'Access, V); return; end; end if; declare WS : PB_Support.Internal.Stream renames PB_Support.Internal.Stream (Stream.all); begin WS.Start_Message; WS.Write_Varint_Packed (1, V.Path); if V.Source_File.Is_Set then WS.Write (2, V.Source_File.Value); end if; if V.PB_Begin.Is_Set then WS.Write_Varint (3, V.PB_Begin.Value); end if; if V.PB_End.Is_Set then WS.Write_Varint (4, V.PB_End.Value); end if; if WS.End_Message then Write_Annotation (WS'Access, V); end if; end; end Write_Annotation; end Google.Protobuf.Descriptor;
alloy4fun_models/trashltl/models/11/8RgnwStRRraJYwMDL.als
Kaixi26/org.alloytools.alloy
0
3835
<gh_stars>0 open main pred id8RgnwStRRraJYwMDL_prop12 { all f : File | (always eventually f in Trash) implies (eventually f not in Trash) } pred __repair { id8RgnwStRRraJYwMDL_prop12 } check __repair { id8RgnwStRRraJYwMDL_prop12 <=> prop12o }
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c45231a.ada
best08618/asylo
7
15105
-- C45231A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT THE RELATIONAL AND MEMBERSHIP OPERATIONS YIELD CORRECT -- RESULTS FOR PREDEFINED TYPE INTEGER (INCLUDING THE CASE IN WHICH THE -- RELATIONAL OPERATORS ARE REDEFINED). -- SUBTESTS ARE: -- (A). TESTS FOR RELATIONAL OPERATORS. -- (B). TESTS FOR MEMBERSHIP OPERATORS. -- (C). TESTS FOR MEMBERSHIP OPERATORS IN THE CASE IN WHICH THE -- RELATIONAL OPERATORS ARE REDEFINED. -- RJW 2/4/86 WITH REPORT; USE REPORT; PROCEDURE C45231A IS BEGIN TEST ( "C45231A", "CHECK THAT THE RELATIONAL AND " & "MEMBERSHIP OPERATIONS YIELD CORRECT " & "RESULTS FOR PREDEFINED TYPE INTEGER " & "(INCLUDING THE CASE IN WHICH THE " & "RELATIONAL OPERATORS ARE REDEFINED)" ); DECLARE -- (A) I1A, I1B : INTEGER := IDENT_INT (1); I2 : INTEGER := IDENT_INT (2); CI2 : CONSTANT INTEGER := 2; BEGIN -- (A) IF (I2 = CI2) AND (NOT (I2 /= CI2)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 1" ); END IF; IF (I2 /= 4) AND (NOT (I2 = 4)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 2" ); END IF; IF (I1A = I1B) AND (NOT (I1A /= I1B)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 3" ); END IF; IF (I2 >= CI2) AND (NOT (I2 < CI2)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 4"); END IF; IF (I2 <= 4) AND (NOT (I2 > 4)) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 5" ); END IF; IF (I1A >= I1B) AND (I1A <= I1B) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 6" ); END IF; IF ">" (LEFT => CI2, RIGHT => I1A) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 7" ); END IF; IF "<" (LEFT => I1A, RIGHT => I2) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 8" ); END IF; IF ">=" (LEFT => I1A, RIGHT => I1A ) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 9 "); END IF; IF "<=" (LEFT => I1A, RIGHT => CI2) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 10 "); END IF; IF "=" (LEFT => I1A, RIGHT => I1B ) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 11 "); END IF; IF "/=" (LEFT => CI2, RIGHT => 4) THEN NULL; ELSE FAILED ( "RELATIONAL TEST - 12 "); END IF; END; -- (A) ---------------------------------------------------------------- DECLARE -- (B) SUBTYPE ST IS INTEGER RANGE -10 .. 10; I1 : INTEGER := IDENT_INT (1); I5 : INTEGER := IDENT_INT (5); CI2 : CONSTANT INTEGER := 2; CI10 : CONSTANT INTEGER := 10; BEGIN -- (B) IF (I1 IN ST) AND (I1 NOT IN CI2 .. CI10) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.1" ); END IF; IF (IDENT_INT (11) NOT IN ST) AND (CI2 IN I1 .. I5) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.2" ); END IF; IF NOT (I5 NOT IN CI2 .. 10) AND NOT (IDENT_INT (-11) IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.3" ); END IF; IF NOT (I1 IN CI2 .. CI10) AND NOT (I5 NOT IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.4" ); END IF; IF (I1 NOT IN I5 .. I1) AND NOT (I5 IN I5 .. I1) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - B.5" ); END IF; END; -- (B) ------------------------------------------------------------- DECLARE -- (C) SUBTYPE ST IS INTEGER RANGE -10 .. 10; I1 : INTEGER := IDENT_INT (1); I5 : INTEGER := IDENT_INT (5); CI2 : CONSTANT INTEGER := 2; CI10 : CONSTANT INTEGER := 10; FUNCTION ">" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) <= INTEGER'POS (R); END; FUNCTION ">=" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) < INTEGER'POS (R); END; FUNCTION "<" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) >= INTEGER'POS (R); END; FUNCTION "<=" ( L, R : INTEGER ) RETURN BOOLEAN IS BEGIN RETURN INTEGER'POS (L) > INTEGER'POS (R); END; BEGIN -- (C) IF (I1 IN ST) AND (I1 NOT IN CI2 .. CI10) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.1" ); END IF; IF (IDENT_INT (11) NOT IN ST) AND (CI2 IN I1 .. I5) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.2" ); END IF; IF NOT (I5 NOT IN CI2 .. 10) AND NOT (IDENT_INT (-11) IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.3" ); END IF; IF NOT (I1 IN CI2 .. CI10) AND NOT (I5 NOT IN ST) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.4" ); END IF; IF (I1 NOT IN I5 .. I1) AND NOT (I5 IN I5 .. I1) THEN NULL; ELSE FAILED ( "MEMBERSHIP TEST - C.5" ); END IF; END; -- (C) RESULT; END C45231A;
oeis/067/A067459.asm
neoneye/loda-programs
11
22929
; A067459: Sum of the remainders when n^2 is divided by squares less than n. ; Submitted by <NAME> ; 0,0,1,7,17,15,43,58,66,90,189,211,273,336,431,398,588,689,910,872,1199,1435,1438,1862,2007,2079,2208,2764,3329,2964,4356,3945,4359,4633,5330,5855,6210,7491,7821,7406,9610,9373,10309,10606,11965,12362,12468,14286,15054,16072,16088,17247,19513,18195,22318,22300,23380,24516,26311,27042,28234,31649,32195,32781,36431,36369,39020,38428,43244,42793,47264,48004,49758,51061,52627,57781,57391,58971,65764,64114,67460,73464,74662,74565,75488,83364,84803,86397,93979,93574,95988,95719,106234,102328,110527 add $0,1 mov $2,$0 pow $0,2 mov $3,1 mov $4,1 lpb $2 add $3,2 add $4,$3 mov $5,$0 mod $5,$4 add $1,$5 mov $5,$0 trn $5,$4 cmp $5,0 cmp $5,0 sub $2,$5 lpe mov $0,$1
programs/oeis/017/A017813.asm
neoneye/loda
22
18841
; A017813: Binomial coefficients C(97,n). ; 1,97,4656,147440,3464840,64446024,988172368,12846240784,144520208820,1429144287220,12576469727536,99468442390512,712857170465336,4660989191504120,27965935149024720,154744841157936784,793067310934426018,3778732481511088674,16794366584493727440,69829208430263393040,272333912878027232856,998557680552766520472,3449562896455011616176,11248574662353298748400,34683105208922671140900,101274667210054199731428,280452924581688553102416,737487320196292121121168,1843718300490730302802920,4386778025305530720462120,9943363524025869633047472,21490495358378492432715504,44324146676655640642475727,87305137393412625507906735,164339082152306118603118560,295810347874151013485613408,509451154672148967669667536,839905957702732081833776208,1326167301635892760790172960,2006253097346606997092825760,2909066991152580145784597352,4044312646236513861212732904,5392416861648685148283643872,6897277381178550771060474720,8464840422355494128119673520,9969700941885359750896504368,11270096716913884935796048416,12229253884310811313310605728,12738806129490428451365214300,12738806129490428451365214300,12229253884310811313310605728,11270096716913884935796048416,9969700941885359750896504368,8464840422355494128119673520,6897277381178550771060474720,5392416861648685148283643872,4044312646236513861212732904,2909066991152580145784597352,2006253097346606997092825760,1326167301635892760790172960,839905957702732081833776208,509451154672148967669667536,295810347874151013485613408,164339082152306118603118560,87305137393412625507906735,44324146676655640642475727,21490495358378492432715504,9943363524025869633047472,4386778025305530720462120,1843718300490730302802920,737487320196292121121168,280452924581688553102416,101274667210054199731428,34683105208922671140900,11248574662353298748400,3449562896455011616176,998557680552766520472,272333912878027232856,69829208430263393040,16794366584493727440,3778732481511088674,793067310934426018,154744841157936784,27965935149024720,4660989191504120,712857170465336,99468442390512,12576469727536,1429144287220,144520208820,12846240784,988172368,64446024,3464840,147440,4656,97,1 mov $1,97 bin $1,$0 mov $0,$1
test/interaction/SplitOnResultCopatternsDisabled.agda
shlevy/agda
1,989
15499
<filename>test/interaction/SplitOnResultCopatternsDisabled.agda<gh_stars>1000+ -- Copatterns disabled! {-# OPTIONS --no-copatterns #-} open import Common.Product test : {A B : Set} (a : A) (b : B) → A × B test a b = {!!} -- Should give error when attempting to split.
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/polygon.lzh/polygon/sample1/Mdatas.asm
prismotizm/gigaleak
0
81615
<reponame>prismotizm/gigaleak<gh_stars>0 Name: Mdatas.asm Type: file Size: 1132 Last-Modified: '1992-09-24T02:23:49Z' SHA-1: A7208CD8A7FDC9854B60CDAF2DD50DB9FED11F9A Description: null
programs/oeis/002/A002378.asm
neoneye/loda
22
8914
; A002378: Oblong (or promic, pronic, or heteromecic) numbers: a(n) = n*(n+1). ; 0,2,6,12,20,30,42,56,72,90,110,132,156,182,210,240,272,306,342,380,420,462,506,552,600,650,702,756,812,870,930,992,1056,1122,1190,1260,1332,1406,1482,1560,1640,1722,1806,1892,1980,2070,2162,2256,2352,2450,2550,2652,2756,2862,2970,3080,3192,3306,3422,3540,3660,3782,3906,4032,4160,4290,4422,4556,4692,4830,4970,5112,5256,5402,5550,5700,5852,6006,6162,6320,6480,6642,6806,6972,7140,7310,7482,7656,7832,8010,8190,8372,8556,8742,8930,9120,9312,9506,9702,9900 mov $1,$0 add $0,1 mul $0,$1
oeis/185/A185456.asm
neoneye/loda-programs
11
167594
; A185456: Payphone packing sequence. ; Submitted by <NAME> ; 1,3,5,8,9,14,15,16,17,26,27,28,29,30,31,32,33,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124 mul $0,4 mov $1,$0 mov $2,1 lpb $1 add $1,1 div $1,2 mul $2,2 lpe add $0,$2 div $0,4 add $0,1
test/succeed/Issue227.agda
asr/agda-kanso
1
10082
<gh_stars>1-10 {-# OPTIONS --universe-polymorphism #-} module Issue227 where open import Common.Level data D (a p b : Level) (A : Set a) (P : A → Set p) : Set (p ⊔ a ⊔ b) where d : ((x : A) → P x) → D a p b A P -- Unsolved trivial constraint: Set (a ⊔ p) =< Set (p ⊔ a). OK : ∀ {a} {A : Set a} → (A → Set) → A → Set _ OK P = P NotOK : ∀ {a} {A : Set a} → (P : A → Set) → A → Set _ NotOK P = P -- Unsolved constraint: -- \/ (Set (a ⊔ suc zero)) (Set (a ⊔ suc zero)) = \/ (Set (a ⊔ suc zero)) (Set (a ⊔ suc zero))
2018/9/ada/marble_mania.ads
jrfondren/adventofcode
0
27541
<filename>2018/9/ada/marble_mania.ads with Ada.Containers.Doubly_Linked_Lists; use Ada.Containers; package Marble_Mania is package Nat_List is new Ada.Containers.Doubly_Linked_Lists (Natural); type List_Ptr is access all Nat_List.List; type Score_Count is mod 2**64; type Player_Scores is array (Positive range <>) of Score_Count; type Circle_Game (Players : Positive) is tagged record Round : Natural := 0; Current : Nat_List.Cursor; Scores : Player_Scores (1 .. Players) := (others => 0); Board : not null List_Ptr := new Nat_List.List; end record; procedure Start (Game : in out Circle_Game) with Pre => Game.Board.Length = 0, Post => Game.Board.Length = 1 and Game.Round = 1; procedure Play (Player : in Positive; Game : in out Circle_Game) with Pre => Player <= Game.Scores'Last and Game.Board.Length > 0, Post => Game'Old.Round + 1 = Game.Round; function Play_Until (Players : in Positive; Last_Marble : in Positive) return Score_Count; end Marble_Mania;
programs/oeis/008/A008867.asm
karttu/loda
1
1542
; A008867: Triangle of truncated triangular numbers: k-th term in n-th row is number of dots in hexagon of sides k, n-k, k, n-k, k, n-k. ; 1,3,3,6,7,6,10,12,12,10,15,18,19,18,15,21,25,27,27,25,21,28,33,36,37,36,33,28,36,42,46,48,48,46,42,36,45,52,57,60,61,60,57,52,45,55,63,69,73,75,75,73,69,63,55,66,75,82,87,90,91,90,87,82,75,66,78,88,96,102,106,108,108,106,102,96,88,78,91,102,111,118,123,126,127,126,123,118,111,102,91,105,117,127,135,141,145,147,147,145,141,135,127,117,105,120,133,144,153,160,165,168,169,168,165,160,153,144,133,120,136,150,162,172,180,186,190,192,192,190,186,180,172,162,150,136,153,168,181,192,201,208,213,216,217,216,213,208,201,192,181,168,153,171,187,201,213,223,231,237,241,243,243,241,237,231,223,213,201,187,171,190,207,222,235,246,255,262,267,270,271,270,267,262,255,246,235,222,207,190,210,228,244,258,270,280,288,294,298,300,300,298,294,288,280,270,258,244,228,210,231,250,267,282,295,306,315,322,327,330,331,330,327,322,315,306,295,282,267,250,231,253,273,291,307,321,333,343,351,357,361,363,363,361,357,351,343,333,321,307 mov $2,$0 add $0,1 cal $0,128139 ; Triangle read by rows: matrix product A004736 * A128132. mov $1,$0 add $1,$2
oeis/143/A143183.asm
neoneye/loda-programs
11
104642
<gh_stars>10-100 ; A143183: Triangle t(n,m) = 1 + (2+n)*abs(n-2m) read by rows, 0<=m<=n. ; Submitted by <NAME>(s2) ; 1,4,4,9,1,9,16,6,6,16,25,13,1,13,25,36,22,8,8,22,36,49,33,17,1,17,33,49,64,46,28,10,10,28,46,64,81,61,41,21,1,21,41,61,81,100,78,56,34,12,12,34,56,78,100,121,97,73,49,25,1,25,49,73,97,121 mul $0,2 mov $1,4 lpb $0 add $0,3 add $2,$1 add $2,2 mov $1,$2 trn $2,$0 trn $0,$1 add $0,$2 lpe mul $1,$0 mov $0,$1 div $0,2 add $0,1
Data/Nat/Show.agda
oisdk/agda-playground
6
376
<filename>Data/Nat/Show.agda {-# OPTIONS --cubical --safe #-} module Data.Nat.Show where open import Prelude open import Data.Nat open import Data.Nat.DivMod open import Data.String open import Data.List showDig : ℕ → Char showDig 0 = '0' showDig 1 = '1' showDig 2 = '2' showDig 3 = '3' showDig 4 = '4' showDig 5 = '5' showDig 6 = '6' showDig 7 = '7' showDig 8 = '8' showDig 9 = '9' showDig _ = '!' showsℕ : ℕ → List Char → List Char showsℕ n xs = go xs n n where go : List Char → ℕ → ℕ → List Char go a zero _ = a go a n@(suc _) (suc t) = go (showDig (rem n 10) ∷ a) (n ÷ 10) t go a (suc _) zero = a showℕ : ℕ → String showℕ n = pack (showsℕ n [])
Comunicacion Serie/Transmisor/Transmisor.asm
nicopassaglia/Simon_digitales
0
99481
<reponame>nicopassaglia/Simon_digitales<filename>Comunicacion Serie/Transmisor/Transmisor.asm list p = 16f887 include "p16f887.inc" cblock 0x21 PUNTERO_FSR w_temp status_temp contador endc org 0x00 goto INICIO org 0x05 goto INT INICIO call CFG_EXTRA call Configuracion_Puerto_Serie call Interrupts_Configuration goto Main ;--------- CFG_EXTRA ;--------- banksel TRISD clrf TRISD clrf TRISB bsf TRISB, 0 banksel ANSELH clrf ANSELH banksel INTCON bsf INTCON, GIE bsf INTCON, INTE clrf contador return ;FIN CONFIG_EXTRA ;------------------------- Configuracion_Puerto_Serie ;------------------------- banksel TRISC bcf TRISC, 6 ;RC6/TX/CK = output bsf TRISC, 7 ;RC7/RX/DT = input banksel BAUDCTL bsf BAUDCTL, BRG16 ;16-bit BAUD Rate Generator is used. banksel SPBRG movlw .51 ;baud rate = 38400 ---> Esto seguro hay que modificarlo. ;(Fosc/(4*(SPBRG+1))) Error + 0.16% movwf SPBRG clrf SPBRGH banksel TXSTA bcf TXSTA, TX9 ;Data is 8-bit wide bsf TXSTA, TXEN ;Data transmission enabled No se para que... bcf TXSTA, SYNC ;Asynchronous mode bsf TXSTA, BRGH ;High-speed baud rate banksel RCSTA bsf RCSTA, SPEN ;RX/DT and TX/CK outputs configuration bcf RCSTA, RX9 ;Select mode for 8-bit data receive bsf RCSTA, CREN ;Receive data enabled bcf RCSTA, ADDEN ;No address detection, ninth bit ;might be used as parity bit movf RCREG, 0 ;cleared RCIF bit banksel BAUDCTL bcf BAUDCTL, SCKP ;unset inverted mode return ;----------------------- Interrupts_Configuration ;----------------------- banksel PIE1 bsf PIE1, RCIE ;USART Rx interrupt enabled banksel INTCON bsf INTCON, PEIE bsf INTCON, GIE return ;-------------- ;Rutina de Interrupcion ;-------------- INT movwf w_temp bcf STATUS, RP0 bcf STATUS, RP1 swapf STATUS, 0 movwf status_temp banksel PIE1 btfss PIE1, RCIE goto NOT_RX232_INT banksel PIR1 btfsc PIR1, RCIF ;Test for USART receive interrupt goto INTERRUPCION_RX232 NOT_RX232_INT banksel INTCON btfss INTCON, INTE goto NOT_INTE btfsc INTCON, INTF goto INTERRUPCION_RB0 NOT_INTE nop ;Otras interrupciones... ;bla bla bla goto FINISH_INT INTERRUPCION_RB0 bcf INTCON, INTF movf contador, 0 movwf TXREG ;Envia datos al otro pic incf contador, 1 movf contador, 0 xorlw 0x04 btfsc STATUS, Z clrf contador nop movlw 0x01 xorwf PORTD, 1 goto FINISH_INT INTERRUPCION_RX232 banksel RCSTA btfsc RCSTA, FERR goto FRAMING_ERROR btfsc RCSTA, OERR goto OVERRUN_ERROR goto RECIBIR_DATO RECIBIR_DATO movf RCREG, 0 andlw b'00000011' movwf PUNTERO_FSR incf FSR, 1 goto EXTRA FRAMING_ERROR bcf RCSTA, FERR ;Limpio el bit de Framing Error movf RCREG, 0 ;Mueve el byte recibido y limpia andlw b'00000011' movwf PUNTERO_FSR incf FSR, 1 ;MOSTRAR QUE HUBO UN ERROR, O USAR BACKUP bsf PORTD, 6 goto EXTRA OVERRUN_ERROR bcf RCSTA, OERR ;Limpio el bit de Overrun Error movf RCREG, 0 andlw b'00000011' movwf PUNTERO_FSR incf FSR, 1 ;MOSTRAR QUE HUBO UN ERROR, O USAR BACKUP bsf PORTD, 5 goto EXTRA FINISH_INT ;Recupero w y status swapf status_temp, 0 movwf STATUS swapf w_temp, 1 swapf w_temp, 0 retfie EXTRA movf PUNTERO_FSR, 0 call TABLA movwf PORTD goto FINISH_INT TABLA addwf PCL, 1 retlw b'00000001' retlw b'00000010' retlw b'00000100' retlw b'00001000' ;---------- Main ;---------- ;Hacer algo para ver si funciona... goto $ ;Se queda aca para siempre... end
TAREAS/Shell/shell_socket.asm
Pter18/AnalisisVuln
0
24055
;nasm -f elf32 -o shell.obj shell.asm && ld -N -m elf_i386 -o shell shell.obj ; https://www.abatchy.com/2017/05/tcp-bind-shell-in-assembly-null global _start section .text _start: ; Limpiamos los registros a utilizar xor eax, eax xor ebx, ebx xor ecx, ecx ; Creacion del socket mov al, 0x66 ; socketcall (102) #define __NR_socketcall 102 mov bl, 0x1 ; SYS_SOCKET (1) #define SYS_SOCKET 1 push ecx ; protocolo (0) colocamos nuestro primer argumento en el stack push ebx ; SOCK_STREAM (1) Unicamente colocamos ebx al stack push 0x2 ; AF_INET (2) Colocamos nuestro segundo argumento en el stack mov ecx, esp ; Colocamos ECX en el tope del stack int 0x80 ; Executamos el socket mov edi, eax ; Movemos el socket a EDI ; Bind el socket mov al, 0x66 ; socketcall (102) #define __NR_socketcall 102 pop ebx ; SYS_BIND (2) xor edx, edx ; Colocamos ceros en el registro EDX push edx ; INADDRY_ANY (0) Despues hay que colocarlo en el stack primer argumento push word 0xB822 ; sin_port = 8888 Definimos el numero del puerto y lo colocamos en el stack push bx ; AF_INET (2) AF_INET ya esta configuradao anteriormente con un 2 mov ecx, esp ; Una vez configurados nuestros argumentos apuntamos ECX en el tope del stack push 0x10 ; sizeof(host_addr) Tamaño de nuestra estructura que es de 16 push ecx ; Colocamos el puntero de la structura host_addr push edi ; socketfd mov ecx, esp ; Colocamos ECX con todos los argumentos en el tope del stack int 0x80 ; Executamos xor eax, eax ; Colocamos cero en EAX ; Configuramos nuestro socket en escucha ;Necesitamos 2 argumentos nuestro socket y el backlog push eax ; backlog (0) push edi ; socketfd mov ecx, esp ; Una vez configurados nuestros argumentos apuntamos ECX en el tope del stack inc ebx ; incremetamos a 3 inc ebx ; incremetamos a 4 mov al, 0x66 ; socketcall (102) #define __NR_socketcall 102 int 0x80 ; Executamos ; Aceptar conexiones accept(host_sock, NULL, NULL) xor edx, edx ; Colocamos cero en EDX push edx ; NULL push edx ; NULL push edi ; socketfd Nuestro socket inc ebx ; SYS_ACCEPT (5) SYS_ACCEPT esta efinido en 5, asi que actualmente contiene un 4 y solo incrementamos mov ecx, esp ; Una vez configurados nuestros argumentos apuntamos ECX en el tope del stack mov al, 0x66 ; socketcall (102) #define __NR_socketcall 102 int 0x80 ; Executamos xchg ebx, eax ; Movemos el client_sock creado en EBX ; REdireccionamos STDIN, STDERR, STDOUT dup2(client_sock, 0); xor ecx, ecx ; Colocamos cero en ECX mov cl, 0x2 ; Configuramos nuestro contador loop: mov al, 0x3f ; dup2 (63) unistd_32.h int 0x80 ; execucion de dup2 dec ecx ; decrementamos nuestro contador jns loop ; Salto hasta que la badera SF sea configurada ; Executamos /bin/sh execve("/bin/sh", NULL, NULL); push edx ; NULL push 0x68732f2f ; "hs//" //sh en codigo ASCII push 0x6e69622f ; "nib/" /bin en codigo ASCII mov ebx, esp ; Una vez configurados nuestros argumentos apuntamos ECX en el tope del stack mov ecx, edx ; NULL mov al, 0xb ; Llamada a execve int 0x80 ; Execucion
src/adda-defaults.adb
alban-linard/adda
0
23544
package body Adda.Defaults is function Hash (Element : in Integer) return Hash_Type is begin return Hash_Type (Element); end Hash; end Adda.Defaults;
antlr-basics/src/main/java/com/poc/chapter_04_part01/CommonLexerRules.g4
cgonul/antlr-poc
0
4816
lexer grammar CommonLexerRules; // note "lexer grammar" ID : [a-zA-Z]+ ; // match identifiers INT : [0-9]+ ; // match integers NEWLINE:'\r'? '\n' ; // return newlines to parser (end-statement signal) WS : [ \t]+ -> skip ; // toss out whitespace
solutions/26 - Budget Brigade 2/size-8_speed-186.asm
michaelgundlach/7billionhumans
45
27140
-- 7 Billion Humans (2087) -- -- 26: Budget Brigade 2 -- -- Author: landfillbaby -- Size: 8 -- Speed: 186 -- Speed Tests: 184, 189, 185, 187, 185 -- Success Rate: 76/100 comment 0 a: if s == printer or s >= 0 and myitem != datacube: takefrom s endif if s == shredder and myitem == datacube: giveto s endif if myitem < 50: giveto w endif giveto e jump a DEFINE COMMENT 0 eJztkD9LwmEUhZ8vEGU1NYaYNDhEWZBYlGBDhTRIQxiURH+WBAmHiDulQ4ODg0NDQ1lZkKA1SYSDVIpD NDT2UTq/91sEHnjg5byXe8+9CaQBfhnkzXxUGKEgThjCj49xJhizEKM2w7BXKi9t06S9p8UJsEyMeUo2 xwuztCzMj/tbYcrW2SDBniW5FHe2yavrsUDOYuRY5ZQ1zpx3QIRD9sUVR9REy/kpFm1b7BCxrGo87fLO scjwSVZ4yhO0AklRtHN5eXpWoueyPBHkUTwwaVVC3BLmhqhdsyS2tHWKqibXlKvBBc/apyGnTtPu+bIK 325GVzfoKEOHsuv7QZu++vrn+gPQwkt2;
programs/oeis/262/A262402.asm
neoneye/loda
22
172787
; A262402: a(n) = number of triangles that can be formed from the points of a 3 X n grid. ; 0,18,76,200,412,738,1200,1824,2632,3650,4900,6408,8196,10290,12712,15488,18640,22194,26172,30600,35500,40898,46816,53280,60312,67938,76180,85064,94612,104850,115800,127488,139936,153170,167212,182088,197820,214434,231952,250400,269800,290178,311556,333960,357412,381938,407560,434304,462192,491250,521500,552968,585676,619650,654912,691488,729400,768674,809332,851400,894900,939858,986296,1034240,1083712,1134738,1187340,1241544,1297372,1354850,1414000,1474848,1537416,1601730,1667812,1735688,1805380,1876914,1950312,2025600,2102800,2181938,2263036,2346120,2431212,2518338,2607520,2698784,2792152,2887650,2985300,3085128,3187156,3291410,3397912,3506688,3617760,3731154,3846892,3965000 mov $2,$0 add $2,1 pow $2,2 div $2,2 mov $1,$2 mov $3,$0 mul $3,4 add $1,$3 mov $4,$0 mul $4,$0 mov $3,$4 mul $3,8 add $1,$3 mul $4,$0 mov $3,$4 mul $3,4 add $1,$3 mov $0,$1
Binding_Zstandard/zstandard.ads
jrmarino/zstd-ada
13
11269
<reponame>jrmarino/zstd-ada<gh_stars>10-100 -- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt package Zstandard is pragma Pure; end Zstandard;
source/amf/ocl/amf-internals-factories-ocl_factories.adb
svn2github/matreshka
24
23954
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE 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. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Internals.Elements; with AMF.Internals.Extents; with AMF.Internals.Helpers; with AMF.Internals.Links; with AMF.Internals.Listener_Registry; with AMF.Internals.Tables.OCL_Constructors; with AMF.Internals.Tables.OCL_Metamodel; with AMF.OCL.Holders.Collection_Kinds; package body AMF.Internals.Factories.OCL_Factories is Collection_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Collection"); Set_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Set"); Ordered_Set_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("OrderedSet"); Bag_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Bag"); Sequence_Img : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("Sequence"); ----------------- -- Constructor -- ----------------- function Constructor (Extent : AMF.Internals.AMF_Extent) return not null AMF.Factories.Factory_Access is begin return new OCL_Factory'(Extent => Extent); end Constructor; ----------------------- -- Convert_To_String -- ----------------------- overriding function Convert_To_String (Self : not null access OCL_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String is pragma Unreferenced (Self); DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Kind then declare Item : constant AMF.OCL.OCL_Collection_Kind := AMF.OCL.Holders.Collection_Kinds.Element (Value); begin case Item is when AMF.OCL.Collection => return Collection_Img; when AMF.OCL.Set => return Set_Img; when AMF.OCL.Ordered_Set => return Ordered_Set_Img; when AMF.OCL.Bag => return Bag_Img; when AMF.OCL.Sequence => return Sequence_Img; end case; end; else raise Program_Error; end if; end Convert_To_String; ------------ -- Create -- ------------ overriding function Create (Self : not null access OCL_Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access is MC : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Meta_Class.all).Element; Element : AMF.Internals.AMF_Element; begin if MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Any_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Any_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Association_Class_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Association_Class_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Bag_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Bag_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Boolean_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Boolean_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Item then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Item; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Range then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Range; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Collection_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Enum_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Enum_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Expression_In_Ocl then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Expression_In_Ocl; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_If_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_If_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Integer_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Integer_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Invalid_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Invalid_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterate_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Iterate_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterator_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Iterator_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Let_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Let_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Message_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Message_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Null_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Null_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Operation_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Operation_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Ordered_Set_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Ordered_Set_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Property_Call_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Property_Call_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Real_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Real_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Sequence_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Sequence_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Set_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Set_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_State_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_State_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_String_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_String_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Template_Parameter_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Template_Parameter_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Part then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Literal_Part; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Tuple_Type; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Type_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Type_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unlimited_Natural_Literal_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Unlimited_Natural_Literal_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unspecified_Value_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Unspecified_Value_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Variable; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable_Exp then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Variable_Exp; elsif MC = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Void_Type then Element := AMF.Internals.Tables.OCL_Constructors.Create_OCL_Void_Type; else raise Program_Error; end if; AMF.Internals.Extents.Internal_Append (Self.Extent, Element); AMF.Internals.Listener_Registry.Notify_Instance_Create (AMF.Internals.Helpers.To_Element (Element)); return AMF.Internals.Helpers.To_Element (Element); end Create; ------------------------ -- Create_From_String -- ------------------------ overriding function Create_From_String (Self : not null access OCL_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder is pragma Unreferenced (Self); use type League.Strings.Universal_String; DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Kind then if Image = Collection_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Collection); elsif Image = Set_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Set); elsif Image = Ordered_Set_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Ordered_Set); elsif Image = Bag_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Bag); elsif Image = Sequence_Img then return AMF.OCL.Holders.Collection_Kinds.To_Holder (AMF.OCL.Sequence); else raise Constraint_Error; end if; else raise Program_Error; end if; end Create_From_String; ----------------- -- Create_Link -- ----------------- overriding function Create_Link (Self : not null access OCL_Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access is pragma Unreferenced (Self); begin return AMF.Internals.Links.Proxy (AMF.Internals.Links.Create_Link (AMF.Internals.Elements.Element_Base'Class (Association.all).Element, AMF.Internals.Helpers.To_Element (First_Element), AMF.Internals.Helpers.To_Element (Second_Element))); end Create_Link; ----------------- -- Get_Package -- ----------------- overriding function Get_Package (Self : not null access constant OCL_Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is pragma Unreferenced (Self); begin return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do Result.Add (Get_Package); end return; end Get_Package; ----------------- -- Get_Package -- ----------------- function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is begin return AMF.CMOF.Packages.CMOF_Package_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MM_OCL_OCL)); end Get_Package; --------------------- -- Create_Any_Type -- --------------------- overriding function Create_Any_Type (Self : not null access OCL_Factory) return AMF.OCL.Any_Types.OCL_Any_Type_Access is begin return AMF.OCL.Any_Types.OCL_Any_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Any_Type)))); end Create_Any_Type; --------------------------------------- -- Create_Association_Class_Call_Exp -- --------------------------------------- overriding function Create_Association_Class_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access is begin return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Association_Class_Call_Exp)))); end Create_Association_Class_Call_Exp; --------------------- -- Create_Bag_Type -- --------------------- overriding function Create_Bag_Type (Self : not null access OCL_Factory) return AMF.OCL.Bag_Types.OCL_Bag_Type_Access is begin return AMF.OCL.Bag_Types.OCL_Bag_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Bag_Type)))); end Create_Bag_Type; -------------------------------- -- Create_Boolean_Literal_Exp -- -------------------------------- overriding function Create_Boolean_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access is begin return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Boolean_Literal_Exp)))); end Create_Boolean_Literal_Exp; ---------------------------- -- Create_Collection_Item -- ---------------------------- overriding function Create_Collection_Item (Self : not null access OCL_Factory) return AMF.OCL.Collection_Items.OCL_Collection_Item_Access is begin return AMF.OCL.Collection_Items.OCL_Collection_Item_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Item)))); end Create_Collection_Item; ----------------------------------- -- Create_Collection_Literal_Exp -- ----------------------------------- overriding function Create_Collection_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access is begin return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Literal_Exp)))); end Create_Collection_Literal_Exp; ----------------------------- -- Create_Collection_Range -- ----------------------------- overriding function Create_Collection_Range (Self : not null access OCL_Factory) return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access is begin return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Range)))); end Create_Collection_Range; ---------------------------- -- Create_Collection_Type -- ---------------------------- overriding function Create_Collection_Type (Self : not null access OCL_Factory) return AMF.OCL.Collection_Types.OCL_Collection_Type_Access is begin return AMF.OCL.Collection_Types.OCL_Collection_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Collection_Type)))); end Create_Collection_Type; ----------------------------- -- Create_Enum_Literal_Exp -- ----------------------------- overriding function Create_Enum_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access is begin return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Enum_Literal_Exp)))); end Create_Enum_Literal_Exp; ------------------------------ -- Create_Expression_In_Ocl -- ------------------------------ overriding function Create_Expression_In_Ocl (Self : not null access OCL_Factory) return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access is begin return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Expression_In_Ocl)))); end Create_Expression_In_Ocl; ------------------- -- Create_If_Exp -- ------------------- overriding function Create_If_Exp (Self : not null access OCL_Factory) return AMF.OCL.If_Exps.OCL_If_Exp_Access is begin return AMF.OCL.If_Exps.OCL_If_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_If_Exp)))); end Create_If_Exp; -------------------------------- -- Create_Integer_Literal_Exp -- -------------------------------- overriding function Create_Integer_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access is begin return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Integer_Literal_Exp)))); end Create_Integer_Literal_Exp; -------------------------------- -- Create_Invalid_Literal_Exp -- -------------------------------- overriding function Create_Invalid_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access is begin return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Literal_Exp)))); end Create_Invalid_Literal_Exp; ------------------------- -- Create_Invalid_Type -- ------------------------- overriding function Create_Invalid_Type (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access is begin return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Invalid_Type)))); end Create_Invalid_Type; ------------------------ -- Create_Iterate_Exp -- ------------------------ overriding function Create_Iterate_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access is begin return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterate_Exp)))); end Create_Iterate_Exp; ------------------------- -- Create_Iterator_Exp -- ------------------------- overriding function Create_Iterator_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access is begin return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Iterator_Exp)))); end Create_Iterator_Exp; -------------------- -- Create_Let_Exp -- -------------------- overriding function Create_Let_Exp (Self : not null access OCL_Factory) return AMF.OCL.Let_Exps.OCL_Let_Exp_Access is begin return AMF.OCL.Let_Exps.OCL_Let_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Let_Exp)))); end Create_Let_Exp; ------------------------ -- Create_Message_Exp -- ------------------------ overriding function Create_Message_Exp (Self : not null access OCL_Factory) return AMF.OCL.Message_Exps.OCL_Message_Exp_Access is begin return AMF.OCL.Message_Exps.OCL_Message_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Exp)))); end Create_Message_Exp; ------------------------- -- Create_Message_Type -- ------------------------- overriding function Create_Message_Type (Self : not null access OCL_Factory) return AMF.OCL.Message_Types.OCL_Message_Type_Access is begin return AMF.OCL.Message_Types.OCL_Message_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Message_Type)))); end Create_Message_Type; ----------------------------- -- Create_Null_Literal_Exp -- ----------------------------- overriding function Create_Null_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access is begin return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Null_Literal_Exp)))); end Create_Null_Literal_Exp; ------------------------------- -- Create_Operation_Call_Exp -- ------------------------------- overriding function Create_Operation_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access is begin return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Operation_Call_Exp)))); end Create_Operation_Call_Exp; ----------------------------- -- Create_Ordered_Set_Type -- ----------------------------- overriding function Create_Ordered_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access is begin return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Ordered_Set_Type)))); end Create_Ordered_Set_Type; ------------------------------ -- Create_Property_Call_Exp -- ------------------------------ overriding function Create_Property_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access is begin return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Property_Call_Exp)))); end Create_Property_Call_Exp; ----------------------------- -- Create_Real_Literal_Exp -- ----------------------------- overriding function Create_Real_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access is begin return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Real_Literal_Exp)))); end Create_Real_Literal_Exp; -------------------------- -- Create_Sequence_Type -- -------------------------- overriding function Create_Sequence_Type (Self : not null access OCL_Factory) return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access is begin return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Sequence_Type)))); end Create_Sequence_Type; --------------------- -- Create_Set_Type -- --------------------- overriding function Create_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Set_Types.OCL_Set_Type_Access is begin return AMF.OCL.Set_Types.OCL_Set_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Set_Type)))); end Create_Set_Type; ---------------------- -- Create_State_Exp -- ---------------------- overriding function Create_State_Exp (Self : not null access OCL_Factory) return AMF.OCL.State_Exps.OCL_State_Exp_Access is begin return AMF.OCL.State_Exps.OCL_State_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_State_Exp)))); end Create_State_Exp; ------------------------------- -- Create_String_Literal_Exp -- ------------------------------- overriding function Create_String_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access is begin return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_String_Literal_Exp)))); end Create_String_Literal_Exp; ------------------------------------ -- Create_Template_Parameter_Type -- ------------------------------------ overriding function Create_Template_Parameter_Type (Self : not null access OCL_Factory) return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access is begin return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Template_Parameter_Type)))); end Create_Template_Parameter_Type; ------------------------------ -- Create_Tuple_Literal_Exp -- ------------------------------ overriding function Create_Tuple_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access is begin return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Exp)))); end Create_Tuple_Literal_Exp; ------------------------------- -- Create_Tuple_Literal_Part -- ------------------------------- overriding function Create_Tuple_Literal_Part (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access is begin return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Literal_Part)))); end Create_Tuple_Literal_Part; ----------------------- -- Create_Tuple_Type -- ----------------------- overriding function Create_Tuple_Type (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access is begin return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Tuple_Type)))); end Create_Tuple_Type; --------------------- -- Create_Type_Exp -- --------------------- overriding function Create_Type_Exp (Self : not null access OCL_Factory) return AMF.OCL.Type_Exps.OCL_Type_Exp_Access is begin return AMF.OCL.Type_Exps.OCL_Type_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Type_Exp)))); end Create_Type_Exp; ------------------------------------------ -- Create_Unlimited_Natural_Literal_Exp -- ------------------------------------------ overriding function Create_Unlimited_Natural_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access is begin return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unlimited_Natural_Literal_Exp)))); end Create_Unlimited_Natural_Literal_Exp; ---------------------------------- -- Create_Unspecified_Value_Exp -- ---------------------------------- overriding function Create_Unspecified_Value_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access is begin return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Unspecified_Value_Exp)))); end Create_Unspecified_Value_Exp; --------------------- -- Create_Variable -- --------------------- overriding function Create_Variable (Self : not null access OCL_Factory) return AMF.OCL.Variables.OCL_Variable_Access is begin return AMF.OCL.Variables.OCL_Variable_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable)))); end Create_Variable; ------------------------- -- Create_Variable_Exp -- ------------------------- overriding function Create_Variable_Exp (Self : not null access OCL_Factory) return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access is begin return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Variable_Exp)))); end Create_Variable_Exp; ---------------------- -- Create_Void_Type -- ---------------------- overriding function Create_Void_Type (Self : not null access OCL_Factory) return AMF.OCL.Void_Types.OCL_Void_Type_Access is begin return AMF.OCL.Void_Types.OCL_Void_Type_Access (Self.Create (AMF.CMOF.Classes.CMOF_Class_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Metamodel.MC_OCL_Void_Type)))); end Create_Void_Type; end AMF.Internals.Factories.OCL_Factories;
lib/src/xr/x86/os2/fppclr.asm
zanud/xds-2.60
53
6048
.386p .387 ; COPYRIGHT (c) 1995,99 XDS. All Rights Reserved. ; Implementation for FPU interface. ifdef SYMANTEC ; =========== Rename publics X2C_FLT_USED equ _X2C_FLT_USED endif ifdef OS2 .model FLAT endif DGROUP group _DATA ifdef OS2 _DATA segment use32 dword public 'DATA' else _DATA segment use32 para public 'DATA' endif public X2C_FLT_USED X2C_FLT_USED dd 0 FPP_init dd 0 fp_env db 28 dup (?) _DATA ends ifdef OS2 _TEXT segment use32 dword public 'CODE' else _TEXT segment use32 para public 'CODE' endif ; assume cs: _TEXT, ds: DGROUP, gs: nothing, fs: nothing public X2C_ClearFPP X2C_ClearFPP proc near cmp byte ptr X2C_FLT_USED, 0 jne short DO cmp byte ptr FPP_init, 0 je short L1 DO: fnstenv fp_env and word ptr fp_env, 0FFC0h ; Unmask all exceptions or word ptr fp_env, 00032h ; Mask precision loss, ; underflow, ; denormalized operand and word ptr fp_env+4H, 0C700h ; Clear exceptions, ; reset TOS to 0 mov word ptr fp_env+8H, 0FFFFh ; Empty stack fldenv fp_env L1: ret X2C_ClearFPP endp ; Clear exception flags, empty FP stack & set control word. ; Set FPP control word: ; - exceptions (except precision loss, underflow and denormalized operand) ; enabled ; - presision control set to 11 -- 64 bit extended presision ; - rounding control set to 00 -- round to nearest or even ; Control word: 0000001100110010B, 0332H public X2C_InitFPP X2C_InitFPP proc near cmp byte ptr FPP_init, 0 jne short L2 fninit push 0332h fldcw [esp] pop eax inc byte ptr FPP_init L2: ret X2C_InitFPP endp ; Set FPP control word: ; ; - exceptions disabled (it conforms to Java spec): ; ; precision loss ; underflow ; overflow ; denormalized operand ; zero divide ; ; - the other exceptions are enabled ; ; - presision control set to 10 -- 53 bit double precision ; - rounding control set to 00 -- round to nearest or even ; ; Control word: 0000_0010_0011_1111B public X2C_InitFPP4NaN X2C_InitFPP4NaN proc near push 023fh fldcw [esp] pop eax ret X2C_InitFPP4NaN endp _TEXT ends end
Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca_notsx.log_21829_925.asm
ljhsiun2/medusa
9
241968
<filename>Transynther/x86/_processed/NONE/_xt_sm_/i9-9900K_12_0xca_notsx.log_21829_925.asm .global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0x17cf8, %rax nop nop nop nop inc %r9 mov $0x6162636465666768, %r13 movq %r13, %xmm5 vmovups %ymm5, (%rax) nop nop nop nop nop xor %r8, %r8 lea addresses_normal_ht+0x4250, %r9 nop nop nop nop nop and $43478, %r13 movb (%r9), %r14b nop nop sub $2300, %rax lea addresses_normal_ht+0x1e69a, %rsi lea addresses_WT_ht+0x17a90, %rdi nop cmp $61048, %rax mov $127, %rcx rep movsb nop nop nop add $10394, %rax lea addresses_WC_ht+0x6090, %r14 clflush (%r14) add $50904, %r13 movb $0x61, (%r14) nop add %r9, %r9 lea addresses_normal_ht+0x1ca8a, %r14 nop sub $51654, %rax mov $0x6162636465666768, %rdi movq %rdi, %xmm7 movups %xmm7, (%r14) nop nop nop nop cmp %r13, %r13 lea addresses_WT_ht+0x8c90, %r13 xor $32635, %r14 mov $0x6162636465666768, %r8 movq %r8, (%r13) nop nop nop nop nop cmp %rax, %rax lea addresses_normal_ht+0xe990, %rax nop inc %r8 mov (%rax), %rdi nop nop nop nop dec %rsi lea addresses_normal_ht+0x1c288, %rcx nop sub %rax, %rax movw $0x6162, (%rcx) nop nop and $10330, %rsi lea addresses_UC_ht+0x12e90, %rax add %r9, %r9 mov (%rax), %ecx inc %r13 lea addresses_WT_ht+0x10190, %rsi lea addresses_UC_ht+0xd890, %rdi nop add %r14, %r14 mov $115, %rcx rep movsb nop nop nop nop and %r13, %r13 lea addresses_WC_ht+0x13690, %rsi lea addresses_D_ht+0xd0b0, %rdi nop nop cmp $4135, %rax mov $57, %rcx rep movsl nop nop nop and $444, %r13 lea addresses_UC_ht+0x28c0, %r9 nop nop nop nop xor $60407, %r8 mov (%r9), %rcx cmp %r13, %r13 lea addresses_WC_ht+0x14c90, %rdi clflush (%rdi) nop xor %r13, %r13 mov $0x6162636465666768, %rax movq %rax, (%rdi) nop nop nop nop nop sub %r14, %r14 lea addresses_WT_ht+0x10b90, %rsi lea addresses_A_ht+0x2e90, %rdi nop nop nop nop nop xor $24178, %rax mov $71, %rcx rep movsw nop sub %r9, %r9 lea addresses_A_ht+0xc3f0, %r8 and $63817, %rcx mov $0x6162636465666768, %r9 movq %r9, %xmm7 movups %xmm7, (%r8) nop nop nop xor %r8, %r8 pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %r9 push %rbp push %rdi push %rdx // Store lea addresses_PSE+0x1be90, %rdx nop nop nop nop nop xor %r9, %r9 mov $0x5152535455565758, %rdi movq %rdi, %xmm4 movups %xmm4, (%rdx) nop and $47923, %rdx // Store lea addresses_PSE+0x1be90, %rdx cmp $64517, %rbp movw $0x5152, (%rdx) nop xor $18814, %rbp // Faulty Load lea addresses_PSE+0x1be90, %rbp nop nop nop nop nop cmp $49573, %r14 movb (%rbp), %dl lea oracles, %rdi and $0xff, %rdx shlq $12, %rdx mov (%rdi,%rdx,1), %rdx pop %rdx pop %rdi pop %rbp pop %r9 pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 5}} {'52': 21829} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
cast-inert.agda
hazelgrove/hazelnut-dynamics-agda
16
3297
<filename>cast-inert.agda open import Nat open import Prelude open import core open import contexts open import typed-elaboration open import lemmas-gcomplete open import lemmas-complete open import progress-checks open import finality module cast-inert where -- if a term is compelete and well typed, then the casts inside are all -- identity casts and there are no failed casts cast-inert : ∀{Δ Γ d τ} → d dcomplete → Δ , Γ ⊢ d :: τ → cast-id d cast-inert dc TAConst = CIConst cast-inert dc (TAVar x₁) = CIVar cast-inert (DCLam dc x₁) (TALam x₂ wt) = CILam (cast-inert dc wt) cast-inert (DCAp dc dc₁) (TAAp wt wt₁) = CIAp (cast-inert dc wt) (cast-inert dc₁ wt₁) cast-inert () (TAEHole x x₁) cast-inert () (TANEHole x wt x₁) cast-inert (DCCast dc x x₁) (TACast wt x₂) with complete-consistency x₂ x x₁ ... | refl = CICast (cast-inert dc wt) cast-inert () (TAFailedCast wt x x₁ x₂) -- in a well typed complete internal expression, every cast is the -- identity cast. complete-casts : ∀{Γ Δ d τ1 τ2} → Γ , Δ ⊢ d ⟨ τ1 ⇒ τ2 ⟩ :: τ2 → d ⟨ τ1 ⇒ τ2 ⟩ dcomplete → τ1 == τ2 complete-casts wt comp with cast-inert comp wt complete-casts wt comp | CICast qq = refl -- relates expressions to the same thing with all identity casts -- removed. note that this is a syntactic rewrite and it goes under -- binders. data no-id-casts : ihexp → ihexp → Set where NICConst : no-id-casts c c NICVar : ∀{x} → no-id-casts (X x) (X x) NICLam : ∀{x τ d d'} → no-id-casts d d' → no-id-casts (·λ x [ τ ] d) (·λ x [ τ ] d') NICHole : ∀{u} → no-id-casts (⦇-⦈⟨ u ⟩) (⦇-⦈⟨ u ⟩) NICNEHole : ∀{d d' u} → no-id-casts d d' → no-id-casts (⦇⌜ d ⌟⦈⟨ u ⟩) (⦇⌜ d' ⌟⦈⟨ u ⟩) NICAp : ∀{d1 d2 d1' d2'} → no-id-casts d1 d1' → no-id-casts d2 d2' → no-id-casts (d1 ∘ d2) (d1' ∘ d2') NICCast : ∀{d d' τ} → no-id-casts d d' → no-id-casts (d ⟨ τ ⇒ τ ⟩) d' NICFailed : ∀{d d' τ1 τ2} → no-id-casts d d' → no-id-casts (d ⟨ τ1 ⇒⦇-⦈⇏ τ2 ⟩) (d' ⟨ τ1 ⇒⦇-⦈⇏ τ2 ⟩) -- removing identity casts doesn't change the type no-id-casts-type : ∀{Γ Δ d τ d' } → Δ , Γ ⊢ d :: τ → no-id-casts d d' → Δ , Γ ⊢ d' :: τ no-id-casts-type TAConst NICConst = TAConst no-id-casts-type (TAVar x₁) NICVar = TAVar x₁ no-id-casts-type (TALam x₁ wt) (NICLam nic) = TALam x₁ (no-id-casts-type wt nic) no-id-casts-type (TAAp wt wt₁) (NICAp nic nic₁) = TAAp (no-id-casts-type wt nic) (no-id-casts-type wt₁ nic₁) no-id-casts-type (TAEHole x x₁) NICHole = TAEHole x x₁ no-id-casts-type (TANEHole x wt x₁) (NICNEHole nic) = TANEHole x (no-id-casts-type wt nic) x₁ no-id-casts-type (TACast wt x) (NICCast nic) = no-id-casts-type wt nic no-id-casts-type (TAFailedCast wt x x₁ x₂) (NICFailed nic) = TAFailedCast (no-id-casts-type wt nic) x x₁ x₂
thirdparty/glut/progs/ada/texgen_procs.adb
ShiroixD/pag_zad_2
1
6258
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with GL; use GL; with Glut; use Glut; package body Texgen_Procs is stripeImage : array (0 .. 95) of aliased GLubyte; procedure makeStripeImage is begin for j in 0 .. 31 loop if j <= 4 then stripeImage (3*j) := 255; else stripeImage (3*j) := 0; end if; if j > 4 then stripeImage (3*j+1) := 255; else stripeImage (3*j+1) := 0; end if; stripeImage (3*j+2) := 0; end loop; end makeStripeImage; sgenparams : array (0 .. 3) of aliased GLfloat := (1.0, 1.0, 1.0, 0.0); procedure DoInit is begin glClearColor (0.0, 0.0, 0.0, 0.0); makeStripeImage; glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage1D (GL_TEXTURE_1D, 0, 3, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, stripeImage(0)'Access); glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv (GL_S, GL_OBJECT_PLANE, sgenparams (0)'ACCESS); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); glEnable (GL_TEXTURE_GEN_S); glEnable (GL_TEXTURE_1D); glEnable (GL_CULL_FACE); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glFrontFace (GL_CW); glCullFace (GL_BACK); glMaterialf (GL_FRONT, GL_SHININESS, 64.0); end DoInit; procedure DoDisplay is begin glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); glPushMatrix; glRotatef (45.0, 0.0, 0.0, 1.0); glutSolidTeapot (2.0); glPopMatrix; glFlush; end DoDisplay; procedure ReshapeCallback (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; if w <= h then glOrtho (-3.5, 3.5, GLdouble (-3.5*GLdouble (h)/GLdouble (w)), GLdouble (3.5*GLdouble (h)/GLdouble (w)), -3.5, 3.5); else glOrtho ((-3.5*GLdouble (w)/GLdouble (h)), GLdouble (3.5*GLdouble (w)/GLdouble (h)), -3.5, 3.5, -3.5, 3.5); end if; glMatrixMode (GL_MODELVIEW); glLoadIdentity; end ReshapeCallback; end Texgen_Procs;
traceur_intermediaire.adb
zyron92/banana_tree_generator
0
21901
<gh_stars>0 with Geometry_Helpers, Ada.Numerics.Generic_Elementary_Functions; use Geometry_Helpers; package body Traceur_Intermediaire is --Calcul des 2 points de contrôle du côté du sommet de départ procedure Calcul_Point_Control(Coord_S_D, Mid: in Coord_Point; Longueur: in Float; Ctl_T, Ctl_I: out Coord_Point) is Angle_Inc : Float := Angle_Incident_Arrete(Coord_S_D,Mid,Longueur); Angle_Croix : Float := En_Radian(45.0); begin --Ctl_T.X => Point Controle Trigo du coté du sommet de départ --Ctl_T.Y => Point Controle Inverse du coté du sommet de départ if A_Droite(Coord_S_D, Mid) then if En_Haut(Coord_S_D, Mid) then -->> Arète en direction nord-ouest (sur le plan svg) Ctl_T.X := Mid.X - Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_T.Y := Mid.Y + Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_I.X := Mid.X + Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_I.Y := Mid.Y + Oppose(Angle_Inc,Angle_Croix,Longueur); else -->>Arète en direction sud-ouest (sur le plan svg) Ctl_T.X := Mid.X + Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_T.Y := Mid.Y - Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_I.X := Mid.X - Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_I.Y := Mid.Y - Adjacent(Angle_Inc,Angle_Croix,Longueur); end if; else -->>Arète en direction nord-est (sur le plan svg) if En_Haut(Coord_S_D, Mid) then Ctl_T.X := Mid.X - Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_T.Y := Mid.Y + Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_I.X := Mid.X + Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_I.Y := Mid.Y + Adjacent(Angle_Inc,Angle_Croix,Longueur); -->>Arrete en direction sud-est (sur le plan svg) else Ctl_T.X := Mid.X + Oppose(Angle_Inc,Angle_Croix,Longueur); Ctl_T.Y := Mid.Y - Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_I.X := Mid.X - Adjacent(Angle_Inc,Angle_Croix,Longueur); Ctl_I.Y := Mid.Y - Oppose(Angle_Inc,Angle_Croix,Longueur); end if; end if; end Calcul_Point_Control; --Mise à jour des champs des points de contrôle et du point de millieu de l'arète procedure Mise_A_Jour_Control_Milieu(Ctl_T, Ctl_I, Mid: Coord_Point; Ptr_Arr: in Ptr_Liste_Arretes_Adj) is begin Ptr_Arr.all.Arr.PCtl_T := Ctl_T; Ptr_Arr.all.Arr.PCtl_I := Ctl_I; Ptr_Arr.all.Arr.PMilieu := Mid; --Trouver les points les plus loin dans le dessin svg pour faciliter la génération de l'entête du fichier svg Tester_Max_Min(Ctl_T); Tester_Max_Min(Ctl_T); end Mise_A_Jour_Control_Milieu; procedure Tracer_Arretes_Controls(G: in Graphe; Fichier: in File_Type; Tracer: in Boolean) is Cour: Ptr_Liste_Arretes_Adj; Coord_S_D, Coord_S_A, Mid, Ctl_T, Ctl_I: Coord_Point; Longueur: Float; begin --D étant l'ID de sommet de départ --Nous parcourons tous les sommets for S in G'Range loop --Nous parcourons toutes les arètes adjacentes au sommet S Cour:=G(S).Liste_Arr_Adj; while Cour /= null loop --Coord_S_D : Coordonnées du sommet de départ & Coord_S_A : celles d'arrivée Coord_S_D := G(S).Coord_Sommet; Coord_S_A := G(Cour.all.Arr.Id_SomArrive).Coord_Sommet; --Tracé d'une arète (un sommet de départ vers un sommet d'arrivée) --si l'ID de sommet d'arrivé est plus grand que celui de départ pour ne pas redessiner l'arète if Cour.all.Arr.Id_SomArrive > S and Tracer then Tracer_Ligne_Droite(Coord_S_D, Coord_S_A, Fichier); end if; Mid := Milieu(Coord_S_D, Coord_S_A); Longueur:= Longueur_Arrete(Coord_S_D, Coord_S_A); --Nous avons choisi la moitié de la longueur de l'arête pour la longueur d'un trait du croix Calcul_Point_Control(Coord_S_D, Mid, Longueur/2.0, Ctl_T, Ctl_I); Mise_A_Jour_Control_Milieu(Ctl_T, Ctl_I, Mid, Cour); --Tracé des segments reliant chaque point contrôle du côté du sommet de départ avec le point du milieu de l'arète --en utilisant les champs dans l'arète qui viennent d'être mis-a-jour pour s'assurer la mise-à-jour est bonne. if Tracer then Tracer_Ligne_Droite(Cour.all.Arr.PCtl_T, Cour.all.Arr.PMilieu, Fichier); Tracer_Ligne_Droite(Cour.all.Arr.PCtl_I, Cour.all.Arr.PMilieu, Fichier); end if; --Nous passons à l'arète adjacente au sommet de départ suivante Cour := Cour.all.Arr_Adj_Suiv; end loop; end loop; end Tracer_Arretes_Controls; procedure Generer_Trace_Intermediaire (Nom_Fichier: in string; Couleur_Trait: in RGB; Epaisseur: in string; G: in Graphe) is Fichier : File_Type; begin --Création et entêtes du fichier SVG Create(Fichier,Out_File,Nom_Fichier); Le_Debut(Fichier); --Le tracé intermédiaire Appliquer_Couleur_Epaisseur(True,Couleur_Trait,Epaisseur,Fichier); Tracer_Arretes_Controls(G,Fichier,True); Fin_Couleur_Translation(Fichier); --Les queues & Fermeture du fichier SVG La_Fin(Fichier); Close(Fichier); end; procedure Le_Debut(Fichier: in File_Type) is W,H,Translat_X,Translat_Y : Float; begin Taille_SVG_Translation(W,H,Translat_X,Translat_Y); Header(W,H,Fichier); Translation_Image(Translat_X,Translat_Y,Fichier); end Le_Debut; procedure La_Fin(Fichier: in File_Type) is begin Fin_Couleur_Translation(Fichier); Footer(Fichier); end La_Fin; end Traceur_Intermediaire;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/unc_memops.adb
best08618/asylo
7
9680
package body Unc_Memops is use type System.Address; type Addr_Array_T is array (1 .. 20) of Addr_T; type Addr_Stack_T is record Store : Addr_Array_T; Size : Integer := 0; end record; procedure Push (Addr : Addr_T; As : access addr_stack_t) is begin As.Size := As.Size + 1; As.Store (As.Size) := Addr; end; function Pop (As : access Addr_Stack_T) return Addr_T is Addr : Addr_T := As.Store (As.Size); begin As.Size := As.Size - 1; return Addr; end; -- Addr_Stack : aliased Addr_Stack_T; Symetry_Expected : Boolean := False; procedure Expect_Symetry (Status : Boolean) is begin Symetry_Expected := Status; end; function Alloc (Size : size_t) return Addr_T is function malloc (Size : Size_T) return Addr_T; pragma Import (C, Malloc, "malloc"); Ptr : Addr_T := malloc (Size); begin if Symetry_Expected then Push (Ptr, Addr_Stack'Access); end if; return Ptr; end; procedure Free (Ptr : addr_t) is begin if Symetry_Expected and then Ptr /= Pop (Addr_Stack'Access) then raise Program_Error; end if; end; function Realloc (Ptr : addr_t; Size : size_t) return Addr_T is begin raise Program_Error; return System.Null_Address; end; end;
tools-src/gnu/gcc/gcc/ada/exp_smem.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
28654
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ S M E M -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1998-2000 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT 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 distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Einfo; use Einfo; with Exp_Util; use Exp_Util; with Nmake; use Nmake; with Namet; use Namet; with Nlists; use Nlists; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Tbuild; use Tbuild; package body Exp_Smem is Insert_Node : Node_Id; -- Node after which a write call is to be inserted ----------------------- -- Local Subprograms -- ----------------------- procedure Add_Read_Before (N : Node_Id); -- Insert a Shared_Var_ROpen call for variable before node N procedure Add_Write_After (N : Node_Id); -- Insert a Shared_Var_WOpen call for variable after the node -- Insert_Node, as recorded by On_Lhs_Of_Assigment (where it points -- to the assignment statement) or Is_Out_Actual (where it points to -- the procedure call statement). procedure Build_Full_Name (E : in Entity_Id; N : out String_Id); -- Build the fully qualified string name of a shared variable. function On_Lhs_Of_Assignment (N : Node_Id) return Boolean; -- Determines if N is on the left hand of the assignment. This means -- that either it is a simple variable, or it is a record or array -- variable with a corresponding selected or indexed component on -- the left side of an assignment. If the result is True, then -- Insert_Node is set to point to the assignment function Is_Out_Actual (N : Node_Id) return Boolean; -- In a similar manner, this function determines if N appears as an -- OUT or IN OUT parameter to a procedure call. If the result is -- True, then Insert_Node is set to point to the assignment. --------------------- -- Add_Read_Before -- --------------------- procedure Add_Read_Before (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Node_Id := Entity (N); begin if Present (Shared_Var_Read_Proc (Ent)) then Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Shared_Var_Read_Proc (Ent), Loc), Parameter_Associations => Empty_List)); end if; end Add_Read_Before; ------------------------------- -- Add_Shared_Var_Lock_Procs -- ------------------------------- procedure Add_Shared_Var_Lock_Procs (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Obj : constant Entity_Id := Entity (Expression (First_Actual (N))); Inode : Node_Id; Vnm : String_Id; begin -- We have to add Shared_Var_Lock and Shared_Var_Unlock calls around -- the procedure or function call node. First we locate the right -- place to do the insertion, which is the call itself in the -- procedure call case, or else the nearest non subexpression -- node that contains the function call. Inode := N; while Nkind (Inode) /= N_Procedure_Call_Statement and then Nkind (Inode) in N_Subexpr loop Inode := Parent (Inode); end loop; -- Now insert the Lock and Unlock calls and the read/write calls -- Two concerns here. First we are not dealing with the exception -- case, really we need some kind of cleanup routine to do the -- Unlock. Second, these lock calls should be inside the protected -- object processing, not outside, otherwise they can be done at -- the wrong priority, resulting in dead lock situations ??? Build_Full_Name (Obj, Vnm); -- First insert the Lock call before Insert_Before_And_Analyze (Inode, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_Lock), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Vnm)))); -- Now, right after the Lock, insert a call to read the object Insert_Before_And_Analyze (Inode, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Shared_Var_Read_Proc (Obj), Loc))); -- Now insert the Unlock call after Insert_After_And_Analyze (Inode, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_Unlock), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Vnm)))); -- Now for a procedure call, but not a function call, insert the -- call to write the object just before the unlock. if Nkind (N) = N_Procedure_Call_Statement then Insert_After_And_Analyze (Inode, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Shared_Var_Assign_Proc (Obj), Loc))); end if; end Add_Shared_Var_Lock_Procs; --------------------- -- Add_Write_After -- --------------------- procedure Add_Write_After (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Node_Id := Entity (N); begin if Present (Shared_Var_Assign_Proc (Ent)) then Insert_After_And_Analyze (Insert_Node, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Shared_Var_Assign_Proc (Ent), Loc), Parameter_Associations => Empty_List)); end if; end Add_Write_After; --------------------- -- Build_Full_Name -- --------------------- procedure Build_Full_Name (E : in Entity_Id; N : out String_Id) is procedure Build_Name (E : Entity_Id); -- This is a recursive routine used to construct the fully -- qualified string name of the package corresponding to the -- shared variable. procedure Build_Name (E : Entity_Id) is begin if Scope (E) /= Standard_Standard then Build_Name (Scope (E)); Store_String_Char ('.'); end if; Get_Decoded_Name_String (Chars (E)); Store_String_Chars (Name_Buffer (1 .. Name_Len)); end Build_Name; begin Start_String; Build_Name (E); N := End_String; end Build_Full_Name; ------------------------------------ -- Expand_Shared_Passive_Variable -- ------------------------------------ procedure Expand_Shared_Passive_Variable (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin -- Nothing to do for protected or limited objects if Is_Limited_Type (Typ) or else Is_Concurrent_Type (Typ) then return; -- If we are on the left hand side of an assignment, then we add -- the write call after the assignment. elsif On_Lhs_Of_Assignment (N) then Add_Write_After (N); -- If we are a parameter for an out or in out formal, then put -- the read before and the write after. elsif Is_Out_Actual (N) then Add_Read_Before (N); Add_Write_After (N); -- All other cases are simple reads else Add_Read_Before (N); end if; end Expand_Shared_Passive_Variable; ------------------- -- Is_Out_Actual -- ------------------- function Is_Out_Actual (N : Node_Id) return Boolean is Parnt : constant Node_Id := Parent (N); Formal : Entity_Id; Call : Node_Id; Actual : Node_Id; begin if (Nkind (Parnt) = N_Indexed_Component or else Nkind (Parnt) = N_Selected_Component) and then N = Prefix (Parnt) then return Is_Out_Actual (Parnt); elsif Nkind (Parnt) = N_Parameter_Association and then N = Explicit_Actual_Parameter (Parnt) then Call := Parent (Parnt); elsif Nkind (Parnt) = N_Procedure_Call_Statement then Call := Parnt; else return False; end if; -- Fall here if we are definitely a parameter Actual := First_Actual (Call); Formal := First_Formal (Entity (Name (Call))); loop if Actual = N then if Ekind (Formal) /= E_In_Parameter then Insert_Node := Call; return True; else return False; end if; else Actual := Next_Actual (Actual); Formal := Next_Formal (Formal); end if; end loop; end Is_Out_Actual; --------------------------- -- Make_Shared_Var_Procs -- --------------------------- procedure Make_Shared_Var_Procs (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : constant Entity_Id := Defining_Identifier (N); Typ : constant Entity_Id := Etype (Ent); Vnm : String_Id; Atr : Node_Id; Assign_Proc : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Ent), 'A')); Read_Proc : constant Entity_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Ent), 'R')); S : Entity_Id; -- Start of processing for Make_Shared_Var_Procs begin Build_Full_Name (Ent, Vnm); -- We turn off Shared_Passive during construction and analysis of -- the assign and read routines, to avoid improper attempts to -- process the variable references within these procedures. Set_Is_Shared_Passive (Ent, False); -- Construct assignment routine -- procedure VarA is -- S : Ada.Streams.Stream_IO.Stream_Access; -- begin -- S := Shared_Var_WOpen ("pkg.var"); -- typ'Write (S, var); -- Shared_Var_Close (S); -- end VarA; S := Make_Defining_Identifier (Loc, Name_uS); Atr := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Typ, Loc), Attribute_Name => Name_Write, Expressions => New_List ( New_Reference_To (S, Loc), New_Occurrence_Of (Ent, Loc))); Set_OK_For_Stream (Atr, True); Insert_After_And_Analyze (N, Make_Subprogram_Body (Loc, Specification => Make_Procedure_Specification (Loc, Defining_Unit_Name => Assign_Proc), -- S : Ada.Streams.Stream_IO.Stream_Access; Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => S, Object_Definition => New_Occurrence_Of (RTE (RE_Stream_Access), Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( -- S := Shared_Var_WOpen ("pkg.var"); Make_Assignment_Statement (Loc, Name => New_Reference_To (S, Loc), Expression => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_WOpen), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Vnm)))), Atr, -- Shared_Var_Close (S); Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_Close), Loc), Parameter_Associations => New_List (New_Reference_To (S, Loc))))))); -- Construct read routine -- procedure varR is -- S : Ada.Streams.Stream_IO.Stream_Access; -- begin -- S := Shared_Var_ROpen ("pkg.var"); -- if S /= null then -- typ'Read (S, Var); -- Shared_Var_Close (S); -- end if; -- end varR; S := Make_Defining_Identifier (Loc, Name_uS); Atr := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Typ, Loc), Attribute_Name => Name_Read, Expressions => New_List ( New_Reference_To (S, Loc), New_Occurrence_Of (Ent, Loc))); Set_OK_For_Stream (Atr, True); Insert_After_And_Analyze (N, Make_Subprogram_Body (Loc, Specification => Make_Procedure_Specification (Loc, Defining_Unit_Name => Read_Proc), -- S : Ada.Streams.Stream_IO.Stream_Access; Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => S, Object_Definition => New_Occurrence_Of (RTE (RE_Stream_Access), Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( -- S := Shared_Var_ROpen ("pkg.var"); Make_Assignment_Statement (Loc, Name => New_Reference_To (S, Loc), Expression => Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_ROpen), Loc), Parameter_Associations => New_List ( Make_String_Literal (Loc, Vnm)))), -- if S /= null then Make_Implicit_If_Statement (N, Condition => Make_Op_Ne (Loc, Left_Opnd => New_Reference_To (S, Loc), Right_Opnd => Make_Null (Loc)), Then_Statements => New_List ( -- typ'Read (S, Var); Atr, -- Shared_Var_Close (S); Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Shared_Var_Close), Loc), Parameter_Associations => New_List (New_Reference_To (S, Loc))))))))); Set_Is_Shared_Passive (Ent, True); Set_Shared_Var_Assign_Proc (Ent, Assign_Proc); Set_Shared_Var_Read_Proc (Ent, Read_Proc); end Make_Shared_Var_Procs; -------------------------- -- On_Lhs_Of_Assignment -- -------------------------- function On_Lhs_Of_Assignment (N : Node_Id) return Boolean is P : constant Node_Id := Parent (N); begin if Nkind (P) = N_Assignment_Statement then if N = Name (P) then Insert_Node := P; return True; else return False; end if; elsif (Nkind (P) = N_Indexed_Component or else Nkind (P) = N_Selected_Component) and then N = Prefix (P) then return On_Lhs_Of_Assignment (P); else return False; end if; end On_Lhs_Of_Assignment; end Exp_Smem;
oeis/161/A161199.asm
neoneye/loda-programs
11
243878
<reponame>neoneye/loda-programs ; A161199: Numerators in expansion of (1-x)^(-5/2). ; 1,5,35,105,1155,3003,15015,36465,692835,1616615,7436429,16900975,152108775,339319575,1502700975,3305942145,115707975075,251835004575,1091285019825,2354878200675,20251952525805,43397041126725,185423721177825,395033145117975,6715563467005575,14236994550051819,60233438480988465,127159481237642315,1071772770431556655,2254418586080170895,9468558061536717759,19853428193544730785,1330179688967496962595,2781284804204766376335,11615954182266965454105,24227561580156813661419,201896346501306780511825 seq $0,2802 ; a(n) = (2*n+3)!/(6*n!*(n+1)!). lpb $0 dif $0,2 lpe
memsim-master/src/test.adb
strenkml/EE368
0
22547
<filename>memsim-master/src/test.adb with Ada.Text_IO; use Ada.Text_IO; with Memory.RAM; use Memory.RAM; with Device; with Test.Cache; with Test.DRAM; with Test.Flip; with Test.Offset; with Test.Prefetch; with Test.RAM; with Test.Register; with Test.Shift; with Test.Split; with Test.SPM; package body Test is function Create_Monitor(latency : Time_Type := 0; ram : Boolean := True) return Monitor_Pointer is result : constant Monitor_Pointer := new Monitor_Type; begin result.latency := latency; if ram then Set_Memory(result.all, Create_RAM(latency => 1, word_size => 8)); end if; return result; end Create_Monitor; function Clone(mem : Monitor_Type) return Memory_Pointer is begin return null; end Clone; procedure Read(mem : in out Monitor_Type; address : in Address_Type; size : in Positive) is begin Check(address < Address_Type(2) ** 32); Read(Container_Type(mem), address, size); mem.last_addr := address; mem.last_size := size; mem.reads := mem.reads + 1; Advance(mem, mem.latency); mem.cycles := mem.cycles + mem.latency; end Read; procedure Write(mem : in out Monitor_Type; address : in Address_Type; size : in Positive) is begin Check(address < Address_Type(2) ** 32); Write(Container_Type(mem), address, size); mem.last_addr := address; mem.last_size := size; mem.writes := mem.writes + 1; Advance(mem, mem.latency); mem.cycles := mem.cycles + mem.latency; end Write; procedure Idle(mem : in out Monitor_Type; cycles : in Time_Type) is begin Idle(Container_Type(mem), cycles); mem.cycles := mem.cycles + cycles; end Idle; procedure Generate(mem : in Monitor_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is other : constant Memory_Pointer := Get_Memory(mem); begin Generate(other.all, sigs, code); end Generate; procedure Run_Tests is begin count := 0; failed := 0; Device.Set_Device("virtex7"); Device.Set_Address_Bits(32); RAM.Run_Tests; Cache.Run_Tests; DRAM.Run_Tests; SPM.Run_Tests; Flip.Run_Tests; Offset.Run_Tests; Shift.Run_Tests; Split.Run_Tests; Prefetch.Run_Tests; Register.Run_Tests; Put_Line("ran" & Natural'Image(count) & " tests"); if failed > 1 then Put_Line(Natural'Image(failed) & " tests failed"); elsif failed = 1 then Put_Line(Natural'Image(failed) & " test failed"); else Put_Line("all tests passed"); end if; end Run_Tests; procedure Check(cond : in Boolean; source : in String := GNAT.Source_Info.File; line : in Natural := GNAT.Source_Info.Line) is lstr : constant String := Natural'Image(line); msg : constant String := source & "[" & lstr(lstr'First + 1 .. lstr'Last) & "]"; begin count := count + 1; if not cond then Put_Line(msg & ": FAILED"); failed := failed + 1; end if; end Check; end Test;
apps/cc1101_modem/modem.adb
ekoeppen/STM32_Generic_Ada_Drivers
1
26325
with Interfaces; use Interfaces; with STM32GD.Board; use STM32GD.Board; with STM32_SVD; use STM32_SVD; with STM32GD.GPIO; with STM32GD.GPIO.Pin; with Drivers.CC1101; with Host_Message; package body Modem is package IRQ renames P2_IN; package Radio is new Drivers.CC1101 (SPI => SPI, Chip_Select => CSN, IRQ => IRQ); Packet: Radio.Packet_Type (1 .. 32); Host_Packet : Host_Message.Packet_Type (1 .. 32); Packet_Length : Natural; Now : RTC.Date_Time_Type; Wait_Time : RTC.Second_Delta_Type := 30; Sync_Word : Unsigned_16 := 16#D391#; function Init return Boolean is begin STM32GD.Board.Init; Host_Message.Send_Hello; Radio.Init; if Radio.Get_Sync_Word = Sync_Word then IRQ.Configure_Trigger (Rising => True); STM32GD.Clear_Event; return True; else return False; end if; end Init; procedure Run is begin Radio.RX_Mode; RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); loop STM32GD.Wait_For_Event; if Radio.RX_Available then LED.Set; Radio.Clear_IRQ; Radio.RX (Packet, Packet_Length); for I in 1 .. Packet_Length loop Host_Packet (I) := Unsigned_8 (Packet (I)); end loop; Host_Message.Send_Packet (Host_Packet, Packet_Length); LED.Clear; end if; if RTC.Alarm_Triggered then RTC.Clear_Alarm; Host_Message.Send_Heartbeat; RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); end if; end loop; end Run; procedure Error is begin loop RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); STM32GD.Wait_For_Event; if RTC.Alarm_Triggered then RTC.Clear_Alarm; Host_Message.Send_Error_Message ("Modem init failed"); end if; end loop; end Error; end Modem;
src/Project7/SimpleAdd.asm
HSU-F20-CS243/p07-starter
0
245904
<filename>src/Project7/SimpleAdd.asm @7 D=A @SP A=M M=D @SP D=M+1 M=D @8 D=A @SP A=M M=D @SP D=M+1 M=D @SP M=M-1 A=M D=M @SP M=M-1 A=M D=D+M @SP A=M M=D @SP M=M+1
src/CopyLinkFromOutlook.applescript
hakanserce/outlook-links-for-macOS
12
3248
tell application "Microsoft Outlook" set selectedMessages to selected objects if selectedMessages is {} then display notification "Please select a message in Outlook before running the script!" else set messageId to id of item 1 of selectedMessages set uri to "outlook://" & messageId set the clipboard to uri display notification "URI " & uri & " copied to clipboard" end if end tell
.emacs.d/elpa/wisi-2.1.1/wisitoken-parse-packrat-procedural.adb
caqg/linux-home
0
15648
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); package body WisiToken.Parse.Packrat.Procedural is function Apply_Rule (Parser : in out Procedural.Parser; R : in Token_ID; Last_Pos : in Base_Token_Index) return Memo_Entry with Post => Apply_Rule'Result.State in Failure .. Success; function Eval (Parser : in out Procedural.Parser; R : in Token_ID; Last_Pos : in Base_Token_Index) return Memo_Entry with Post => Eval'Result.State in Failure .. Success; ---------- -- bodies function Eval (Parser : in out Procedural.Parser; R : in Token_ID; Last_Pos : in Base_Token_Index) return Memo_Entry is Descriptor : WisiToken.Descriptor renames Parser.Trace.Descriptor.all; subtype Terminal is Token_ID range Descriptor.First_Terminal .. Descriptor.Last_Terminal; Pos : Base_Token_Index := Last_Pos; -- last token parsed. begin for RHS_Index in Parser.Grammar (R).RHSs.First_Index .. Parser.Grammar (R).RHSs.Last_Index loop declare use all type Ada.Containers.Count_Type; RHS : WisiToken.Productions.Right_Hand_Side renames Parser.Grammar (R).RHSs (RHS_Index); Memo : Memo_Entry; -- for temporary or intermediate results begin if RHS.Tokens.Length = 0 then return (State => Success, Result => Parser.Tree.Add_Nonterm (Production => (R, RHS_Index), Action => RHS.Action, Children => (1 .. 0 => Syntax_Trees.Invalid_Node_Index), Default_Virtual => False), Last_Pos => Pos); else declare Children : Syntax_Trees.Valid_Node_Index_Array (SAL.Base_Peek_Type (RHS.Tokens.First_Index) .. SAL.Base_Peek_Type (RHS.Tokens.Last_Index)); begin for I in RHS.Tokens.First_Index .. RHS.Tokens.Last_Index loop if RHS.Tokens (I) in Terminal then if Pos = Parser.Terminals.Last_Index then goto Fail_RHS; elsif Parser.Terminals (Pos + 1).ID = RHS.Tokens (I) then Pos := Pos + 1; Children (SAL.Base_Peek_Type (I)) := Tree_Index (Pos); else goto Fail_RHS; end if; else Memo := Apply_Rule (Parser, RHS.Tokens (I), Pos); case Memo.State is when Success => Children (SAL.Base_Peek_Type (I)) := Memo.Result; Pos := Memo.Last_Pos; when Failure => goto Fail_RHS; when No_Result => raise SAL.Programmer_Error; end case; end if; end loop; return (State => Success, Result => Parser.Tree.Add_Nonterm (Production => (R, RHS_Index), Action => RHS.Action, Children => Children, Default_Virtual => False), Last_Pos => Pos); <<Fail_RHS>> Pos := Last_Pos; end; end if; end; end loop; -- get here when all RHSs fail return (State => Failure); end Eval; function Apply_Rule (Parser : in out Procedural.Parser; R : in Token_ID; Last_Pos : in Base_Token_Index) return Memo_Entry is Descriptor : WisiToken.Descriptor renames Parser.Trace.Descriptor.all; Pos : Base_Token_Index := Last_Pos; -- last token parsed. Start_Pos : constant Token_Index := Last_Pos + 1; -- first token in current nonterm Memo : Memo_Entry := Parser.Derivs (R)(Start_Pos); Pos_Recurse_Last : Base_Token_Index := Last_Pos; Result_Recurse : Memo_Entry; begin case Memo.State is when Success => return Memo; when Failure => return (State => Failure); when No_Result => if Parser.Direct_Left_Recursive (R) then Parser.Derivs (R).Replace_Element (Start_Pos, (State => Failure)); else Memo := Eval (Parser, R, Last_Pos); if Trace_Parse > Detail and then Memo.State = Success then Parser.Trace.Put_Line (Parser.Tree.Image (Memo.Result, Descriptor, Include_Children => True)); end if; Parser.Derivs (R).Replace_Element (Start_Pos, Memo); return Memo; end if; end case; loop Pos := Last_Pos; if Pos > Parser.Terminals.Last_Index then -- FIXME: this can't pass here; Last_Pos never > last_index -- There might be an empty nonterm after the last token return (State => Failure); end if; Result_Recurse := Eval (Parser, R, Pos); if Result_Recurse.State = Success then if Result_Recurse.Last_Pos > Pos_Recurse_Last then Parser.Derivs (R).Replace_Element (Start_Pos, Result_Recurse); Pos := Result_Recurse.Last_Pos; Pos_Recurse_Last := Pos; if WisiToken.Trace_Parse > Detail then Parser.Trace.Put_Line (Parser.Tree.Image (Result_Recurse.Result, Descriptor, Include_Children => True)); end if; -- continue looping elsif Result_Recurse.Last_Pos = Pos_Recurse_Last then if Parser.Tree.Is_Empty (Result_Recurse.Result) then Parser.Derivs (R).Replace_Element (Start_Pos, Result_Recurse); end if; exit; else -- Result_Recurse.Last_Pos < Pos_Recurse_Last exit; end if; else exit; end if; end loop; return Parser.Derivs (R)(Start_Pos); end Apply_Rule; ---------- -- Public subprograms function Create (Grammar : in WisiToken.Productions.Prod_Arrays.Vector; Direct_Left_Recursive : in Token_ID_Set; Start_ID : in Token_ID; Trace : access WisiToken.Trace'Class; Lexer : WisiToken.Lexer.Handle; User_Data : WisiToken.Syntax_Trees.User_Data_Access) return Procedural.Parser is begin return Parser : Procedural.Parser (Grammar.First_Index, Grammar.Last_Index) do Parser.Trace := Trace; Parser.Lexer := Lexer; Parser.User_Data := User_Data; Parser.Grammar := Grammar; Parser.Start_ID := Start_ID; Parser.Direct_Left_Recursive := Direct_Left_Recursive; end return; end Create; overriding procedure Parse (Parser : aliased in out Procedural.Parser) is Descriptor : WisiToken.Descriptor renames Parser.Trace.Descriptor.all; Junk : WisiToken.Syntax_Trees.Valid_Node_Index; pragma Unreferenced (Junk); Result : Memo_Entry; begin Parser.Base_Tree.Clear; Parser.Tree.Initialize (Parser.Base_Tree'Unchecked_Access, Flush => True); Parser.Lex_All; for Nonterm in Descriptor.First_Nonterminal .. Parser.Trace.Descriptor.Last_Nonterminal loop Parser.Derivs (Nonterm).Clear; Parser.Derivs (Nonterm).Set_First (Parser.Terminals.First_Index); -- There might be an empty nonterm after the last token Parser.Derivs (Nonterm).Set_Last (Parser.Terminals.Last_Index + 1); end loop; for Token_Index in Parser.Terminals.First_Index .. Parser.Terminals.Last_Index loop Junk := Parser.Tree.Add_Terminal (Token_Index, Parser.Terminals); -- FIXME: move this into Lex_All, delete Terminals, just use Syntax_Tree end loop; Result := Apply_Rule (Parser, Parser.Start_ID, Parser.Terminals.First_Index - 1); if Result.State /= Success then if Trace_Parse > Outline then Parser.Trace.Put_Line ("parse failed"); end if; raise Syntax_Error with "parse failed"; -- FIXME: need better error message! else Parser.Tree.Set_Root (Result.Result); end if; end Parse; overriding function Tree (Parser : in Procedural.Parser) return Syntax_Trees.Tree is begin return Parser.Tree; end Tree; end WisiToken.Parse.Packrat.Procedural;
libsrc/gfx/wide/w_stencil_add_side.asm
ahjelm/z88dk
640
81820
<filename>libsrc/gfx/wide/w_stencil_add_side.asm ; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Compute the line coordinates and put into a vector ; Basic concept by <NAME> (calculate_side) ; ; <NAME> - 13/3/2009 ; ; ; $Id: w_stencil_add_side.asm,v 1.3 2016-04-23 20:37:40 dom Exp $ ; ;; void stencil_add_side(int x1, int y1, int x2, int y2, unsigned char *stencil) IF !__CPU_INTEL__ & !__CPU_GBZ80__ SECTION code_graphics PUBLIC stencil_add_side PUBLIC _stencil_add_side EXTERN w_line EXTERN stencil_add_pixel EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN stencil_ptr EXTERN __graphics_end INCLUDE "graphics/grafix.inc" .stencil_add_side ._stencil_add_side push ix ld ix,2 add ix,sp ld l,(ix+2) ;pointer to stencil ld h,(ix+3) ld (stencil_ptr),hl ld l,(ix+10) ld h,(ix+11) ld e,(ix+8) ld d,(ix+9) IF NEED_swapgfxbk = 1 call swapgfxbk ENDIF call stencil_add_pixel ld l,(ix+6) ld h,(ix+7) ld e,(ix+4) ld d,(ix+5) ld ix,stencil_add_pixel call w_line IF NEED_swapgfxbk jp __graphics_end ELSE pop ix ret ENDIF ENDIF
ch1/range_example.adb
drm343/drm343.github.io
0
9635
with Ada.Text_IO; use Ada.Text_IO; procedure Range_Example is type Range_2_Based is array (Positive range 2 .. 4) of Integer; ARR : Range_2_Based := (3, 5, 7); begin <<example_1>> Put_Line ("example 1"); for Index in 2 .. 4 loop Put_Line (Integer'image (ARR (Index))); end loop; <<example_2>> Put_Line ("example 2"); for Index in ARR'first .. ARR'last loop Put_Line (Integer'image (ARR (Index))); end loop; <<example_3>> Put_Line ("example 3"); for Index in ARR'range loop Put_Line (Integer'image (ARR (Index))); end loop; end;
programs/oeis/067/A067894.asm
neoneye/loda
22
25824
; A067894: Write 0, 1, ..., n in binary and add as if they were decimal numbers. ; 0,1,11,22,122,223,333,444,1444,2445,3455,4466,5566,6667,7777,8888,18888,28889,38899,48910,59010,69111,79221,89332,100332,111333,122343,133354,144454,155555,166665,177776,277776,377777,477787,577798,677898,777999,878109,978220,1079220,1180221,1281231,1382242,1483342,1584443,1685553,1786664,1896664,2006665,2116675,2226686,2336786,2446887,2556997,2667108,2778108,2889109,3000119,3111130,3222230,3333331,3444441,3555552,4555552,5555553,6555563,7555574,8555674,9555775,10555885,11555996,12556996,13557997,14559007,15560018,16561118,17562219,18563329,19564440,20574440,21584441,22594451,23604462,24614562,25624663,26634773,27644884,28655884,29666885,30677895,31688906,32700006,33711107,34722217,35733328,36833328,37933329,39033339,40133350 lpb $0 mov $2,$0 sub $0,1 seq $2,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2. add $1,$2 lpe mov $0,$1
test/Fail/Issue3983.agda
cruhland/agda
1,989
13811
{-# OPTIONS --safe #-} data ⊥ : Set where private {-# TERMINATING #-} f : ⊥ f = f mutual {-# TERMINATING #-} g : ⊥ g = f abstract {-# TERMINATING #-} h : ⊥ h = f record I : Set where {-# TERMINATING #-} i : ⊥ i = f instance {-# TERMINATING #-} j : I j = j
tp10/stack.als
vitorhugo13/feup-mfes
0
4636
<gh_stars>0 open util/ordering[StackState] //biblioteca para criar o conjunto ordenado (posições do stack state ordenados) sig Element {} sig StackState { elements: seq Element //conjunto ordenado de elements }{ // } abstract sig Event { pre, post: disj StackState }{ // constraints that should hold for each Event } /* fact firstState { // constraints for the first StackState //inicialmente stack vazia first.elements.isEmpty } */ //predicado init substitui o fact firstState pred init [a: StackState]{ a.elements.isEmpty } fact trace { // relate all `StackState`s and `Event`s //initial state init [first] //se usar o facto inves do predicado nao preciso disto aqui //post-conditions all s: StackState - last | let s1 = s.next | some e: Event { e.pre = s e.post = s1 } } sig Push extends Event { value: Element }{ // -- model pushing by relating `pre`, `post`, and `value` value = post.elements.first // same as below: post.elements = pre.elements.insert [0, value] post.elements.rest = pre.elements } sig Pop extends Event { // value: one Element //valor a ser removido do topo da stack }{ not pre.elements.isEmpty //stack must not be empty value = pre.elements.first post.elements = pre.elements.rest } assert popThenPush { // Pop followed by a Push of the same element //pre.s1 dá todos os eventos antes de s1(state1). //no entanto esses eventos podem ser push ou pop, //para restringir a Pop fazemos pre.s1 <: Pop //last é para ao criar os pares nao fazer par com o ultimo elem e algo que nao existe all s: StackState - last | let s1 = s.next | (some pre.s1 <: Push and some pre.s <: Pop) implies (pre.s <: Pop).value = (pre.s1 <: Push).value } check popThenPush fact InitEqualsFinal { first.elements.isEmpty last.elements.isEmpty } // para isto acontecer a stack tem de estar vazia assert sameNumberPushesPops { #Pop = #Push } check sameNumberPushesPops assert noPopFromEmpty { // nao ha nenhum evento Pop, em que pre esteja vazio no popE: Pop | popE.pre.elements.isEmpty } check noPopFromEmpty run {}
extern/gnat_sdl/gnat_sdl2/src/sdl_audio_h.ads
AdaCore/training_material
15
19092
<reponame>AdaCore/training_material pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_stdinc_h; with System; with Interfaces.C.Strings; limited with SDL_rwops_h; package SDL_audio_h is SDL_AUDIO_MASK_BITSIZE : constant := (16#FF#); -- ..\SDL2_tmp\SDL_audio.h:71 SDL_AUDIO_MASK_DATATYPE : constant := (2**8); -- ..\SDL2_tmp\SDL_audio.h:72 SDL_AUDIO_MASK_ENDIAN : constant := (2**12); -- ..\SDL2_tmp\SDL_audio.h:73 SDL_AUDIO_MASK_SIGNED : constant := (2**15); -- ..\SDL2_tmp\SDL_audio.h:74 -- arg-macro: function SDL_AUDIO_BITSIZE (x) -- return x and SDL_AUDIO_MASK_BITSIZE; -- arg-macro: function SDL_AUDIO_ISFLOAT (x) -- return x and SDL_AUDIO_MASK_DATATYPE; -- arg-macro: function SDL_AUDIO_ISBIGENDIAN (x) -- return x and SDL_AUDIO_MASK_ENDIAN; -- arg-macro: function SDL_AUDIO_ISSIGNED (x) -- return x and SDL_AUDIO_MASK_SIGNED; -- arg-macro: function SDL_AUDIO_ISINT (x) -- return notSDL_AUDIO_ISFLOAT(x); -- arg-macro: function SDL_AUDIO_ISLITTLEENDIAN (x) -- return notSDL_AUDIO_ISBIGENDIAN(x); -- arg-macro: function SDL_AUDIO_ISUNSIGNED (x) -- return notSDL_AUDIO_ISSIGNED(x); AUDIO_U8 : constant := 16#0008#; -- ..\SDL2_tmp\SDL_audio.h:89 AUDIO_S8 : constant := 16#8008#; -- ..\SDL2_tmp\SDL_audio.h:90 AUDIO_U16LSB : constant := 16#0010#; -- ..\SDL2_tmp\SDL_audio.h:91 AUDIO_S16LSB : constant := 16#8010#; -- ..\SDL2_tmp\SDL_audio.h:92 AUDIO_U16MSB : constant := 16#1010#; -- ..\SDL2_tmp\SDL_audio.h:93 AUDIO_S16MSB : constant := 16#9010#; -- ..\SDL2_tmp\SDL_audio.h:94 -- unsupported macro: AUDIO_U16 AUDIO_U16LSB -- unsupported macro: AUDIO_S16 AUDIO_S16LSB AUDIO_S32LSB : constant := 16#8020#; -- ..\SDL2_tmp\SDL_audio.h:103 AUDIO_S32MSB : constant := 16#9020#; -- ..\SDL2_tmp\SDL_audio.h:104 -- unsupported macro: AUDIO_S32 AUDIO_S32LSB AUDIO_F32LSB : constant := 16#8120#; -- ..\SDL2_tmp\SDL_audio.h:112 AUDIO_F32MSB : constant := 16#9120#; -- ..\SDL2_tmp\SDL_audio.h:113 -- unsupported macro: AUDIO_F32 AUDIO_F32LSB -- unsupported macro: AUDIO_U16SYS AUDIO_U16LSB -- unsupported macro: AUDIO_S16SYS AUDIO_S16LSB -- unsupported macro: AUDIO_S32SYS AUDIO_S32LSB -- unsupported macro: AUDIO_F32SYS AUDIO_F32LSB SDL_AUDIO_ALLOW_FREQUENCY_CHANGE : constant := 16#00000001#; -- ..\SDL2_tmp\SDL_audio.h:140 SDL_AUDIO_ALLOW_FORMAT_CHANGE : constant := 16#00000002#; -- ..\SDL2_tmp\SDL_audio.h:141 SDL_AUDIO_ALLOW_CHANNELS_CHANGE : constant := 16#00000004#; -- ..\SDL2_tmp\SDL_audio.h:142 SDL_AUDIO_ALLOW_SAMPLES_CHANGE : constant := 16#00000008#; -- ..\SDL2_tmp\SDL_audio.h:143 -- unsupported macro: SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE) SDL_AUDIOCVT_MAX_FILTERS : constant := 9; -- ..\SDL2_tmp\SDL_audio.h:203 -- unsupported macro: SDL_AUDIOCVT_PACKED __attribute__((packed)) -- arg-macro: procedure SDL_LoadWAV (file, spec, audio_buf, audio_len) -- SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) SDL_MIX_MAXVOLUME : constant := 128; -- ..\SDL2_tmp\SDL_audio.h:616 -- Simple DirectMedia Layer -- Copyright (C) 1997-2018 <NAME> <<EMAIL>> -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- 3. This notice may not be removed or altered from any source distribution. -- --* -- * \file SDL_audio.h -- * -- * Access to the raw audio mixing buffer for the SDL library. -- -- Set up for C function definitions, even when using C++ --* -- * \brief Audio format flags. -- * -- * These are what the 16 bits in SDL_AudioFormat currently mean... -- * (Unspecified bits are always zero). -- * -- * \verbatim -- ++-----------------------sample is signed if set -- || -- || ++-----------sample is bigendian if set -- || || -- || || ++---sample is float if set -- || || || -- || || || +---sample bit size---+ -- || || || | | -- 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 -- \endverbatim -- * -- * There are macros in SDL 2.0 and later to query these bits. -- subtype SDL_AudioFormat is SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_audio.h:64 --* -- * \name Audio flags -- -- @{ --* -- * \name Audio format flags -- * -- * Defaults to LSB byte order. -- -- @{ -- @} --* -- * \name int32 support -- -- @{ -- @} --* -- * \name float32 support -- -- @{ -- @} --* -- * \name Native audio byte ordering -- -- @{ -- @} --* -- * \name Allow change flags -- * -- * Which audio format changes are allowed when opening a device. -- -- @{ -- @} -- @} -- Audio flags --* -- * This function is called when the audio device needs more data. -- * -- * \param userdata An application-specific parameter saved in -- * the SDL_AudioSpec structure -- * \param stream A pointer to the audio data buffer. -- * \param len The length of that buffer in bytes. -- * -- * Once the callback returns, the buffer will no longer be valid. -- * Stereo samples are stored in a LRLRLR ordering. -- * -- * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if -- * you like. Just open your audio device with a NULL callback. -- type SDL_AudioCallback is access procedure (arg1 : System.Address; arg2 : access SDL_stdinc_h.Uint8; arg3 : int); pragma Convention (C, SDL_AudioCallback); -- ..\SDL2_tmp\SDL_audio.h:163 --* -- * The calculated values in this structure are calculated by SDL_OpenAudio(). -- * -- * For multi-channel audio, the default SDL channel mapping is: -- * 2: FL FR (stereo) -- * 3: FL FR LFE (2.1 surround) -- * 4: FL FR BL BR (quad) -- * 5: FL FR FC BL BR (quad + center) -- * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) -- * 7: FL FR FC LFE BC SL SR (6.1 surround) -- * 8: FL FR FC LFE BL BR SL SR (7.1 surround) -- --*< DSP frequency -- samples per second type SDL_AudioSpec is record freq : aliased int; -- ..\SDL2_tmp\SDL_audio.h:180 format : aliased SDL_AudioFormat; -- ..\SDL2_tmp\SDL_audio.h:181 channels : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_audio.h:182 silence : aliased SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_audio.h:183 samples : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_audio.h:184 padding : aliased SDL_stdinc_h.Uint16; -- ..\SDL2_tmp\SDL_audio.h:185 size : aliased SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_audio.h:186 callback : SDL_AudioCallback; -- ..\SDL2_tmp\SDL_audio.h:187 userdata : System.Address; -- ..\SDL2_tmp\SDL_audio.h:188 end record; pragma Convention (C_Pass_By_Copy, SDL_AudioSpec); -- ..\SDL2_tmp\SDL_audio.h:178 --*< Audio data format --*< Number of channels: 1 mono, 2 stereo --*< Audio buffer silence value (calculated) --*< Audio buffer size in sample FRAMES (total samples divided by channel count) --*< Necessary for some compile environments --*< Audio buffer size in bytes (calculated) --*< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). --*< Userdata passed to callback (ignored for NULL callbacks). type SDL_AudioCVT; type SDL_AudioFilter is access procedure (arg1 : access SDL_AudioCVT; arg2 : SDL_AudioFormat); pragma Convention (C, SDL_AudioFilter); -- ..\SDL2_tmp\SDL_audio.h:193 --* -- * \brief Upper limit of filters in SDL_AudioCVT -- * -- * The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is -- * currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, -- * one of which is the terminating NULL pointer. -- --* -- * \struct SDL_AudioCVT -- * \brief A structure to hold a set of audio conversion filters and buffers. -- * -- * Note that various parts of the conversion pipeline can take advantage -- * of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require -- * you to pass it aligned data, but can possibly run much faster if you -- * set both its (buf) field to a pointer that is aligned to 16 bytes, and its -- * (len) field to something that's a multiple of 16, if possible. -- -- This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't -- pad it out to 88 bytes to guarantee ABI compatibility between compilers. -- vvv -- The next time we rev the ABI, make sure to size the ints and add padding. -- -- --*< Set to 1 if conversion possible type SDL_AudioCVT_filters_array is array (0 .. 9) of SDL_AudioFilter; type SDL_AudioCVT is record needed : aliased int; -- ..\SDL2_tmp\SDL_audio.h:228 src_format : aliased SDL_AudioFormat; -- ..\SDL2_tmp\SDL_audio.h:229 dst_format : aliased SDL_AudioFormat; -- ..\SDL2_tmp\SDL_audio.h:230 rate_incr : aliased double; -- ..\SDL2_tmp\SDL_audio.h:231 buf : access SDL_stdinc_h.Uint8; -- ..\SDL2_tmp\SDL_audio.h:232 len : aliased int; -- ..\SDL2_tmp\SDL_audio.h:233 len_cvt : aliased int; -- ..\SDL2_tmp\SDL_audio.h:234 len_mult : aliased int; -- ..\SDL2_tmp\SDL_audio.h:235 len_ratio : aliased double; -- ..\SDL2_tmp\SDL_audio.h:236 filters : SDL_AudioCVT_filters_array; -- ..\SDL2_tmp\SDL_audio.h:237 filter_index : aliased int; -- ..\SDL2_tmp\SDL_audio.h:238 end record; pragma Convention (C_Pass_By_Copy, SDL_AudioCVT); -- ..\SDL2_tmp\SDL_audio.h:226 --*< Source audio format --*< Target audio format --*< Rate conversion increment --*< Buffer to hold entire audio data --*< Length of original audio buffer --*< Length of converted audio buffer --*< buffer must be len*len_mult big --*< Given len, final size is len*len_ratio --*< NULL-terminated list of filter functions --*< Current audio conversion function -- Function prototypes --* -- * \name Driver discovery functions -- * -- * These functions return the list of built in audio drivers, in the -- * order that they are normally initialized by default. -- -- @{ function SDL_GetNumAudioDrivers return int; -- ..\SDL2_tmp\SDL_audio.h:251 pragma Import (C, SDL_GetNumAudioDrivers, "SDL_GetNumAudioDrivers"); function SDL_GetAudioDriver (index : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_audio.h:252 pragma Import (C, SDL_GetAudioDriver, "SDL_GetAudioDriver"); -- @} --* -- * \name Initialization and cleanup -- * -- * \internal These functions are used internally, and should not be used unless -- * you have a specific need to specify the audio driver you want to -- * use. You should normally use SDL_Init() or SDL_InitSubSystem(). -- -- @{ function SDL_AudioInit (driver_name : Interfaces.C.Strings.chars_ptr) return int; -- ..\SDL2_tmp\SDL_audio.h:263 pragma Import (C, SDL_AudioInit, "SDL_AudioInit"); procedure SDL_AudioQuit; -- ..\SDL2_tmp\SDL_audio.h:264 pragma Import (C, SDL_AudioQuit, "SDL_AudioQuit"); -- @} --* -- * This function returns the name of the current audio driver, or NULL -- * if no driver has been initialized. -- function SDL_GetCurrentAudioDriver return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_audio.h:271 pragma Import (C, SDL_GetCurrentAudioDriver, "SDL_GetCurrentAudioDriver"); --* -- * This function opens the audio device with the desired parameters, and -- * returns 0 if successful, placing the actual hardware parameters in the -- * structure pointed to by \c obtained. If \c obtained is NULL, the audio -- * data passed to the callback function will be guaranteed to be in the -- * requested format, and will be automatically converted to the hardware -- * audio format if necessary. This function returns -1 if it failed -- * to open the audio device, or couldn't set up the audio thread. -- * -- * When filling in the desired audio spec structure, -- * - \c desired->freq should be the desired audio frequency in samples-per- -- * second. -- * - \c desired->format should be the desired audio format. -- * - \c desired->samples is the desired size of the audio buffer, in -- * samples. This number should be a power of two, and may be adjusted by -- * the audio driver to a value more suitable for the hardware. Good values -- * seem to range between 512 and 8096 inclusive, depending on the -- * application and CPU speed. Smaller values yield faster response time, -- * but can lead to underflow if the application is doing heavy processing -- * and cannot fill the audio buffer in time. A stereo sample consists of -- * both right and left channels in LR ordering. -- * Note that the number of samples is directly related to time by the -- * following formula: \code ms = (samples*1000)/freq \endcode -- * - \c desired->size is the size in bytes of the audio buffer, and is -- * calculated by SDL_OpenAudio(). -- * - \c desired->silence is the value used to set the buffer to silence, -- * and is calculated by SDL_OpenAudio(). -- * - \c desired->callback should be set to a function that will be called -- * when the audio device is ready for more data. It is passed a pointer -- * to the audio buffer, and the length in bytes of the audio buffer. -- * This function usually runs in a separate thread, and so you should -- * protect data structures that it accesses by calling SDL_LockAudio() -- * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL -- * pointer here, and call SDL_QueueAudio() with some frequency, to queue -- * more audio samples to be played (or for capture devices, call -- * SDL_DequeueAudio() with some frequency, to obtain audio samples). -- * - \c desired->userdata is passed as the first parameter to your callback -- * function. If you passed a NULL callback, this value is ignored. -- * -- * The audio device starts out playing silence when it's opened, and should -- * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready -- * for your audio callback function to be called. Since the audio driver -- * may modify the requested size of the audio buffer, you should allocate -- * any local mixing buffers after you open the audio device. -- function SDL_OpenAudio (desired : access SDL_AudioSpec; obtained : access SDL_AudioSpec) return int; -- ..\SDL2_tmp\SDL_audio.h:318 pragma Import (C, SDL_OpenAudio, "SDL_OpenAudio"); --* -- * SDL Audio Device IDs. -- * -- * A successful call to SDL_OpenAudio() is always device id 1, and legacy -- * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls -- * always returns devices >= 2 on success. The legacy calls are good both -- * for backwards compatibility and when you don't care about multiple, -- * specific, or capture devices. -- subtype SDL_AudioDeviceID is SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_audio.h:330 --* -- * Get the number of available devices exposed by the current driver. -- * Only valid after a successfully initializing the audio subsystem. -- * Returns -1 if an explicit list of devices can't be determined; this is -- * not an error. For example, if SDL is set up to talk to a remote audio -- * server, it can't list every one available on the Internet, but it will -- * still allow a specific host to be specified to SDL_OpenAudioDevice(). -- * -- * In many common cases, when this function returns a value <= 0, it can still -- * successfully open the default device (NULL for first argument of -- * SDL_OpenAudioDevice()). -- function SDL_GetNumAudioDevices (iscapture : int) return int; -- ..\SDL2_tmp\SDL_audio.h:344 pragma Import (C, SDL_GetNumAudioDevices, "SDL_GetNumAudioDevices"); --* -- * Get the human-readable name of a specific audio device. -- * Must be a value between 0 and (number of audio devices-1). -- * Only valid after a successfully initializing the audio subsystem. -- * The values returned by this function reflect the latest call to -- * SDL_GetNumAudioDevices(); recall that function to redetect available -- * hardware. -- * -- * The string returned by this function is UTF-8 encoded, read-only, and -- * managed internally. You are not to free it. If you need to keep the -- * string for any length of time, you should make your own copy of it, as it -- * will be invalid next time any of several other SDL functions is called. -- function SDL_GetAudioDeviceName (index : int; iscapture : int) return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_audio.h:359 pragma Import (C, SDL_GetAudioDeviceName, "SDL_GetAudioDeviceName"); --* -- * Open a specific audio device. Passing in a device name of NULL requests -- * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). -- * -- * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but -- * some drivers allow arbitrary and driver-specific strings, such as a -- * hostname/IP address for a remote audio server, or a filename in the -- * diskaudio driver. -- * -- * \return 0 on error, a valid device ID that is >= 2 on success. -- * -- * SDL_OpenAudio(), unlike this function, always acts on device ID 1. -- function SDL_OpenAudioDevice (device : Interfaces.C.Strings.chars_ptr; iscapture : int; desired : access constant SDL_AudioSpec; obtained : access SDL_AudioSpec; allowed_changes : int) return SDL_AudioDeviceID; -- ..\SDL2_tmp\SDL_audio.h:376 pragma Import (C, SDL_OpenAudioDevice, "SDL_OpenAudioDevice"); --* -- * \name Audio state -- * -- * Get the current audio state. -- -- @{ type SDL_AudioStatus is (SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED); pragma Convention (C, SDL_AudioStatus); -- ..\SDL2_tmp\SDL_audio.h:400 function SDL_GetAudioStatus return SDL_AudioStatus; -- ..\SDL2_tmp\SDL_audio.h:401 pragma Import (C, SDL_GetAudioStatus, "SDL_GetAudioStatus"); function SDL_GetAudioDeviceStatus (dev : SDL_AudioDeviceID) return SDL_AudioStatus; -- ..\SDL2_tmp\SDL_audio.h:404 pragma Import (C, SDL_GetAudioDeviceStatus, "SDL_GetAudioDeviceStatus"); -- @} -- Audio State --* -- * \name Pause audio functions -- * -- * These functions pause and unpause the audio callback processing. -- * They should be called with a parameter of 0 after opening the audio -- * device to start playing sound. This is so you can safely initialize -- * data for your callback function after opening the audio device. -- * Silence will be written to the audio device during the pause. -- -- @{ procedure SDL_PauseAudio (pause_on : int); -- ..\SDL2_tmp\SDL_audio.h:417 pragma Import (C, SDL_PauseAudio, "SDL_PauseAudio"); procedure SDL_PauseAudioDevice (dev : SDL_AudioDeviceID; pause_on : int); -- ..\SDL2_tmp\SDL_audio.h:418 pragma Import (C, SDL_PauseAudioDevice, "SDL_PauseAudioDevice"); -- @} -- Pause audio functions --* -- * This function loads a WAVE from the data source, automatically freeing -- * that source if \c freesrc is non-zero. For example, to load a WAVE file, -- * you could do: -- * \code -- * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); -- * \endcode -- * -- * If this function succeeds, it returns the given SDL_AudioSpec, -- * filled with the audio data format of the wave data, and sets -- * \c *audio_buf to a malloc()'d buffer containing the audio data, -- * and sets \c *audio_len to the length of that audio buffer, in bytes. -- * You need to free the audio buffer with SDL_FreeWAV() when you are -- * done with it. -- * -- * This function returns NULL and sets the SDL error message if the -- * wave file cannot be opened, uses an unknown data format, or is -- * corrupt. Currently raw and MS-ADPCM WAVE files are supported. -- function SDL_LoadWAV_RW (src : access SDL_rwops_h.SDL_RWops; freesrc : int; spec : access SDL_AudioSpec; audio_buf : System.Address; audio_len : access SDL_stdinc_h.Uint32) return access SDL_AudioSpec; -- ..\SDL2_tmp\SDL_audio.h:441 pragma Import (C, SDL_LoadWAV_RW, "SDL_LoadWAV_RW"); --* -- * Loads a WAV from a file. -- * Compatibility convenience function. -- --* -- * This function frees data previously allocated with SDL_LoadWAV_RW() -- procedure SDL_FreeWAV (audio_buf : access SDL_stdinc_h.Uint8); -- ..\SDL2_tmp\SDL_audio.h:457 pragma Import (C, SDL_FreeWAV, "SDL_FreeWAV"); --* -- * This function takes a source format and rate and a destination format -- * and rate, and initializes the \c cvt structure with information needed -- * by SDL_ConvertAudio() to convert a buffer of audio data from one format -- * to the other. An unsupported format causes an error and -1 will be returned. -- * -- * \return 0 if no conversion is needed, 1 if the audio filter is set up, -- * or -1 on error. -- function SDL_BuildAudioCVT (cvt : access SDL_AudioCVT; src_format : SDL_AudioFormat; src_channels : SDL_stdinc_h.Uint8; src_rate : int; dst_format : SDL_AudioFormat; dst_channels : SDL_stdinc_h.Uint8; dst_rate : int) return int; -- ..\SDL2_tmp\SDL_audio.h:468 pragma Import (C, SDL_BuildAudioCVT, "SDL_BuildAudioCVT"); --* -- * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), -- * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of -- * audio data in the source format, this function will convert it in-place -- * to the desired format. -- * -- * The data conversion may expand the size of the audio data, so the buffer -- * \c cvt->buf should be allocated after the \c cvt structure is initialized by -- * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. -- * -- * \return 0 on success or -1 if \c cvt->buf is NULL. -- function SDL_ConvertAudio (cvt : access SDL_AudioCVT) return int; -- ..\SDL2_tmp\SDL_audio.h:488 pragma Import (C, SDL_ConvertAudio, "SDL_ConvertAudio"); -- SDL_AudioStream is a new audio conversion interface. -- The benefits vs SDL_AudioCVT: -- - it can handle resampling data in chunks without generating -- artifacts, when it doesn't have the complete buffer available. -- - it can handle incoming data in any variable size. -- - You push data as you have it, and pull it when you need it -- -- this is opaque to the outside world. type u_SDL_AudioStream is null record; -- incomplete struct subtype SDL_AudioStream is u_SDL_AudioStream; -- ..\SDL2_tmp\SDL_audio.h:499 --* -- * Create a new audio stream -- * -- * \param src_format The format of the source audio -- * \param src_channels The number of channels of the source audio -- * \param src_rate The sampling rate of the source audio -- * \param dst_format The format of the desired audio output -- * \param dst_channels The number of channels of the desired audio output -- * \param dst_rate The sampling rate of the desired audio output -- * \return 0 on success, or -1 on error. -- * -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamFlush -- * \sa SDL_AudioStreamClear -- * \sa SDL_FreeAudioStream -- function SDL_NewAudioStream (src_format : SDL_AudioFormat; src_channels : SDL_stdinc_h.Uint8; src_rate : int; dst_format : SDL_AudioFormat; dst_channels : SDL_stdinc_h.Uint8; dst_rate : int) return access SDL_AudioStream; -- ..\SDL2_tmp\SDL_audio.h:519 pragma Import (C, SDL_NewAudioStream, "SDL_NewAudioStream"); --* -- * Add data to be converted/resampled to the stream -- * -- * \param stream The stream the audio data is being added to -- * \param buf A pointer to the audio data to add -- * \param len The number of bytes to write to the stream -- * \return 0 on success, or -1 on error. -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamFlush -- * \sa SDL_AudioStreamClear -- * \sa SDL_FreeAudioStream -- function SDL_AudioStreamPut (stream : access SDL_AudioStream; buf : System.Address; len : int) return int; -- ..\SDL2_tmp\SDL_audio.h:541 pragma Import (C, SDL_AudioStreamPut, "SDL_AudioStreamPut"); --* -- * Get converted/resampled data from the stream -- * -- * \param stream The stream the audio is being requested from -- * \param buf A buffer to fill with audio data -- * \param len The maximum number of bytes to fill -- * \return The number of bytes read from the stream, or -1 on error -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamFlush -- * \sa SDL_AudioStreamClear -- * \sa SDL_FreeAudioStream -- function SDL_AudioStreamGet (stream : access SDL_AudioStream; buf : System.Address; len : int) return int; -- ..\SDL2_tmp\SDL_audio.h:558 pragma Import (C, SDL_AudioStreamGet, "SDL_AudioStreamGet"); --* -- * Get the number of converted/resampled bytes available. The stream may be -- * buffering data behind the scenes until it has enough to resample -- * correctly, so this number might be lower than what you expect, or even -- * be zero. Add more data or flush the stream if you need the data now. -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamFlush -- * \sa SDL_AudioStreamClear -- * \sa SDL_FreeAudioStream -- function SDL_AudioStreamAvailable (stream : access SDL_AudioStream) return int; -- ..\SDL2_tmp\SDL_audio.h:573 pragma Import (C, SDL_AudioStreamAvailable, "SDL_AudioStreamAvailable"); --* -- * Tell the stream that you're done sending data, and anything being buffered -- * should be converted/resampled and made available immediately. -- * -- * It is legal to add more data to a stream after flushing, but there will -- * be audio gaps in the output. Generally this is intended to signal the -- * end of input, so the complete output becomes available. -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamClear -- * \sa SDL_FreeAudioStream -- function SDL_AudioStreamFlush (stream : access SDL_AudioStream) return int; -- ..\SDL2_tmp\SDL_audio.h:590 pragma Import (C, SDL_AudioStreamFlush, "SDL_AudioStreamFlush"); --* -- * Clear any pending data in the stream without converting it -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamFlush -- * \sa SDL_FreeAudioStream -- procedure SDL_AudioStreamClear (stream : access SDL_AudioStream); -- ..\SDL2_tmp\SDL_audio.h:602 pragma Import (C, SDL_AudioStreamClear, "SDL_AudioStreamClear"); --* -- * Free an audio stream -- * -- * \sa SDL_NewAudioStream -- * \sa SDL_AudioStreamPut -- * \sa SDL_AudioStreamGet -- * \sa SDL_AudioStreamAvailable -- * \sa SDL_AudioStreamFlush -- * \sa SDL_AudioStreamClear -- procedure SDL_FreeAudioStream (stream : access SDL_AudioStream); -- ..\SDL2_tmp\SDL_audio.h:614 pragma Import (C, SDL_FreeAudioStream, "SDL_FreeAudioStream"); --* -- * This takes two audio buffers of the playing audio format and mixes -- * them, performing addition, volume adjustment, and overflow clipping. -- * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME -- * for full audio volume. Note this does not change hardware volume. -- * This is provided for convenience -- you can mix your own audio data. -- procedure SDL_MixAudio (dst : access SDL_stdinc_h.Uint8; src : access SDL_stdinc_h.Uint8; len : SDL_stdinc_h.Uint32; volume : int); -- ..\SDL2_tmp\SDL_audio.h:624 pragma Import (C, SDL_MixAudio, "SDL_MixAudio"); --* -- * This works like SDL_MixAudio(), but you specify the audio format instead of -- * using the format of audio device 1. Thus it can be used when no audio -- * device is open at all. -- procedure SDL_MixAudioFormat (dst : access SDL_stdinc_h.Uint8; src : access SDL_stdinc_h.Uint8; format : SDL_AudioFormat; len : SDL_stdinc_h.Uint32; volume : int); -- ..\SDL2_tmp\SDL_audio.h:632 pragma Import (C, SDL_MixAudioFormat, "SDL_MixAudioFormat"); --* -- * Queue more audio on non-callback devices. -- * -- * (If you are looking to retrieve queued audio from a non-callback capture -- * device, you want SDL_DequeueAudio() instead. This will return -1 to -- * signify an error if you use it with capture devices.) -- * -- * SDL offers two ways to feed audio to the device: you can either supply a -- * callback that SDL triggers with some frequency to obtain more audio -- * (pull method), or you can supply no callback, and then SDL will expect -- * you to supply data at regular intervals (push method) with this function. -- * -- * There are no limits on the amount of data you can queue, short of -- * exhaustion of address space. Queued data will drain to the device as -- * necessary without further intervention from you. If the device needs -- * audio but there is not enough queued, it will play silence to make up -- * the difference. This means you will have skips in your audio playback -- * if you aren't routinely queueing sufficient data. -- * -- * This function copies the supplied data, so you are safe to free it when -- * the function returns. This function is thread-safe, but queueing to the -- * same device from two threads at once does not promise which buffer will -- * be queued first. -- * -- * You may not queue audio on a device that is using an application-supplied -- * callback; doing so returns an error. You have to use the audio callback -- * or queue audio with this function, but not both. -- * -- * You should not call SDL_LockAudio() on the device before queueing; SDL -- * handles locking internally for this function. -- * -- * \param dev The device ID to which we will queue audio. -- * \param data The data to queue to the device for later playback. -- * \param len The number of bytes (not samples!) to which (data) points. -- * \return 0 on success, or -1 on error. -- * -- * \sa SDL_GetQueuedAudioSize -- * \sa SDL_ClearQueuedAudio -- function SDL_QueueAudio (dev : SDL_AudioDeviceID; data : System.Address; len : SDL_stdinc_h.Uint32) return int; -- ..\SDL2_tmp\SDL_audio.h:676 pragma Import (C, SDL_QueueAudio, "SDL_QueueAudio"); --* -- * Dequeue more audio on non-callback devices. -- * -- * (If you are looking to queue audio for output on a non-callback playback -- * device, you want SDL_QueueAudio() instead. This will always return 0 -- * if you use it with playback devices.) -- * -- * SDL offers two ways to retrieve audio from a capture device: you can -- * either supply a callback that SDL triggers with some frequency as the -- * device records more audio data, (push method), or you can supply no -- * callback, and then SDL will expect you to retrieve data at regular -- * intervals (pull method) with this function. -- * -- * There are no limits on the amount of data you can queue, short of -- * exhaustion of address space. Data from the device will keep queuing as -- * necessary without further intervention from you. This means you will -- * eventually run out of memory if you aren't routinely dequeueing data. -- * -- * Capture devices will not queue data when paused; if you are expecting -- * to not need captured audio for some length of time, use -- * SDL_PauseAudioDevice() to stop the capture device from queueing more -- * data. This can be useful during, say, level loading times. When -- * unpaused, capture devices will start queueing data from that point, -- * having flushed any capturable data available while paused. -- * -- * This function is thread-safe, but dequeueing from the same device from -- * two threads at once does not promise which thread will dequeued data -- * first. -- * -- * You may not dequeue audio from a device that is using an -- * application-supplied callback; doing so returns an error. You have to use -- * the audio callback, or dequeue audio with this function, but not both. -- * -- * You should not call SDL_LockAudio() on the device before queueing; SDL -- * handles locking internally for this function. -- * -- * \param dev The device ID from which we will dequeue audio. -- * \param data A pointer into where audio data should be copied. -- * \param len The number of bytes (not samples!) to which (data) points. -- * \return number of bytes dequeued, which could be less than requested. -- * -- * \sa SDL_GetQueuedAudioSize -- * \sa SDL_ClearQueuedAudio -- function SDL_DequeueAudio (dev : SDL_AudioDeviceID; data : System.Address; len : SDL_stdinc_h.Uint32) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_audio.h:722 pragma Import (C, SDL_DequeueAudio, "SDL_DequeueAudio"); --* -- * Get the number of bytes of still-queued audio. -- * -- * For playback device: -- * -- * This is the number of bytes that have been queued for playback with -- * SDL_QueueAudio(), but have not yet been sent to the hardware. This -- * number may shrink at any time, so this only informs of pending data. -- * -- * Once we've sent it to the hardware, this function can not decide the -- * exact byte boundary of what has been played. It's possible that we just -- * gave the hardware several kilobytes right before you called this -- * function, but it hasn't played any of it yet, or maybe half of it, etc. -- * -- * For capture devices: -- * -- * This is the number of bytes that have been captured by the device and -- * are waiting for you to dequeue. This number may grow at any time, so -- * this only informs of the lower-bound of available data. -- * -- * You may not queue audio on a device that is using an application-supplied -- * callback; calling this function on such a device always returns 0. -- * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use -- * the audio callback, but not both. -- * -- * You should not call SDL_LockAudio() on the device before querying; SDL -- * handles locking internally for this function. -- * -- * \param dev The device ID of which we will query queued audio size. -- * \return Number of bytes (not samples!) of queued audio. -- * -- * \sa SDL_QueueAudio -- * \sa SDL_ClearQueuedAudio -- function SDL_GetQueuedAudioSize (dev : SDL_AudioDeviceID) return SDL_stdinc_h.Uint32; -- ..\SDL2_tmp\SDL_audio.h:758 pragma Import (C, SDL_GetQueuedAudioSize, "SDL_GetQueuedAudioSize"); --* -- * Drop any queued audio data. For playback devices, this is any queued data -- * still waiting to be submitted to the hardware. For capture devices, this -- * is any data that was queued by the device that hasn't yet been dequeued by -- * the application. -- * -- * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For -- * playback devices, the hardware will start playing silence if more audio -- * isn't queued. Unpaused capture devices will start filling the queue again -- * as soon as they have more data available (which, depending on the state -- * of the hardware and the thread, could be before this function call -- * returns!). -- * -- * This will not prevent playback of queued audio that's already been sent -- * to the hardware, as we can not undo that, so expect there to be some -- * fraction of a second of audio that might still be heard. This can be -- * useful if you want to, say, drop any pending music during a level change -- * in your game. -- * -- * You may not queue audio on a device that is using an application-supplied -- * callback; calling this function on such a device is always a no-op. -- * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use -- * the audio callback, but not both. -- * -- * You should not call SDL_LockAudio() on the device before clearing the -- * queue; SDL handles locking internally for this function. -- * -- * This function always succeeds and thus returns void. -- * -- * \param dev The device ID of which to clear the audio queue. -- * -- * \sa SDL_QueueAudio -- * \sa SDL_GetQueuedAudioSize -- procedure SDL_ClearQueuedAudio (dev : SDL_AudioDeviceID); -- ..\SDL2_tmp\SDL_audio.h:794 pragma Import (C, SDL_ClearQueuedAudio, "SDL_ClearQueuedAudio"); --* -- * \name Audio lock functions -- * -- * The lock manipulated by these functions protects the callback function. -- * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that -- * the callback function is not running. Do not call these from the callback -- * function or you will cause deadlock. -- -- @{ procedure SDL_LockAudio; -- ..\SDL2_tmp\SDL_audio.h:806 pragma Import (C, SDL_LockAudio, "SDL_LockAudio"); procedure SDL_LockAudioDevice (dev : SDL_AudioDeviceID); -- ..\SDL2_tmp\SDL_audio.h:807 pragma Import (C, SDL_LockAudioDevice, "SDL_LockAudioDevice"); procedure SDL_UnlockAudio; -- ..\SDL2_tmp\SDL_audio.h:808 pragma Import (C, SDL_UnlockAudio, "SDL_UnlockAudio"); procedure SDL_UnlockAudioDevice (dev : SDL_AudioDeviceID); -- ..\SDL2_tmp\SDL_audio.h:809 pragma Import (C, SDL_UnlockAudioDevice, "SDL_UnlockAudioDevice"); -- @} -- Audio lock functions --* -- * This function shuts down audio processing and closes the audio device. -- procedure SDL_CloseAudio; -- ..\SDL2_tmp\SDL_audio.h:815 pragma Import (C, SDL_CloseAudio, "SDL_CloseAudio"); procedure SDL_CloseAudioDevice (dev : SDL_AudioDeviceID); -- ..\SDL2_tmp\SDL_audio.h:816 pragma Import (C, SDL_CloseAudioDevice, "SDL_CloseAudioDevice"); -- Ends C function definitions when using C++ -- vi: set ts=4 sw=4 expandtab: end SDL_audio_h;
src/boot/boot.asm
Cc618/OctOs
2
81742
; This file aims to : ; - Load the kernel in memory ; - Switch to 32 bits ; - Call kernel entry ; --- Header --- ; [org 0x7C00] [bits 16] %include "constants.inc" ; --- Boot --- ; ; Main function _bootloaderMain: ; - Init - ; ; Default drive id mov byte [defaultDrive], dl ; - Stack - ; ; Setup stack mov bp, BOOT_STACK_HIGH mov sp, bp ; - Loading - ; ; Loading kernel... mov si, STR_LOAD call print ; Load kernel call loadKernel ; Test if the kernel is loaded mov ax, [KERNEL_OFFSET] cmp ax, KERNEL_MAGIC je .kernel_loaded ; Error kernel not successfully loaded (incorrect magic number) mov si, STR_ERROR_LOAD_CHECK call print jmp end .kernel_loaded: ; Kernel loaded mov si, STR_LOAD_OK call print ; Init call switchPm32 end: jmp $ ; --- Functions --- ; ; Prints with the BIOS the null terminated string pointed by si ; - si : Address of the string to print ; * Adds also a line feed print: push ax ; For the BIOS print function mov ah, 0x0E ; - Loop - ; .loop: ; Retrieve the char pointed by si in al mov al, [si] ; Break if it's a null char cmp al, 0 je .loop_end ; Print the char int 10h inc si jmp .loop .loop_end: ; - Line feed (CRLF) - ; mov al, 0xD int 10h mov al, 0xA int 10h pop ax ret ; Loads the kernel loadKernel: pusha ; Clear carry flag (set to no errors) clc ; - Load kernel - ; ; Set kernel location (es:bx) mov bx, (KERNEL_OFFSET >> 4) mov es, bx xor bx, bx ; Set the sectors to read number mov al, byte [LOAD_SECTORS_OFFSET] ; Cylinder (0) xor ch, ch ; Sector 2 (the boot is the sector 1) mov cl, 2 ; Head (0) xor dh, dh ; Drive, same drive as when we have booted mov dl, [defaultDrive] ; Call read function mov ah, 2 int 13h ; - Check errors - ; ; Carry flag error = can't read jnc .noErrorRead ; Cannot load kernel (read) mov si, STR_ERROR_LOAD_READ call print jmp end .noErrorRead: ; al is the number of sectors read cmp al, byte [LOAD_SECTORS_OFFSET] je .noErrorSector ; Cannot load kernel (load) mov si, STR_ERROR_LOAD_SECTORS call print jmp end .noErrorSector: popa ret ; Procedure to switch to the 32 bits protected mode switchPm32: ; Disable interrupts cli ; Load GDT lgdt [gdt_descriptor] ; Set the protected mode bit mov eax, cr0 or eax, 1 mov cr0, eax ; Far jump with the code segment to 32 bits jmp CODE_SEG:initPm32 ret ; --- 32 bits Protected Mode --- ; [bits 32] ; Procedure to init the 32 bits protected mode initPm32: ; Set the data segment mov ax, DATA_SEG mov ds, ax mov ss, ax mov es, ax mov fs, ax mov gs, ax ; Update stack base to the top of the free space mov ebp, KERNEL_STACK_HIGH mov esp, ebp ; Go to OS' main 32 bits protected mode entry point call mainPm32 ret ; The entry point of the OS in 32 bits protected mode in assembly ; Calls the entry point in high level (C) mainPm32: ; Give control to the kernel ; Call the kernel entry function, just after the magic word call (KERNEL_OFFSET + 2) ; Infinite loop when the kernel leaves ; TODO : Halt jmp $ ; --- GDT --- ; %include "gdt.inc" ; --- Constants --- ; STR_LOAD: db "Loading kernel...", 0 STR_ERROR_LOAD_READ: db "Error: Cannot load kernel, drive read error", 0 STR_ERROR_LOAD_SECTORS: db "Error: Cannot load kernel, incorrect number of sectors read", 0 STR_ERROR_LOAD_CHECK: db "Error: Kernel not successfully loaded, incorrect magic number", 0 STR_LOAD_OK: db "Kernel loaded", 0 ; --- Variables --- ; ; The default drive id to read sectors from it defaultDrive: db 0 ; --- Footer --- ; ; Padding times 509 - ($ - $$) db 0
src/main/antlr4/tmp/PlayPlus.g4
fredunam/compilateur
0
1075
<filename>src/main/antlr4/tmp/PlayPlus.g4<gh_stars>0 grammar PlayPlus; import PlayPlusWords; root: instruction+; instruction: AFFECT '(' ID ',' expression ')' #affectInstr ; expression: NUMBER #constantExpr | ID #variableExpr | expression opArithmetique expression #arithmetiqueExpr ; varDecl: ID AS type ';'; type: scalar | array; scalar: BOOLEAN | INTEGER | SQUARE; array: scalar (ANY_SPACE)* '[' NUMBER+ (',' (NUMBER+))? (ANY_SPACE)* ']'; exprD : exprEnt | exprBool | exprCase | exprG | ID '(' (exprD (COMMA exprD)*) ')' | '(' exprD ')'; exprEnt: NUMBER | LATITUDE | LONGITUDE | GRID_SIZE | ( MAP | RADIO | AMMO | FRUITS | SODA ) COUNT | LIFE; exprArithmetique: exprEnt opArithmetique exprEnt; cardinaux: (NORTH | SOUTH | EAST | WEST); exprBool: TRUE | FALSE | ENNEMI IS cardinaux | GRAAL IS cardinaux | exprEnt opBoolCompare2 exprEnt | exprBool opBoolCompare1 exprBool | NOT exprBool | exprBool opBoolEqual exprBool | exprEnt opBoolEqual exprEnt; exprCase: ' '; exprG: ' '; opArithmetique: '-' | '+' | '*' | '/' | '%'; opBoolCompare1: AND | OR | NOT; opBoolCompare2: SMALLER | BIGGER; opBoolEqual: EQUAL;
src/utilities/imagemagick.ads
SKNZ/BoiteMaker
0
5189
<gh_stars>0 with ada.strings.unbounded; use ada.strings.unbounded; package imagemagick is imagemagick_failure : exception; -- transforme l'image passée en chaine base64 et obtient ses dimensions procedure get_base64(file : string; base64 : out unbounded_string; width, height : out integer); private base64_temp_file : constant string := "base64.txt"; end imagemagick;
programs/oeis/258/A258340.asm
karttu/loda
1
96241
; A258340: a(n) = (7^n + 3^n - 2)/8. ; 1,7,46,310,2131,14797,103216,721420,5046661,35316787,247187986,1730227330,12111325591,84778481977,593446982356,4154121702040,29078830390921,203551748166367,1424862043454326,9974033723049550,69818234317954651 mov $3,$0 add $3,1 mov $4,3 pow $4,$3 mov $1,$4 mov $2,7 pow $2,$3 add $1,$2 div $1,24 mul $1,3 add $1,1
notes/FOT/FOTC/Relation/Binary/Bisimilarity/Type.agda
asr/fotc
11
8354
------------------------------------------------------------------------------ -- A stronger (maybe invalid) principle for ≈-coind ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Relation.Binary.Bisimilarity.Type where open import FOTC.Base open import FOTC.Base.List open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ -- A stronger (maybe invalid) principle for ≈-coind. postulate ≈-stronger-coind : ∀ (B : D → D → Set) {xs ys} → (B xs ys → ∃[ x' ] ∃[ xs' ] ∃[ ys' ] xs ≡ x' ∷ xs' ∧ ys ≡ x' ∷ ys' ∧ B xs' ys') → B xs ys → xs ≈ ys
programs/oeis/332/A332162.asm
neoneye/loda
22
18526
<reponame>neoneye/loda<gh_stars>10-100 ; A332162: a(n) = 6*(10^(2*n+1)-1)/9 - 4*10^n. ; 2,626,66266,6662666,666626666,66666266666,6666662666666,666666626666666,66666666266666666,6666666662666666666,666666666626666666666,66666666666266666666666,6666666666662666666666666,666666666666626666666666666,66666666666666266666666666666,6666666666666662666666666666666 seq $0,177108 ; a(n) = 4*(10^n-3). mul $0,2 pow $0,2 sub $0,3136 div $0,960 add $0,2
src/util-concurrent-pools.adb
Letractively/ada-util
0
22289
----------------------------------------------------------------------- -- Util.Concurrent.Pools -- Concurrent Pools -- Copyright (C) 2011, 2014 <NAME> -- Written by <NAME> (<EMAIL>) -- -- 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. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; package body Util.Concurrent.Pools is -- ------------------------------ -- Get an element instance from the pool. -- Wait until one instance gets available. -- ------------------------------ procedure Get_Instance (From : in out Pool; Item : out Element_Type) is begin From.List.Get_Instance (Item); end Get_Instance; -- ------------------------------ -- Put the element back to the pool. -- ------------------------------ procedure Release (Into : in out Pool; Item : in Element_Type) is begin Into.List.Release (Item); end Release; -- ------------------------------ -- Set the pool size. -- ------------------------------ procedure Set_Size (Into : in out Pool; Capacity : in Positive) is begin Into.List.Set_Size (Capacity); end Set_Size; -- ------------------------------ -- Release the pool elements. -- ------------------------------ overriding procedure Finalize (Object : in out Pool) is begin Object.List.Set_Size (0); end Finalize; -- Pool of objects protected body Protected_Pool is -- ------------------------------ -- Get an element instance from the pool. -- Wait until one instance gets available. -- ------------------------------ entry Get_Instance (Item : out Element_Type) when Available > 0 is begin Item := Elements (Available); Available := Available - 1; end Get_Instance; -- ------------------------------ -- Put the element back to the pool. -- ------------------------------ procedure Release (Item : in Element_Type) is begin Available := Available + 1; Elements (Available) := Item; end Release; -- ------------------------------ -- Set the pool size. -- ------------------------------ procedure Set_Size (Capacity : in Natural) is procedure Free is new Ada.Unchecked_Deallocation (Element_Array, Element_Array_Access); begin if Capacity = 0 then Free (Elements); elsif Elements = null then Elements := new Element_Array (1 .. Capacity); else declare New_Array : constant Element_Array_Access := new Element_Array (1 .. Capacity); begin if Capacity > Elements'Size then New_Array (1 .. Elements'Last) := Elements (1 .. Elements'Last); else New_Array (1 .. Capacity) := Elements (1 .. Capacity); end if; Free (Elements); Elements := New_Array; end; end if; end Set_Size; end Protected_Pool; end Util.Concurrent.Pools;
src/wiki-plugins.ads
jquorning/ada-wiki
18
29447
----------------------------------------------------------------------- -- wiki-plugins -- Wiki plugins -- Copyright (C) 2016, 2018, 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- 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. ----------------------------------------------------------------------- with Wiki.Attributes; with Wiki.Documents; with Wiki.Filters; with Wiki.Strings; -- == Plugins {#wiki-plugins} == -- The `Wiki.Plugins` package defines the plugin interface that is used by the wiki -- engine to provide pluggable extensions in the Wiki. The plugins works by using -- a factory that finds and gives access to a plugin given its name. -- The plugin factory is represented by the `Wiki_Plugin` limited interface which -- must only implement the `Find` function. A simple plugin factory can be created -- by declaring a tagged record that implements the interface: -- -- type Factory is new Wiki.Plugins.Plugin_Factory with null record; -- overriding function -- Find (Factory : in Factory; -- Name : in String) return Wiki.Plugins.Wiki_Plugin_Access; -- -- @include wiki-plugins-variables.ads -- @include wiki-plugins-conditions.ads -- @include wiki-plugins-templates.ads package Wiki.Plugins is pragma Preelaborate; type Plugin_Context; type Wiki_Plugin is limited interface; type Wiki_Plugin_Access is access all Wiki_Plugin'Class; type Plugin_Factory is limited interface; type Plugin_Factory_Access is access all Plugin_Factory'Class; -- Find a plugin knowing its name. function Find (Factory : in Plugin_Factory; Name : in String) return Wiki_Plugin_Access is abstract; type Plugin_Context is limited record Previous : access Plugin_Context; Filters : Wiki.Filters.Filter_Chain; Factory : Plugin_Factory_Access; Variables : Wiki.Attributes.Attribute_List; Syntax : Wiki.Wiki_Syntax; Ident : Wiki.Strings.UString; Is_Hidden : Boolean := False; Is_Included : Boolean := False; end record; -- Expand the plugin configured with the parameters for the document. procedure Expand (Plugin : in out Wiki_Plugin; Document : in out Wiki.Documents.Document; Params : in out Wiki.Attributes.Attribute_List; Context : in out Plugin_Context) is abstract; end Wiki.Plugins;
Ada/problem_11/problem_11.adb
PyllrNL/Project_Euler_Solutions
0
23309
<gh_stars>0 with Ada.Text_IO; use Ada.Text_IO; package body Problem_11 is function Solution_1( G : Grid ) return Integer is Column, Row : Natural := 0; Highest_Row : constant Natural := G'Length(1); Highest_Column : constant Natural := G'Length(2); Max : Integer := 0; Temp : Natural := 0; begin for I in 0 .. Highest_Row - 1 loop for J in 0 .. Highest_Column - 1 loop if I <= (Highest_Row - 4) then Temp := G(I,J) * G(I+1,J) * G(I+2,J) * G(I+3,J); if Temp > Max then Max := Temp; end if; end if; if J <= ( Highest_Column - 4 ) then Temp := G(I,J) * G(I,J+1) * G(I,J+2) * G(I,J+3); if Temp > Max then Max := Temp; end if; end if; if I <= (Highest_Row - 4) and J <= (Highest_Column - 4) then Temp := G(I,J) * G(I+1,J+1) * G(I+2,J+2) * G(I+3,J+3); if Temp > Max then Max := Temp; end if; end if; if I >= 4 and J <= (Highest_Column - 4) then Temp := G(I,J) * G(I-1,J+1) * G(I-2,J+2) * G(I-3,J+3); if Temp > Max then Max := Temp; end if; end if; end loop; end loop; return Max; end Solution_1; procedure Test_Solution_1 is Input : constant Grid := ( (8,2,22,97,38,15,0,40,0,75,4,5,7,78,52,12,50,77,91,8), (49,49,99,40,27,81,18,57,60,87,17,40,98,43,69,48,4,56,62,0), (81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3,49,13,36,65), (52,70,95,23,4,60,11,42,69,24,68,56,1,32,56,71,37,2,36,91), (22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80), (24,47,32,60,99,3,45,2,44,75,33,53,78,36,84,20,35,17,12,50), (32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70), (67,26,20,68,2,62,12,20,95,63,94,39,63,8,40,91,66,49,94,21), (24,55,58,5,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72), (21,36,23,9,75,0,76,44,20,45,35,14,0,61,33,97,34,31,33,95), (78,17,53,28,22,75,31,67,15,94,3,80,4,62,16,14,9,53,56,92), (16,39,5,42,96,35,31,47,55,58,88,24,0,17,54,24,36,29,85,57), (86,56,0,48,35,71,89,7,5,44,44,37,44,60,21,58,51,54,17,58), (19,80,81,68,5,94,47,69,28,73,92,13,86,52,17,77,4,89,55,40), (4,52,8,83,97,35,99,16,7,97,57,32,16,26,26,79,33,27,98,66), (88,36,68,87,57,62,20,72,3,46,33,67,46,55,12,32,63,93,53,69), (4,42,16,73,38,25,39,11,24,94,72,18,8,46,29,32,40,62,76,36), (20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4,36,16), (20,73,35,29,78,31,90,1,74,31,49,71,48,86,81,16,23,57,5,54), (1,70,54,71,83,51,54,69,16,92,33,48,61,43,52,1,89,19,67,48)); Solution : constant Integer := 70600674; begin Assert( Solution_1(Input) = Solution ); end Test_Solution_1; function Get_Solutions return Solution_Case is Ret : Solution_Case; begin Set_Name( Ret, "Problem 11"); Add_Test( Ret, Test_Solution_1'Access ); return Ret; end Get_Solutions; end Problem_11;