

; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 1

;

;	0001	MODULE SMALOC (

;	0002			LANGUAGE (BLISS32),

;	0003			IDENT = 'A0009'

;	0004			) =

;	0005	BEGIN

;	0006	

;	0007	!

;	0008	! Copyright (c) 1977

;	0009	! Digital Equipment Corporation, Maynard, Massachusetts 01754

;	0010	!

;	0011	! This software is furnished  under a license for use only on a single

;	0012	! computer  system and  may be  copied only with  the inclusion of the

;	0013	! above copyright notice.  This software, or any other copies thereof,

;	0014	! may not be provided or  otherwise made available to any other person

;	0015	! except for use on such system and to one who agrees to these license

;	0016	! terms.  Title to and  ownership of the  software  shall at all times

;	0017	! remain in DEC.

;	0018	!

;	0019	! The information in this software is subject to change without notice

;	0020	! and should  not be construed  as a commitment  by Digital  Equipment

;	0021	! Corporation.

;	0022	!

;	0023	! DEC assumes  no  responsibility  for  the use or  reliability of its

;	0024	! software on equipment which is not supplied by DEC.

;	0025	

;	0026	!++

;	0027	!

;	0028	! FACILITY:  F11ACP Structure Level 1

;	0029	!

;	0030	! ABSTRACT:

;	0031	!

;	0032	!	This module contains the routines that manipulate the volume

;	0033	!	storage bitmap. These include the routines to allocate a contiguous

;	0034	!	area, deallocate an area, and the  basic bitmap scanner.

;	0035	!

;	0036	! ENVIRONMENT:

;	0037	!

;	0038	!	STARLET operating system, including privileged system services

;	0039	!	and internal exec routines.

;	0040	!

;	0041	!--

;	0042	!

;	0043	!

;	0044	! AUTHOR:  Andrew C. Goldstein,	 CREATION DATE:  21-Feb-1977  18:42

;	0045	!

;	0046	! REVISION HISTORY:

;	0047	!

;	0048	!   Andrew C. Goldstein, 18-Mar-1977  15:01

;	0049	!   X0002 - Add RETURN_BLOCKS routine

;	0050	!

;	0051	!   Andrew C. Goldstein, 22-Mar-1977  13:50

;	0052	!   X0003 - Fix disk full handling on noncontiguous request

;	0053	!

;	0054	!   Andrew C. Goldstein, 6-Apr-1977  15:57

;	0055	!   X0004 - Add LBN bounds check and bitmap bounds check



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 1-1

;

;	0056	!

;	0057	!   Andrew C. Goldstein, 12-Apr-1977  15:43

;	0058	!   X0005 - Modify for buffer manager

;	0059	!

;	0060	!   Andrew C. Goldstein, 7-Jun-1977  15:52

;	0061	!   X0006 - Redesign storage map wrap around

;	0062	!

;	0063	!   Andrew C. Goldstein, 26-Sep-1977  15:12

;	0064	!   X0007 - Add contiguous as possible mode

;	0065	!

;	0066	!   Andrew C. Goldstein, 27-Dec-1977  15:59

;	0067	!   X0008 - Change allocation strategy to rotating scan

;	0068	!

;	0069	!   Andrew C. Goldstein, 17-Feb-1978  14:54

;	0070	!   X0009 - Use new bug check

;	0071	!

;	0072	!**

;	0073	

;	0074	

;	0075	LIBRARY 'SYS$LIBRARY:LIB.L32';

;	0076	REQUIRE 'SRC$:FCPDEF.B32';

;	0395	

;	0396	

;	0397	!

;	0398	! Modes of operation of the bit scanner.

;	0399	!

;	0400	

;	0401	LITERAL

;	0402		FIND_SET	= 0,		! find first one

;	0403		FIND_CLEAR	= 1,		! find first zero

;	0404		SET_BITS	= 2,		! set n bits

;	0405		CLEAR_BITS	= 3;		! clear n bits

;	0406	

;	0407	

;	0408	FORWARD ROUTINE

;	0409		ALLOC_BLOCKS	: NOVALUE,

;	0410		RETURN_BLOCKS	: NOVALUE,

;	0411		BITSCAN,

;	0412		SET_SMVBN	: NOVALUE,

;	0413		UPDATE_FREE	: NOVALUE;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 2

;

;	0414	GLOBAL ROUTINE ALLOC_BLOCKS (FIB, BLOCKS_NEEDED, START_LBN, BLOCKS_ALLOC) : NOVALUE =

;	0415	

;	0416	!++

;	0417	!

;	0418	! FUNCTIONAL DESCRIPTION:

;	0419	!

;	0420	!	This routine allocates a single contiguous area of disk.

;	0421	!	Mode of allocation is determined by the allocation control

;	0422	!	in the FIB.

;	0423	!

;	0424	! CALLING SEQUENCE:

;	0425	!	ALLOC_BLOCKS (ARG1, ARG2, ARG3, ARG4)

;	0426	!

;	0427	! INPUT PARAMETERS:

;	0428	!	ARG1: address of FIB for this operation

;	0429	!	ARG2: number of blocks to allocate

;	0430	!

;	0431	! IMPLICIT INPUTS:

;	0432	!	CURRENT_VCB: ADDRESS OF VCB IN PROCESS

;	0433	!

;	0434	! OUTPUT PARAMETERS:

;	0435	!	ARG3: address of longword to store starting LBN

;	0436	!	ARG4: address of longword to store block count

;	0437	!

;	0438	! IMPLICIT OUTPUTS:

;	0439	!	NONE

;	0440	!

;	0441	! ROUTINE VALUE:

;	0442	!	NONE

;	0443	!

;	0444	! SIDE EFFECTS:

;	0445	!	storage map and VCB modified

;	0446	!

;	0447	!--

;	0448	

;	0449	BEGIN

;	0450	

;	0451	MAP

;	0452		FIB		: REF BBLOCK;	! FIB of request

;	0453	

;	0454	LOCAL

;	0455		BITS_NEEDED,			! number of map bits to allocate

;	0456		START_BLOCK,			! starting storage map VBN

;	0457		BLOCK_COUNT,			! number of map blocks to process

;	0458		START_BIT,			! bit address in storage map

;	0459		BIT_COUNT,			! number of bits to scan

;	0460		FIRST_SET,			! start of free area

;	0461		BITS_SCANNED,			! number of bits processed by scanner

;	0462		END_BIT,			! last bit processed

;	0463		BEST_STARTBIT,			! start of largest free area

;	0464		BEST_BITSFOUND;			! size of largest free area

;	0465	

;	0466	LABEL

;	0467		MAP_SCAN;			! code block to scan the storage map

;	0468	



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 2-1

;

;	0469	EXTERNAL

;	0470		USER_STATUS	: VECTOR,	! user I/O status block

;	0471		CURRENT_VCB	: REF BBLOCK;	! VCB of volume

;	0472	

;	0473	

;	0474	! Adjust the desired block count to a bit count through the volume

;	0475	! cluster factor. Set up the running parameters.

;	0476	!

;	0477	

;	0478	BITS_NEEDED = (.BLOCKS_NEEDED + .CURRENT_VCB[VCB$W_CLUSTER] - 1)

