changeset 1515:30c1d42f3913

Added comments, slow optimization progress
author boisy
date Thu, 22 Jan 2004 18:42:14 +0000
parents b7d6cb1df834
children 9a9734ef451c
files level1/modules/boot_1773.asm
diffstat 1 files changed, 94 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/level1/modules/boot_1773.asm	Tue Jan 20 02:43:23 2004 +0000
+++ b/level1/modules/boot_1773.asm	Thu Jan 22 18:42:14 2004 +0000
@@ -28,6 +28,10 @@
          use   rbfdefs
          ENDC
 
+* Sector Size
+SECTSIZE equ   256
+
+
 * Step Rate:
 *      $00  = 6ms
 *      $01  =
@@ -48,14 +52,14 @@
 
          mod   eom,name,tylg,atrv,start,size
 
-u0000    rmb   2
+drvsel   rmb   1
 buffptr  rmb   2
 currtrak rmb   1
-ddfmt    rmb   1
+*ddfmt    rmb   1
 ddtks    rmb   1		no. of sectors per track
-u0007    rmb   1
+*ddtot    rmb   1
 dblsided rmb   1
-u0009    rmb   1
+side     rmb   1
 size     equ   .
 
 name     fcs   /Boot/
@@ -71,20 +75,19 @@
          ldx   #DPort+8
          lda   #$D0
          sta   ,x
-         lbsr  L01AA
+         lbsr  Delay2		delay a bit
          lda   ,x
          lda   #$FF
-         sta   currtrak,u
-         leax  >NMIRtn,pcr
+         sta   currtrak,u	set current track to 255
+         leax  >NMIRtn,pcr	point to NMI routine
          IFGT  Level-1
-         stx   <D.NMI
-         lda   #$09
+         stx   <D.NMI		save address
          ELSE
-         stx   >D.XNMI+1
+         stx   >D.XNMI+1	save address
          lda   #$7E
          sta   >D.XNMI
-         lda   #$08+BootDr   permit alternate drives
          ENDC
+         lda   #$08+BootDr	permit alternate drives
          sta   >DPort
 
 * delay loop
@@ -106,66 +109,69 @@
          subd  #$0001
          bne   L003A
 
-* search for a free page (to use as a 256 byte disk buffer)
-         pshs  u,y,x,b,a
-         ldd   #$0001
-         os9   F$SRqMem
-         bcs   L00AA
-         tfr   u,d
-         ldu   $06,s
-         std   buffptr,u
+* search for memory to use as a sector buffer
+         pshs  u,y,x,b,a	save regs
+         ldd   #SECTSIZE	get sector size in D
+         os9   F$SRqMem		request that much memory
+         bcs   L00AA		branch if there is an error
+         tfr   u,d		move pointer to D temporarily
+         ldu   $06,s		restore U (saved earlier)
+         std   buffptr,u	save alloced mem pointer in statics
          clrb
 
 * go get LSN0
-         ldx   #$0000
-         bsr   ReadSect
-         bcs   L00AA
+         ldx   #$0000		we want LSN0
+         bsr   ReadSect		go get it
+         bcs   L00AA		branch if error
 
-* get bootfile size from LSN0 and allocate memory for it
-         ldd   DD.TOT+1,y
-         std   u0007,u
+* From LSN0, we get various pieces of info.
+*         ldd   DD.TOT+1,y
+*         std   ddtot,u
          lda   <DD.FMT,y		get format byte of LSN0
-         sta   ddfmt,u			save it for ???
+*         sta   ddfmt,u			save it for ???
          anda  #FMT.SIDE		keep side bit
          sta   dblsided,u		and save it
          lda   DD.TKS,y			get sectors per track
          sta   ddtks,u			and save
-         ldd   <DD.BSZ,y
-         std   ,s
-         ldx   <DD.BT+1,y
-         pshs  x
-         ldd   #256
-         ldu   buffptr,u
-         os9   F$SRtMem
-         ldd   $02,s
+         ldd   <DD.BSZ,y		get bootfile size
+         std   ,s			save on stack
+         ldx   <DD.BT+1,y		get start sector of bootfile
+         pshs  x			push on the stack
+         ldd   #SECTSIZE		load D with sector size
+         ldu   buffptr,u		and point to the buffer pointer
+         os9   F$SRtMem			return the memory
+         ldd   $02,s			get the bootfile size
          IFGT  Level-1
          os9   F$BtMem
          ELSE
-         os9   F$SRqMem
+         os9   F$SRqMem			get the memory from the system
          ENDC
-         puls  x
-         bcs   L00AA
-         stu   $02,s
-         ldu   $06,s
-         ldd   $02,s
-         std   buffptr,u
-         ldd   ,s
-         beq   L00A3
+         puls  x			pull bootfile start sector off stack
+         bcs   L00AA			branch if error
+         stu   $02,s			save pointer to bootfile mem on stack
+         tfr   u,d			transfer to D for later store
+         ldu   $06,s			restore original U
+*         ldd   $02,s			get pointer to bootfile mem
+         std   buffptr,u		and save pointer
+         ldd   ,s			get bootfile size
+         beq   L00A3			branch if zero
 
 * this loop reads a sector at a time from the bootfile
-L0091    pshs  x,b,a
+* X = start sector
+* D = bootfile size
+L0091    pshs  x,b,a			save params
          clrb
-         bsr   ReadSect
-         bcs   L00A8
+         bsr   ReadSect			read sector
+         bcs   L00A8			branch if error
          IFGT  Level-1
