Hi!

Part four, changed only comments, code unchanged.

- fixed wrong comments, more and better comments.

--- Begin Message ---
diff -ruNp old/drivers/floppy.asm new/drivers/floppy.asm
--- old/drivers/floppy.asm      2004-06-08 20:35:36.000000000 +0000
+++ new/drivers/floppy.asm      2004-06-08 21:12:22.000000000 +0000
@@ -43,12 +43,11 @@ FL_RESET:
                pop     ax              ; return address
                pop     dx              ; drive
                push    ax              ; restore address
-                mov     ah,0            ; BIOS reset diskette & fixed disk
+               mov     ah,0            ; reset disk
                 int     13h
-
-                sbb    ax,ax           ; cy==1 is error
-               inc     ax              ; TRUE on success, FALSE on failure
-                ret
+               sbb     ax,ax           ; CF=1: error
+               inc     ax              ; ...return TRUE (1) on success,
+               ret                     ;  FALSE (0) on error
 
 ;
 ; int ASMPASCAL fl_diskchanged(UBYTE drive);
@@ -60,11 +59,11 @@ FL_RESET:
                global  FL_DISKCHANGED
 FL_DISKCHANGED:
                pop     ax              ; return address
-               pop     dx              ; get the drive number
+               pop     dx              ; drive
                push    ax              ; restore stack
-               push    si              ; restore stack
 
-                mov     ah,16h          ;  read change status type
+               push    si
+               mov     ah,16h          ; read change status type
                xor     si,si           ; RBIL: avoid crash on AT&T 6300
                 int     13h
                pop     si
@@ -87,52 +86,47 @@ FL_DISKCHANGED:
 
                global  FL_FORMAT
 FL_FORMAT:
-                mov     ah, 5
+               mov     ah,5            ; format track
                 jmp     short fl_common
 
                global  FL_READ
 FL_READ:
-                mov     ah,2            ; cmd READ
+               mov     ah,2            ; read sector(s)
                 jmp short fl_common
                 
                global  FL_VERIFY
 FL_VERIFY:
-                mov     ah,4            ; cmd verify
+               mov     ah,4            ; verify sector(s)
                 jmp short fl_common
                 
                global  FL_WRITE
 FL_WRITE:
-                mov     ah,3            ; cmd WRITE
+               mov     ah,3            ; write sector(s)
 
 fl_common:                
-                push    bp              ; C entry
+               push    bp
                 mov     bp,sp
 
-                mov     cx,[bp+0Ch]     ; cylinder number (lo only if hard)
-
-                mov     al,1            ; this should be an error code                
     
-                cmp     ch,3            ; this code can't write above 3ff=1023
-                ja      fl_error
-
-                xchg    ch,cl           ; ch=low 8 bits of cyl number
-                ror     cl,1           ; extract bits 8+9 to cl
-                ror     cl,1
-                or      cl,[bp+0Ah]    ; or in the sector number (bits 0-5)
-
-                mov     al,[bp+08h]     ; count to read/write
-                les     bx,[bp+04h]     ; Load 32 bit buffer ptr
-
-                mov     dl,[bp+10h]     ; get the drive (if or'ed 80h its
-                                        ; hard drive.
-                mov     dh,[bp+0Eh]     ; get the head number
-
-                int     13h             ;  write sectors from mem es:bx
+               mov     cx,[bp+12]      ; cylinder number
+               mov     al,1            ; error code
+               cmp     ch,3
+               ja      fl_error        ; can't write above 3FFh=1023
+
+               xchg    ch,cl           ; ch=low 8 bits of cylinder number
+               ror     cl,1            ; bits 8-9 of cylinder number...
+                ror    cl,1            ; ...to bits 6-7 in CL
+               or      cl,[bp+10]      ; sector number (bits 0-5)
+
+               mov     al,[bp+8]       ; number of sectors
+               les     bx,[bp+4]       ; 32-bit buffer ptr
+               mov     dl,[bp+16]      ; drive (if or'ed 80h its hard drive)
+               mov     dh,[bp+14]      ; head number
+               int     13h             ; process sectors
 
                sbb     al,al           ; carry: al=ff, else al=0
                and     al,ah           ; carry: error code, else 0
-                                       ; (Zero transfer count)
 fl_error:
-                mov     ah,0            ; force into < 255 count
+                mov     ah,0
                 pop     bp
                 ret     14
 
@@ -144,23 +138,19 @@ fl_error:
 
                global  FL_LBA_READWRITE
 FL_LBA_READWRITE:
-               push    bp              ; C entry
+               push    bp
                mov     bp,sp
-               
                push    ds
-               push    si              ; wasn't in kernel < KE2024Bo6!!
-
-               mov     dl,[bp+10]      ; get the drive (if ored 80h harddrive)
-               mov     ax,[bp+8]       ; get the command
-               lds     si,[bp+4]       ; get far dap pointer
-               int     13h             ; read from/write to drive
-               
+               push    si
+               mov     dl,[bp+10]      ; drive (if or'ed 80h its hard drive)
+               mov     ax,[bp+8]       ; command
+               lds     si,[bp+4]       ; far dap pointer
+               int     13h             ; process sectors
                 pop     si
                pop     ds
-
                pop     bp
-               mov     al,ah           ; place any error code into al
-               mov     ah,0            ; zero out ah           
+               mov     al,ah           ; place error code into al
+               mov     ah,0
                ret     8
 
 ;
@@ -180,10 +170,10 @@ FL_READKEY:
                global  FL_SETDISKTYPE
 FL_SETDISKTYPE:
                pop     bx              ; return address
-               pop     ax              ; disk type (al)
-               pop     dx              ; drive number (dl)
+               pop     ax              ; disk type
+               pop     dx              ; drive
                push    bx              ; restore stack
-                mov     ah,17h
+               mov     ah,17h          ; set disk type for format
                 int     13h
 ret_AH:
                mov     al,ah           ; place error code into al
@@ -200,21 +190,19 @@ FL_SETMEDIATYPE:
                pop     ax              ; return address
                 pop     bx             ; sectors/track
                pop     cx              ; number of tracks
-               pop     dx              ; drive number
+               pop     dx              ; drive
                push    ax              ; restore stack
                 push    di
 
-               dec     cx              ; should be highest track
-                xchg    ch,cl           ; low 8 bits of cyl number
-                
-                ror     cl,1           ; extract bits 8+9 to cl bit 6+7
-                ror     cl,1
-                
-                or      cl,bl           ; or in bits 7-6
-
-                mov     ah,18h
+               dec     cx              ; last cylinder number
+               xchg    ch,cl           ; CH=low 8 bits of last cyl number
+               ror     cl,1            ; bits 8-9 of cylinder number...
+                ror    cl,1            ; ...to bits 6-7 in CL
+               or      cl,bl           ; sectors/track (bits 0-5)
+               mov     ah,18h          ; set media type for format
                 int     13h
                jc      skipint1e
+
                push    es
                 xor     dx,dx
                 mov     es,dx

--- End Message ---

Reply via email to