;	0479			/ .CURRENT_VCB[VCB$W_CLUSTER];

;	0480	BEST_BITSFOUND = 0;

;	0481	START_BLOCK = .CURRENT_VCB[VCB$B_SBMAPVBN];

;	0482	

;	0483	! The outer loop potentially scans the map twice: once from the given starting

;	0484	! point through to the end and then from beginning to end, if necessary to

;	0485	! locate a large contiguous area with a bad start.

;	0486	!

;	0487	

;	0488	MAP_SCAN:

;	0489	    BEGIN

;	0490	    WHILE 1 DO

;	0491		BEGIN

;	0492		BLOCK_COUNT = .CURRENT_VCB[VCB$B_SBMAPSIZE] - .START_BLOCK;

;	0493		START_BIT = .START_BLOCK * 4096;

;	0494		BIT_COUNT = .BLOCK_COUNT * 4096;

;	0495	

;	0496	! Now scan the bitmap for the first free block. Having found it, scan

;	0497	! to see how many free blocks there are there. If it is a non-contiguous

;	0498	! allocation, accept the blocks regardless. If it is contiguous, and the

;	0499	! free area is too small, keep looking.

;	0500	!

;	0501	

;	0502		WHILE 1 DO

;	0503		    BEGIN

;	0504		    IF BITSCAN (FIND_SET, .START_BIT, .BIT_COUNT, FIRST_SET, BITS_SCANNED)

;	0505		    THEN EXITLOOP;		! out if end of map

;	0506	

;	0507		    BIT_COUNT = .BIT_COUNT - .BITS_SCANNED;

;	0508		    BITSCAN (FIND_CLEAR, .FIRST_SET, MIN (.BIT_COUNT, .BITS_NEEDED),

;	0509				START_BIT, BITS_SCANNED);

;	0510	

;	0511		    BIT_COUNT = .BIT_COUNT - .BITS_SCANNED;

;	0512	

;	0513		    IF .BITS_SCANNED GTRU .BEST_BITSFOUND

;	0514		    THEN

;	0515			BEGIN

;	0516			BEST_STARTBIT = .FIRST_SET;

;	0517			BEST_BITSFOUND = .BITS_SCANNED;

;	0518			END;

;	0519	

;	0520		    IF .BEST_BITSFOUND GEQU .BITS_NEEDED

;	0521		    OR NOT (.FIB[FIB$V_ALCON] OR .FIB[FIB$V_ALCONB])

;	0522		    THEN LEAVE MAP_SCAN;	! found what we were after

;	0523	



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 2-2

;

;	0524		    IF .BIT_COUNT EQL 0

;	0525		    THEN EXITLOOP;		! end of storage map

;	0526	

;	0527		    END;			! end of map scan loop

;	0528	

;	0529	! We get here when we run into the end of the storage map. If the scan

;	0530	! started in the middle, do it once more from the top.

;	0531	!

;	0532	

;	0533		IF .START_BLOCK EQL 0 THEN LEAVE MAP_SCAN;

;	0534		START_BLOCK = 0;

;	0535		END;				! end of outer loop

;	0536	    END;				! end of block MAP_SCAN

;	0537	

;	0538	! We have either found a cluster of free blocks suitable to the occasion

;	0539	! or we have searched the entire map. If nothing was found, or for a

;	0540	! normal contiguous request, return error if the number of blocks is

;	0541	! insufficient; otherwise, allocate the blocks.

;	0542	!

;	0543	

;	0544	IF .BEST_BITSFOUND EQL 0

;	0545	OR (.FIB[FIB$V_ALCON] AND NOT .FIB[FIB$V_ALCONB]

;	0546	    AND .BEST_BITSFOUND LSSU .BITS_NEEDED)

;	0547	THEN

;	0548	    BEGIN

;	0549	    USER_STATUS[1] = .BEST_BITSFOUND * .CURRENT_VCB[VCB$W_CLUSTER];

;	0550	    FIB[FIB$L_EXSZ] = .BEST_BITSFOUND * .CURRENT_VCB[VCB$W_CLUSTER];

;	0551	    ERR_EXIT (SS$_DEVICEFULL);

;	0552	    END;

;	0553	

;	0554	BITSCAN (CLEAR_BITS, .BEST_STARTBIT, .BEST_BITSFOUND, END_BIT, BITS_SCANNED);

;	0555	

;	0556	KERNEL_CALL (SET_SMVBN, .END_BIT / 4096);

;	0557	

;	0558	.START_LBN = .BEST_STARTBIT * .CURRENT_VCB[VCB$W_CLUSTER];

;	0559	.BLOCKS_ALLOC = .BEST_BITSFOUND * .CURRENT_VCB[VCB$W_CLUSTER];

;	0560	

;	0561	KERNEL_CALL (UPDATE_FREE, - ..BLOCKS_ALLOC);

;	0562	

;	0563	END;					! end of routine ALLOC_BLOCKS





							    .TITLE  SMALOC

							    .IDENT  \A0009\



							    .EXTRN  USER_STATUS, CURRENT_VCB, SYS$CMKRNL



							    .PSECT  $CODE$,NOWRT,2



					 07FC 00000 	    .ENTRY  ALLOC_BLOCKS, Save R2,R3,R4,R5,R6,R7,R8,R9,R10	      ; 0414

		         5A 	0000V  CF  9E 00002 	    MOVAB   BITSCAN, R10					      ;

		         59 	0000G  CF  9E 00007 	    MOVAB   CURRENT_VCB, R9					      ;

		         58 00000000G  9F  9E 0000C 	    MOVAB   @#SYS$CMKRNL, R8					      ;

		         5E 	       10  C2 00013 	    SUBL2   #16, SP						      ;

		         50 	       69  D0 00016 	    MOVL    CURRENT_VCB, R0					      ; 0478



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 2-3