-         lda   #'.		dump out a period for boot debugging
-         jsr   <D.BtBug		do the debug stuff     
+         lda   #'.			dump out a period for boot debugging
+         jsr   <D.BtBug			do the debug stuff     
          ENDC
-         puls  x,b,a
-         inc   buffptr,u
-         leax  1,x
-         subd  #256
-         bhi   L0091
+         puls  x,b,a			get params
+         inc   buffptr,u		point to next 256 bytes
+         leax  1,x			move to next sector
+         subd  #SECTSIZE		subtract sector bytes from size
+         bhi   L0091			continue if more space
 L00A3    clrb
          puls  b,a
          bra   L00AC
@@ -177,7 +183,7 @@
          rts
 
 L00B7    lda   #$28+BootDr    permit alternate drives
-         sta   ,u
+         sta   drvsel,u
          clr   currtrak,u
          lda   #$05
          lbsr  L0170
@@ -188,10 +194,10 @@
 * Entry: X = LSN to read
 ReadSect lda   #$91
          cmpx  #$0000		LSN0?
-         bne   L00DF
-         bsr   L00DF
-         bcs   L00D6
-         ldy   buffptr,u
+         bne   L00DF		branch if not
+         bsr   L00DF		else branch subroutine
+         bcs   L00D6		branch if error
+         ldy   buffptr,u	get buffer pointer in Y for caller
          clrb
 L00D6    rts
 
@@ -199,24 +205,24 @@
          pshs  x,b,a
          bsr   L00B7
          puls  x,b,a
-L00DF    pshs  x,b,a
+L00DF    pshs  x,b,a		save LSN, command
          bsr   L00EA
-         puls  x,b,a
-         bcc   L00D6
+         puls  x,b,a		get LSN, command
+         bcc   L00D6		branch if OK
          lsra
          bne   L00D7
 L00EA    bsr   L013C
-         bcs   L00D6
-         ldx   buffptr,u
-         orcc  #IntMasks
-         pshs  y
+         bcs   L00D6		if error, return to caller
+         ldx   buffptr,u	get address of buffer to fill
+         orcc  #IntMasks	mask interrupts
+         pshs  y		save Y
          ldy   #$FFFF
          ldb   #$80 
          stb   >DPort+8 
-         ldb   ,u
+         ldb   drvsel,u
 * Notes on the next line:
 * The byte in question comes after telling the controller that it should
-* read a sector. RegB is then loaded (ldb ,u) which means it is set to $29
+* read a sector. RegB is then loaded (ldb drvsel,u) which means it is set to $29
 * (%00101001) or the default boot drive if sub L00B7 has been run. At this
 * point an orb #$30 or orb #%00110000 means that write precomp and double
 * density flags are or'd in. This does not make any sense at all for a
@@ -226,18 +232,18 @@
 * 09/02/03: Futher investigation shows that the OS-9 Level One Booter will
 * FAIL if orb #$28 is used.  It does not fail if orb #$30 is used. ????
          orb   #$30		was $30 which RG thinks is an error
-         tst   u0009,u
+         tst   side,u
          beq   L0107
          orb   #$40
 L0107    stb   >DPort
-         lbsr  L01AA
+         lbsr  Delay2
          orb   #$80
 *         lda   #$02
 *L0111    bita  >DPort+8
 *         bne   L0123
 *         leay  -$01,y
 *         bne   L0111
-*         lda   ,u
+*         lda   drvsel,u
 *         sta   >DPort
 *         puls  y
 *         bra   L0138
@@ -251,7 +257,7 @@
          nop
          bra   L0123
 
-NMIRtn   leas  R$Size,s
+NMIRtn   leas  R$Size,s		adjust stack
          puls  y
          ldb   >DPort+8
          bitb  #$04
@@ -260,20 +266,21 @@
          ldb   #E$Read
          rts
 
-L013C    lda   #$08+BootDr   permit alternate drives
-         sta   ,u
-         clr   u0009,u
+L013C    lda   #$08+BootDr	permit alternate drives
+         sta   drvsel,u
+         clr   side,u		assume side 0
          tfr   x,d
          cmpd  #$0000
          beq   L016C
-         clr   ,-s
+         clr   ,-s		clear space on stack
          tst   dblsided,u	disk double sided?
          beq   L0162		branch if not
          bra   L0158
-L0152    com   u0009,u
+* Double-sided code
+L0152    com   side,u
          bne   L0158
          inc   ,s
-L0158    subb  ddtks,u
+L0158    subb  ddtks,u		
          sbca  #$00
          bcc   L0152
          bra   L0168
@@ -304,33 +311,35 @@
          bne   L0138
          clrb
          rts
-L0195    bsr   L01A8
+L0195    bsr   Delay1
 L0197    ldb   >DPort+8
          bitb  #$01
          bne   L0197
          rts
-L019F    lda   ,u
+L019F    lda   drvsel,u
          sta   >DPort
          stb   >DPort+$08
          rts
-L01A8 
+
+* Delay branches
+Delay1 
          IFNE  H6309
          nop
          ENDC
          bsr   L019F
-L01AA  
+Delay2  
          IFNE  H6309
          nop
          nop
          ENDC
-         lbsr  L01AD
-L01AD 
+         lbsr  Delay3
+Delay3 
          IFNE  H6309
          nop
          nop
          ENDC
-         lbsr  L01B0
-L01B0 
+         lbsr  Delay4
+Delay4 
          IFNE  H6309
          nop
          ENDC