# HG changeset patch # User robertgault # Date 1316465488 0 # Node ID 75847753c6a3f2879f07ce88d0b688cc08ae1a93 # Parent f7f97fe766e3e300f1df6ab4d4552ba77edba72a Cleaned up code and removed multiple calculations of shift divisor by calculating it once and storing it in data. Corrected sector count calculation to include partial clusters. diff -r f7f97fe766e3 -r 75847753c6a3 level1/cmds/cobbler.asm --- a/level1/cmds/cobbler.asm Fri Sep 16 12:54:58 2011 +0000 +++ b/level1/cmds/cobbler.asm Mon Sep 19 20:51:28 2011 +0000 @@ -24,6 +24,12 @@ * 2011/09/16 Robert Gault * Corrected a typo which occured when committing code. Exit of Initcalc had * ABM3 in wrong place. +* +* 2011/09/18 Robert Gault +* Cleaned up code and removed multiple calculations of shift divisor by +* calculating it once and storing it in data. +* Corrected sector count calculation to include partial clusters. + nam Cobbler ttl Write OS9Boot to a disk @@ -33,7 +39,7 @@ *The next line needed for stand-alone compiling. It should not * be present in the NitrOS-9 project. -*Level equ 2 +Level equ 2 IFP1 use defsfile @@ -44,7 +50,7 @@ tylg set Prgrm+Objct atrv set ReEnt+rev rev set $00 -edition set 8 +edition set 9 mod eom,name,tylg,atrv,start,size @@ -52,7 +58,9 @@ lsn0buff rmb 26 Buffer to hold data from LSN0 of traget device newbpath rmb 1 devpath rmb 3 -EndDevName rmb 2 pointer to last character of device name when moving to fullbnam +EndDevName rmb 2 pointer to last character of device name when moving to fullbnam +btshift rmb 2 division factor +bitflag rmb 1 indicates fractional division fullbnam rmb 20 this buffer hodls the entire name (i.e. /D0/OS9Boot) u0034 rmb 16 BootBuf rmb 7 Area to read part of current boot area into, to check for boot stuff @@ -94,9 +102,9 @@ fcc "Error - cannot gen to hard disk" fcb C$CR SeekErr fcb C$LF - fcc "Error seeking sector" - fcb C$CR - IFNE DRAGON + fcc "Error seeking sector" + fcb C$CR + IFNE DRAGON FileWarn fcb C$LF fcc "Warning - not a Dragon " fcb C$LF @@ -179,15 +187,14 @@ lda bitmbuf,u ldy bitmbuf,u point X to our bitmap buffer bsr GetBitmapBit regA is bit from table * New code to obtain a shift value R.G. pshs d,y - bsr FShift - cmpy #0 - bne CA2 - puls d,y - bra CA3 -CA2 ldd 2,s recover regY sector count + ldy btshift,u + cmpy #0 + bne CA2 + puls d,y,pc +CA2 ldd 2,s recover number of sectors + clr bitflag,u * Divide sector count by DD.BIT CAloop lsra - rorb - leay -1,y - bne CAloop - cmpd #0 - bne CAnz - incb should never be zero bits -CAnz tfr d,y regY has been divided by DD.BIT - ldd ,s recover content - leas 4,s clean stack -CA3 rts + rorb + bcc CAlp2 + inc bitflag,u indicate fractional result +CAlp2 leay -1,y + bne CAloop + tst bitflag,u + beq CAnz + incb include partial cluster +CAnz tfr d,y regY has been divided by DD.BIT + ldd ,s recover content + leas 4,s clean stack + rts * * CheckAlloc, check to see if a block of sectors is allocated. @@ -529,10 +540,10 @@ * * I think regY needs to be divided by DD.BIT R.G. CheckAlloc - pshs y,x,b,a - bsr Initcalc + pshs y,x,b,a + bsr Initcalc * Back to older code - sta ,-s save off + sta ,-s save off bmi L03CB lda ,x Get bitmap byte of our LSN @@ -540,14 +551,14 @@ L03BB anda ,s Is our LSN allocated ? bne L03F7 Yes : flag error - leay -$01,y Decrement sector count + leay -$01,y Decrement sector count beq L03F3 All done : yes, exit - lda WritErr,pcr clrb bra DisplayErrorAndExit -SeekBad leax SeekErr,pcr - clrb - bsr DisplayErrorAndExit +SeekBad leax SeekErr,pcr + clrb + bsr DisplayErrorAndExit TrkAlloc leax >FileWarn,pcr clrb bra DisplayErrorAndExit -NoMem leax >MemSpace,pcr - clrb - bra DisplayErrorAndExit +NoMem leax >MemSpace,pcr + clrb + bra DisplayErrorAndExit IFGT Level-1 NoRel leax >RelMsg,pcr diff -r f7f97fe766e3 -r 75847753c6a3 level1/cmds/os9gen.asm --- a/level1/cmds/os9gen.asm Fri Sep 16 12:54:58 2011 +0000 +++ b/level1/cmds/os9gen.asm Mon Sep 19 20:51:28 2011 +0000 @@ -41,6 +41,11 @@ * 14 2011/09/16 Robert Gault * Corrected a typo which occured when committing code. Exit of Initcalc had * ABM3 in wrong place. Also included C$CR in file name copy. +* +* 2011/09/18 Robert Gault +* Cleaned up code and removed multiple calculations of shift divisor by +* calculating it once and storing it in data. +* Corrected sector count calculation to include partial clusters. nam OS9Gen ttl OS-9 bootfile generator @@ -48,7 +53,7 @@ * Disassembled 02/07/06 13:11:11 by Disasm v1.6 (C) 1988 by RML *Needed for stand alone compile -*LEVEL equ 2 +LEVEL equ 2 IFP1 use defsfile @@ -91,6 +96,8 @@ eflag rmb 1 sngldrv rmb 1 bootdev rmb 32 +btshift rmb 2 +bitflag rmb 1 lsn0 rmb 26 btfstr rmb 160 u007B rmb 2 @@ -405,6 +412,8 @@ ldy #256 os9 I$Read read LSN0 bcs L033C + lbsr FShift + sty btshift,u save divisor value R.G. L0361 lda u047E,u ldy