;

		         51 	  3C   A0  3C 00019 	    MOVZWL  60(R0), R1						      ;

		         51 	  08   AC  C0 0001D 	    ADDL2   BLOCKS_NEEDED, R1					      ;

				       51  D7 00021 	    DECL    R1							      ;

		         53 	  3C   A0  3C 00023 	    MOVZWL  60(R0), BITS_NEEDED					      ; 0479

	   53 	         51 	       53  C7 00027 	    DIVL3   BITS_NEEDED, R1, BITS_NEEDED			      ;

				       55  D4 0002B 	    CLRL    BEST_BITSFOUND					      ; 0480

		         54 	  3B   A0  9A 0002D 	    MOVZBL  59(R0), START_BLOCK					      ; 0481

		         50 	       69  D0 00031 1$:     MOVL    CURRENT_VCB, R0					      ; 0492

		         56 	  39   A0  9A 00034 	    MOVZBL  57(R0), BLOCK_COUNT					      ;

		         56 	       54  C2 00038 	    SUBL2   START_BLOCK, BLOCK_COUNT				      ;

      04   AE	         54 	       0C  78 0003B 	    ASHL    #12, START_BLOCK, START_BIT				      ; 0493

	   52 	         56 	       0C  78 00040 	    ASHL    #12, BLOCK_COUNT, BIT_COUNT				      ; 0494

				  0C   AE  9F 00044 2$:     PUSHAB  BITS_SCANNED					      ; 0504

				  0C   AE  9F 00047 	    PUSHAB  FIRST_SET						      ;

				       52  DD 0004A 	    PUSHL   BIT_COUNT						      ;

				  10   AE  DD 0004C 	    PUSHL   START_BIT						      ;

				       7E  D4 0004F 	    CLRL    -(SP)						      ;

		         6A 	       05  FB 00051 	    CALLS   #5, BITSCAN						      ;

		         44 	       50  E8 00054 	    BLBS    R0, 6$						      ;

		         52 	  0C   AE  C2 00057 	    SUBL2   BITS_SCANNED, BIT_COUNT				      ; 0507

				  0C   AE  9F 0005B 	    PUSHAB  BITS_SCANNED					      ; 0508

				  08   AE  9F 0005E 	    PUSHAB  START_BIT						      ;

				       52  DD 00061 	    PUSHL   BIT_COUNT						      ;

		         53 	       6E  D1 00063 	    CMPL    (SP), BITS_NEEDED					      ;

				       03  15 00066 	    BLEQ    3$							      ;

		         6E 	       53  D0 00068 	    MOVL    BITS_NEEDED, (SP)					      ;

				  14   AE  DD 0006B 3$:     PUSHL   FIRST_SET						      ;

				       01  DD 0006E 	    PUSHL   #1							      ;

		         6A 	       05  FB 00070 	    CALLS   #5, BITSCAN						      ;

		         52 	  0C   AE  C2 00073 	    SUBL2   BITS_SCANNED, BIT_COUNT				      ; 0511

		         55 	  0C   AE  D1 00077 	    CMPL    BITS_SCANNED, BEST_BITSFOUND			      ; 0513

				       08  1B 0007B 	    BLEQU   4$							      ;

		         57 	  08   AE  D0 0007D 	    MOVL    FIRST_SET, BEST_STARTBIT				      ; 0516

		         55 	  0C   AE  D0 00081 	    MOVL    BITS_SCANNED, BEST_BITSFOUND			      ; 0517

		         53 	       55  D1 00085 4$:     CMPL    BEST_BITSFOUND, BITS_NEEDED				      ; 0520

				       19  1E 00088 	    BGEQU   7$							      ;

		         50 	  04   AC  D0 0008A 	    MOVL    FIB, R0						      ; 0521

		         05 	  16   A0  E8 0008E 	    BLBS    22(R0), 5$						      ;

	   0C 	    16   A0	       01  E1 00092 	    BBC     #1, 22(R0), 7$					      ;

				       52  D5 00097 5$:     TSTL    BIT_COUNT						      ; 0524

				       A9  12 00099 	    BNEQ    2$							      ;

				       54  D5 0009B 6$:     TSTL    START_BLOCK						      ; 0533

				       04  13 0009D 	    BEQL    7$							      ;

				       54  D4 0009F 	    CLRL    START_BLOCK						      ; 0534

				       8E  11 000A1 	    BRB     1$							      ; 0490

				       55  D5 000A3 7$:     TSTL    BEST_BITSFOUND					      ; 0544

				       12  13 000A5 	    BEQL    8$							      ;

		         50 	  04   AC  D0 000A7 	    MOVL    FIB, R0						      ; 0545

		         25 	  16   A0  E9 000AB 	    BLBC    22(R0), 9$						      ;

	   20 	    16   A0	       01  E0 000AF 	    BBS     #1, 22(R0), 9$					      ;

		         53 	       55  D1 000B4 	    CMPL    BEST_BITSFOUND, BITS_NEEDED				      ; 0546

				       1B  1E 000B7 	    BGEQU   9$							      ;

		         50 	       69  D0 000B9 8$:     MOVL    CURRENT_VCB, R0					      ; 0549

		         51 	  3C   A0  3C 000BC 	    MOVZWL  60(R0), R1						      ;

		         51 	       55  C4 000C0 	    MULL2   BEST_BITSFOUND, R1					      ;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 2-4

;

		  0000G  CF	       51  D0 000C3 	    MOVL    R1, USER_STATUS+4					      ;

		         50 	  04   AC  D0 000C8 	    MOVL    FIB, R0						      ; 0550

		    18   A0	       51  D0 000CC 	    MOVL    R1, 24(R0)						      ;

				0850   8F  BF 000D0 	    CHMU    #2128						      ; 0551

				  0C   AE  9F 000D4 9$:     PUSHAB  BITS_SCANNED					      ; 0554

				  04   AE  9F 000D7 	    PUSHAB  END_BIT						      ;

				       55  DD 000DA 	    PUSHL   BEST_BITSFOUND					      ;

				       57  DD 000DC 	    PUSHL   BEST_STARTBIT					      ;

				       03  DD 000DE 	    PUSHL   #3							      ;

		         6A 	       05  FB 000E0 	    CALLS   #5, BITSCAN						      ;

	   7E 	         6E 00001000   8F  C7 000E3 	    DIVL3   #4096, END_BIT, -(SP)				      ; 0556

				       01  DD 000EB 	    PUSHL   #1							      ;

				       5E  DD 000ED 	    PUSHL   SP							      ;

				0000V  CF  9F 000EF 	    PUSHAB  SET_SMVBN						      ;

		         68 	       04  FB 000F3 	    CALLS   #4, SYS$CMKRNL					      ;

		         50 	       69  D0 000F6 	    MOVL    CURRENT_VCB, R0					      ; 0558

		         51 	  3C   A0  3C 000F9 	    MOVZWL  60(R0), R1						      ;

      0C   BC	         57 	       51  C5 000FD 	    MULL3   R1, BEST_STARTBIT, @START_LBN			      ;

		         51 	  3C   A0  3C 00102 	    MOVZWL  60(R0), R1						      ; 0559

      10   BC	         55 	       51  C5 00106 	    MULL3   R1, BEST_BITSFOUND, @BLOCKS_ALLOC			      ;

		         7E 	  10   BC  CE 0010B 	    MNEGL   @BLOCKS_ALLOC, -(SP)				      ; 0561

				       01  DD 0010F 	    PUSHL   #1							      ;

				       5E  DD 00111 	    PUSHL   SP							      ;

				0000V  CF  9F 00113 	    PUSHAB  UPDATE_FREE						      ;

		         68 	       04  FB 00117 	    CALLS   #4, SYS$CMKRNL					      ;

					   04 0011A 	    RET     							      ; 0414



; Routine Size:  283 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 3

;

;	0564	GLOBAL ROUTINE RETURN_BLOCKS (START_LBN, BLOCK_COUNT) : NOVALUE =

;	0565	

;	0566	!++

;	0567	!

;	0568	! FUNCTIONAL DESCRIPTION:

;	0569	!

;	0570	!	This routine returns a single contiguous area to the storage map.

;	0571	!

;	0572	! CALLING SEQUENCE:

;	0573	!	RETURN_BLOCKS (ARG1, ARG2)

;	0574	!

;	0575	! INPUT PARAMETERS:

;	0576	!	ARG1: starting LBN to free

;	0577	!	ARG2: number of blocks to free

;	0578	!

;	0579	! IMPLICIT INPUTS:

;	0580	!	CURRENT_VCB: VCB of volume

;	0581	!	CURRENT_UCB: UCB of device

;	0582	!

