******************************************************************************** * GETAUS * 7.5.2012: corrected >3200 sector allocation routine ********** * * R5 CONTAINS SECTOR # WITHIN FILE * * MAKE SURE THAT FILE HAS AT LEAST R5 # OF SECTORS * * USES ALL REGISTERS (EXCEPT R3,R4,R12-R15) * * RETURN: R1 IS SECTOR # ON DISK OF SECTOR R5 WITHIN FILE. * * 7.5.2012: * - Sector/Allocation routine failed at cluster boundaries. Original calcs * were incorrect. Rewrote routine to properly calculate AUs based on * request to GETAUS. * 7.6.2012: * - Limited maximum sector allocation (and thus file size) to * >0FF0 (4080) sectors. Reason: the total sector count in the cluster * is limited to three nibbles and may not exceed >0FFF, even if the disk * capacity is greater. * - NOTE: must perform additional tests here. * 7.6.2012: * - Myarc FDC DSR and HFDC DSR behave differently. MDOS DSR also has a few * wrinkles. Errors and actions are inconsistent. Not all DSRs allocate * additional sectors based on maximum relative file size. Bug? Someone * failing to test? Need to test with TI FDC, CorComp, and others. * - Updated comments to reflect HFDC manual description of cluster ******************************************************************************** * GETAUS MOV R11,@R11SAV MOV R5,@R5SAVE JEQ XX01 JMP XX0 XX01 B @GETAF3 DON'T NEED ANY AU'S. XX0 CLR @R1SAVE IN CASE THERE WERE NO CLUSTERS TO START WITH * * Clint's routine forces GETAUS to reserve sectors for FDRs * LI R0,34 Start at sector 34 [original default] BL @GETVIB get the VIB DATA BADOP MOV @VIBBUF+TOTAUS,R11 total sectors on disk CI R11,718 JL HCP1A SSSD LI R0,50 DSSD CI R11,1438 JL HCP1A IF DSSD LI R0,66 CI R11,2878 JL HCP1A IF DSSD LI R0,256 CI R11,3201 *seems silly to jump so high here JL HCP1A LI R0,512 HCP1A MOV @R5SAVE,R5 *------END OF CLINT'S ROUTINE MOV @D76,@CLUSNO MAX NUMBER OF CLUSTERS SETO R8 USE R8 AS INDEX INTO CLUSTERS DEC R5 ADJUST NUMBER BASE TO ZERO MOV R3,R9 R9 POINTS TO CLUSTERS AI R9,CLUSTR+FCB BL @PTTOWD GET FIRST CLUSTER PAIR-> EQUAL FLAG FOR R1=0 MOV R1,R1 JEQ UNUSED BRANCH IF NOT USED (NEED TO GET MORE SECTORS) * USEDCL C R2,R5 JHE XX02 JMP XX03 XX02 B @GETAUF BRANCH IF ENOUGH ALREADY ALLOCATED * XX03 DEC @CLUSNO ONE LESS CLUSTER POSSIBLE JNE RANGE B @DSKFUL NO MORE POSSIBLE CLUSTERS. * RANGE MOV R8,R7 HIGH POINTER FROM PREVIOUS CLUSTER MOV R2,R8 HIGH POINTER FROM THIS CLUSTER MOV R1,R0 BL @PTTOWD MOV R1,R1 JNE USEDCL BRANCH IF USED CLUSTER * A R8,R0 S R7,R0 R0 IS NOW POINTER TO SECTOR AFTER LAST ONE IN FILE * GETAU1 MOV R0,@R1SAVE SAVE POINTER PAST END OF FILE INTO R1 UNUSED MOV R9,@R9SAVE SAVE R9 * * 7-6, Test before allocating sector? Dangerous? C @MAXFILESECTORS,@LV2REC+FCB(R3) >0fff maximum, >0ff0 reality JHE NOWGETSEC B @DSKFUL ********************** NOWGETSEC BL @GETSEC R6 RETURNS # OF SECTORS ALLOCATED (1,2,4, or 8) DATA DSKFUL R0 returns absolute starting sector * MOV @R9SAVE,R9 RESTORE R9 * LI R8,3 CONSTANT 3 IS USED LOTS S R8,R9 POINT TO THIS CLUSTER MOV R0,R1 C R0,@R1SAVE is returned sector same as requested? JNE NEWC BRANCH IF NOT CONTIGUOUS (ie, new cluster) * S R8,R9 POINT TO LAST USED CLUSTER INC @CLUSNO COMPENSATE FOR REUSING SAME CLUSTER BL @PTTOWD S R8,R9 JMP NEWCL * NEWC CLR @JGSFLG NEWCL A R6,@LV2REC+FCB(R3) MOV @LV2REC+FCB(R3),R2 * * 7.6.12: can we check for max lv2rec here? or must it be elsewher? * Let's test and see what happens * A cluster's logical sector count may NEVER exceed >0fff * Doing so will send GETAUS into a tailspin * Are level 2 rec == cluster sectors? Reduce max to >0ff0 * See above. Where is right test place? ** C @MAXFILESECTORS,@LV2REC+FCB(R3) >0fff maximum, >0ff0 reality ** JHE MASH1 ** B @DSKFUL * ------------------- MASH1 DEC R2 ADJUST TO BASE #0 FROM BASE #1 * MOV R1,@TTFIXR1 *7.5.2012tt Save for our HD routine below * MOVB @3(R4),*R9+ SAVE CLUSTR SLA R2,4 AB @5(R4),R1 * H0005 EQU $-2 LODCOD EQU $-1 * MOVB R1,*R9+ * 7.5: Original code for High Density manipulation C @D3200,@VIBBUF+TOTAUS 3200 sectors? JHE NO144 less or equal, skip next routine *------------------------------------------------- * 7.5.12: start of new code for cluster allocation * applies reverse algorithm to starting cluster sector * does not and must not change the relative pointer * Cluster 6 byte/nibble definiton: [N2N1 M1N3 M3M2] * First Sector: xN3N2N1 * High Sector: xM3M2M1 , highest sector of the file IN THIS CLUSTER * this is NOT a count of sectors in the cluster DECT R9 reset cluster pointer MOV R10,@JGSR10 save R10 MOV @TTFIXR1,R10 SRL R10,2 assume 3200 or more C @D6400,@VIBBUF+TOTAUS JHE NOTSL * SRL R10,2 YATTFU SRL R10,1 NOTSL MOVB @5(R4),R1 m1n3 ANDI R1,>F000 Only want M1 A R1,R10 Create M1N3N2N1 SWPB R10 N2N1M1N3 MOVB R10,*R9+ store cluster SWPB R10 M1N3N2N1 MOVB R10,*R9+ store cluster MOV @JGSR10,R10 restore R10 B @NO144 skip old code and continue *------end new code/start old code----------------- **Original code by JGS ** MOV @JGSFLG,@JGSFLG ** JNE JGS1ST ** MOV R0,@JGSMEM ** SETO @JGSFLG **JGS1ST DECT R9 ** MOV R10,@JGSR10 ** MOVB @3(R4),R10 ** SWPB R10 ** MOVB R1,R10 ** ANDI R10,>0FFF ** SRL R10,2 ** C @D6400,@VIBBUF+TOTAUS ** JHE NOT8AU ** SRL R10,1 **NOT8AU MOV @JGSMEM,R1 ** CI R1,>0FFF ** JLE NOVER ** C @D6400,@VIBBUF+TOTAUS ** JLE BIT8 ** AI R10,>0200 **BIT8 AI R10,>0200 7.5-indicator of AU allocation problem ** **NOVER MOVB @5(R4),R1 ** ANDI R1,>F000 ** A R1,R10 ** SWPB R10 ** MOVB R10,*R9+ ** SWPB R10 ** MOVB R10,*R9+ ** MOV @JGSR10,R10 *---------end of old code------------------ NO144 MOVB R2,*R9+ * A R8,R9 MOV R0,R1 A R6,R0 C @LV2REC+FCB(R3),@R5SAVE have we allocated enough sectors? JHE GETAF4 yes---maybe even too many * GETAUG DEC @CLUSNO JNE GETAU1 JMP DSKFUL * GETAUF A R5,R1 S R8,R1 DEC R1 * * 7.21.2012: Is this the reason files cannot allocate beyond initial size * without writing to the maximum record? ie, * OPEN #1:"DSK1.TEST",RELATIVE 300,FIXED 255,DISPLAY * If above is executed, 300 sector file produced. A second time with * larger relative allocation won't always increase file size. * This is one reason RAMdisks and floppies react differently to programs * that expect allocation up front (usually to inhibit fracturign) * GETAF3 C @LV2REC+FCB(R3),@R5SAVE this is a fix for random i/o files JHE GETAF5 don't change lv2rec if in file * GETAF4 MOV @R5SAVE,@LV2REC+FCB(R3) GETAF5 MOV @R11SAV,R11 CLR @JGSFLG INCT R11 RT * DSKFUL MOV @R11SAV,R11 LI R10,>8000 ERROR CODE (4) * B @BUDOP4 * H8000 EQU $-2 H80 EQU $-2 * CLR @JGSFLG MOV *R11,R11 RT JGSFLG DATA 0 JGSMEM DATA 0 JGSHD DATA 0 TTFIXR1 DATA 0 MAXFILESECTORS DATA >0FF0 maximum possible sectors a file may allocate! * 7.7.2012technically >0fff but need to adjust for FDR *eof