;	0583	! OUTPUT PARAMETERS:

;	0584	!	NONE

;	0585	!

;	0586	! IMPLICIT OUTPUTS:

;	0587	!	NONE

;	0588	!

;	0589	! ROUTINE VALUE:

;	0590	!	NONE

;	0591	!

;	0592	! SIDE EFFECTS:

;	0593	!	storage map and VCB modified

;	0594	!

;	0595	!--

;	0596	

;	0597	BEGIN

;	0598	

;	0599	LOCAL

;	0600		VOLUME_SIZE,			! size in logical blocks of volume

;	0601		START_BIT,			! starting bit number in storage map

;	0602		BIT_COUNT,			! number of bits to set

;	0603		DUMMY1,				! dummies to receive return data

;	0604		DUMMY2;				! from BITSCAN, which is not used

;	0605	

;	0606	EXTERNAL

;	0607		CURRENT_VCB	: REF BBLOCK,	! VCB of volume in process

;	0608		CURRENT_UCB	: REF BBLOCK;	! UCB of device unit

;	0609	

;	0610	

;	0611	! First check the blocks being returned against the volume size.

;	0612	!

;	0613	

;	0614	VOLUME_SIZE =	.CURRENT_UCB[UCB$B_SECTORS] *

;	0615			.CURRENT_UCB[UCB$B_TRACKS] *

;	0616			.CURRENT_UCB[UCB$W_CYLINDERS];

;	0617	

;	0618	IF .START_LBN + .BLOCK_COUNT GTRU .VOLUME_SIZE



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 3-1

;

;	0619	THEN ERR_EXIT (SS$_BADFILEHDR);

;	0620	

;	0621	! Divide down by the volume cluster factor to convert blocks to storage

;	0622	! map bits. If there are non-zero remainders, reject the operation on grounds

;	0623	! of a bad file header.

;	0624	!

;	0625	

;	0626	IF .START_LBN MOD .CURRENT_VCB[VCB$W_CLUSTER] NEQ 0

;	0627	THEN ERR_EXIT (SS$_BADFILEHDR);

;	0628	START_BIT = .START_LBN / .CURRENT_VCB[VCB$W_CLUSTER];

;	0629	

;	0630	IF .BLOCK_COUNT MOD .CURRENT_VCB[VCB$W_CLUSTER] NEQ 0

;	0631	THEN ERR_EXIT (SS$_BADFILEHDR);

;	0632	BIT_COUNT = .BLOCK_COUNT / .CURRENT_VCB[VCB$W_CLUSTER];

;	0633	

;	0634	! Call the bit scanner to set the appropriate

;	0635	! bits. Finally update the volume free block count.

;	0636	!

;	0637	

;	0638	BITSCAN (SET_BITS, .START_BIT, .BIT_COUNT, DUMMY1, DUMMY2);

;	0639	

;	0640	KERNEL_CALL (UPDATE_FREE, .BLOCK_COUNT);

;	0641	

;	0642	END;					! end of routine RETURN_BLOCKS







							    .EXTRN  CURRENT_UCB



					 001C 0011B 	    .ENTRY  RETURN_BLOCKS, Save R2,R3,R4			      ; 0564

		         54 	0000G  CF  9E 0011D 	    MOVAB   CURRENT_VCB, R4					      ;

		         5E 	       08  C2 00122 	    SUBL2   #8, SP						      ;

		         50 	0000G  CF  D0 00125 	    MOVL    CURRENT_UCB, R0					      ; 0614

		         51 	  3C   A0  9A 0012A 	    MOVZBL  60(R0), R1						      ;

		         52 	  3D   A0  9A 0012E 	    MOVZBL  61(R0), R2						      ;

		         51 	       52  C4 00132 	    MULL2   R2, R1						      ;

		         53 	  3E   A0  3C 00135 	    MOVZWL  62(R0), R3						      ; 0615

		         51 	       53  C4 00139 	    MULL2   R3, VOLUME_SIZE					      ;

	   50 	    04   AC	  08   AC  C1 0013C 	    ADDL3   BLOCK_COUNT, START_LBN, R0				      ; 0618

		         51 	       50  D1 00142 	    CMPL    R0, VOLUME_SIZE					      ;

				       04  1B 00145 	    BLEQU   1$							      ;

				0810   8F  BF 00147 	    CHMU    #2064						      ; 0619

		         50 	       64  D0 0014B 1$:     MOVL    CURRENT_VCB, R0					      ; 0626

		         50 	  3C   A0  3C 0014E 	    MOVZWL  60(R0), R0						      ;

	   00 	    04   AC	       01  7A 00152 	    EMUL    #1, START_LBN, #0, -(SP)				      ;

				       7E     00157									      ;

	   50 	         8E 	       50  7B 00158 	    EDIV    R0, (SP)+, R0, R0					      ;

				       50     0015C									      ;

				       50  D5 0015D 	    TSTL    R0							      ;

				       04  13 0015F 	    BEQL    2$							      ;

				0810   8F  BF 00161 	    CHMU    #2064						      ; 0627

		         50 	       64  D0 00165 2$:     MOVL    CURRENT_VCB, R0					      ; 0628

		         51 	  3C   A0  3C 00168 	    MOVZWL  60(R0), START_BIT					      ;

	   51 	    04   AC	       51  C7 0016C 	    DIVL3   START_BIT, START_LBN, START_BIT			      ;

		         50 	  3C   A0  3C 00171 	    MOVZWL  60(R0), R0						      ; 0630



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 3-2

;

	   00 	    08   AC	       01  7A 00175 	    EMUL    #1, BLOCK_COUNT, #0, -(SP)				      ;

				       7E     0017A									      ;

	   50 	         8E 	       50  7B 0017B 	    EDIV    R0, (SP)+, R0, R0					      ;

				       50     0017F									      ;

				       50  D5 00180 	    TSTL    R0							      ;

				       04  13 00182 	    BEQL    3$							      ;

				0810   8F  BF 00184 	    CHMU    #2064						      ; 0631

		         50 	       64  D0 00188 3$:     MOVL    CURRENT_VCB, R0					      ; 0632

		         50 	  3C   A0  3C 0018B 	    MOVZWL  60(R0), BIT_COUNT					      ;

	   50 	    08   AC	       50  C7 0018F 	    DIVL3   BIT_COUNT, BLOCK_COUNT, BIT_COUNT			      ;

				  04   AE  9F 00194 	    PUSHAB  DUMMY2						      ; 0638

				  04   AE  9F 00197 	    PUSHAB  DUMMY1						      ;

				       50  DD 0019A 	    PUSHL   BIT_COUNT						      ;

				       51  DD 0019C 	    PUSHL   START_BIT						      ;

				       02  DD 0019E 	    PUSHL   #2							      ;

		  0000V  CF	       05  FB 001A0 	    CALLS   #5, BITSCAN						      ;

				  08   AC  DD 001A5 	    PUSHL   BLOCK_COUNT						      ; 0640

				       01  DD 001A8 	    PUSHL   #1							      ;

				       5E  DD 001AA 	    PUSHL   SP							      ;

				0000V  CF  9F 001AC 	    PUSHAB  UPDATE_FREE						      ;

	      00000000G  9F	       04  FB 001B0 	    CALLS   #4, @#SYS$CMKRNL					      ;

					   04 001B7 	    RET     							      ; 0564



; Routine Size:  157 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4

;

;	0643	GLOBAL ROUTINE BITSCAN (MODE, STARTBIT, BITCOUNT, STOPBIT, LENGTHFOUND) =

;	0644	

;	0645	!++

;	0646	!

;	0647	! FUNCTIONAL DESCRIPTION:

;	0648	!

;	0649	!	This routine is the basic bitmap scanner. It scans the bitmap

;	0650	!	over the specified number of bits, performing the operation

;	0651	!	specified by the mode.

;	0652	!

;	0653	! CALLING SEQUENCE:

;	0654	!	BITSCAN (ARG1, ARG2, ARG3, ARG4, ARG5)

;	0655	!

;	0656	! INPUT PARAMETERS:

;	0657	!	ARG1: mode of operation - see module preface

;	0658	!	ARG2: starting bit address in bitmap

;	0659	!	ARG3: maximum number of bits to process

;	0660	!

;	0661	! IMPLICIT INPUTS:

;	0662	!	CURRENT_VCB: address of VCB in process

;	0663	!

;	0664	! OUTPUT PARAMETERS:

;	0665	!	ARG4: address of longword to receive ending bit address

;	0666	!	ARG5: address of longword to receive number of bits scanned

;	0667	!

;	0668	! IMPLICIT OUTPUTS:

;	0669	!	NONE

;	0670	!

;	0671	! ROUTINE VALUE:

;	0672	!	1 if maximum bit count processed

;	0673	!	0 if not

;	0674	!

;	0675	! SIDE EFFECTS:

;	0676	!	bitmap blocks may be altered, read, and written

;	0677	!

;	0678	!--

;	0679	

;	0680	BEGIN

;	0681	

;	0682	LOCAL

;	0683		COUNT,				! number of bits to go

;	0684		BLOCK,				! current bitmap block number

;	0685		CBYTE,				! current byte offset in block

;	0686		CBIT,				! current bit number within byte

;	0687		BYTELIM,			! number of bytes to scan

;	0688		BITLIM,				! number of bits to scan

;	0689		BUFFER,				! address of bitmap buffer

;	0690		ENDBYTE,			! end of current byte scan

;	0691		ENDBIT;				! end of current bit scan

;	0692	

;	0693	EXTERNAL

;	0694		BITMAP_VBN,			! VBN of current storage map block

;	0695		BITMAP_BUFFER	: REF BITVECTOR, ! address of current map block

;	0696		CURRENT_VCB	: REF BBLOCK;	! VCB in process

;	0697	



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-1

;

;	0698	EXTERNAL ROUTINE

;	0699		MARK_DIRTY,			! mark buffer for writeback

;	0700		READ_BLOCK;			! read a disk block

;	0701	

;	0702	

;	0703	! Initialize by setting the count and setting up the pointers to

;	0704	! the starting position. Read the first map block.

;	0705	!

;	0706	

;	0707	COUNT = .BITCOUNT;

;	0708	BLOCK = .STARTBIT<12,20>;

;	0709	IF .BLOCK GEQU .CURRENT_VCB[VCB$B_SBMAPSIZE]

;	0710	THEN BUG_CHECK (BADSBMBLK, FATAL, 'ACP tried to reference off end of bitmap');

;	0711	

;	0712	IF .BLOCK+1 EQL .BITMAP_VBN

;	0713	THEN

;	0714	    BUFFER = .BITMAP_BUFFER

;	0715	ELSE

;	0716	    BEGIN

;	0717	    BUFFER = READ_BLOCK (.BLOCK+.CURRENT_VCB[VCB$L_SBMAPLBN], 1, BITMAP_TYPE);

;	0718	    BITMAP_VBN = .BLOCK+1;

;	0719	    BITMAP_BUFFER = .BUFFER;

;	0720	    END;

;	0721	

;	0722	CBYTE = .BUFFER + .STARTBIT<3,9>;

;	0723	CBIT = .STARTBIT<0,3>;

;	0724	

;	0725	! The outer loop allows us to use the same set of bit processing instructions

;	0726	! for the odd bits at both the start and end of the scan.

;	0727	!

;	0728	

;	0729	WHILE 1 DO

;	0730	    BEGIN

;	0731	

;	0732	! Process bits from the starting position up to the first byte boundary.

;	0733	!

;	0734	

;	0735	    BITLIM = MIN (8 - .CBIT, .COUNT);	! max number of bits to scan

;	0736	    CASE .MODE FROM 0 TO 3 OF

;	0737		SET

;	0738		[FIND_SET]:	FFS (CBIT, BITLIM, .CBYTE, ENDBIT);

;	0739	

;	0740		[FIND_CLEAR]:	FFC (CBIT, BITLIM, .CBYTE, ENDBIT);

;	0741	

;	0742		[SET_BITS]:	(IF NOT FFS (CBIT, BITLIM, .CBYTE, ENDBIT)

;	0743				THEN ERR_EXIT (SS$_BADFILEHDR)

;	0744				ELSE

;	0745				    BEGIN

;	0746				    (.CBYTE)<.CBIT, .BITLIM> = -1;

;	0747				    MARK_DIRTY (.BUFFER);

;	0748				    END);

;	0749	

;	0750		[CLEAR_BITS]:	(IF NOT FFC (CBIT, BITLIM, .CBYTE, ENDBIT)

;	0751				THEN BUG_CHECK (ALCSMBCLR, FATAL, 'ACP tried to allocate space already allocated')

;	0752				ELSE



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-2

;

;	0753				    BEGIN

;	0754				    (.CBYTE)<.CBIT, .BITLIM> = 0;

;	0755				    MARK_DIRTY (.BUFFER);

;	0756				    END);

;	0757	

;	0758		TES;

;	0759	

;	0760	! Update the counters and pointers.

;	0761	!

;	0762	

;	0763	    COUNT = .COUNT - (.ENDBIT - .CBIT);

;	0764	

;	0765	! If we are now positioned on a byte boundary, we can process the bitmap

;	0766	! on a byte by byte basis. Page through the bitmap until the count runs out.

;	0767	!

;	0768	

;	0769	    IF .COUNT EQL 0 OR .ENDBIT NEQ 8 THEN EXITLOOP;

;	0770	

;	0771	    CBYTE = .CBYTE + 1;

;	0772	    CBIT = 0;

;	0773	

;	0774	    WHILE 1 DO

;	0775		BEGIN

;	0776		BYTELIM = MIN (.COUNT/8, 512 - (.CBYTE-.BUFFER));

;	0777	

;	0778		CASE .MODE FROM 0 TO 3 OF

;	0779		    SET

;	0780	

;	0781		    [FIND_SET]:	    ENDBYTE = CH$FIND_NOT_CH (.BYTELIM, .CBYTE, 0);

;	0782	

;	0783		    [FIND_CLEAR]:   ENDBYTE = CH$FIND_NOT_CH (.BYTELIM, .CBYTE, 255);

;	0784	

;	0785		    [SET_BITS]:	    (IF NOT CH$FAIL (ENDBYTE = CH$FIND_NOT_CH (.BYTELIM,

;	0786					    .CBYTE, 0))

;	0787				    THEN ERR_EXIT (SS$_BADFILEHDR)

;	0788				    ELSE

;	0789					BEGIN

;	0790					CH$FILL (255, .BYTELIM, .CBYTE);

;	0791					MARK_DIRTY (.BUFFER);

;	0792					END);

;	0793	

;	0794		    [CLEAR_BITS]:   (IF NOT CH$FAIL (ENDBYTE = CH$FIND_NOT_CH (.BYTELIM,

;	0795					    .CBYTE, 255))

;	0796				    THEN BUG_CHECK (ALCSMBCLR, FATAL, 'ACP tried to allocate space already allocated')

;	0797				    ELSE

;	0798					BEGIN

;	0799					CH$FILL (0, .BYTELIM, .CBYTE);

;	0800					MARK_DIRTY (.BUFFER);

;	0801					END);

;	0802	

;	0803		    TES;

;	0804	

;	0805		IF CH$FAIL (.ENDBYTE) THEN ENDBYTE = .CBYTE + .BYTELIM;

;	0806	

;	0807	! If the count runs out or we run into an end condition leave the loop.



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-3

;

;	0808	! Otherwise read the next block, wrapping around the end of the bitmap

;	0809	! when necessary, and loop.

;	0810	!

;	0811	

;	0812		COUNT = .COUNT - (.ENDBYTE - .CBYTE) * 8;

;	0813		IF .ENDBYTE - .BUFFER NEQ 512 OR .COUNT EQL 0 THEN EXITLOOP;

;	0814	

;	0815		BLOCK = .BLOCK + 1;

;	0816		IF .BLOCK GEQU .CURRENT_VCB[VCB$B_SBMAPSIZE]

;	0817		THEN BUG_CHECK (BADSBMBLK, FATAL, 'ACP tried to reference off end of bitmap');

;	0818	

;	0819		BUFFER = READ_BLOCK (.BLOCK+.CURRENT_VCB[VCB$L_SBMAPLBN], 1, BITMAP_TYPE);

;	0820		BITMAP_VBN = .BLOCK+1;

;	0821		BITMAP_BUFFER = .BUFFER;

;	0822		CBYTE = .BUFFER;

;	0823		END;				! end of block scan loop

;	0824	

;	0825	! We have either found the desired end condition or the count will run

;	0826	! out within the next byte. Process the final byte bit by bit.

;	0827	!

;	0828	

;	0829	    IF .COUNT EQL 0 THEN EXITLOOP;

;	0830	    CBYTE = .ENDBYTE;

;	0831	    END;				! end of major loop

;	0832	

;	0833	! Scan is completed. Return the output values.

;	0834	!

;	0835	

;	0836	.LENGTHFOUND = .BITCOUNT - .COUNT;

;	0837	.STOPBIT = .STARTBIT + ..LENGTHFOUND;

;	0838	RETURN .COUNT EQL 0;

;	0839	

;	0840	END;					! end of routine BITSCAN







							    .PSECT  $LOCKEDC2$,NOWRT,2



				  FEFF  0000  00000 P.AAA:  .WORD   0, -257						      ;

					0000* 00004 	    .WORD   <BUG$_BADSBMBLK!4>					      ;

					      00006	    .BLKB   2

				  FEFF  0000  00008 P.AAB:  .WORD   0, -257						      ;

					0000* 0000C 	    .WORD   <BUG$_ALCSMBCLR!4>					      ;

					      0000E	    .BLKB   2

				  FEFF  0000  00010 P.AAC:  .WORD   0, -257						      ;

					0000* 00014 	    .WORD   <BUG$_ALCSMBCLR!4>					      ;

					      00016	    .BLKB   2

				  FEFF  0000  00018 P.AAD:  .WORD   0, -257						      ;

					0000* 0001C 	    .WORD   <BUG$_BADSBMBLK!4>					      ;

					      0001E	    .BLKB   2



							    .EXTRN  BITMAP_VBN, BITMAP_BUFFER, MARK_DIRTY, READ_BLOCK

							    .EXTRN  BUG$_BADSBMBLK, BUG$_ALCSMBCLR



							    .PSECT  $CODE$,NOWRT,2



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-4

;



					 0FFC 001B8 	    .ENTRY  BITSCAN, Save R2,R3,R4,R5,R6,R7,R8,R9,R10,R11	      ; 0643

		         5E 	       0C  C2 001BA 	    SUBL2   #12, SP						      ;

		         59 	  0C   AC  D0 001BD 	    MOVL    BITCOUNT, COUNT					      ; 0707

      09   AC	         14 	       04  EF 001C1 	    EXTZV   #4, #20, STARTBIT+1, BLOCK				      ; 0708

				       56     001C6									      ;

		         50 	0000G  CF  D0 001C7 	    MOVL    CURRENT_VCB, R0					      ; 0709

      39   A0	         08 	       00  ED 001CC 	    CMPZV   #0, #8, 57(R0), BLOCK				      ;

				       56     001D1									      ;

				       05  1A 001D2 	    BGTRU   1$							      ;

		  0000'  CF	       00  FB 001D4 	    CALLS   #0, P.AAA						      ; 0710

		         52 	  01   A6  9E 001D9 1$:     MOVAB   1(R6), R2						      ; 0712

		  0000G  CF	       52  D1 001DD 	    CMPL    R2, BITMAP_VBN					      ;

				       07  12 001E2 	    BNEQ    2$							      ;

		         58 	0000G  CF  D0 001E4 	    MOVL    BITMAP_BUFFER, BUFFER				      ; 0714

				       1F  11 001E9 	    BRB     3$							      ; 0712

				       01  DD 001EB 2$:     PUSHL   #1							      ; 0717

				       01  DD 001ED 	    PUSHL   #1							      ;

		         50 	0000G  CF  D0 001EF 	    MOVL    CURRENT_VCB, R0					      ;

				  34 B046  9F 001F4 	    PUSHAB  @52(R0)[BLOCK]					      ;

		  0000G  CF	       03  FB 001F8 	    CALLS   #3, READ_BLOCK					      ;

		         58 	       50  D0 001FD 	    MOVL    R0, BUFFER						      ;

		  0000G  CF	       52  D0 00200 	    MOVL    R2, BITMAP_VBN					      ; 0718

		  0000G  CF	       58  D0 00205 	    MOVL    BUFFER, BITMAP_BUFFER				      ; 0719

      08   AC	         09 	       03  EF 0020A 3$:     EXTZV   #3, #9, STARTBIT, CBYTE				      ; 0722

				       57     0020F									      ;

		         57 	       58  C0 00210 	    ADDL2   BUFFER, CBYTE					      ;

      08   AC	         03 	       00  EF 00213 	    EXTZV   #0, #3, STARTBIT, CBIT				      ; 0723

				       6E     00218									      ;

	   50 	         08 	       6E  C3 00219 4$:     SUBL3   CBIT, #8, R0					      ; 0735

		         59 	       50  D1 0021D 	    CMPL    R0, COUNT						      ;

				       03  15 00220 	    BLEQ    5$							      ;

		         50 	       59  D0 00222 	    MOVL    COUNT, R0						      ;

		    04   AE	       50  D0 00225 5$:     MOVL    R0, BITLIM						      ;

	   03 	         00 	  04   AC  CF 00229 	    CASEL   MODE, #0, #3					      ; 0736

	 001A 	       0011 	     0008     0022E 6$:     .WORD   7$-6$,-						      ;

				     0035     00234		    8$-6$,-						      ;

								    9$-6$,-						      ;

								    11$-6$						      ;

	   67 	    04   AE	       6E  EA 00236 7$:     FFS     CBIT, BITLIM, (CBYTE), ENDBIT			      ; 0738

				  08   AE     0023B									      ;

				       41  11 0023D 	    BRB     14$							      ; 0736

	   67 	    04   AE	       6E  EB 0023F 8$:     FFC     CBIT, BITLIM, (CBYTE), ENDBIT			      ; 0740

				  08   AE     00244									      ;

				       38  11 00246 	    BRB     14$							      ; 0736

	   67 	    04   AE	       6E  EA 00248 9$:     FFS     CBIT, BITLIM, (CBYTE), ENDBIT			      ; 0742

				  08   AE     0024D									      ;

				       06  13 0024F 	    BEQL    10$							      ;

				0810   8F  BF 00251 	    CHMU    #2064						      ; 0743

				       29  11 00255 	    BRB     14$							      ; 0742

      04   AE	         6E FFFFFFFF   8F  F0 00257 10$:    INSV    #-1, CBIT, BITLIM, (CBYTE)				      ; 0746

				       67     00260									      ;

				       16  11 00261 	    BRB     13$							      ; 0747

	   67 	    04   AE	       6E  EB 00263 11$:    FFC     CBIT, BITLIM, (CBYTE), ENDBIT			      ; 0750

				  08   AE     00268									      ;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-5

;

				       07  13 0026A 	    BEQL    12$							      ;

		  0000'  CF	       00  FB 0026C 	    CALLS   #0, P.AAB						      ; 0751

				       0D  11 00271 	    BRB     14$							      ; 0750

      04   AE	         6E 	       00  F0 00273 12$:    INSV    #0, CBIT, BITLIM, (CBYTE)				      ; 0754

				       67     00278									      ;

				       58  DD 00279 13$:    PUSHL   BUFFER						      ; 0755

		  0000G  CF	       01  FB 0027B 	    CALLS   #1, MARK_DIRTY					      ;

	   50 	         6E 	  08   AE  C3 00280 14$:    SUBL3   ENDBIT, CBIT, R0					      ; 0763

		         59 	       50  C0 00285 	    ADDL2   R0, COUNT						      ;

				       03  12 00288 	    BNEQ    16$							      ; 0769

				     00EB  31 0028A 15$:    BRW     35$							      ;

		         08 	  08   AE  D1 0028D 16$:    CMPL    ENDBIT, #8						      ;

				       F7  12 00291 	    BNEQ    15$							      ;

				       57  D6 00293 	    INCL    CBYTE						      ; 0771

				       6E  D4 00295 	    CLRL    CBIT						      ; 0772

	   50 	         59 	       08  C7 00297 17$:    DIVL3   #8, COUNT, R0					      ; 0776

	   51 	         58 	       57  C3 0029B 	    SUBL3   CBYTE, BUFFER, R1					      ;

		         51 	0200   C1  9E 0029F 	    MOVAB   512(R1), R1						      ;

		         51 	       50  D1 002A4 	    CMPL    R0, R1						      ;

				       03  15 002A7 	    BLEQ    18$							      ;

		         50 	       51  D0 002A9 	    MOVL    R1, R0						      ;

		         5B 	       50  D0 002AC 18$:    MOVL    R0, BYTELIM						      ;

	   03 	         00 	  04   AC  CF 002AF 	    CASEL   MODE, #0, #3					      ; 0778

	 001C 	       000E 	     0008     002B4 19$:    .WORD   20$-19$,-						      ;

				     0038     002BA		    21$-19$,-						      ;

								    24$-19$,-						      ;

								    27$-19$						      ;

	   67 	         5B 	       00  3B 002BC 20$:    SKPC    #0, BYTELIM, (CBYTE)				      ; 0781

				       05  11 002C0 	    BRB     22$							      ;

	   67 	         5B 	  FF   8F  3B 002C2 21$:    SKPC    #255, BYTELIM, (CBYTE)				      ; 0783

				       02  12 002C7 22$:    BNEQ    23$							      ;

				       51  D4 002C9 	    CLRL    R1							      ;

		         5A 	       51  D0 002CB 23$:    MOVL    R1, ENDBYTE						      ;

				       3E  11 002CE 	    BRB     31$							      ; 0778

	   67 	         5B 	       00  3B 002D0 24$:    SKPC    #0, BYTELIM, (CBYTE)				      ; 0785

				       02  12 002D4 	    BNEQ    25$							      ;

				       51  D4 002D6 	    CLRL    R1							      ;

		         5A 	       51  D0 002D8 25$:    MOVL    R1, ENDBYTE						      ;

				       06  13 002DB 	    BEQL    26$							      ; 0786

				0810   8F  BF 002DD 	    CHMU    #2064						      ; 0787

				       2B  11 002E1 	    BRB     31$							      ; 0785

      FF   8F	         6E 	       00  2C 002E3 26$:    MOVC5   #0, (SP), #255, BYTELIM, (CBYTE)			      ; 0790

		         67 	       5B     002E8									      ;

				       1B  11 002EA 	    BRB     30$							      ; 0791

	   67 	         5B 	  FF   8F  3B 002EC 27$:    SKPC    #255, BYTELIM, (CBYTE)				      ; 0794

				       02  12 002F1 	    BNEQ    28$							      ;

				       51  D4 002F3 	    CLRL    R1							      ;

		         5A 	       51  D0 002F5 28$:    MOVL    R1, ENDBYTE						      ;

				       07  13 002F8 	    BEQL    29$							      ; 0795

		  0000'  CF	       00  FB 002FA 	    CALLS   #0, P.AAC						      ; 0796

				       0D  11 002FF 	    BRB     31$							      ; 0794

	   00 	         6E 	       00  2C 00301 29$:    MOVC5   #0, (SP), #0, BYTELIM, (CBYTE)			      ; 0799

		         67 	       5B     00305									      ;

				       58  DD 00307 30$:    PUSHL   BUFFER						      ; 0800

		  0000G  CF	       01  FB 00309 	    CALLS   #1, MARK_DIRTY					      ;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 4-6

;

				       5A  D5 0030E 31$:    TSTL    ENDBYTE						      ; 0805

				       04  12 00310 	    BNEQ    32$							      ;

	   5A 	         57 	       5B  C1 00312 	    ADDL3   BYTELIM, CBYTE, ENDBYTE				      ;

	   50 	         57 	       5A  C3 00316 32$:    SUBL3   ENDBYTE, CBYTE, R0					      ; 0812

		         50 	       50  CE 0031A 	    MNEGL   R0, R0						      ;

		         50 	       08  C4 0031D 	    MULL2   #8, R0						      ;

		         59 	       50  C2 00320 	    SUBL2   R0, COUNT						      ;

	   50 	         5A 	       58  C3 00323 	    SUBL3   BUFFER, ENDBYTE, R0					      ; 0813

	      00000200   8F	       50  D1 00327 	    CMPL    R0, #512						      ;

				       3E  12 0032E 	    BNEQ    34$							      ;

				       59  D5 00330 	    TSTL    COUNT						      ;

				       3A  13 00332 	    BEQL    34$							      ;

				       56  D6 00334 	    INCL    BLOCK						      ; 0815

		         50 	0000G  CF  D0 00336 	    MOVL    CURRENT_VCB, R0					      ; 0816

      39   A0	         08 	       00  ED 0033B 	    CMPZV   #0, #8, 57(R0), BLOCK				      ;

				       56     00340									      ;

				       05  1A 00341 	    BGTRU   33$							      ;

		  0000'  CF	       00  FB 00343 	    CALLS   #0, P.AAD						      ; 0817

				       01  DD 00348 33$:    PUSHL   #1							      ; 0819

				       01  DD 0034A 	    PUSHL   #1							      ;

		         50 	0000G  CF  D0 0034C 	    MOVL    CURRENT_VCB, R0					      ;

				  34 B046  9F 00351 	    PUSHAB  @52(R0)[BLOCK]					      ;

		  0000G  CF	       03  FB 00355 	    CALLS   #3, READ_BLOCK					      ;

		         58 	       50  D0 0035A 	    MOVL    R0, BUFFER						      ;

		  0000G  CF	  01   A6  9E 0035D 	    MOVAB   1(R6), BITMAP_VBN					      ; 0820

		  0000G  CF	       58  D0 00363 	    MOVL    BUFFER, BITMAP_BUFFER				      ; 0821

		         57 	       58  D0 00368 	    MOVL    BUFFER, CBYTE					      ; 0822

				     FF29  31 0036B 	    BRW     17$							      ; 0774

				       59  D5 0036E 34$:    TSTL    COUNT						      ; 0829

				       06  13 00370 	    BEQL    35$							      ;

		         57 	       5A  D0 00372 	    MOVL    ENDBYTE, CBYTE					      ; 0830

				     FEA1  31 00375 	    BRW     4$							      ; 0729

      14   BC	    0C   AC	       59  C3 00378 35$:    SUBL3   COUNT, BITCOUNT, @LENGTHFOUND			      ; 0836

      10   BC	    08   AC	  14   BC  C1 0037E 	    ADDL3   @LENGTHFOUND, STARTBIT, @STOPBIT			      ; 0837

				       50  D4 00385 	    CLRL    R0							      ; 0838

				       59  D5 00387 	    TSTL    COUNT						      ;

				       02  12 00389 	    BNEQ    36$							      ;

				       50  D6 0038B 	    INCL    R0							      ;

					   04 0038D 36$:    RET     							      ; 0643



; Routine Size:  470 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 5

;

;	0841	ROUTINE SET_SMVBN (VBN) : NOVALUE =

;	0842	

;	0843	!++

;	0844	!

;	0845	! FUNCTIONAL DESCRIPTION:

;	0846	!

;	0847	!	This routine updates the current storage map VBN in the VCB.

;	0848	!	It must be called in kernel mode.

;	0849	!

;	0850	! CALLING SEQUENCE:

;	0851	!	SET_SMVBN (ARG1)

;	0852	!

;	0853	! INPUT PARAMETERS:

;	0854	!	ARG1: new storage map VBN

;	0855	!

;	0856	! IMPLICIT INPUTS:

;	0857	!	NONE

;	0858	!

;	0859	! OUTPUT PARAMETERS:

;	0860	!	NONE

;	0861	!

;	0862	! IMPLICIT OUTPUTS:

;	0863	!	CURRENT_VCB: address of volume VCB

;	0864	!

;	0865	! ROUTINE VALUE:

;	0866	!	NONE

;	0867	!

;	0868	! SIDE EFFECTS:

;	0869	!	storage map VBN altered

;	0870	!

;	0871	!--

;	0872	

;	0873	BEGIN

;	0874	

;	0875	EXTERNAL

;	0876		CURRENT_VCB	: REF BBLOCK;	! VCB of volume

;	0877	

;	0878	

;	0879	CURRENT_VCB[VCB$B_SBMAPVBN] = .VBN;

;	0880	

;	0881	END;					! end of routine SET_SMVBN











					 0000 0038E SET_SMVBN:

							    .WORD   Save nothing					      ; 0841

		         50 	0000G  CF  D0 00390 	    MOVL    CURRENT_VCB, R0					      ; 0879

		    3B   A0	  04   AC  90 00395 	    MOVB    VBN, 59(R0)						      ;

					   04 0039A 	    RET     							      ; 0841



; Routine Size:  13 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 5-1

;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 6

;

;	0882	ROUTINE UPDATE_FREE (COUNT) : NOVALUE =

;	0883	

;	0884	!++

;	0885	!

;	0886	! FUNCTIONAL DESCRIPTION:

;	0887	!

;	0888	!	This routine updates the free block count in the volume's VCB.

;	0889	!	It must be called in kernel mode.

;	0890	!

;	0891	! CALLING SEQUENCE:

;	0892	!	UPDATE_FREE (ARG1)

;	0893	!

;	0894	! INPUT PARAMETERS:

;	0895	!	ARG1: value (positive or negative) to alter free count

;	0896	!

;	0897	! IMPLICIT INPUTS:

;	0898	!	NONE

;	0899	!

;	0900	! OUTPUT PARAMETERS:

;	0901	!	NONE

;	0902	!

;	0903	! IMPLICIT OUTPUTS:

;	0904	!	CURRENT_VCB: VCB of volume

;	0905	!

;	0906	! ROUTINE VALUE:

;	0907	!	NONE

;	0908	!

;	0909	! SIDE EFFECTS:

;	0910	!	free count altered

;	0911	!

;	0912	!--

;	0913	

;	0914	BEGIN

;	0915	

;	0916	EXTERNAL

;	0917		CURRENT_VCB	: REF BBLOCK;	! VCB of volume

;	0918	

;	0919	

;	0920	CURRENT_VCB[VCB$L_FREE] = .CURRENT_VCB[VCB$L_FREE] + .COUNT;

;	0921	

;	0922	END;					! end of routine UPDATE_FREE











					 0000 0039B UPDATE_FREE:

							    .WORD   Save nothing					      ; 0882

		         50 	0000G  CF  D0 0039D 	    MOVL    CURRENT_VCB, R0					      ; 0920

		    40   A0	  04   AC  C0 003A2 	    ADDL2   COUNT, 64(R0)					      ;

					   04 003A7 	    RET     							      ; 0882



; Routine Size:  13 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 23:04:46	DBB3:[F11A.SRC]SMALOC.B32;7					Page 6-1

;

;	0923	

;	0924	END

;	0925	ELUDOM













;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  $CODE$         	   936  NOWRT,  RD ,  EXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)

;  $LOCKEDC2$     	    32  NOWRT,  RD ,  EXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)









;				LIBRARY STATISTICS

;

;					     -------- Symbols --------    Blocks

;	File				     Total    Loaded   Percent      Read

;

;  DBA4:[SYSLIB]LIB.L32;1		      5582        14         0       230











; Size:		936 code + 32 data bytes

; Run Time:	00:16.5

; Elapsed Time:	00:36.8

; Memory Used:	335 pages

; Compilation Complete

